2007 Feb 06 11:40 AM
Hello All
Can anyone find out mistake in this code.
DATA: I TYPE I, " Number of PO item lines
HEADER_AMOUNT LIKE TKOMV-KWERT. " Header amount
Determine header condition amount.
READ TABLE TKOMV WITH KEY KPOSN = 0 KSCHL = XKOMV-KSCHL.
CHECK SY-SUBRC IS INITIAL.
HEADER_AMOUNT = TKOMV-KWERT.
Determine number of PO item lines
LOOP AT TKOMV WHERE NOT KPOSN IS INITIAL.
AT NEW KPOSN.
I = I + 1.
ENDAT.
ENDLOOP.
CHECK NOT I IS INITIAL.
Apportion header amount to item condition
XKWERT = HEADER_AMOUNT / I.
The loop is not ending in this case.
Points will be rewarded if my problem is solved.
Hi Sonal,
Is KPOSN the first field in the table TKOMV? It should be the first field to use at new kposn.
Also, you must sort t_komv on the field KPOSN first .
sort t_komv by KPOSN.
Regards,
Ravi
2007 Feb 06 11:50 AM
Sonal,
To find the number of items please correct the code as below:
Determine number of PO item lines
LOOP AT TKOMV WHERE<b> KNUMV = TKOMV-KNUMV</b>
AND NOT KPOSN IS INITIAL.
AT NEW KPOSN.
I = I + 1.
ENDAT.
ENDLOOP.
Keep rest all code as it is.
Let me know if this works,
Thanks.
2007 Feb 06 11:51 AM
Putting a Where statement on your LOOP. Then having the AT NEW command will not work.
Try the following: -
LOOP AT TKOMV.
check not KPOSN is initial.
AT NEW KPOSN.
I = I + 1.
ENDAT.
ENDLOOP.
2007 Feb 06 11:53 AM
Hi Sonal,
Is KPOSN the first field in the table TKOMV? It should be the first field to use at new kposn.
Also, you must sort t_komv on the field KPOSN first .
sort t_komv by KPOSN.
Regards,
Ravi
2007 Feb 06 12:00 PM
Sonal ,
KPOSN will always Unique for each and every line, So no need to do all these Stuff . Directly u can find out no of line items ?
<b>by using describe or loop-endloop.</b>
Reegards
prabhu
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |