Application Development 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: 

How to find the type of dynamic internal table?

Former Member
0 Kudos

Hello Experts,

i want to know the method to find the type of dynamic internal table?

I am having an dynamic internal table <gfs_dyn_table>.

Here i want to create an static internal table with field which can store dynamic internal table. To create internal table i need to create an structure .

TYPES : BEGIN OF STRUCT,

               IT_DYN TYPE <?????????>, " here i need to put the type of dynamic internal table

END OF STRUCT.

DATA : IT TYPE STAANDARD TABLE OF STRUCT,

           WA LIKE LINE OF IT.

LOOP AT IT INTO WA.

WA-IT_DYN = <GFS_DYN_TABLE>.

APPEND WA TO IT.

ENDLOOP.

Thanks in Advance.

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos

Do as follows:

TYPES : BEGIN OF STRUCT,

               REF_IT_DYN TYPE REF TO DATA, " here i need to put the type of dynamic internal table

END OF STRUCT.

DATA : IT TYPE STAANDARD TABLE OF STRUCT,

           WA LIKE LINE OF IT.

FIELD-SYMBOLS <IT_DYN> TYPE ANY TABLE.

FIELD-SYMBOLS <WA_DYN> TYPE ANY.

FIELD-SYMBOLS <FIELD_DYN> TYPE ANY.

GET REFERENCE OF <GFS_DYN_TABLE> INTO WA-REF_IT_DYN.

APPEND WA TO IT.

LOOP AT IT INTO WA.

ASSIGN WA-REF_IT_DYN->* TO <IT_DYN>.

LOOP AT <IT_DYN> ASSIGNING <WA_DYN>.

ASSIGN COMPONENT 'YOURFIELD' OF STRUCTURE <WA_DYN> TO <FIELD_DYN>.

ENDLOOP.

ENDLOOP.

8 REPLIES 8

0 Kudos

Hi ,

In Debugging mode , you can find the structure of dynamic internal table(by double-clicking on dynamic internal table) at that point and

you can use the same fields to declare structure and inturn to create static internal table.

Thanks.

0 Kudos

Hi Pavan,

Thanks for the reply, i dont want to move data from one internal table to other, i just want to store whole internal table into particular field i.e. it_dyn.

Sandra_Rossi
Active Contributor
0 Kudos

Do as follows:

TYPES : BEGIN OF STRUCT,

               REF_IT_DYN TYPE REF TO DATA, " here i need to put the type of dynamic internal table

END OF STRUCT.

DATA : IT TYPE STAANDARD TABLE OF STRUCT,

           WA LIKE LINE OF IT.

FIELD-SYMBOLS <IT_DYN> TYPE ANY TABLE.

FIELD-SYMBOLS <WA_DYN> TYPE ANY.

FIELD-SYMBOLS <FIELD_DYN> TYPE ANY.

GET REFERENCE OF <GFS_DYN_TABLE> INTO WA-REF_IT_DYN.

APPEND WA TO IT.

LOOP AT IT INTO WA.

ASSIGN WA-REF_IT_DYN->* TO <IT_DYN>.

LOOP AT <IT_DYN> ASSIGNING <WA_DYN>.

ASSIGN COMPONENT 'YOURFIELD' OF STRUCTURE <WA_DYN> TO <FIELD_DYN>.

ENDLOOP.

ENDLOOP.

0 Kudos

hello Sandra,

thanks for the reply.

When i debug my program REF_IT_DYN is showing REF_IT_DYN[fref] it must be REF_IT_DYN[Internal Table].

Because i need to pass this internal table (it) to the transformation so that i would get data in JSON Format .

CALL TRANSFORMATION ID

             SOURCE DATA_NODE = IT

             RESULT XML JSON_WRITER.

       "here we are using class cl_zxml_string_writer

       DATA(JSON) = JSON_WRITER->GET_OUTPUT( ).

       OUT->WRITE_JSON( JSON ).

*

*  Assert symmetry of transformation

       ASSERT JSON_WRITER->GET_OUTPUT( ) = JSON.

       OUT->DISPLAY( ). " method of class cl_demo_output

0 Kudos

Please tell us exactly the JSON format you expect, so that we can give you a meaningful answer.

0 Kudos

Hello Sandra,

I am working on a program which is used to load data from multitab excel to internal table and then pass that internal table to json format.

i used <gfs_dyn_table> as a dynamic internal table which stores data from each sheet.

when i passed <gfs_dyn_table> to transformation only last sheet get converted into json because <gfs_dyn_table> get overwrite for every sheet.

Thats why i need an internal table which which store all those dynamic internal table and i can pass this internal table to transformation so that i can display data from all sheets together.

0 Kudos

As you only gave a very small portion of your code, it's hard to understand where your problem is.

But it seems that you don't need a dynamic internal table, because the source of your data is of the same nature, i.e. it's an excel file with multiple tabs, each containing rows of cells with a text Inside it.

TYPES: CELL TYPE STRING.

TYPES: ROW TYPE STANDARD TABLE OF CELL WITH EMPTY KEY.

TYPES: WORKSHEET TYPE STANDARD TABLE OF ROW WITH EMPTY KEY.

TYPES: WORKBOOK TYPE STANDARD TABLE OF WORKSHEET WITH EMPTY KEY.

DATA workbook TYPE WORKBOOK.