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: 

Copy and Modify from one internal table to another.Please help.

Former Member
0 Kudos
58

Hi,

I have an internal table having a structure like below.

Account Entity Category period1value pd2value

10 A C 100 200.

where account corresponds to 10

entity A

category C

period1 value = 100

period2 value = 200.

Now I need to populate it into another table having structure like

Account Entity Category period Value

10 A C 1 100

10 A C 2 200.

If u see this carefully a new column, period is added in the database table and thus for each row there will be only 1value.

Instead of period1 value and period2 value being in the same row they will come in different rows.One row will be like the value for period1 and next for value like period2.

Pleadse help

Ankit

2 REPLIES 2

Former Member
0 Kudos
30

Hi

Do this

Account Entity Category period1value pd2value

10 A C 100 200.

loop at ITAB1.

itab2-Account = ITAB1-Account.

itab2-Entity = ITAB1-Entity.

itab2-Category = ITAB1-Category.

itab2-period1value = ITAB1-period1value.

append itab2.

if itab1-pd2value is not initial.

itab2-pd2value = ITAB1-pd2value.

append itab2.

endif.

endloop.

Regards

Aditya

Former Member
0 Kudos
30

Hi,

u can do as follows,

LOOP AT itab1 into wa_itab1.

wa_itab2-account = wa_itab1-account.

wa_itab2-entity = wa_itab1-entity.

wa_itab2-category = wa_itab1-category.

if not wa_itab1-period1 is initial.

wa_itab2-period = wa_itab1-period1.

endif.

if not wa_itab1-period2 is intial.

wa_itab2-period = wa_itab1-period2.

endif.

wa_itab2-value = wa_itab1-value.

append wa_tab2 to itab2.

clear:wa_itab1-period1 ,

wa_itab2-period .

endloop.