Skip to Content
3
Former Member
Aug 13, 2009 at 06:02 AM

"AT END OF " statement not working

12274 Views

Dear All,

I have the code as below ,where i need to display the report customer wise and at the end of each customer wants the total of the qty for that customer.

But the AT END OF KUNNR is not working as expected.

SORT ITAB_RESULT BY KUNNR.

FORMAT RESET.

LOOP AT itab_result.

WRITE: /1(18) itab_result-matnr,

20(4) itab_result-spart,

25(15) itab_result-description,

42(8) itab_result-cr_date,

52(12) itab_result-kunnr,

65(8) itab_result-req_qty,

75(8) itab_result-sug_qty,

85(8) itab_result-ersda,

95(8) itab_result-fob,

105(8) itab_result-po_qty,

115(8) itab_result-atp_stock,

125(8) itab_result-po_receive_qty,

135(8) itab_result-po_sn_qty,

145(8) itab_result-bo_qty,

155(15) itab_result-netcbm LEFT-JUSTIFIED,

170(15) itab_result-grocbm LEFT-JUSTIFIED,

185(8) itab_result-mm01,

195(8) itab_result-mm02,

205(8) itab_result-mm03,

215(8) itab_result-mm04,

225(8) itab_result-mm05,

235(8) itab_result-mm06,

245(8) itab_result-mm07,

255(8) itab_result-mm08,

265(8) itab_result-mm09,

275(8) itab_result-mm10,

285(8) itab_result-mm11,

295(8) itab_result-mm12.

AT END OF kunnr.

FORMAT INTENSIFIED ON.

SKIP 1.

WRITE: /1 sy-uline.

SUM.

WRITE: /50 'CUSTOMER Total : ',

65(8) itab_result-req_qty DECIMALS 0,

75(8) itab_result-sug_qty DECIMALS 0.

WRITE: /1 sy-uline.

SKIP 1.

ENDAT.

AT LAST.

SKIP 1.

WRITE: /1 sy-uline.

SUM.

WRITE: /50 'Final Total : ',

65(8) itab_result-req_qty DECIMALS 0,

75(8) itab_result-sug_qty DECIMALS 0.

ENDAT.

ENDLOOP.

The result report displays the total after each record even the two records are for the same customer.

Please suggest what's worng in the coding.

Thanks in advance,

Swati