ABAPABAP 740

ABAP 740: Calling Functions

Method Chaining

This feature is released as part of 7.02 but example referenced here. 

From the top of document mostly we are discussing on possibility to eliminate the variable declarations. We often create variables to hold the data in runtime for a short time in program before passing this data to another function call or methods. These variables are called as Tramp Data which is used only for the purpose of storing data for short period.  The usage of this variables could be avoided using chaining of methods.

Avoid type mismatch while calling functions

Often while calling the methods to avoid the type conflict dump we have to declare the variables and internal tables of same type compatible with methods interface. These types declarations can be avoided by directly declaring the data at the time of calling functions.

Note: Inline declaration of data is not available with older construct like function module.

Declare data while importing the value.

Using Constructor Operator to convert string

Let’s say we have a scenario where i am going to get the name variable as an importing parameter from an function call ( with type string ) and i have to pass it on to another method ( char40 ). The only way we can do it is we can import the value to an intermediary field and then declare another variable of type CHAR40, assign to it and pass it on to the second function to make it compatible. 

Method chaining cannot be used in this case they are incompatible variables. You can use the CONV function to solve this problem by converting the variable data into compatible type while passing to second function.

You can use conversion function to convert to compatible type rather than declaring tramp variables.

Function that expect type ref to Data

When we declare functions or methods, a specific type of parameter is usually required. However in certain scenarios a the type of data is not known until runtime and the dynamic data reference variable (TYPE REF TO DATA) is required in such cases. 

Let’s say you have a function module or method to which you need to pass the data as (type ref to data ). In such cases we declare a data reference variable and pass it to the the methods. This can be simplified as below.


Comment here