‎2007 Jan 02 11:43 AM
Dear experts,
i need to put the below 4 internal table values into i_final internal table,
SELECT warpl wstra plnnr plnal
FROM mpos INTO CORRESPONDING FIELDS OF TABLE i_mpos
WHERE warpl IN p_warpl.
SELECT warpl abnum zaehl nplda terma stadt lrmdt
offze offzo abrud abrna
INTO CORRESPONDING FIELDS OF TABLE i_mhis
FROM mhis
FOR ALL ENTRIES IN i_mpos
where warpl = i_mpos-warpl.
SELECT plnnr plnal plnkn paket zaehl datuv strat
INTO CORRESPONDING FIELDS OF TABLE i_plwp
FROM plwp
FOR ALL ENTRIES IN i_mpos
WHERE plnnr = i_mpos-plnnr AND
plnal = i_mpos-plnal.
SELECT plnnr plnkn ltxa1 arbei
INTO CORRESPONDING FIELDS OF TABLE i_plpo
FROM plpo
FOR ALL ENTRIES IN i_plwp
WHERE plnnr = i_plwp-plnnr AND
plnkn = i_plwp-plnkn.
could any one pls send coding for the above
thanks in advance
karthik
‎2007 Jan 02 11:46 AM
refer demo code below -
Sort itab_vbap by vbeln posnr.
sort itab_vbkd by vbeln posnr.
Loop at itab_vbap into wa_vbap.
read table itab_vbkd into wa_vbkd with key vbeln = wa_vbap-vbeln posnr = wa_vbap-posnr binary search.
if sy-subrc = 0.
move corresponding wa_vbap to wa_final.
move corresponding wa_vbkd to wa_final.
append wa_final to itab_final.
endif.
endloop.
For move corresponding statement the name of the fields should match in both the work areas.
‎2007 Jan 02 11:52 AM
Hi Karthik,
1.Create a workarea for the final internal table.
2. Read the 4 internal tables and transfer the data from work areas of the 4 internal tables to the final internal table.
Regards
Kannaiah
‎2007 Jan 02 12:01 PM
Hi Karthik,
sort i_mpos by warpl.
sort i_mhis by warpl.
sort i_plwp by plnnr.
sort i_plpo by plnnr.
loop at i_mpos.
move-corresponding i_mpos to it_final.
read table i_mhis with key warpl eq i_mpos-warpl binary search.
if sy-subrc eq 0.
move-corresponding i_mhis to it_final.
endif.
read table i_plwp with key plnnr eq i_mpos-plnnr binary search.
if sy-subrc eq 0.
move-corresponding i_plwp to it_final.
endif.
read table i_plpo with key plnnr eq i_mpos-plnnr binary search.
if sy-subrc eq 0.
move-corresponding i_plpo to it_final.
endif.
append it_final.
clear it_final.
endloop.
‎2007 Jan 02 12:18 PM
Dear Sekar,
The problem is all the four internal table containd different number of entries.
I applied you code but only one record is coming in the final internal table, bez the mpos table containd only one entry and mhis table contains 12 entries and plwp comtains 4 entries
‎2007 Jan 02 12:45 PM
hi,
loop at i_plpo.
read table i_plwp with key plnnr = i_plpo-plnnr.
read table i_mhis with key zaehl = i_plwp-zaehl.
read table i_mpos with key warpl = i_mhis-warpl.
then assign the final table fields value from respective internal table.
append finaltable.
endloop.
if helpful get me some points.
regards.
Praveen.
‎2007 Jan 02 2:25 PM
I cannot check fully because i dont have records for this combination. you can try this with your records.
I hope it will work.
*****************************
REPORT Z_TESTYUVA .
Tables : MPOS,
MHIS,
PLWP,
PLPO.
*data p_warpl LIKE mpos-warpl.
Parameter : p_warpl LIKE mpos-warpl.
DATA : i_mpos LIKE mpos Occurs 0 With Header Line,
i_mhis LIKE mhis Occurs 0 With Header Line,
i_plwp LIKE plwp Occurs 0 With Header Line,
i_plpo LIKE plpo Occurs 0 With Header Line.
DATA : Begin of it_final Occurs 0 ,
warpl LIKE MPOS-warpl,
wstra LIKE MPOS-wstra,
plnnr LIKE MPOS-plnnr,
plnal LIKE MPOS-plnal,
abnum LIKE MHIS-abnum,
zaehl LIKE MHIS-zaehl,
nplda LIKE MHIS-nplda,
terma LIKE MHIS-terma,
stadt LIKE MHIS-stadt,
lrmdt LIKE MHIS-lrmdt,
offze LIKE MHIS-offze,
offzo LIKE MHIS-offzo,
abrud LIKE MHIS-abrud,
abrna LIKE MHIS-abrna,
plnkn LIKE PLWP-plnkn,
paket LIKE PLWP-paket,
datuv LIKE PLWP-datuv,
strat LIKE PLWP-strat,
ltxa1 LIKE PLPO-ltxa1,
arbei LIKE PLPO-arbei,
END OF it_final.
SELECT warpl wstra plnnr plnal
FROM mpos INTO CORRESPONDING FIELDS OF TABLE i_mpos
WHERE warpl = p_warpl.
SELECT warpl abnum zaehl nplda terma stadt lrmdt
offze offzo abrud abrna
INTO CORRESPONDING FIELDS OF TABLE i_mhis
FROM mhis
FOR ALL ENTRIES IN i_mpos
where warpl = i_mpos-warpl.
SELECT plnnr plnal plnkn paket zaehl datuv strat
INTO CORRESPONDING FIELDS OF TABLE i_plwp
FROM plwp
FOR ALL ENTRIES IN i_mpos
WHERE plnnr = i_mpos-plnnr AND
plnal = i_mpos-plnal.
SELECT plnnr plnkn ltxa1 arbei
INTO CORRESPONDING FIELDS OF TABLE i_plpo
FROM plpo
FOR ALL ENTRIES IN i_plwp
WHERE plnnr = i_plwp-plnnr AND
plnkn = i_plwp-plnkn.
loop at i_mpos.
move-corresponding i_mpos to it_final.
LOOP AT i_mhis WHERE warpl = i_mpos-warpl.
move-corresponding i_mhis to it_final.
APPEND it_final.
CLEAR it_final.
ENDLOOP.
LOOP AT i_plwp WHERE plnnr = i_mpos-plnnr AND
plnal = i_mpos-plnal.
move-corresponding i_plwp to it_final.
MODIFY it_final TRANSPORTING plnnr plnal plnkn paket zaehl datuv strat "You can try giving all to transporting
WHERE plnnr = i_mpos-plnnr AND
plnal = i_mpos-plnal.
LOOP AT i_plpo WHERE plnnr = i_plwp-plnnr AND
plnkn = i_plwp-plnkn.
move-corresponding i_plpo to it_final.
MODIFY it_final TRANSPORTING plnnr plnkn ltxa1 arbei "You can try giving all to transporting
WHERE plnnr = i_plwp-plnnr AND
plnal = i_plwp-plnal.
ENDLOOP.
ENDLOOP.
ENDLOOP.
BY
Yuvaram.
Reward if useful
‎2007 Jan 02 3:05 PM
Well in my eyes you sould either have a global structure for your final ITAB, or you should define one locally.
then just make your selects into the corresponding fields of your final ITAB.
Example:
This creates you an internal table with all the attributes of the four internal tables
DATA: Begin of i_final,
Include mpos (if the type of your itab i_mpos is not mpos, use this type),
Include mhis (same goes for those itabs),
Include plpw (same goes for those itabs),
Include plpo (same goes for those itabs),
End of i_final.
SELECT warpl wstra plnnr plnal
FROM mpos
INTO CORRESPONDING FIELDS OF TABLE i_final
where warpl in p_warpl.
SELECT abnum zaehl nplda terma stadt lrmdt
FROM mhis
INTO CORRESPONDING FIELDS OF TABLE i_final
FOR ALL ENTRIES IN i_mpos
WHERE warpl = p_warpl.
SELECT plnnr plnal plnkn paket zeahl datuv strat
FROM plpw
INTO CORRESPONDING FIELDS OF TABLE i_final
WHERE plnnr = i_final-plnnr
AND plnal = i_final-plnal.
SELECT itxa arbei
FROM plpo
INTO CORRESPONDING FIELDS OF TABLE i_final
WHERE plnnr = i_final-plnnr
AND plnkn = i_final-plnkn.