‎2006 Dec 27 10:35 AM
HI experts,
i had done the normal report,it comes one problem i.e
i am taken Material has HEADER and link the open balance to that HEADER,
because i need the open balance in HEADER.
remaining all are items data
my problem is i am using this logic
loop at ITEM where MENGE_CL = 0 AND MENGE_ADD = 0 AND
MENGE_S = 0 AND MENGE_TO = 0 AND
MENGE_CR = 0 AND MENGE_R = 0 AND
MENGE_AD = 0 AND MENGE_BAL = 0 AND MENGE_O = 0.
delete HEADER where MATERAL = ITEM-MATERIAL.
endloop.
problem is
when open balance have some value it also deleted.
because i am link the header material.
i need this one
material 57768
open balace 500.00
mat no doc no doc date mvt invoice invoice date bal
0.000 0.000 0.000 .000 0.000 0.000 0.000
all zeros i need to delete this one
material 57769
open balace 0.00
mat no doc no doc date mvt invoice invoice date bal
0.000 0.000 0.000 0.000 0.000 0.000 0.000
but in the above logic both were deleting.
I need items all zeros and open balance have some value material.
Thanks & Regards
Sreedhar
‎2006 Dec 27 10:39 AM
change ur delete statement as below and checkout
delete HEADER where MATERAL = ITEM-MATERIAL and <Opening balance> eq 0.
‎2006 Dec 27 10:39 AM
loop at ITEM where MENGE_CL = 0 AND MENGE_ADD = 0 AND
MENGE_S = 0 AND MENGE_TO = 0 AND
MENGE_CR = 0 AND MENGE_R = 0 AND
MENGE_AD = 0 AND MENGE_BAL = 0 AND MENGE_O = 0.
<b>READ TABLE HEADER WITH KEY MATERAL = ITEM-MATERIAL.
Delete only if open balance is zero
IF sy-subrc EQ 0.
delete HEADER where MATERAL = ITEM-MATERIAL AND <OPEN_BALANCE> EQ 0.
ENDIF></b>
endloop.
Regards
Kathirvel
‎2006 Dec 27 11:06 AM
HI all,
delete HEADER where MATERAL = ITEM-MATERIAL and
Opening_balance eq 0.
IN THIS LOGIC BOTH MATERIALS IS COMMING.
Remaining all logic both were deleted.
like this
loop at ITEM where MENGE_CL = 0 AND MENGE_ADD = 0 AND
MENGE_S = 0 AND MENGE_TO = 0 AND
MENGE_CR = 0 AND MENGE_R = 0 AND
MENGE_AD = 0 AND MENGE_BAL = 0 AND MENGE_O = 0.
<b>READ TABLE HEADER WITH KEY MATERAL = ITEM-MATERIAL.
Delete only if open balance is zero
IF HEADER-<OPEN_BALANCE> EQ 0.
delete HEADER where MATERAL = ITEM-MATERIAL.
ENDIF></b>
thanks,
Sreedhar
‎2006 Dec 27 11:11 AM
why do you need to loop at item? replace all that code with
<b>delete header where open_balance eq 0.</b>
~Suresh
‎2006 Dec 27 11:19 AM
Hi,
u r logic is right, but some materials like this
Material No 64567
Opening Balance 0.00
mat no Mat date invoice No Invoice date Mvt Bal
64567 12.08.2006 9476747453 12.08.2006 101 453
open Balance is zero but item have data, i need this one.
Thanks,
Sreedhar.
‎2006 Dec 27 11:24 AM
OK.. then you have to loop at item..did u try this?
loop at ITEM where MENGE_CL = 0 AND MENGE_ADD = 0 AND
MENGE_S = 0 AND MENGE_TO = 0 AND
MENGE_CR = 0 AND MENGE_R = 0 AND
MENGE_AD = 0 AND MENGE_BAL = 0 AND MENGE_O = 0.
delete HEADER where MATERAL = ITEM-MATERIAL and
OPEN_BALANCE EQ 0.
endloop.
~Suresh
‎2006 Dec 27 11:30 AM
Hi,
In This logic both were deleting.
because i am linking the open balance to header material.
open balance logic
SELECT SUM( MZUBB ) SUM( MAGBB ) INTO (V_STOCK, V_STOCK1)
FROM S031 WHERE <b>MATNR = IT_HEADER-MATNR</b> AND
WERKS = ITAB-WERKS AND
SPMON LT V_MONTH1 AND LGORT = ITAB-LGORT.
OSTOCK = V_STOCK1 - V_STOCK.
IF OSTOCK < 0.
OSTOCK = OSTOCK * -1.
MENGE_RE = OSTOCK.
ENDIF.
Thanks,
Sreedhar
‎2006 Dec 27 10:40 AM
Try this way;
loop at ITEM where MENGE_CL = 0 AND MENGE_ADD = 0 AND
MENGE_S = 0 AND MENGE_TO = 0 AND
MENGE_CR = 0 AND MENGE_R = 0 AND
MENGE_AD = 0 AND MENGE_BAL = 0 AND MENGE_O = 0.
delete HEADER where MATERAL = ITEM-MATERIAL and open_balance = 0.
endloop.
‎2006 Dec 27 10:41 AM
delete HEADER where MATERAL = ITEM-MATERIAL and
Opening_balance eq 0.
‎2006 Dec 27 10:42 AM
Hi Sreedhar ,
See in your case Loop at item where all quantity are zero you are deleting the Header table before that you can check for open Balance field also then delete the header table based on material.
for eg.
loop at ITEM where MENGE_CL = 0 AND MENGE_ADD = 0 AND
MENGE_S = 0 AND MENGE_TO = 0 AND
MENGE_CR = 0 AND MENGE_R = 0 AND
MENGE_AD = 0 AND MENGE_BAL = 0 AND MENGE_O = 0.
<b>read table header with key material = ITEM-MATERIAL .
if open-balance field is initial and sy-subrc = 0.</b>delete HEADER where MATERAL = ITEM-MATERIAL.
<b>endif.</b>
endloop.