Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Delete zero data material

Former Member
0 Likes
618

Hi Experts,

i need material have all zero's like this it as deleted.

Matrial No 1567

open Balance 0.00

Mat Doc Mat Dat Mvt Doc No Recipts issues balance

0.00 0.00 0.00 0.00 0.00 0.00

But i am using below logic it had deleted the below material also,

below material, opening balance have some value,

But in this logic both were deleted

if below once like ( Mat doc ) all are zeros having opening balance also deleted,

i need material having all zeros one deleted.

Matrial No 1567

open Balance 550.00

Mat Doc Mat Dat Mvt Doc No Recipts issues balance

0.00 0.00 0.00 0.00 0.00 0.00

logic is

LOOP AT INT_DATA WHERE MENGE_O = 0 AND MENGE_RT = 0 AND

MENGE_CL = 0 AND MENGE_AD = 0 AND

MENGE_S = 0 AND MENGE_TO = 0 AND

MENGE_CR = 0 AND MENGE_R = 0 AND MENGE_BAL = 0.

DELETE IT_HEADER WHERE MATNR = INT_DATA-MATNR.

ENDLOOP.

opening bal logic is

FORM GET_OPENING_STOCK.

SELECT SUM( MZUBB ) SUM( MAGBB ) INTO (V_STOCK, V_STOCK1)

FROM S031 WHERE MATNR = IT_HEADER-MATNR 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.

ENDFORM. " GET_OPENING_STOCK

Thanks & Regards,

Sreedhar.

6 REPLIES 6
Read only

Former Member
0 Likes
572

Hi ,

Do you have multiple entreis for the same material in the table IT_HEADER ,e.g for the material 1567 , do you have more than one record

Regards

Arun

Read only

Former Member
0 Likes
572

<b>if it_header-matnr is not initial.</b> " this will pick only for a material having a value.

SELECT SUM( MZUBB ) SUM( MAGBB ) INTO (V_STOCK, V_STOCK1)
FROM S031 WHERE MATNR = IT_HEADER-MATNR 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.

<b>endif.</b>

LOOP AT INT_DATA WHERE MENGE_O = 0 AND MENGE_RT = 0 AND

MENGE_CL = 0 AND MENGE_AD = 0 AND

MENGE_S = 0 AND MENGE_TO = 0 AND

MENGE_CR = 0 AND MENGE_R = 0 AND MENGE_BAL = 0.

  • here sy-subrc is so it_header is deleted .

<b>in order to retain this

if open_stock/open balance eq 0. "bring in this logic so that *it_hheader is retained as it has some value

DELETE IT_HEADER WHERE MATNR = INT_DATA-MATNR.

endif.</b>ENDLOOP.

check if this works,

hope this helps ,

regards,

vijay

Message was edited by:

Vijay

Message was edited by:

Vijay

Read only

Former Member
0 Likes
572

hi

LOOP AT INT_DATA .

if ((((((INT_DATA -MENGE_O is initial) AND (INT_DATA-MENGE_RT is initial) AND

(INT_DATA-MENGE_CL is initial) AND ( INT_DATA-MENGE_AD is initial) AND

( INT_DATA-MENGE_S is initial) AND ( INT_DATA-MENGE_TO is initial) AND

( INT_DATA-MENGE_CR is initial) AND ( INT_DATA-MENGE_R is initial) AND ( INT_DATA-MENGE_BAL is initial ))))))).

DELETE IT_HEADER WHERE MATNR = INT_DATA-MATNR.

ENDLOOP.

Adjust the brackets.

Regs

Manas

Read only

Former Member
0 Likes
572

delete from internal table where open balance = 0.00

This will delete only those records wherein open balance is 0.00

Read only

Former Member
0 Likes
572

I dont think there is anything wrong with the code please check if you have more than one record for the particular material in IT_HEADER. I feel that is the case and hence the record is getting deleted.

Regards

Anurag

Read only

Former Member
0 Likes
572

Or else try with this statement ...

LOOP AT INT_DATA.

If INT_DATA-MENGE_O is initial AND

INT_DATA-MENGE_RT is initial AND

INT_DATA-MENGE_CL is initial and

INT_DATA-MENGE_AD is initial AND

INT_DATA-MENGE_S is initial AND

INT_DATA-MENGE_TO is intial AND

INT_DATA-MENGE_CR is initial AND

INT_DATA-MENGE_R is initial AND

INT_DATA-MENGE_BAL is initial.

DELETE IT_HEADER.

endif.

ENDLOOP.