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

Filling dynamic internal table using data from some other internal table

Former Member
0 Likes
1,084

Hi,

One of my internal table is filled from transparent table. Second internal table is created using RTTI ( dynamic table ). I want to fill the second table by looping on the first table and moving matching fields and other fields based on conditions. How to do it? how to compare the table of two fields during runtime, and then move. Kindly help me out in filling the 2nd table.

new_type = cl_abap_structdescr=>create( fcat_table ).

TRY.

CALL METHOD CL_ABAP_TABLEDESCR=>CREATE

EXPORTING

P_LINE_TYPE = new_type

P_TABLE_KIND = cl_abap_tabledescr=>tablekind_std

P_UNIQUE = ABAP_FALSE

  • P_KEY =

  • P_KEY_KIND = KEYDEFKIND_DEFAULT

RECEIVING

P_RESULT = new_tab

.

CATCH CX_SY_TABLE_CREATION .

ENDTRY.

ASSIGN tab_records->* to <disp_tab>.

CREATE DATA tab_line like line of <disp_tab>.

LOOP AT i_validn_categ ASSIGNING <struc_dbtable>.

ENDLOOP.

Regards,

DPM

8 REPLIES 8
Read only

former_member209703
Active Contributor
0 Likes
827

If your dynamic IT is assigned you can just use move-corresponding to move the common fields from your first table to the dynamic Table/Work Area.

It would be something like ithis:

[]

Read only

Shahid
Product and Topic Expert
Product and Topic Expert
0 Likes
827

Do you want to check the FIELDNAME and then you want to move the value to other table

or

simply you want to push the records from one tab to other tab?

Read only

Former Member
0 Likes
827

Yes, some fields are common. There is one field in 1st internal table, which is split across many fields in 2nd table, most of the remaining fields are same in both the tables. So based on condition value will move to field in 2nd bucket.

Thanks,

DPM

Read only

Former Member
0 Likes
827

Hi

You need to use the field-symbol, but how depends on the conditions you need

Max

Read only

sivaprasad_ml
Participant
0 Likes
827

Hello,

Loop at the tab1 to tab1 work area.

move corresponding fields of tabl wa to tab2 wa.

modify tab2 from tab2 work area.

end the loop.

This is a method of transferring datas from one table to another

Rgds

Siva

Read only

Former Member
0 Likes
827

My Team Lead helped in resolving the issue. Thanks to all of you for your support.

Solution:

I was trying to fill the empty dynamic table from another table which was already filled. I changed the approach and instead filled a known field of a dynamic table from database table followed by:

looping at dynamic internal table and assigning component of structure ,then using read table from the 1st table( already filled using select query from dbtable), I managed to fill the other fields.

Regards,

DPM

Read only

0 Likes
827

This message was moderated.

Read only

0 Likes
827

Hi,

Please check the "Last Logged In:" of DEBOPRIYO MALLICK......

Regards .