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: 

Optimization for a query for reversal checking.....!

anup_deshmukh4
Active Contributor
498

Hey experts I have one query...!

in MSEG field lfbnr contains the reference document no.

I want to eliminate the entries which have reversal ....!

like if one( MBLNR 123 with moment 101 has lfbnr null ) and its reversal is ( MBLNR 456 with moment 102 with lfbnr = 123 check ! )

i want to eliminate both

the query will somwhat look like below....athough its not actual....!



 SELECT MBLNR 
      FROM MSEG INTO CORRESPONDING FIELDS OF TABLE IT_MSEG 
                                         WHERE
                                         BWART  = '101'  AND
                                          mblnr not in
                                     ( SELECT lfbnr as mblnr FROM mseg WHERE bwart = '102' ).

above is just an example...just for test....

plz suggest a solution or suggest a aternative for same thing

Thanks in Advance.

4 REPLIES 4

Former Member
0 Kudos
371

Hi Anup,

Select all material documents in one internal table.

For all entries in this table select all entries from MSEG where ref. doc number equals material doc.

Then looping through one table and reading another table insert all matching entries in final internal table.

Finally u have all entries as u required in Final table, delete those entries.

Regards,

Deepak.

ThomasZloch
Active Contributor
0 Kudos
371

You want to check for reversed material document items, right? Please tell me why you are using LFBNR and not SMBLN for this check. I'm asking because there is a secondary index for SMBLN, but not for LFBNR.

Thomas

0 Kudos
371

Thanks a lot for the suggestion

0 Kudos
366

SMBLN is empty while LFBNR is not