Skip to Content
author's profile photo Former Member
Former Member

Problem with JOIN, repat data

Hello,

I have query below:

SELECT a~j_3gblart "Clase documento
          b~j_3gbelnri  "Número de documento PBE
          b~j_3gposnri " Número de posición PBE
          b~j_3guposnr "Subposición
          b~erdat      "Creado el:
          b~ernam      "Creado por
          b~pernr      "Nº personal
          b~j_3gemppsp "Elemento PEP
          b~j_3gemppro "Nº proyecto
          b~j_3gempkos  "Cemtro de coste
          b~j_3gbelsta  "Stat.doc.interno
          b~j_3gbelste  "Stat.doc.externo
          b~j_3gempfae  "Destinatario
          b~j_3glvart     "Clase Actividad
          b~matnr       "Material
          b~j_3gdatlab  "Fe.prest.actividad
          b~j_3gmenge   "Cantidad
          b~j_3gmeins   "Unidad de medida
          c~name1
          c~name2
          d~eqart  " Categoria del Equipo
          d~vbeln  " Documento Venta
          d~posnr  "Posicion
          d~netwr  "Valor Neto
          d~waerk  "Moneda
          e~vbeln AS vbeln2 "vbeln de la VBRP
       FROM j_3gbelk AS a

     INNER JOIN j_3gbelp AS b
     ON a~mandt EQ b~mandt
     AND a~j_3gbelnri  EQ b~j_3gbelnri
     INNER JOIN vbap AS d ON d~j_3gbelnri EQ b~j_3gbelnri
     LEFT JOIN vbrp AS e ON d~vbeln EQ e~aubel
     INNER JOIN kna1 AS c ON c~kunnr = b~j_3gempfae
     INTO CORRESPONDING FIELDS OF TABLE it_alv
     WHERE b~j_3gbelnri IN p_etm
     AND   b~j_3guposnr IS NOT NULL
     AND   j_3gdatlab IN p_factiv
     AND   j_3gblart IN p_cdoc
     AND   b~equnr IN p_equipo
     AND   b~pernr IN p_person
     AND   b~j_3gempfae IN p_desti
     AND   eqart IN p_catequ.

When I run my ALV report with this document: J_3GBELNRI = 2000003987 and I get repeat data:

If I go to the table, I get only 12 rows, this is the correct result, and I want to have this result in my ALV Report, Could anyone can help me?

data_repeat.PNG (180.1 kB)
data no repeat.PNG (63.0 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Dec 10, 2014 at 06:20 AM

    Hi,

    please remove VBRP (e) from the JOIN and check the result. VBRP might give several matches, where one will be fine.

    Regards,

    Klaus.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 10, 2014 at 06:00 PM

    Hi Luis,

    I think is not a good practice this query join. I recommend you have no more than 2 tables in join, and you can use others query by separately.

    In your loop you will need READ for your other transparents tables.

    I hope help my advice.

    Regards.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 10, 2014 at 06:50 PM

    Hello gurus, now I have identify the problem, in my first table (J_3GBELP) I have 12 rows if with this key: J_3GBELNRI = 2000003987, in VBAP I have 3 rows with this key, "but" in VBAP exist VBELN, this value, is not equal, then, this value repeat my query, 12 * 3 = 36 rows. Please see image below:

    Anyone can help me?


    duplicados.PNG (214.6 kB)
    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.