02-13-2007 2:35 PM
Hi,
DATA: SCHED_QUAN LIKE CETT-MENGE,
FIFTEEN_DAYS LIKE SY-DATUM.
FIFTEEN_DAYS = SY-DATUM + 15.
SCHED_QUAN = 0.
SORT CETT BY EBELP EINDT.
LOOP AT CETT.
IF CETT-EINDT GT FIFTEEN_DAYS.
EXIT.
ELSE.
SCHED_QUAN = CETT-MENGE + SCHED_QUAN.
ENDIF.
ENDLOOP.
F1 = SCHED_QUAN.
F2 = F1.
This code calculates the quantity(MENGE) of the individual items (EBELP) in the Purchase order to the delivered from the first record till 15 days from current date... However I am facing problems in the displaying the results... as it is returning the same quantity (last EBELP one) to all Items... How can i fix this one...
02-13-2007 3:02 PM
Hi!
DATA: SCHED_QUAN LIKE CETT-MENGE,
FIFTEEN_DAYS LIKE SY-DATUM.
FIFTEEN_DAYS = SY-DATUM + 15.
SCHED_QUAN = 0.
SORT CETT BY EBELP EINDT.
LOOP AT CETT.
IF CETT-EINDT GT FIFTEEN_DAYS.
CONTINUE. "EXIT. <<< to skip only the actual step
ELSE.
SCHED_QUAN = CETT-MENGE + SCHED_QUAN.
ENDIF.
ENDLOOP.
F1 = SCHED_QUAN.
F2 = F1.
Your version is working only if you are sorting by EINDT and then EBELP.
Regards
Tamá
02-13-2007 3:21 PM
You have removed the EXIT and replaced it with continue... Why????
Also what's the reason that its working only when sorted by EINDT and by EBELP.
02-13-2007 3:49 PM
Yes, but you wrote it in wrong order in your program. You can let the EXIT, if you write the EINDT first and EBELP second.
SORT CETT BY EINDT EBELP.
Or else you have to change EXIT to CONTINUE.
This is because if you sort your internal table first by EBELP, this field might cause wrong order in the dates. And in worst case if the lowest EBELP document has EINDT higher than 15 days, the processing will terminate immediately. Anyways wrong order will cause unstable working in your program.
Regards
Tamá