‎2010 Feb 09 1:55 PM
Hi Experts,
I Have two internal tables.
Table 1 structure:
Name
Age
Table 2 structure :
Name
age
branch
Now the table 1 has some 5 data's and table 2 is empty.
First i want to move that 5 data's from table 1 to table 2.
Then the branch field is same for all records. its stored in a separate field called 'Branch'.
finallay i need to move that branch to internal table 2 for all records.
So the Table 2 should has five records and each record should have the branch.Its like,
Name Age Branch
name1 10 ECE
name2 10 ECE
I didnt use with header line for both tables. In function module i declared as table parameter.
Please give me a logic.
Helps will be appreciated.
‎2010 Feb 09 2:02 PM
hi,
Try this.
itab2 = itab1.
wa2-brach = 'ECE'. (wa2 is WA for ITab2)
Modify itab2 transporting branch from wa2.
Regards,
Komal
‎2010 Feb 09 1:58 PM
‎2010 Feb 09 2:01 PM
The logic is quite simple. Loop at the first table, inside that loop, loop through the branches appropiate for that name and age, and for each appropiate branch append a record in the second table.
‎2010 Feb 09 2:02 PM
hi,
Try this.
itab2 = itab1.
wa2-brach = 'ECE'. (wa2 is WA for ITab2)
Modify itab2 transporting branch from wa2.
Regards,
Komal
‎2010 Feb 09 2:31 PM
hi,
try this.
loop at itab1 into wa1.
read table itab2 into wa2.
wa2-name = wa1-name.
wa2-age = wa1-age.
append wa2 to itab2.
endloop.
clear wa1.
clear wa2.
loop at itab2 into wa2.
wa2-branch = 'ECE'.
modify itab2 transaporting wa2-branch.
endloop.
regards,
sakshi
‎2010 Feb 09 2:46 PM
Dear Jain,
Since the second table is empty and we only move the data of first table to second table, in this case there is no need of read statement.
There is also no need of second loop because we can populate branch field in first loop itself.
‎2010 Feb 09 2:41 PM
Since the structure of yur both internal table is different so you can't use ITAB1[] = ITAB2[] statements.
In this case you have to loop on first table then move data into second table and appned data into second table.
Declare work area for both table with like line of statement as follows
data: wa_itab1 like line of itab1,
wa_itab2 like line of itab2.
Loop at ita1 into wa_itab1.
wa_itab2-name = wa_itab1-name.
wa_itab2-age = wa_itab1-age.
wa_itab2-branch = 'ECE'.
append wa_itab to itab2.
clear wa_itab1, wa_itab2.
endloop.
Hope this will solve your problem.
‎2010 Feb 10 9:41 AM