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: 

Reduction of Data in SAP Query

Former Member
0 Kudos

Hi Experts,

I have an Infoset query which have multiple table joins on Material master data. All these tables are linked only by Material number.

Due to this there are many duplicate records coming in the output.

We use the SAP List viewer as output type for our Queries here.

I have tried writing a piece of code to remove the duplicates in Infoset Query -> Code section. I have written my logic in the event END-OF-SELECTION (Before List). All mu data declarations are in DATA section.

But my problem is I am not able to trigger the code I have written. Any idea on how to trigger this code or how to reduce the duplicates?

Or is there any BAdi or User exits available?

Thanks in Advance,

Abhinay

11 REPLIES 11

Former Member
0 Kudos

Hi Abhinay,

I have not worked on infoset queries but in general what we do is

*)Sort the internal table by matnr 

*)delete adjacent duplicates from the internal table comparing matnr

*) Use For-all Entries clause to fetch the data from other SAP Tables like MARC, MARD, MBEW, MVKE, MAKT etc.

Thanks,

Ankit

Former Member
0 Kudos

Hi Ankit,

Thanks for your response.

But this issue I face in Infoset Query and not in a report. We can enhance the infoset query with our custom code if needed and SAP provides that provision there.

Here my issue is as to why the events END-OF-SELECTION does not trigger for SAP List viewer output. Or are there any Badi's or user exits that can be triggered after all the data is extracted from the tables.

Thanks,

Abhinay

0 Kudos

Hi Abhinay,

Try writing your code in START-OF-SELECTION event.

0 Kudos

Hi Abhinay,

If possible just try putting a write statement in the code and debug it. 'Write' Statements are used in end-of-selection only.

Thanks,

Ankit.

0 Kudos

Hi Satish,

The code I worte triggers in event Record Processing (after the START-OF-SELECTION).

But the problem is that the logic I wrote will trigger before the final data is appended to the output table. So, even after using the Sort and Delete adjacent Duplicates (which happens inside a loop by the way) I still get 1 record as duplicate.

I am not able to delete that record.

Thanks,

Abhinay

0 Kudos

Hi Ankit,

I just put a simple statement like BREAK-POINT.

It was still not triggering in the END-OF-SELECTION event.

Thanks,

Abhinay

0 Kudos

Hi Abinay,

Sorry but i would not be able to help then,

Please see if this helps,

http://scn.sap.com/thread/2111132

http://f0j00fec.benxbrain.com/en(bD1lbiZjPTAwMQ==)/index.do?onInputProcessing(brai_object_thread)&00...


SAP mentors and Gurus please help.

Regards,

Ankit.

0 Kudos

So your logic is in end of selection but this event is not getting triggered. Then check whether you have written some "CHECK" statement inside start-of-selection or at beginning of end-of-selection. If there is "CHECK" statement make sure that the condition is getting satisfied.

If possible can you paste your code that you have written in start-of-selection and end-of-selection.

0 Kudos

Hi Abhinay,

Try this:

1. DATA section

     DATA: it_mara TYPE TABLE OF mara,

                  st_mara TYPE                     mara.

2. Record Processing section

     READ TABLE it_mara  INTO st_mara
                    WITH KEY MATNR = mara-MATNR.
     IF sy-subrc NE 0.
       SELECT  * FROM mara INTO TABLE it_mara
         WHERE  MATNR = mara-MATNR.

     ELSE.
       CHECK 0 = 1.
     ENDIF.

I use " READ TABLE it_mara .... "  to determine the first line for each Material among

all the lines which query supplies for every Material.

Regards

Boris    

Former Member
0 Kudos

Hi

Sometimes, from reasons I haven't discovered yet, the query output options are not the same: when you execute the query the "Output specifications" in the parameter screen sometimes have only one field of "Layout", and sometimes there are several output uptions.

If the full list of options is shown when you run the query, the END-OF-SELECTION will be triggered.

If you see only one option ("SAP List viewer") when you execute the query, go to the query definition (SQ01), in the first screen choose one of the options besides "SAP List viewer". Now try to execute the query and you'll see that END-OF-SELECTION is triggered.

In the execution of the query you/the user can choose again the regular Output specifications = "SAP List viewer".

Sorsha

0 Kudos

Hi,

Check this link