2009 May 09 8:05 AM
hi experts .....
i dont know wats wrong in my loop , the problem is in it_ekpo i have only 5 entries but
when it gets executed it checks for the condition
where ebeln = wa_bseg-ebeln in it_ekpo loop and bring all entries of it_bseg, but i want only
the 5 entries which is it_ekpo.....can u pls help me out ...where i have gone wrong
Code
=====
sort it_ekpo by ebeln.
sort it_bkpf by belnr.
loop at it_bkpf into wa_bkpf .
wa_final-budat = wa_bkpf-budat.
loop at it_bseg into wa_bseg where belnr = wa_bkpf-belnr.
wa_final-ebeln = wa_bseg-ebeln.
read table it_lfa1 into wa_lfa1 with key lifnr = wa_bseg-lifnr.
if sy-subrc = 0.
wa_final-name1 = wa_lfa1-name1.
wa_final-ort01 = wa_lfa1-ort01.
Endif.
read table it_J_1IMOVEND into wa_J_1IMOVEND with key lifnr = wa_bseg-lifnr.
if sy-subrc = 0.
wa_final-J_1ILSTNO = wa_J_1IMOVEND-J_1ILSTNO.
endif.
loop at it_ekpo into wa_ekpo where ebeln = wa_bseg-ebeln .
read table it_ekko into wa_ekko with key ebeln = wa_ekpo-ebeln.
wa_final-ematn = wa_ekpo-ematn.
wa_final-txz01 = wa_ekpo-txz01.
wa_final-menge = wa_ekpo-menge.
wa_final-netwr = wa_ekpo-netwr.
QTY = QTY + WA_FINAL-MENGE.
move qty to wa_final-qty.
*****FOR TAX CODE 45
If wa_ekpo-mwskz = '45' .
wa_final-ZBED = ( wa_final-netwr * TAX3 ) / 100.
tot2 = tot2 + wa_final-zbed.
move tot2 to wa_final-t3.
wa_final-ZEX1 = ( wa_final-netwr * TAX4 ) / 100.
tot3 = tot3 + wa_Final-zex1.
move tot3 to wa_final-t4.
wa_final-ZEX2 = ( wa_final-netwr * TAX5 ) / 100.
tot4 = tot4 + wa_final-zex2.
move tot4 to wa_final-t4.
wa_final-JIPC = ( wa_final-netwr * TAX2 ) / 100.
tot5 = tot5 + wa_final-jipc.
move tot5 to wa_final-t5.
Endif.
sort it_bseg by ebeln.
delete adjacent duplicates from it_bseg comparing ebeln.
Endloop.
append wa_final to it_final.
clear :wa_ekpo, wa_ekko.
Endloop.
clear : wa_bseg.
Endloop.
Endif.Edited by: Rachel Arun on May 9, 2009 12:36 PM
2009 May 09 8:35 AM
Hi Rachel,
I have made small change in your code please check that --
sort it_ekpo by ebeln.
sort it_bkpf by belnr.
LOOP AT it_ekpo INTO wa_ekpo. " Added
loop at it_bkpf into wa_bkpf .
wa_final-budat = wa_bkpf-budat.
loop at it_bseg into wa_bseg where belnr = wa_bkpf-belnr.
wa_final-ebeln = wa_bseg-ebeln.
read table it_lfa1 into wa_lfa1 with key lifnr = wa_bseg-lifnr.
if sy-subrc = 0.
wa_final-name1 = wa_lfa1-name1.
wa_final-ort01 = wa_lfa1-ort01.
Endif.
read table it_J_1IMOVEND into wa_J_1IMOVEND with key lifnr = wa_bseg-lifnr.
if sy-subrc = 0.
wa_final-J_1ILSTNO = wa_J_1IMOVEND-J_1ILSTNO.
endif.
loop at it_ekpo into wa_ekpo where ebeln = wa_bseg-ebeln .
read table it_ekko into wa_ekko with key ebeln = wa_ekpo-ebeln.
wa_final-ematn = wa_ekpo-ematn.
wa_final-txz01 = wa_ekpo-txz01.
wa_final-menge = wa_ekpo-menge.
wa_final-netwr = wa_ekpo-netwr.
QTY = QTY + WA_FINAL-MENGE.
move qty to wa_final-qty.
*****FOR TAX CODE 45
If wa_ekpo-mwskz = '45' .
wa_final-ZBED = ( wa_final-netwr * TAX3 ) / 100.
tot2 = tot2 + wa_final-zbed.
move tot2 to wa_final-t3.
wa_final-ZEX1 = ( wa_final-netwr * TAX4 ) / 100.
tot3 = tot3 + wa_Final-zex1.
move tot3 to wa_final-t4.
wa_final-ZEX2 = ( wa_final-netwr * TAX5 ) / 100.
tot4 = tot4 + wa_final-zex2.
move tot4 to wa_final-t4.
wa_final-JIPC = ( wa_final-netwr * TAX2 ) / 100.
tot5 = tot5 + wa_final-jipc.
move tot5 to wa_final-t5.
Endif.
sort it_bseg by ebeln.
delete adjacent duplicates from it_bseg comparing ebeln.
Endloop.
clear :wa_ekpo, wa_ekko.
Endloop.
append wa_final to it_final. " Place changed
endloop. "Added
clear : wa_bseg.
Endloop.
Endif.Regards
Pinaki
Hello,
Technically the code is correct. Please explain your requirement in details. Also provide the data in the internal table, whicvh will help in detailed analysis.
2009 May 09 8:28 AM
Hello,
Technically the code is correct. Please explain your requirement in details. Also provide the data in the internal table, whicvh will help in detailed analysis.
2009 May 09 8:33 AM
Hi,
I am not very sure of your requirement. You are taking EKPO-ematn in your final table but your are not appending your final table within the LOOP-ENDLOOP on EKPO table.
However you are doing it within the LOOP-ENDLOOP of BSEG table.
This is the result why you are getting all entries on BSEG.
If i presume that you just need the sum of the quantities of EKPO and not the actual 5 entries then to achieve that do the following.
Immediately after the ENDLOOP on EKPO, do a sy-subrc check.
append only if the sy-subrc value is 0.
By this you will get the EBELN which is in BSEG and EKPO.
If you want all the 5 entries on EKPO then do the append within the LOOP-ENDLOOP of EKPO.
PLease remove the Delete adjacent duplicate statement on BSEG within the EKPO loop.
It does not make any sense.
Regards,
Ankur Parab
2009 May 09 8:35 AM
Hi Rachel,
I have made small change in your code please check that --
sort it_ekpo by ebeln.
sort it_bkpf by belnr.
LOOP AT it_ekpo INTO wa_ekpo. " Added
loop at it_bkpf into wa_bkpf .
wa_final-budat = wa_bkpf-budat.
loop at it_bseg into wa_bseg where belnr = wa_bkpf-belnr.
wa_final-ebeln = wa_bseg-ebeln.
read table it_lfa1 into wa_lfa1 with key lifnr = wa_bseg-lifnr.
if sy-subrc = 0.
wa_final-name1 = wa_lfa1-name1.
wa_final-ort01 = wa_lfa1-ort01.
Endif.
read table it_J_1IMOVEND into wa_J_1IMOVEND with key lifnr = wa_bseg-lifnr.
if sy-subrc = 0.
wa_final-J_1ILSTNO = wa_J_1IMOVEND-J_1ILSTNO.
endif.
loop at it_ekpo into wa_ekpo where ebeln = wa_bseg-ebeln .
read table it_ekko into wa_ekko with key ebeln = wa_ekpo-ebeln.
wa_final-ematn = wa_ekpo-ematn.
wa_final-txz01 = wa_ekpo-txz01.
wa_final-menge = wa_ekpo-menge.
wa_final-netwr = wa_ekpo-netwr.
QTY = QTY + WA_FINAL-MENGE.
move qty to wa_final-qty.
*****FOR TAX CODE 45
If wa_ekpo-mwskz = '45' .
wa_final-ZBED = ( wa_final-netwr * TAX3 ) / 100.
tot2 = tot2 + wa_final-zbed.
move tot2 to wa_final-t3.
wa_final-ZEX1 = ( wa_final-netwr * TAX4 ) / 100.
tot3 = tot3 + wa_Final-zex1.
move tot3 to wa_final-t4.
wa_final-ZEX2 = ( wa_final-netwr * TAX5 ) / 100.
tot4 = tot4 + wa_final-zex2.
move tot4 to wa_final-t4.
wa_final-JIPC = ( wa_final-netwr * TAX2 ) / 100.
tot5 = tot5 + wa_final-jipc.
move tot5 to wa_final-t5.
Endif.
sort it_bseg by ebeln.
delete adjacent duplicates from it_bseg comparing ebeln.
Endloop.
clear :wa_ekpo, wa_ekko.
Endloop.
append wa_final to it_final. " Place changed
endloop. "Added
clear : wa_bseg.
Endloop.
Endif.Regards
Pinaki
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |