cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Method call with local variable "type ref to data"

former_member205645
Participant
0 Likes
1,130

Hello,

i am calling a method that has one exporting parameter with type ANY TABLE.

My problem is that abap won't let me activate the code because of the incompatible actual parameter:

    data: lt_dynamic type ref to data,

            lo_node type ref to if_wd_context_node,

    field-symbols: <ls_dynamic> type any table.

*   create data lt_dynamic type ?

    lo_node->get_static_attributes_table( importing table = lt_dynamic ). <-- not activating

    lo_node->get_static_attributes_table( importing table = <lt_dynamic> ). <-- activating but the field symbol is not assigned

I need the reference of the table "table" of the method "get_static_attributes_table" in this example.

Regards

Ioan.

Accepted Solutions (0)

Answers (2)

Answers (2)

alex_campbell
Contributor
0 Likes

You're correct that you can't create & assign a field of type 'ANY TABLE'. You have to know what type of data to create, and then assign it to your field symbol.

I did a quick where-used on the interface of that method, and it looks like the type of that table depends on the element which that node represents. So for example when the node has name 'EXTR_SELECT_TABLE' the type of the table passed into the method is if_main_view=>element_extr_select_table. It appears that each application will know the proper type for the element node that it's working with, so I think you'll need to roll up your sleeves and do some reverse-engineering to find out what type your table needs to be. The good news is if you're only working with a single static element node, you can just declare your table of the correct type using the DATA keyword. You won't have to use pointers/field symbols/references.

former_member205645
Participant
0 Likes

Hello Alex,

thank you for the reply. Yes i did the reverse eingineering. You are right, the standard uses the parameter to determine the table type and then creates a internal table of that type.

I wanted a method that is fully dynamic, but that is not possible

Kind regards,

Ioan.

former_member205645
Participant
0 Likes

Hello,

i just found out, what i am trying i not possible. The method GET_STATIC_ATTRIBUTES_TABLE also uses the exporting parameter to determine the type of the table .

And generally i don't think that this is possible. The <lt_dynamic> field symbol has to be assigned and for that you need a variable/memory area, that can store any table. I don't have too much time now to look but in my opinion is not possible ... for now at least