Skip to Content
P D

Reason for duplicate entries

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

9 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 26, 2013 at 06:07 AM

    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.
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 26, 2013 at 06:21 AM

    hi ,

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

    to delete multiple items in the Table.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 25, 2013 at 07:02 AM

    Try to write

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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 25, 2013 at 07:03 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 25, 2013 at 07:05 AM

    Hi Marina,

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

    Check the POSNR fields....

    Thanks & Regards

    😊

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 25, 2013 at 07:09 AM

    Hi all,

    How can i avoid getting duplicate entries?

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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • Posted on Aug 25, 2013 at 09:08 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 26, 2013 at 03:48 AM

    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


    pastedImage_0.png (17.6 kB)
    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Sep 27, 2013 at 05:19 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.