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: 

Transferring internal table contents to Dynamic internal table

sanjana_lingras
Active Participant
0 Kudos

Hi Experts,

I am facing issue while transferring contents of internal table to dynamic internal table.

The internal table contents which I want to transfer to dynamic internal table is in the output format of FM "RFC_READ_TABLE".

This internal table contains rows in string format. Below is the data in static internal table in the format of string.

Header 1

XXXXXXX         XYXYXYXY      ZZZZZZZZ          BBBBBBBB

XXXXXX1         XYXYXYX2       ZZZZZZZ2          BBBBBBB2
XXXXXX3         XYXYXYX3       ZZZZZZZ3         BBBBBBB3

Now I want to transfer this data to dynamic internal table.

I have already created dynamic internal table with required fields. Below is the screenshot of dynamic internal table.

BANKLBANKNBANKSLIFNR

I tried reading substring from row of static internal table (using offset and length) and transfer to dynamic internal , but I am not able to do it.

Values are only getting appended to first column of dynamic internal table. How can we transpose these rows to dynamic internal table.

Is there any way to populate dynamic internal table from static internal table of string format contents?

Regards,

Sanjana

7 REPLIES 7

former_member289261
Active Contributor
0 Kudos

Hi,

1.Read the row in a variable. Suppose variable name is ROW ( of type string ).

2. Create a structure of same line type as of your dynamic internal table. Suppose with name LS.

3. CONDENSE ROW.

4. SPLIT ROW AT SPACE INTO LS-Field1     LS-Field2     LS-Field3     LS-Field4.

5. APPEND LS TO ITAB.

Regards,

Ashish

former_member201275
Active Contributor
0 Kudos

Are you using OO for this? This is pretty much an FAQ and there are many links for this. Here is a good example using OO:

http://scn.sap.com/docs/DOC-42525

0 Kudos

Hi Ashish,

I need help split command as each time fields will change in dynamic internal table.

Regards,

Sanjana

0 Kudos

Hi,

DATA dyn_wa TYPE REF TO DATA. "work area for dynamic table

FIELD-SYMBOLS :     <fs_wa>, <fs_field>.

DATA lt TYPE TABLE OF STRING.

DATA wa TYPE STRING.

LOOP AT itab INTO lv.

SPLIT lv AT SPACE INTO TABLE lt.

Now you will have a table containing values in separate rows.

CREATE DATA dyn_wa LIKE LINE OF dyn_itab.

ASSIGN dyn_wa->* TO <fs_wa>.


LOOP lt INTO wa.

     ASSIGN COMPONENT SY-TABIX OF STRUCTURE <fs_wa> TO <fs_field>.

     <fs_field> = wa.

ENDLOOP.

APPEND <fs_wa> TO dyn_itab.

FREE : <fs_wa>, <fs_field>.

REFRESH lt.

ENDLOOP.

So, 1st value will be assigned to 1st field of structure,

2nd value will be assigned to 2nd field of structure and so on....

Regards,

Ashish

0 Kudos

Hi Ashish,

I will try to implement this and confirm.

Regards,

Sanjana

0 Kudos

Thanks Ashish, it worked.

Regards,

Sanjana

former_member289261
Active Contributor
0 Kudos

Hi,

Can I know why my answer which was marked correct got revoked ?