2006 Oct 03 7:07 AM
hi friends,
I have two internal tables
Itab1 with fields A and B with data
Itab2 with fields C and D with data
I want to move data from itab1 and itab2 to finalitab where the finalitab fields are A B C and D
Pls code the following.
Thanx in advance.
Pravesh.
2006 Oct 03 7:16 AM
Hi,
You need a common field in tables itab1 and itab2.Then only,it will be meaningful to move the entries to finalitab.
loop at itab1 into wa1.
move-corresponding wa1 into wa_final.
loop at itab2 into wa2 where a = wa2-a.
move-corresponding wa2 into wa-final.
endloop.
append wa_final to finalitab.
endloop.
Kindly reward points by clicking the star on the left of reply,if it helps.
Message was edited by: Jayanthi Jayaraman
Hi,
You need a common field in tables itab1 and itab2.Then only,it will be meaningful to move the entries to finalitab.
loop at itab1 into wa1.
move-corresponding wa1 into wa_final.
loop at itab2 into wa2 where a = wa2-a.
move-corresponding wa2 into wa-final.
endloop.
append wa_final to finalitab.
endloop.
Kindly reward points by clicking the star on the left of reply,if it helps.
Message was edited by: Jayanthi Jayaraman
2006 Oct 03 7:10 AM
U HAVE TO MAKE ANY RELATIONSHIP B/W ITAB1 AND ITAB2.
OTHERWISE JUST APPEND INDIVIDULAL TABLE INTO ITAB_FINAL.
EX-
itab have. field a,b,c.
itab2 have field c,d.
it is . becoz there is one field a which is common in both.
2006 Oct 03 7:11 AM
Hi,
It doesn't seem that there is a common key for both tables. How do you want to join them? What do you want to happen when table 1 hasn't the same amount of records as table 2?
Eddy
PS.
Put yourself on the SDN world map (http://sdn.idizaai.be/sdn_world/sdn_world.html) and earn 25 points.
Spread the wor(l)d!
2006 Oct 03 7:11 AM
U can do this,but i think u are not clear as without key fields why do u want to move.
U can do like this,
loop at itab1.
move itab1 to final itab.
endloop.
loop at itab2.
move itab2 to final itab.
modify final itab.
endloop.
Make ur self clear and let me know if u face any problem
Regards
2006 Oct 03 7:13 AM
HI,
there should be some matching field in itab1 and itab2 on which you transfer to final itab.
try like this.
LOOP AT itab1.
READ table itab2 index = sy-tabix.
IF sy-subrc = 0.
final_itab-A = itab1-A.
final_itab-B = itab1-B.
final_itab-C = itab2-C.
final_itab-D = itab2-D.
APPEND final_itab.
ENDIF.
ENDLOOP.
Regards,
2006 Oct 03 7:13 AM
hi friends,
I have two internal tables
Itab1 with fields A and B with data
Itab2 with fields A and C with data
I want to move data from itab1 and itab2 to finalitab where the finalitab fields are A B and C.
Pls code the following.
Thanx in advance.
Pravesh.
2006 Oct 03 7:16 AM
sort itab1.
sort itab2.
itab_final[] = itab1[].
loop at itab_final.
reab table itab2 binary search with key a = itab_final-a.
itab_final-c = itab2-c.
modify itab_final.
endloop.
2006 Oct 03 7:17 AM
HI,
try the following code.
it will do you want.
<b>
LOOP AT itab1.
READ table itab2 with key A = itab1-A.
IF sy-subrc = 0.
final_itab-A = itab1-A.
final_itab-B = itab1-B.
final_itab-C = itab2-C.
APPEND final_itab.
ENDIF.
ENDLOOP.</b>
Regards,
2006 Oct 03 7:18 AM
u can do like this.
loop at itab1.
move itab1 to itab3.
loop at itab2 where a = itab1-a.
move itab2 to itab3.
endloop.
append itab3.
clear itab3.
endloop.
check and let me know if u face any problem.
Regards
2006 Oct 03 7:16 AM
Hi,
You need a common field in tables itab1 and itab2.Then only,it will be meaningful to move the entries to finalitab.
loop at itab1 into wa1.
move-corresponding wa1 into wa_final.
loop at itab2 into wa2 where a = wa2-a.
move-corresponding wa2 into wa-final.
endloop.
append wa_final to finalitab.
endloop.
Kindly reward points by clicking the star on the left of reply,if it helps.
Message was edited by: Jayanthi Jayaraman
2006 Oct 03 7:22 AM
Hi Parvez,
Inorder to do that there should be one field in common between ITAB1 and ITAB2. Lets assume the field E is common between two tables. Then :
loop at itab1.
itabfinal-a = itab1-a.
itabfinal-b = itab1-b.
read table itab2 into watab2 with key e = itab1-e.
if sy-subrc eq 0.
itabfinal-c = watab2-c.
itabfinal-d = watab2-d.
endif.
append itabfinal.
endloop.
Best regards,
Prashant
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |