08-13-2014 9:32 AM
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.
BANKL | BANKN | BANKS | LIFNR |
---|---|---|---|
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
08-13-2014 9:42 AM
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
08-13-2014 9:42 AM
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:
08-13-2014 11:45 AM
Hi Ashish,
I need help split command as each time fields will change in dynamic internal table.
Regards,
Sanjana
08-13-2014 12:12 PM
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
08-13-2014 1:30 PM
Hi Ashish,
I will try to implement this and confirm.
Regards,
Sanjana
08-14-2014 7:17 AM
08-14-2014 9:46 AM
Hi,
Can I know why my answer which was marked correct got revoked ?