SAP CALL METHOD PARAMETERS ABAP Statements

Get Example source ABAP code based on a different SAP table
  



meth( ... ) - Pass by Parameter

Short Reference
• = ABAP_METHOD_CALL
• = CALL METHOD


ABAP Syntax ... [EXPORTING p1 = a1 p2 = a2 ...]

[IMPORTING p1 = a1 p2 = a2 ...]
[CHANGING p1 = a1 p2 = a2 ...]
[RECEIVING r = a ]
[EXCEPTIONS [exc1 = n1 exc2 = n2 ...]
[OTHERS = n_others] ].

ABAP Addition
1 ... EXPORTING p1 = a1 p2 = a2 ...
2 ... IMPORTING p1 = a1 p2 = a2 ...
3 ... CHANGING p1 = a1 p2 = a2 ...
4 ... RECEIVING r = a
5 ... EXCEPTIONS exc1 = n1 exc2 = n2 ... [OTHERS = n_others]

What does it do? With the exception of addition EXCEPTIONS, these additions assign actual parameters a1 a2... to the formal parameters p1 p2 ... or r of the parameter interface of the called method. Any data objects with a data type that matches the typing of the corresponding formal parameter according to the rules of the typing check can be specified as actual parameters.

With the exception of the return code r for functional methods and arithmetic expressions for input parameters, every formal parameter assumes all attributes of the assigned actual parameters when called. Non-class-based exceptions can be handled using the addition EXCEPTIONS. The order of the additions is fixed.



Latest notes:Unlike function module calls
, static passes by parameter are checked by the syntax check and not just by the extended program check.
• EXPORTING ABAP_METHOD_CALL
• EXPORTING CALL METHOD

ABAP Addition

What does it do? If non-optional input parameters are defined for the called method in statement METHODS or CLASS-METHODS after IMPORTING, actual parameters must be assigned to these using EXPORTING. Actual parameters can be assigned to optional input parameters. When called, either a reference to an actual parameter is passed, or the content of an actual parameter is assigned to the relevant formal parameter, depending on the passing type.

a1, a2, ... are general expression positions. In other words, functions and expressions can be passed as actual parameters, alongside data objects. Special rules apply in this case.



Latest notes:No substring access is possible
after an actual parameter of type string or xstring specified after EXPORTING.
• IMPORTING ABAP_METHOD_CALL
• IMPORTING CALL METHOD

ABAP Addition

What does it do? If output parameters are defined for the called method in statement METHODS or CLASS-METHODS after EXPORTING, actual parameters can be assigned to these using IMPORTING. In pass-by-reference, a reference is passed to an actual parameter when the call is made. In pass-by-value, the content of an output parameter is assigned to the actual parameter in question only if the method is completed without errors. The actual parameters are result positions, which means that variables and writable expressions can be specified. Special rules apply in this case.

Existing variables or expressions can be specified as actual parameters for functional method calls . Inline declarations DATA(var) can also be specified for standalone method calls. If an inline declaration is specified and a formal parameter is fully typed, this type is used for the declaration. If the formal parameter is typed generically, the following data types are used:
string for csequence and clike
xstring for xsequence
decfloat34 for numeric and decfloat
p with the length 8 and no decimal places if p is generic
The standard key for a standard table type with generic primary table key
Other generic data types cannot be made concrete for the inline declaration in a useful way and produce a syntax error.



Latest notes:If, for example, a formal parameter is typed with the
generic type c or x, string or xstring cannot be used as the type for an inline declaration, since this means the typing cannot be checked.
• CHANGING ABAP_METHOD_CALL
• CHANGING CALL METHOD

ABAP Addition

What does it do? If non-optional input/output parameters are defined for the called method in statement METHODS or CLASS-METHODS after CHANGING, actual parameters must be assigned to these using CHANGING. Actual parameters can be assigned to optional input/output parameters. When called, either a reference to an actual parameter is p assed, or the content of an actual parameter is assigned to the relevant formal parameter, depending on the passing type. In pass-by-value, the content of an input/output parameter is assigned to the actual parameter in question only if the method is completed without errors. The actual parameters are result positions, which means that variables and writable expressions can be specified. Special rules apply in this case.
• RECEIVING ABAP_METHOD_CALL
• RECEIVING CALL METHOD

