Programming Instance-Independent Methods

No object reference is passed to an instance-independent method when it is called. But the method can create or establish an object (for example, the methods Create and Find ). In order to inform the method caller of the reference to the generated object, the key field structure or key field established in the method must be passed on to the relevant variables OBJECT-KEY-... of the program.

Use the macro instruction SWC_SET_OBJECTKEY for this.

Example

Example of implementing a Create method ( create object). The functionality is implemented by calling an existing transaction.

The key fields of the created object can be established as SET/GET parameters after execution of the method.

* Method Create
************************************************************
BEGIN_METHOD CREATE CHANGING CONTAINER.
  CALL TRANSACTION '<TCode>'.
  GET PARAMETER ID '<PI1>' FIELD <KEYSTRUCT>-<Key1>.
  GET PARAMETER ID '<PI2>' FIELD <KEYSTRUCT>-<Key2>.

  SWC_SET_OBJECTKEY <KEYSTRUCT>.
END_METHOD.