I have the following piece of code.
REPORT ZZY.
CLASS lcl_main DEFINITION FINAL CREATE PRIVATE.
PUBLIC SECTION.
CLASS-METHODS:
convert_to_xstring
IMPORTING
i_param1 TYPE i
i_param2 TYPE i
RETURNING
VALUE(rv_result) TYPE xstring,
main.
ENDCLASS.
CLASS lcl_main IMPLEMENTATION.
METHOD convert_to_xstring.
ENDMETHOD.
METHOD main.
DATA: lt_binary_tab TYPE STANDARD TABLE OF x.
DATA(lv_result) = convert_to_xstring( i_param1 = 1 i_param2 = 2 ).
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lcl_main=>convert_to_xstring(
EXPORTING
i_param1 = 1
i_param2 = 2
)
TABLES
binary_tab = lt_binary_tab.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
lcl_main=>main( ).
A functional method call that is not a part of a function module call can be written like that.
DATA(lv_result) = convert_to_xstring( i_param1 = 1 i_param2 = 2 ).
However when I want to use it exactly as written above
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lcl_main=>convert_to_xstring( i_param1 = 1 i_param2 = 2 )
TABLES
binary_tab = lt_binary_tab.
I get the following syntax error.
Field "CONVERT_TO_XSTRING(" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement. "DATA" statement.
It looks like the compiler needs some guidance in this case to distinguish between an attribute and a method. Why would it be ambiguous for the compiler to let such a case without writing EXPORTING
?
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lcl_main=>convert_to_xstring( EXPORTING i_param1 = 1 i_param2 = 2 )
TABLES
binary_tab = lt_binary_tab.
CALL FUNCTION
is a mess - is that enough of an answer? ;-) – Stinkpotinline
function in C++, they are good alternative for preprocessor macros. – Pantomimist