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

Return/pass dynamic table in a method

Former Member
0 Likes
3,044

How can I retrieve a dynamic table (empty though) from a method if the structure of the dynamic table depends on the import parameters?

E.g.:

CALL METHOD zcl_aansl_util=>create_itab_connection
  EXPORTING
    i_name = 'FRUIT' " e.g. FRUIT or VEGETABLES and so on.
  IMPORTING
    e_dyn  = lt_dyn_table. " dynamically built table which differs for each call

So, in case of 'FRUIT' I want a certain dynamic table structure which would be different when I pass 'VEGETABLES'. The method already creates the dynamic table without any problems, the only challenge lies in PASSING the dynamic table. The dyn table should be/is empty.

If I would be able to predict how the dynamic table would look like, there would be no problem. The point is, that the structure differs for each call. I browse at SDN and I didn't found any solution, I did find posts about how to create a dyn table and so on... but that is not the problem. One suggestion I was thinking of, is to pass a string (with table information).

1 REPLY 1
Read only

Former Member
0 Likes
861

Problem solved.

I left out 1 line of code within my method (the assigning part).

So:

CALL METHOD zcl_aansl_util=>create_itab_connection
    EXPORTING
      i_name      = 'FRUIT' " Just as an example
    IMPORTING
      et_newtable = lt_newtable. " .... = TYPE REF TO data.
  ASSIGN lt_newtable->* TO <fs_collection>. "This part I put outside the method...