‎2009 May 08 10:51 AM
Hi,
SELECT * FROM EKBE INTO CORRESPONDING FIELDS OF TABLE IT_EKBE
FOR ALL ENTRIES IN IT_MSEG WHERE EBELN = IT_MSEG-EBELN
AND EBELP = IT_MSEG-EBELP
AND WERKS = IT_MSEG-WERKS
AND BUDAT IN S_BUDAT.
LOOP AT IT_MSEG.
MOVE-CORRESPONDING IT_MSEG TO IT_FINAL.
LOOP AT IT_EKBE WHERE EBELN = IT_MSEG-EBELN
AND EBELP = IT_MSEG-EBELP
AND WERKS = IT_MSEG-WERKS
AND BUDAT IN S_BUDAT.
IF IT_EKBE-SHKZG = 'H'.
IT_EKBE-MENGE = IT_EKBE-MENGE * -1.
ELSE.
IT_EKBE-MENGE = IT_EKBE-MENGE.
ENDIF.
QUAN = QUAN + IT_EKBE-MENGE.
ENDLOOP.
MOVE QUAN TO IT_FINAL-QUAN.
APPEND IT_FINAL.
CLEAR: QUAN,IT_FINAL.
ENDLOOP.From this code i am getting Quan.Once again I need to sum Quan field to Quan_tot.
ie) I need the summation of Quan field which has to be moved to it_final-Quan_tot.
Suggest some ideas.
Regards,
Bathri.
Edited by: Bathrinath Sankaranarayanan on May 8, 2009 11:51 AM
‎2009 May 08 10:56 AM
SELECT * FROM EKBE INTO CORRESPONDING FIELDS OF TABLE IT_EKBE
FOR ALL ENTRIES IN IT_MSEG WHERE EBELN = IT_MSEG-EBELN
AND EBELP = IT_MSEG-EBELP
AND WERKS = IT_MSEG-WERKS
AND BUDAT IN S_BUDAT.
LOOP AT IT_MSEG.
MOVE-CORRESPONDING IT_MSEG TO IT_FINAL.
LOOP AT IT_EKBE WHERE EBELN = IT_MSEG-EBELN
AND EBELP = IT_MSEG-EBELP
AND WERKS = IT_MSEG-WERKS
AND BUDAT IN S_BUDAT.
IF IT_EKBE-SHKZG = 'H'.
IT_EKBE-MENGE = IT_EKBE-MENGE * -1.
ELSE.
IT_EKBE-MENGE = IT_EKBE-MENGE.
ENDIF.
QUAN = QUAN + IT_EKBE-MENGE.
ENDLOOP.
QUAN_TOTAL = QUAN + QUAN_TOTAL. MOVE QUAN TO IT_FINAL-QUAN.
MOVE QUAN_TOTAL TO IT_FINAL-QUAN_TOTAL.
APPEND IT_FINAL.
CLEAR: QUAN,IT_FINAL.
ENDLOOP.
‎2009 May 08 10:59 AM
Hi,
try this:
SELECT * FROM EKBE INTO CORRESPONDING FIELDS OF TABLE IT_EKBE
FOR ALL ENTRIES IN IT_MSEG WHERE EBELN = IT_MSEG-EBELN
AND EBELP = IT_MSEG-EBELP
AND WERKS = IT_MSEG-WERKS
AND BUDAT IN S_BUDAT.
LOOP AT IT_MSEG.
MOVE-CORRESPONDING IT_MSEG TO IT_FINAL.
LOOP AT IT_EKBE WHERE EBELN = IT_MSEG-EBELN
AND EBELP = IT_MSEG-EBELP
AND WERKS = IT_MSEG-WERKS
AND BUDAT IN S_BUDAT.
IF IT_EKBE-SHKZG = 'H'.
IT_EKBE-MENGE = IT_EKBE-MENGE * -1.
ELSE.
IT_EKBE-MENGE = IT_EKBE-MENGE.
ENDIF.
QUAN = QUAN + IT_EKBE-MENGE.
QUAN_SUM = QUAN_SUM + IT_EKBE-MENGE. "Don't clear this field
ENDLOOP.
MOVE QUAN TO IT_FINAL-QUAN.
APPEND IT_FINAL.
CLEAR: QUAN,IT_FINAL.
ENDLOOP.
loop at IT_FINAL.
it_final-QUAN_SUM = QUAN_SUM.
modify it_final index sy-tabix.
endloop
regards, Dieter
‎2009 May 08 11:00 AM
In the second loop add following code :
quan_tot = quan_tot + quan.
move quan_tot to it_final-quan_tot.
write this code just befor the append statement for table IT_FINAL.
But this will give you accumulated sum for QUAN_TOT on each row and the final row will contain the final total. Do you need it in this way ?
Or you want to add the final total quantity in each row of your final internal table ?
Reg
Ashwa
‎2009 May 08 11:10 AM
HI,
I need summation of Quan in a single field ie)it_final-Quan_tot.
if i do subtotal I will get the summation. That value I need to store it it it_final-Quan_tot.
By ur method I am getting values which is not the subtotal of Quan.
‎2009 May 08 11:25 AM
you are already doing that , you will get the subtotal of quantity based on your document number, plant etc in QUAN field in your inner loop.
On what basis you want to add this QUAN field ? what should be the condition for your subtotal ?