Application Development and Automation 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: 
Read only

Join fails between tables !!

Former Member
0 Likes
1,277

Hi all,

The below join statement fails to retrieve necessary data. For every PO number(ebeln) in EKBE table, multiple entries of document numbers(belnr) will be found in RSEG table. But the below statement returns zero entries.

IF NOT it_ekpo[] IS INITIAL.

SELECT  a~ebeln  "PO number

            a~ebelp   

            a~zekkn

            a~vgabe

            a~gjahr

            a~belnr    "Document Number

            a~buzei

            b~menge

            b~shkzg

            b~wrbtr

      INTO CORRESPONDING FIELDS OF TABLE it_ekbe

      FROM ekbe AS a

      INNER JOIN rseg as b

      ON  a~ebeln = b~ebeln

      AND a~ebelp = b~ebelp

      AND a~buzei = b~buzei

      AND a~gjahr = b~gjahr

      AND a~belnr = b~belnr

      For all entries in it_ekpo

      WHERE a~ebeln = it_ekpo-ebeln

      AND   a~ebelp = it_ekpo-ebelp.

   ENDIF.

Please suggest. Thanks.

Hema.

1 ACCEPTED SOLUTION
Read only

amy_king
Active Contributor
0 Likes
1,090

Hi Hema,

Use a LEFT OUTER JOIN to join RSEG to EKBE instead of an INNER JOIN.

Cheers,

Amy

Hi all,

The below join statement fails to retrieve necessary data. For every PO number(ebeln) in EKBE table, multiple entries of document numbers(belnr) will be found in RSEG table. But the below statement returns zero entries.

IF NOT it_ekpo[] IS INITIAL.

SELECT  a~ebeln  "PO number

            a~ebelp   

            a~zekkn

            a~vgabe

            a~gjahr

            a~belnr    "Document Number

            a~buzei

            b~menge

            b~shkzg

            b~wrbtr

      INTO CORRESPONDING FIELDS OF TABLE it_ekbe

      FROM ekbe AS a

      INNER JOIN rseg as b

      ON  a~ebeln = b~ebeln

      AND a~ebelp = b~ebelp

      AND a~buzei = b~buzei

      AND a~gjahr = b~gjahr

      AND a~belnr = b~belnr

      For all entries in it_ekpo

      WHERE a~ebeln = it_ekpo-ebeln

      AND   a~ebelp = it_ekpo-ebelp.

   ENDIF.

Please suggest. Thanks.

Hema.

5 REPLIES 5
Read only

Former Member
0 Likes
1,090

Hi,

The code in which you have written does not contain common key, i.e "b~ebeln" is not been written and in inner join you taken

ON  a~ebeln = b~ebeln

      AND a~ebelp = b~ebelp

      AND a~buzei = b~buzei

      AND a~gjahr = b~gjahr

      AND a~belnr = b~belnr

Read only

sjeevan
Active Contributor
0 Likes
1,090

Your table join seems right. I suggest you to check if it_ekpo is empty or if it's not empty it may not have history (no entries in EKBE for the corresponding EBELN of it_ekpo) or no invoices (no entries in RSEG for the corresponding EBELN of it_ekpo) .

Read only

amy_king
Active Contributor
0 Likes
1,091

Hi Hema,

Use a LEFT OUTER JOIN to join RSEG to EKBE instead of an INNER JOIN.

Cheers,

Amy

Read only

Former Member
0 Likes
1,090

Thanks Amy... LEFT OUTER JOIN worked.

Read only

Former Member
0 Likes
1,090

hi sundar

Use more conditions to increase the speed of the program  because for given vendor der are many po nums so that to increase the speed use more condtions and selection parameters.and use for all entries.

Regards

R Sai Kiran