"Inline declaration is not possible in this position"方法参数



下面的代码给出这个错误:

内联声明&;DATA(LV_DESKTOP)&;是不可能的

CALL METHOD cl_gui_frontend_services=>get_desktop_directory
CHANGING
desktop_directory = data(lv_desktop). "Declaring in method

不能在方法调用中对CHANGINGEXPORTING类型的参数使用内联声明。

ABAP文档没有说明确,但明确提到内联声明类型的可用于参数IMPORTINGRECEIVING,有一定的局限性,没有说任何关于这两个其他类型。

这里和这里进行了广泛的讨论。

方法调用的内联声明示例:

cl_gui_frontend_services=>FILE_GET_ATTRIBUTES
EXPORTING
filename = `C:test.txt`
IMPORTING
readonly = DATA(readonly) ).
cl_ixml=>create(
RECEIVING
rval = DATA(ixml) ).

关于EXPORTINGCHANGING,您必须处理旧的声明。例子:

DATA lv_desktop TYPE string.
cl_gui_frontend_services=>get_desktop_directory(
CHANGING
desktop_directory = lv_desktop ).

相关内容

最新更新