ABAP Addition

What does it do? This addition is only possible for standalone method calls and not for functional method calls. If a return code is defined for the called method in METHODS or CLASS-METHODS after RETURNING, an actual parameter can be assigned to this code using RECEIVING. The data type of the actual parameter does not have to comply with the general rules of the typing check; it is sufficient if the return code can be converted to the actual parameter in accordance with the conversion rules.

If the method ends without errors, the content of the formal parameter is assigned to the actual parameter. The content is converted if necessary.

The actual parameter is a result position, which means that variables and writable expressions can be specified. Special rules apply in this case.

An existing variable or an expression or inline declaration DATA(var) can be specified as an actual parameter. An inline declaration is made with the fully known data type of the return value.



Latest notes:The RECEIVING addition is usually not used for
static method calls. A functional method with a return code is usually not called as a standalone method call . Instead it is usually called as a functional method call in operand positions.
• EXCEPTIONS ABAP_METHOD_CALL
• OTHERS ABAP_METHOD_CALL
• EXCEPTIONS CALL METHOD
• OTHERS CALL METHOD

ABAP Addition n_others]

What does it do? This addition can only be used in standalone method calls and not in functional method calls.
ABAP Code Snippet

You can use EXCEPTIONS to assign return values to non-class-based exceptions exc1 exc2 ... declared in the parameter interface. Each exception exc1 exc2 ... that the caller wants to handle must be assigned to a directly specified number n1 n2 .... You can specify all numbers between 0 and 65535. The behavior outside of this range is undefined.
INTHINT All other intervals 2^n bis 2^(n+1)-1
INTHINT within the range of INT4 are mapped to
INTHINT 0 to 65535. Smaller numbers than the range of INT4 always
INTHINT give 0 and larger numbers always give 65535.

By specifying OTHERS as the last item after EXCEPTIONS , you can assign all exceptions not listed explicitly in exc1 exc2... a common return code, by assigning a number n_others. You can assign the same return code to different exceptions (including OTHERS). The behavior when an exception is raised is as follows: If the statement RAISE or MESSAGE RAISING is used to raise an exception exc1 exc2 ... (to which a return code is assigned) the procedure is ended immediately, any output parameters or return values passed by value are canceled, and the number n1 n2 ... assigned to the exception is available to be evaluated in sy-subrc . If the call of an exception raised by RAISE does not assign a return value, the program terminates with a runtime error. If the call of an exception raised by MESSAGE RAISING does not assign a return value, the message is sent and the system continues in accordance with the message type.

If no exception is raised, a call sets sy-subrc to 0.

If class-based exceptions are declared in the parameter interface, the addition EXCEPTIONS cannot be specified in the call.
ABAP Code Snippet

The specified exceptions must be present in the parameter interface of the method.



Latest notes:If the value 0 is assigned to an exception, this indicates
that the caller wants to ignore this exception. If the exception is raised in the method, no runtime error occurs, but the exception cannot be handled.



Example ABAP Coding
The method GET_DOCU of the class
CL_ABAP_DOCU_ITF has two input parameters and two output parameters, plus a return value that indicates whether the method was executed successfully. Functionally, the method is called as an operand of a comparison expression in a logical expression. The values in the output are reused in further method calls only if the method completed successfully. DATA: itf TYPE tline_tab,
head TYPE thead.

IF cl_abap_docu_itf=>get_docu(
EXPORTING langu = sy-langu
object = 'ABENABAP'
IMPORTING itf = itf
head = head ) = 0.
cl_abap_docu_itf=>get_docu_includes(
EXPORTING head = head
CHANGING itf = itf ).
ENDIF.

Return to menu