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

Multiple Table Join Selection

Former Member
0 Likes
603

In the following select statement, I just hope to exclude the PO item if delivery is complete, but when I get two same item (same material) in one PO and only one is delivery completed, all 2 items were picked into internal table?!

Any suggestion?!

SELECT ekkolifnr ekkoebeln ekpomatnr ekpotxz01 ekkoaedat ekpomenge ekpomeins eketwemng stpoidnrk mkpfmblnr

INTO TABLE gt_prodord

FROM ekpo

JOIN ekko ON ekkoebeln = ekpoebeln

JOIN eket ON eketebeln = ekpoebeln

AND eketebelp = ekpoebelp

JOIN mast ON mastmatnr = ekpomatnr

AND mastwerks = ekpowerks

JOIN stpo ON stpostlnr = maststlnr

LEFT OUTER JOIN mkpf ON ekpoebeln = mkpfbktxt

WHERE ekko~bsart = 'NB'

AND ekpo~elikz NE 'X'

AND ekpo~loekz NE 'L'

AND stpo~postp = 'L'

AND ekpo~werks BETWEEN lv_werks_l AND lv_werks_h

AND ekpo~matkl BETWEEN lv_matkl_l AND lv_matkl_h

AND ekko~lifnr BETWEEN lv_lifnr_l AND lv_lifnr_h

AND ekko~aedat BETWEEN lv_aedat_l AND lv_aedat_h

ORDER BY ekkolifnr ekkoebeln.

Thanks in advance

Edited by: abapsydney on Jul 14, 2008 8:16 AM

3 REPLIES 3
Read only

Former Member
0 Likes
532

No Suggestion?!

Read only

Rashid_Javed
Contributor
0 Likes
532

With reference to your question

[but when I get two same item (same material) in one PO and only one is delivery completed, all 2 items were picked into internal table]

I think may be system is repeating the line item whose delivery is not complete twice.

To verify this you can include like item number EKPO-EBELP in your output (Make sure to add it also in your internal table gt_prodord) and verify if it is repeated or the line items returned are truly unique?

"SELECT ekkolifnr ekkoebeln

ekpo~matnr

ekpo-ebelp "Just add PO line item number

ekpotxz01 ekkoaedat ekpomenge ekpomeins eketwemng stpoidnrk mkpf~mblnr

INTO TABLE gt_prodord ...............

....................

.......................

"

This way you can check if the line items you are getting are repeated or not.

RJv
Read only

ThomasZloch
Active Contributor
0 Likes
532

this link here might cause a problem:

LEFT OUTER JOIN mkpf ON ekpo~ebeln = mkpf~bktxt

I think as soon as there is more than one MKPF found with BKTXT = EBELN, you end up with multiple lines in your internal table. Also EKET can have more than one line per EKPO.

Greetings

Thomas