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: 

ABAP QUERY suppress muliple output lines

former_member271718
Participant
0 Kudos

Hi there,

I am using SQ01 and created a table join woth SQ02

My question is, is it possible to suppress additional lines of a certain key value.

The output at this moment is (simplified)

Customer Sales Org DC Div Contract

1 XXXX 01 01 ZABC

1 XXXX 01 01 ZABC

1 XXXX 01 01 ZABC

2 XXXX 01 01 ZABC

2 XXXX 01 01 ZABC

3 XXXX 01 01 ZABC

3 XXXX 01 01 ZABC

The customer data comes form table KNA1VV and the contract type comes from the VBAK table (inner join). In the selection I enter always a specific contract type in this example ZABC. The first three lines means that customer 1 has three different contracts of type ZABC, the second two lines means that customer 2 has two different contracts of type ZABC etcetera.. What I want to know (and see on the output) which customers have a valid contract of type ZABC?

This is what I need. I don't want duplicated records of the VBAK table.

1 XXXX 01 01 ZABC

2 XXXX 01 01 ZABC

3 XXXX 01 01 ZABC

Can anybody tell me how to acheive that?

4 REPLIES 4

naimesh_patel
Active Contributor
0 Kudos

In this type of situation, I use this method to avoid the duplicates:

1. Take one more field from the table in your selection fields.

2. Now, in the Infoset write a code to populate this field.

Go to Infoset.

GO TO > Code > Data

declare a field which can hold the previous value

GO TO > Code > Record Processing

Check if the previous values differs from the current value

If yes, than put 1 in the dummy field taken in the Step 1

If no, than put 2 in the dummy field.

3. Now, in the Query, the dummy field set 1 and save it as a default selection screen variant.

Make sure you run the query with the default variant.

Regards,

Naimesh Patel

0 Kudos

Hi Naimesh Patel,

Thanks for your fast reply. I am not sure whether I understand your advice fully. I tried the following.

Defined field DUPL_RECORD (type Char 1) and PREV_CUST (like KNA1-KUNNR).

PREV_CUST got the following code:

IF PREV_CUST EQ KNA1-KUNNR.

DUPL_RECORD = 'Y'.

ELSE.

DUPL_RECORD = 'N'.

PREV_CUST = KNA1-KUNNR.

ENDIF.

I listed both fields in the query to be sure that the fields were populated correctly and that was the case. However when I defined DUPL_RECORD = 'N' as selection there was no result at all. Probably I didn't quite understand your answer. Please let me know what I did wrong?

Regards Kees

Former Member
0 Kudos

Hi K_Van,

Firstly, it is important to know why you are having the multiple lines. This is because you have not made the right join to VBAK. I guess you have joined the fied VBAK-KUNNR = KNA1VV-KUNNR. This gives the multiple lines.

I will suggest:

Join on

First join: VBAK-VBELN = VBPA-VBELN

Second Join: VBPA-KUNNR = KNA1VV-KUNNR

Third Join: VBPA-ADRNR = KNA1VV-ADRNR

where VBPA-PARVW = the partner you need. E.g. AG = Sold-to-party, WE = Ship-to-party etc

This should take care of the problem.

<REMOVED BY MODERATOR - REQUEST OR OFFER POINTS ARE FORBIDDEN>

Blacky

Edited by: BlackMoses on Aug 29, 2008 4:38 PM

Edited by: Alvaro Tejada Galindo on Sep 1, 2008 4:06 PM

0 Kudos

BlackMoses,

Thanks for your reply.

The join is an inner join of KNA1 (or KNA1VV) and the VBAK based on the fields KUNNR. I will get muliple lines because a customer can have muliple valid contracts. If the customer has one or more contracts of a specific order type then I want to see that customer once on the list. I have simplified the issue to describe the actual problem and that is don't print multiple lines. The request of the customer is I want a list with customers who have a specific contract type so that is the reason to start with the KNA1.

I thought there was an option in some an older version of the ABAP query where you could mark that you should not display muliple lines but I am not sure. Do you know another option?

Regards Kees