ASSIGN fails with variable from debugger path

主宰稳场 提交于 2020-03-04 15:35:12

问题


I am trying to assign the value of this stucture path to a fieldsymbol, but this path does not work because it has a table in it's path.

But with in the debugger this value of this path is shown correctly.

Is there a way to dynamically assign a component of a table line to a fieldsymbol, by passing one path? If not then I will just read the table line and then use the path to get the wanted value.

ls_struct (Struct)
    - SUPPLYCHAINTRADETRANSACTION (Struct)
        - INCL_SUPP_CHAIN_ITEM (Table)
            - ASSOCIATEDDOCUMENTLINEDOCUMENT (Element)   


i_component_path = |IG_DDIC-SUPPLYCHAINTRADETRANSACTION-INCL_SUPP_CHAIN_ITEM[1]-ASSOCIATEDDOCUMENTLINEDOCUMENT|.
ASSIGN (i_component_path) TO FIELD-SYMBOL(<lg_value>).
IF <lg_value> IS NOT ASSIGNED.
    return.
ENDIF.

<lg_value> won't be assigned 

回答1:


Solution by Sandra Rossi

The debugger has its own syntax and own logic, it doesn't apply the ASSIGN algorithm at all. With ABAP source code, you have to use ASSIGN twice, the first one to reach the internal table, then you select the first line, and the second one to reach the component of the line.

The debugger works completely differently, the debugger code works only in debug mode, you can't call the code from the debugger (i.e. if you call it, the kernel code used by the debugger will fail). No, there's no "abappath". There are the XSL transformation objects (xpath), but it's slow for what you ask.

Thank you very much




回答2:


This seems to be a rather unexpected limitation of the ASSIGN statement. Probably worth a ticket to SAP's ABAP language group to clarify whether it's even a bug.

While this works:

ASSIGN data-some_table[ 1 ]-some_field TO FIELD-SYMBOL(<lv_source>).

the same expressed as a string doesn't:

ASSIGN (`data-some_table[ 1 ]-some_field`) TO FIELD-SYMBOL(<lv_source>).

Alternative 1 for (name) of the ABAP keyword documentation for the ASSIGN statement says that "[t]he name in name is structured in the same way as if specified directly".

However, this declaration is immediately followed by "the content of name must be the name of a data object which may contain offsets and lengths, structure component selectors, and component selectors for assigning structured data objects and attributes in classes or objects", a list that does not include the table expressions we would need here.



来源:https://stackoverflow.com/questions/60187170/assign-fails-with-variable-from-debugger-path

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!