Skip to Content
0
Nov 15, 2007 at 03:52 PM

AT END OF within LOOP does not work

32 Views

Hello,

I want to loop over a table and make sums per arbpl:

TYPES: BEGIN OF hd_auf,

aufnr TYPE afko-aufnr,

matnr TYPE afko-plnbez,

eckd TYPE afko-gltrp,

arbpl TYPE crhd-arbpl,

rmenge TYPE zzppauftrag-gutmenge,

rzeit TYPE zzppauftrag-ruestzeit,

ist TYPE zzppauftrag-istgeschw,

END OF hd_auf.

TYPES: auftragsinfo TYPE TABLE OF hd_auf.

DATA: auf_header TYPE hd_auf.

DATA: auf TYPE auftragsinfo.

... put data into table auf ...

SORT auf BY arbpl ASCENDING eckd ASCENDING.

LOOP AT auf INTO auf_header.

WRITE:/01 auf_header-arbpl, auf_header-aufnr, auf_header-matnr,

auf_header-eckd, auf_header-rmenge, auf_header-ist,

auf_header-rzeit, status.

AT END OF arbpl.

SUM.

WRITE: /01 auf_header-rzeit.

ENDAT.

ENDLOOP.

This does not work. I will always get one sum per line, regardless how much equal lines with the same arbpl are in the table auf.

This is the output (the line with the number is the sum-line):

D-OFF 1000840 110220-1

0,013

D-OFF 1000740 211220-1

16,667

THM-U001 1000642 250220-17373G

0,028

THM-U001 1000660 250220-10021S

0,167

UMM. 001 1000640 250220-17373G

0,111

UMM. 001 1000641 250220-17373G

0,056

UMM. 001 1000629 250220-17373G

0,111

UMM. 001 1000780 211220-10101

0,167

UMM. 001 1000741 211220-10101

0,139

But I need the following output:

D-OFF 1000840 110220-1

D-OFF 1000740 211220-1

16,68

THM-U001 1000642 250220-17373G

THM-U001 1000660 250220-10021S

0,195

UMM. 001 1000640 250220-17373G

UMM. 001 1000641 250220-17373G

UMM. 001 1000629 250220-17373G

UMM. 001 1000780 211220-10101

UMM. 001 1000741 211220-10101

0,584

What is wrong with my loop?

Could anyone please help me?

Thanks.

Regards,

Oliver