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

How to move data from dynamic internal table into static internal table.

Former Member
0 Likes
6,775

Hi Experts,

I have move data from dynamic internal table to static internal table means <dyn_table> this is the dynamic internal table having records.These records are i want to move into  gt_dyntab this internal table.gt_dyntab in this internal table two fields having name nad data.The name field is holding internal table name and data field is holding column of internal table, So i want move records into in data field of internal table gt_dyntab.Anybody can help me for this requirement.

CREATE DATA gs_dyntab-data TYPE STANDARD TABLE OF (v_kotab).

APPEND gs_dyntab TO gt_dyntab. CLEAR gs_dyntab.

MOVE-CORRESPONDING <dyn_table> TO gt_dyntab-data.

Thanks.

Hi Experts,

I have move data from dynamic internal table to static internal table means <dyn_table> this is the dynamic internal table having records.These records are i want to move into  gt_dyntab this internal table.gt_dyntab in this internal table two fields having name nad data.The name field is holding internal table name and data field is holding column of internal table, So i want move records into in data field of internal table gt_dyntab.Anybody can help me for this requirement.

CREATE DATA gs_dyntab-data TYPE STANDARD TABLE OF (v_kotab).

APPEND gs_dyntab TO gt_dyntab. CLEAR gs_dyntab.

MOVE-CORRESPONDING <dyn_table> TO gt_dyntab-data.

Thanks.

3 REPLIES 3
Read only

Former Member
0 Likes
2,810

Hi;

You can use following form if you have ABAP 7.40 version.

MOVE-CORRESPONDING [EXACT] itab1 TO itab2
EXPANDING NESTED TABLE]

ABAP Keyword Documentation

Alternatively you can use :

loop at table <dyn_table> into <dyn_str>.

MOVE-CORRESPONDING <dyn_str> TO gs_dyntab.

append gs_dyntab to gt_dyntab.

endloop.

Read only

rajkumarnarasimman
Active Contributor
0 Likes
2,810

Hi Pradeep,

Also you can check the below code too.


DATA: l_line TYPE REF TO data.


CREATE DATA l_line LIKE LINE OF <dyn_table>.


FIELD-SYMBOLS: <fs_line> TYPE ANY.


ASSIGN l_line->* TO <fs_line>.


"Run the Loop

LOOP AT <dyn_table> INTO <fs_line>.

"Assign the value

ASSIGN COMPONENT 'BWART' OF STRUCTURE <fs_line> TO <fs_bwart>.

"Check value is initialized

IF <fs_bwart> IS ASSIGNED.

"Assign to final work area

  WA_FINAL-BWART = <FS_BWART>.

ENDIF.

"Append final internal table

APPEND WA_FINAL TO IT_FINAL.

"Clear WA

CLEAR WA_FINAL.


ENDLOOP.

Regards

Rajkumar Narasimman

Read only

matt
Active Contributor
0 Likes
2,810

Moderator message: why is your question identical to this one http://scn.sap.com/thread/3698440 by http://scn.sap.com/people/ram.sahoo

Note: failure to address my question adequately may result in further moderation action.

Edit: I know why. It's because the question was rejected already three times for Ram Sahoo. Refusal to accept moderator decisions can result in your account being suspended. Do not do this again. If you disagree with a moderator decision, take it to http://scn.sap.com/community/support