Background documentationProgramming Synchronous Methods (BOR) Locate this document in the navigation structure

 

You program an synchronous method in the implementation program between the macro instructions BEGIN_METHOD <Method> and END_METHOD.

The unique ID of the object is available in the structure of the key fields under the variable OBJECT-KEY.

An synchronous method can be implemented with a function module. The function module is called in the program with the ABAP command CALL FUNCTION. The application called from the method should contain no COMMIT WORK and therefore no update task call for synchronous methods.

In the case of synchronous methods, a result and/or the export parameters can be returned to the caller if you pass the result to the container CONTAINER within the method implementation. To do this, use the macro instruction SWC_SET_ELEMENT for a single-line result or export parameter, or the macro instruction SWC_SET_TABLE for a multiline result or export parameter.

The result is always put into the container element RESULT. The export parameters are put into the container with their IDs. The result is available in the task container in the container element _WI_RESULT.

This graphic is explained in the accompanying text.

Example

Implementing the synchronous method Approve, which returns a result:

The method operates on an object of the object type FORMABSENC (form: notification of absence). This object type has the key field Number. This method has one exception an no import parameters.

You implement this method by calling the function module SWX_FORMABS_APPROVE.

The result of the method, which can be derived from the export parameter of the function module, has the reference field PROCSTATE from the reference table SWXFORMABS as data type reference.

Syntax Syntax

  1. * Methode Approve
    ************************************************************
     BEGIN_METHOD APPROVE CHANGING CONTAINER.
       DATA:         APPROVE LIKE SWXFORMABS-PROCSTATE.
       CALL FUNCTION 'SWX_FORMABS_APPROVE'
         EXPORTING
           FORMNUMBER = OBJECT-KEY-NUMBER
         IMPORTING
           PROC_STATE = PROC_STATE
         EXCEPTIONS
           DOCUMENT_NOT_FOUND = 01
           ABORTED            = 02
           OTHERS             = 03.
       CASE SY-SUBRC.
         WHEN 00.
           * Im Erfolgsfall: Zuweisung des Ergebnisses
           * an das Element RESULT im Container CONTAINER
           ******************************************************
           SWC_SET_ELEMENT CONTAINER RESULT APPROVE.
         WHEN 01.
           EXIT_RETURN 1301 SPACE SPACE SPACE SPACE.
         WHEN 02.
            EXIT_CANCELLED.
         WHEN OTHERS.         "to be implemented
       ENDCASE.
     END_METHOD.
End of the code.

An exception is defined for this object method with the number 1301 (document not found), which you raise with the macro instruction EXIT_RETURN.

With the macro instruction EXIT_CANCELLED, you can leave the method implementation if a user cancels. A single-step task in which this method is referenced is not yet completed in this case. The relevant work item retains the status In process.

Note Note

If you have fully maintained the ABAP function type of the method and the method parameters, the system implements the call to the relevant function and the data declaration of the method parameters used.

End of the note.