Application Development 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: 

How to drop the reversed GRs while selecting from EKBE ?

Former Member
0 Kudos

Hi,

I have a requirement to select only GR which are not reversed. Suppose we have a PO with 2 items with 3000 quantity each. First time user did GR (using MIGO) with quantity 1000 for each item by mistake. So the user comes back to MIGO, reverse it and do a GR again for 1100 each item. If you look at EKBE for this PO, you will see three lines for each item. First line will be GR(moment type 101) with quantity 1000, 2nd line will be reverse of it ( with moment type 102), with quantity 1000 and the 3rd line will the new GR(moment type 101) with quantity 1100. Now in my requirement is to select this new GRs from EKBE for each item. I am using a select..for all entries of ts_ekpo (assume that this table is filled already with right PO items) internal table into another internal table ts_ekbe. So I am selecting total 6 lines, 3 lines for each item. I don't want to select the reversed lines. Will there be any flag in EKBE table to identify that the line is reversed or that the line is new GR line ? If you need more clarity please let me know. Your help will be appriciated.

Thank you,

Surya.

4 REPLIES 4

Former Member
0 Kudos

Hi Surya,

If I'm not mistaken you can use MSEG-SMBLN field to identify that the line is reversed.

Link between MSEG and EKBE is MSEG-MBLNR = EKBE-BELNR.

Regards,

Hendy

0 Kudos

Hi,

You will have to 1st retrieve all the Mat Docs corresponding to the POs from the MSEG table for Movement type 101.

If you want to whether the Mat Doc is reversed, as hendy has suggested you will have to do the following.

If you consider that T_MSEG is the Internal table that was populated with the Mat Docs for Move Type 101.

SELECT ...... FOR ALL ENTRIES IN T_MSEG

WHERE SJAHR EQ T_MSEG-SJAHR

AND SMBLN EQ T_MSEG-MBLNR

AND SMBLP EQ T_MSEG-ZEILE

AND BWART EQ '102'.

This suggests that for Move Type 102 if you find the actual Mat Doc existing in the field SMBLN and SMBLP, then the GR is reversed.

regards,

Mahesh

0 Kudos

Handy / Mahesh,

Thank you for your quick response. I was confident of your solution and I tried creating a PO, did GR and reversed and again GR. But in MSEG these fields smbln, smblp, and sjahr are not filled. I really don't know what to do. Am I missing any thing while creating PO ?

Thank you,

Surya

0 Kudos

Hi,

Thanks for your replies on this. I started working on this issue again. I have got doubt when I looked at some of the fields of tables EKBE and MSEG. The fields LFBNR, and LFPOS are in both EKBE and MSEG tables. What are they for ? For cancelled GRs in MSEG these fields (LFBNR and LFPOS) have same value as fields SMBLN and SMBLP. If you look at EKBE these fields are filled as they are in MSEG. I am bit confused of this. Can any one clarify me?

Thank you,

Surya