cancel
Showing results for 
Search instead for 
Did you mean: 

Reason for duplicate entries

former_member207873
Participant
0 Kudos

Hi Experts,

can any one explain me why I am getting duplicate entries for billing doc no ( vbeln ) for this join statement.

SELECT  vbrk~fkdat  vbrk~spart

           vbrk~vbeln

           vbrk~fkart

           vbrk~kunag

           vbrk~kunrg

           vbrk~vkorg

           vbrk~vtweg

           vbrk~netwr

           vbrk~sfakn

           vbrk~knkli

           vbrp~posnr

           vbrp~vkbur

           INTO CORRESPONDING FIELDS OF TABLE it_vbrk

           FROM vbrk JOIN vbrp ON vbrk~vbeln = vbrp~vbeln

           WHERE vbrk~fkdat IN so_fkdat.

so_fkdat is the select options for date field.

Regards,

Marina.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Marina,

If you have duplicate entries in the final internal table, then

  1. Sort the internal table based on the key you need.
  2. Delete duplicate records using from internal table DELETE ADJACENT DUPLICATES.

Answers (8)

Answers (8)

Former Member
0 Kudos

Hi.

instead of join you can use for all entries also to get values from multiple table. Still if duplicate entries are there just sort the internal table and delete the duplicates

With reagards

Suneesh

Former Member
0 Kudos

hi ,

I think  you have to sort the Final internal table then use keyword DELETE ADJACENT DUPLICATES

to delete multiple items in the Table.

former_member209120
Active Contributor
0 Kudos

Hi Marina Debrova,

You are not getting duplicate entries your code is correct pl check like this

VBELN - Billing Document

POSNR - Billing item

your are getting values based on  billing document and billing item wise

Former Member
0 Kudos

Dear Marina,

VBRK Table is Billing header table.

VBRP is Billing Line item table.

when you do inner join both the table Based on the header table fetch line item multiple entries.

If for billing only one line item, will get only one entry other wise if it is more than one line item will get multiple entry.

Please check on VF03 pass your billing number and check the line item.

Thanks and Regards,

buz_sap

anishoommen
Explorer
0 Kudos

Hi Marina,

You are Joining the Line item and Header level table, and hence you will be getting multiple lines with same VBELN, provided they are appearing as multiple line items in the VBRP Table.

The best method would be to sort the final internal table based on VBELN and then do a DELETE ADJACENT DUPLICATES.

Although I doubt if you would want to get Just a single entry for VBELN. But again, it depends on the logic in question :-).

Best Regards,

Anish Oommen

former_member207873
Participant
0 Kudos

Hi all,

How can i avoid getting duplicate entries?

Will delete adjacent duplicates comparing vbeln will be a long lasting solution?

Former Member
0 Kudos

this is the best solution. If you are not getting where are you appending/ fetching duplicate entry then sort your data and use delete adjacent comparing all field/or based on ur req....

BR

Chandra..

Former Member
0 Kudos

first of all...its not duplicates. field like posnr is item specific and will have different values for each item so if you want to display such fields you have to display items also and in turn billing doc. number may appear more than once. try to visualize it as header(vbeln) and items (posnr) level you will know the significance of both.

Rgds

Former Member
0 Kudos

Hi Marina,

You are joining VBRK and VBRP that's why you are getting duplicate entries based on VBELN.

So kindly explain why you are querying VBRP?

Thanks

 

former_member207873
Participant
0 Kudos

Hi Manu,

I need Vkbur from vbrp.

Former Member
0 Kudos

Hi Marina,

You have multiple entries for a VBELN in VBRP based on Item number POSNR, for example

VBELN POSNR

123456  10

123456  20

123456  30

And you want VBRP-VKBUR irrespective of POSNR (Item Number), if 'am correct, it means you can have multiple entries for VBELN in VBRP based on VKBUR, that is for example;

VBELN POSNR VKBUR

123456  10         a     

123456  20         b    

123456  30         a

Here you can sort the entries of the itab based on VBELN and VKBUR.

And DELETE ADJACENT DUPLICATES FROM itab COMPARING vbeln vkbur.

Hope this will help you

Thanks

Former Member
0 Kudos

from reporting point of view what is the point of deleting VKBURs specially when you know there could be more than one within a billing doc. more importantly...user WANT to see it in the output.

VijayaKrishnaG
Active Contributor
0 Kudos

Hi Marina,

The multiple records with same VBELN will carry different line Items of that particular VBELN. So that you cannot delete duplicates comparing VBELN.

There won't be question of deleting duplicate entries in your case as you said you need VKBURs in the output.

If you are getting the multiple entries with same VBELN, POSNR and VKBURS then you can delete records comparing these three fields. This might not be happen actually.

Thanks & Regards,

-Vijay

Former Member
0 Kudos

Hi Marina,

You are joining Header and Item table, hence you will get duplicate entries for VBELN.

Check the POSNR fields....

Thanks & Regards

Former Member
0 Kudos

you are getting duplicate billing docs because for each billing doc. in vbrk there could be multiple items in vbrp (POSNR). so when this query executes it will fetch all items of billing docs. fall under your where condition.

Rgds

Former Member
0 Kudos

Try to write

FROM vbrk INNER JOIN vbrp ON vbrk~vbeln = vbrp~vbeln