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

Problem in Header

Former Member
0 Likes
905

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

10 REPLIES 10
Read only

Former Member
0 Likes
875

change ur delete statement as below and checkout

delete HEADER where MATERAL = ITEM-MATERIAL and <Opening balance> eq 0.

Read only

Former Member
0 Likes
875

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

Read only

0 Likes
875

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

Read only

0 Likes
875

why do you need to loop at item? replace all that code with

<b>delete header where open_balance eq 0.</b>

~Suresh

Read only

0 Likes
875

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.

Read only

0 Likes
875

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

Read only

0 Likes
875

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

Read only

Former Member
0 Likes
875

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.

Read only

Former Member
0 Likes
875

delete HEADER where MATERAL = ITEM-MATERIAL and

Opening_balance eq 0.

Read only

Former Member
0 Likes
875

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.