Reputation: 535
I want to use the return value of methods directly. For example in C++, we can use:
//Some codes
cout << obj1.get_foo() << endl;
int a = obj2->get_value() + 100 + obj2->get_value();
or
//...
obj1->set_color("BLUE");
cout << "Color is:" << obj1->get_color();
printf("Color is: %s", obj1->get_color()); // C Version
When I do this in ABAP like:
OBJ1->SET_COLOR( 'BLUE' ). "That's OK.
WRITE:/ 'Color is:', OBJ1->GET_COLOR( ). "Error!
And I expected this output:
Color is: BLUE
Edit: I used Parameter word in Title not as ABAP Keyword, but as function arguments.
Upvotes: 0
Views: 385
Reputation: 2617
An other solution:
DATA : STRING TYPE STRING.
CONCATENATE 'Color is:' OBJ1->GET_COLOR( ) INTO STRING SEPARATED BY ' '.
WRITE :/ STRING .
if you have a multilingual application, with this method, you can get the right language for 'Color is:' at the same time.
Upvotes: 0
Reputation: 196
What you can do is.
* before 740
OBJ1->SET_COLOR( 'BLUE' ).
DATA COLOR TYPE NAME.
COLOR = OBJ1->GET_COLOR( ).
WRITE:/ 'Color is:', COLOR.
or
* since 740
OBJ1->SET_COLOR( 'BLUE' ).
DATA(COLOR) = OBJ1->GET_COLOR( ).
WRITE:/ 'Color is:', COLOR.
Best regards, Tapio
Upvotes: 1