我想直接使用方法的返回值。 例如,在C ++中,我们可以使用:
//Some codes
cout << obj1.get_foo() << endl;
int a = obj2->get_value() + 100 + obj2->get_value();
或
//...
obj1->set_color("BLUE");
cout << "Color is:" << obj1->get_color();
printf("Color is: %s", obj1->get_color()); // C Version
当我在ABAP中执行此操作时:
OBJ1->SET_COLOR( 'BLUE' ). "That's OK.
WRITE:/ 'Color is:', OBJ1->GET_COLOR( ). "Error!
我期待这个输出:
Color is: BLUE
编辑:我在标题中使用参数字而不是ABAP关键字,而是使用函数参数。
答案 0 :(得分:1)
你能做的是。
* before 740
OBJ1->SET_COLOR( 'BLUE' ).
DATA COLOR TYPE NAME.
COLOR = OBJ1->GET_COLOR( ).
WRITE:/ 'Color is:', COLOR.
或
* since 740
OBJ1->SET_COLOR( 'BLUE' ).
DATA(COLOR) = OBJ1->GET_COLOR( ).
WRITE:/ 'Color is:', COLOR.
祝你好运, 塔皮奥
答案 1 :(得分:0)
另一种解决方案:
DATA : STRING TYPE STRING.
CONCATENATE 'Color is:' OBJ1->GET_COLOR( ) INTO STRING SEPARATED BY ' '.
WRITE :/ STRING .
如果你有一个多语言应用程序,使用这种方法,你可以得到正确的语言&#39;颜色是:&#39;在同一时间。