2009 Feb 27 11:43 AM
Hi Experts ...
hope you will help me out...
I have use AT End of , expecting that will solve my problem.....
but since iam new to control break stmt....iam struggling abit to fix it off...
As per my code....
The same value gets repeated for WA_FINAL-GROSS and WA_FINAL-NET
its not refreshing , and same value gets repeated...
can you please help me out correctin my AT End of code
CODE
sort it_bseg by belnr.
loop at it_bseg into wa_bseg .
wa_final-kunnr = wa_bseg-kunnr.
read table it_amount into wa_amount with key belnr = wa_bseg-belnr.
At end of belnr.
if wa_bseg-hkont = '0000500100'.
if sy-subrc = 0.
wa_final-gross = wa_amount-dmbtr.
endif.
endif.
if wa_bseg-koart = 'D'.
if sy-subrc = 0.
wa_final-net = wa_amount-dmbtr.
Endif.
Endif.
*at end of belnr.
*Endif.
read table it_bkpf into wa_bkpf with key belnr = wa_bseg-belnr.
if sy-subrc = 0.
wa_final-xblnr = wa_bkpf-xblnr.
wa_final-bldat = wa_bkpf-bldat.
endif.
*At end of belnr.
append wa_final to it_final.
Endat.
clear wa_amount.
clear wa_final.
endloop.
2009 Feb 27 11:48 AM
Hello Rachel,
A typical problem faced with LOOP control stmts. Declare another work area WA_BSEG1 and use it for processing:
SORT it_bseg BY belnr.
DATA: wa_bseg1 LIKE wa_bseg.
LOOP AT it_bseg INTO wa_bseg.
wa_bseg1 = wa_bseg.
wa_final-kunnr = wa_bseg1-kunnr.
READ TABLE it_amount INTO wa_amount WITH KEY belnr = wa_bseg1-belnr.
AT END OF belnr.
IF wa_bseg1-hkont = '0000500100'.
IF sy-subrc = 0.
wa_final-gross = wa_amount-dmbtr.
ENDIF.
ENDIF.
IF wa_bseg1-koart = 'D'.
IF sy-subrc = 0.
wa_final-net = wa_amount-dmbtr.
ENDIF.
ENDIF.
READ TABLE it_bkpf INTO wa_bkpf WITH KEY belnr = wa_bseg1-belnr.
IF sy-subrc = 0.
wa_final-xblnr = wa_bkpf-xblnr.
wa_final-bldat = wa_bkpf-bldat.
ENDIF.
*At end of belnr.
APPEND wa_final TO it_final.
ENDAT.
CLEAR wa_amount.
CLEAR wa_final.
ENDLOOP.
Hope this helps.
BR,
Suhas
2009 Feb 27 12:07 PM
Thanx for helping me out...
I tried the way u said...but still doesnt reflect any changes........
2009 Feb 27 11:48 AM
At end of triggers for every end of the unique combination of the fields left to the BELNR in your case.
You need not to write if sy-subrc inside, ex if wa_bseg-hkont = '0000500100'.
if sy-subrc = 0. In this case Sy-subrc is not required. the above check is enough.
If you understand the concept of At end of it will be easy.
2009 Feb 27 11:52 AM
Use statement clear wa_bseg at the end of each loop ..
Regards
Nishit .
2009 Feb 27 11:50 AM
i think the 1st At end of belnr statement should be before the READ staement.
regards,
sravan
2009 Feb 27 11:53 AM
Check the codes:
DATA:W_index type i,
w_index1 type i.
sort it_bseg by belnr.
loop at it_bseg into wa_bseg .
add 1 to w_index.
wa_final-kunnr = wa_bseg-kunnr.
read table it_amount into wa_amount with key belnr = wa_bseg-belnr.
At end of belnr.
w_index1 = w_index.
Endat.
IF w_index1 = w_index.
if wa_bseg-hkont = '0000500100'.
if sy-subrc = 0.
wa_final-gross = wa_amount-dmbtr.
endif.
endif.
if wa_bseg-koart = 'D'.
if sy-subrc = 0.
wa_final-net = wa_amount-dmbtr.
Endif.
Endif.
*at end of belnr.
*Endif.
read table it_bkpf into wa_bkpf with key belnr = wa_bseg-belnr.
if sy-subrc = 0.
wa_final-xblnr = wa_bkpf-xblnr.
wa_final-bldat = wa_bkpf-bldat.
endif.
*At end of belnr.
append wa_final to it_final.
ENDIF.
clear wa_amount.
clear wa_final.
endloop.
Regards,
Gurpreet