Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Method call with dynamic types

Former Member
0 Likes
577

Hi,

I have created a method with 2 parameters:

i_struc   type any   (import)

ct_table type any table. (changing)

in my method call I have the types for the parameters defined already, so e.g.

data: ls_struc type my_struc,

        lt_table  type standard table of my_struc.

call method xyz

  exporting

   i_struct = ls_struc

  changing

   ct_table = lt_table.

Now in my method I need to refer to the types in the method call, so e.g.

ls_struc-field1 = 'ABC'.

ls_struc-field2 = 'DEF'.

append ls_struc to ct_table.

But of course the ls_struc inside the method has no structure, so I am missing the part where the type from the method call can be used inside the method. The method logic should be generic because I will have different method calls with different types for structure and table. Do I need to use ASSIGN COMPONENT.....?

Any help is appreciated.

Thanks,

Tim

1 ACCEPTED SOLUTION
Read only

0 Likes
541

Hi Tim,

Since you have not given the (static) structure type in the method declaration, I guess Assign component and dynamic programming is the only option left for you. You can get some help from the following post. Best of luck.

Dynamic Internal table - ABAP Development - SCN Wiki

Regards,

Saurabh

2 REPLIES 2
Read only

0 Likes
542

Hi Tim,

Since you have not given the (static) structure type in the method declaration, I guess Assign component and dynamic programming is the only option left for you. You can get some help from the following post. Best of luck.

Dynamic Internal table - ABAP Development - SCN Wiki

Regards,

Saurabh

Read only

former_member206479
Participant
0 Likes
541

Tim,

check some of the standard methods are function modules from SAP like Function module GUI_DOWNLOAD with DATA_TAB parameter

Thanks

Venkat