2008 Jan 21 10:09 AM
Material | Vendor | Mat.Doc.No | Transaction Qty | Bal.Qty | MENGE1 |
INPUT1 | INDP006 | 500542 | 1.000 | 1.000 | 0 |
INPUT1 | INDP006 | 500561 | 30.000 | 31.000 | 11 |
INPUT1 | INDP006 | 1000000696 | 10.000 | 21.000 | 10 |
At this point different vendor but the same material
INPUT1 | INIU003 | 500526 | 10.000 | 31.000 | 0 |
INPUT1 | INIU003 | 500527 | 2.000 | 33.000 | 0 |
INPUT1 | INIU003 | 1000000623 | 6.000 | 27.000 | 0 |
INPUT1 | INIU003 | 1000000624 | 4.000 | 23.000 | 0 |
INPUT1 | INIU003 | 1000000625 | 1.000 | 22.000 | 0 |
INPUT1 | INIU003 | 1000000626 | 1.000 | 21.000 | 0 |
ROH1 | INDP006 | 500543 | 2.000 | 2.000 | 2 |
LOOP AT ITFINAL.
AT NEW MATNR.
CLEAR: SUM1,SUM2.
*ENDAT.
AT NEW LIFNR.
CLEAR: SUM1,SUM2.
ENDAT.
ENDAT.
PREVIOUS1 = ITFINAL-LIFNR.
PREVIOUS2 = ITFINAL-MATNR.
PERFORM DDIFF.
IF ITFINAL-LIFNR EQ PREVIOUS1 AND
ITFINAL-MATNR EQ PREVIOUS2.
IF ITFINAL-SHKZG = 'S'.
ITFINAL-BLQTY1 = SUM1 + ITFINAL-MENGE.
MOVE: ITFINAL-BLQTY1 TO SUM1,
ITFINAL-BLQTY1 TO SUM2.
ELSE.
CLEAR: SUM1.
ITFINAL-BLQTY1 = SUM2 - ITFINAL-MENGE.
MOVE ITFINAL-BLQTY1 TO SUM2.
MOVE SUM2 TO SUM1.
ENDIF.
ENDIF.
*balance Quantity Value.
ITFINAL-TRV = ITFINAL-ASV * ITFINAL-BLQTY1.
*Excise Duty
ITFINAL-EXCD = ITFINAL-TRV * '16.48' / 100.
IF ITFINAL-SHKZG = 'S'.
ITFINAL-DCTXT = 'Debit'.
ELSE.
ITFINAL-DCTXT = 'Credit'.
ENDIF.
MODIFY ITFINAL.
ENDLOOP.
I am tyring to clear the variables sum1 and sum2 at every new vendor as well as new matnr.It is working fine when the matnr as well as lifnr changes but when the lifnr changes and material remains the same it is not clearing the varaibles and thus it is getting carried forward resulting in a wrong value.Kindly let me know what is wrong with the control break statement.
Thanks,
K.Kiran.
Material | Vendor | Mat.Doc.No | Transaction Qty | Bal.Qty | MENGE1 |
INPUT1 | INDP006 | 500542 | 1.000 | 1.000 | 0 |
INPUT1 | INDP006 | 500561 | 30.000 | 31.000 | 11 |
INPUT1 | INDP006 | 1000000696 | 10.000 | 21.000 | 10 |
At this point different vendor but the same material
INPUT1 | INIU003 | 500526 | 10.000 | 31.000 | 0 |
INPUT1 | INIU003 | 500527 | 2.000 | 33.000 | 0 |
INPUT1 | INIU003 | 1000000623 | 6.000 | 27.000 | 0 |
INPUT1 | INIU003 | 1000000624 | 4.000 | 23.000 | 0 |
INPUT1 | INIU003 | 1000000625 | 1.000 | 22.000 | 0 |
INPUT1 | INIU003 | 1000000626 | 1.000 | 21.000 | 0 |
ROH1 | INDP006 | 500543 | 2.000 | 2.000 | 2 |
LOOP AT ITFINAL.
AT NEW MATNR.
CLEAR: SUM1,SUM2.
*ENDAT.
AT NEW LIFNR.
CLEAR: SUM1,SUM2.
ENDAT.
ENDAT.
PREVIOUS1 = ITFINAL-LIFNR.
PREVIOUS2 = ITFINAL-MATNR.
PERFORM DDIFF.
IF ITFINAL-LIFNR EQ PREVIOUS1 AND
ITFINAL-MATNR EQ PREVIOUS2.
IF ITFINAL-SHKZG = 'S'.
ITFINAL-BLQTY1 = SUM1 + ITFINAL-MENGE.
MOVE: ITFINAL-BLQTY1 TO SUM1,
ITFINAL-BLQTY1 TO SUM2.
ELSE.
CLEAR: SUM1.
ITFINAL-BLQTY1 = SUM2 - ITFINAL-MENGE.
MOVE ITFINAL-BLQTY1 TO SUM2.
MOVE SUM2 TO SUM1.
ENDIF.
ENDIF.
*balance Quantity Value.
ITFINAL-TRV = ITFINAL-ASV * ITFINAL-BLQTY1.
*Excise Duty
ITFINAL-EXCD = ITFINAL-TRV * '16.48' / 100.
IF ITFINAL-SHKZG = 'S'.
ITFINAL-DCTXT = 'Debit'.
ELSE.
ITFINAL-DCTXT = 'Credit'.
ENDIF.
MODIFY ITFINAL.
ENDLOOP.
I am tyring to clear the variables sum1 and sum2 at every new vendor as well as new matnr.It is working fine when the matnr as well as lifnr changes but when the lifnr changes and material remains the same it is not clearing the varaibles and thus it is getting carried forward resulting in a wrong value.Kindly let me know what is wrong with the control break statement.
Thanks,
K.Kiran.
2008 Jan 21 10:13 AM
HI,
AT NEW MATNR.
CLEAR: SUM1,SUM2.
ENDAT.
*ENDAT.
AT NEW LIFNR.
CLEAR: SUM1,SUM2.
ENDAT.
regards
NIcole
2008 Jan 21 10:17 AM
Nicole,
I tried that way too,but it is not yeilding the desired result.When I give like that even if the vendor is the same it is clearing the variables.
Thanks,
K.Kiran.
2008 Jan 21 10:14 AM
Hi!
LOOP AT ITFINAL.
AT NEW MATNR.
SUM.
now you have the MATNR group total in the header of the ITFINAL
ENDAT.
AT NEW LIFNR.
SUM.
now you have the LIFNR group total in the header of the ITFINAL
ENDAT.
*...
ENDLOOP.
Regards
Tamá
2008 Jan 21 10:16 AM
hi
see this simple report you can understand very easily
Using AT FIRST , AT NEW, AT THE END OF , AT LAST.
DATA: BEGIN OF ITAB OCCURS 0,
F1 TYPE I,
F2(6) TYPE C,
F3(10) TYPE N,
F4(16) TYPE P DECIMALS 2,
END OF ITAB.
DATA: SUB_TOT(10) TYPE P DECIMALS 3.
**--1
ITAB-F1 = 1.
ITAB-F2 = 'ONE'.
ITAB-F3 = 10.
ITAB-F4 = '1000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 1.
ITAB-F2 = 'ONE'.
ITAB-F3 = 20.
ITAB-F4 = '2000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 1.
ITAB-F2 = 'ONE'.
ITAB-F3 = 30.
ITAB-F4 = '3000.00'.
APPEND ITAB.
CLEAR ITAB.
*--2
ITAB-F1 = 2.
ITAB-F2 = 'TWO'.
ITAB-F3 = 10.
ITAB-F4 = '1000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 2.
ITAB-F2 = 'TWO'.
ITAB-F3 = 20.
ITAB-F4 = '2000.00'.
APPEND ITAB.
CLEAR ITAB.
*-- 3
ITAB-F1 = 3.
ITAB-F2 = 'THREE'.
ITAB-F3 = 10.
ITAB-F4 = '1000.00'.
APPEND ITAB.
CLEAR ITAB.
ITAB-F1 = 3.
ITAB-F2 = 'THREE'.
ITAB-F3 = 20.
ITAB-F4 = '2000.00'.
APPEND ITAB.
CLEAR ITAB.
SORT ITAB BY F1.
LOOP AT ITAB.
AT FIRST.
WRITE: /35 ' MATERIAL DETAILS:'.
ULINE.
ENDAT.
AT NEW F1.
WRITE: / 'DETAILS OF MATERIAL:' COLOR 7 , ITAB-F1.
ULINE.
ENDAT.
WRITE: / ITAB-F1, ITAB-F2, ITAB-F3, ITAB-F4.
SUB_TOT = SUB_TOT + ITAB-F4.
AT END OF F1.
ULINE.
WRITE: / 'SUB TOTAL :' COLOR 3 INVERSE ON, SUB_TOT COLOR 3 INVERSE ON.
CLEAR SUB_TOT.
ENDAT.
AT LAST.
SUM.
ULINE.
WRITE: 'SUM:', ITAB-F4.
ULINE.
ENDAT.
ENDLOOP.
2008 Jan 21 10:17 AM