2008 Jun 04 2:33 PM
I'd like to call one method with the results of another method and I keep getting the error 'The field XYZ(' is unknown but there is a field with a similar name' Error.
Consider the simple example below:
CLASS ZLCL_HELPER DEFINITION.
PUBLIC SECTION.
CLASS-METHODS emit IMPORTING text TYPE string.
CLASS-METHODS get_text RETURNING text TYPE string.
ENDCLASS.
I'd like to call emit with value of get_text without declaring a string type object in the caller such as:
START-OF-SELECTION.
DATA: text TYPE string.
text = zlcl_helper=>get_text( ).
zlcl_helper=>emit( text ).
I'd rather do something like:
START-OF-SELECTION.
zlcl_helper=>emit( zlcl_helper=>get_text( ) ).
Is there a way to do this?
Thanks,
-Ryan
2008 Jun 04 2:49 PM
Hi Ryan,
you got it almost right....try using following syntax...
zlcl_helper=>emit( text = zlcl_helper=>get_text( ) ).
~Piyush
2008 Jun 04 2:49 PM
Hi Ryan,
you got it almost right....try using following syntax...
zlcl_helper=>emit( text = zlcl_helper=>get_text( ) ).
~Piyush
2008 Jun 04 3:06 PM
I still have the field "GET_TEXT(" is unknown problem. Here is the code that I tried. Am I missing something else?
CLASS zlcl_helper DEFINITION.
PUBLIC SECTION.
CLASS-METHODS emit IMPORTING text TYPE string.
CLASS-METHODS get_text RETURNING VALUE(text) TYPE string.
ENDCLASS.
CLASS zlcl_helper IMPLEMENTATION.
METHOD get_text.
text = 'xyz'.
ENDMETHOD.
METHOD emit.
WRITE text.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
zlcl_helper=>emit( text = zlcl_helper=>get_text( ) ).
2008 Jun 04 3:48 PM
You can't nest method calls. You have to split it into two.
some_text = zlcl_helper=>get_text( ).
zlcl_helper=>emit( text = some_text( ).
2008 Jun 05 5:36 AM
Hi Ryan,
The syntax requires a space after the opening bracket '(' and before the closing one ')'....thats it..
rest the code is fine....works for me..
~Piyush