ABAP Keyword Documentation → ABAP − Reference → Calling and leaving program units → Calling Processing Blocks → Calling Procedures → External Procedure Call
Fixed Point Arithmetic in External Procedure Calls
A procedure called externally is executed in accordance with the attribute Fixed Point Arithmetic set in its master program. Here, each actual parameter bound to a formal parameter of the procedure is also handled in accordance with the called program, independently both of the corresponding attribute of the calling program and of the parameter type and pass by type.
Other versions: 7.31 | 7.40 | 7.54
Note
The justification for the behavior described here is that parameter passing should be independent of pass by reference and pass by value. To avoid the associated problems, it is strongly recommended that fixed point arithmetic is not switched off in any program. In this context, this applies particularly to class pools and function groups.
Example
The following example is a global class:
PUBLIC SECTION.
CLASS-METHODS meth RETURNING value(p) TYPE string.
ENDCLASS.
CLASS cl_test IMPLEMENTATION.
METHOD meth.
p = '1000'.
ENDMETHOD.
ENDCLASS.
A calling program section could be as follows:
DATA pack TYPE p DECIMALS 2.
pack = cl_test=>meth( ).
Depending on the attributes, the result is as follows. Here, the attributes of the calling program are in the top row and the attributes of the called program are in the left column:
Fixed Point Arithmetic | on | off |
---|---|---|
on | 1000.00 | 1000.00 |
off | 10.00 | 10.00 |
The formal parameter is assigned to the bound actual parameter (including the associated conversion while respecting the decimal separators) only if fixed point arithmetic is switched on in the called procedure. If fixed point arithmetic is switched off in the called procedure, the decimal separator of the actual parameter is ignored.
The call could also, however, be made as follows:
DATA pack TYPE p DECIMALS 2.
pack = + cl_test=>meth( ).
In this case, the result looks like this:
Fixed Point Arithmetic | on | off |
---|---|---|
on | 1000.00 | 10.00 |
off | 1000.00 | 10.00 |
In this case, the call takes place in an arithmetic expression. The return value of the call is assigned to an intermediate result of the same type as the formal parameter and this is then converted to the calculation type of the arithmetic expression in the calling program. In this case, therefore, the attribute of the calling program determines whether the decimal separator is respected.
The behavior in the second case generally meets the expectations of a calling program. This can, of course, also be done by using a helper variable of the same type as the formal parameter, First it is used as an actual parameter in the calling program and then assigned to the target field.