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

select option from table which is left outer join

Former Member
0 Likes
1,817

Hi,

I have problems with select option field again. I have conected 3 tables EKKO and EKPO as inner join and EKKN table as left outer join.

How to include into select option fields from EKKN table?

Please give me an example,

Thanks in advance

here is my select:

SELECT EKKOBUKRS EKKOEBELN EKKOLIFNR EKKOLPONR EKPO~EBELN

EKPOEBELP EKPOLGORT EKPOMEINS EKPOMENGE EKPO~WERKS

EKKNAUFNR EKKNEBELN EKKNEBELP EKKNKOSTL

INTO (LW_EKKO-BUKRS, LW_EKKO-EBELN, LW_EKKO-LIFNR, LW_EKKO-LPONR,

LW_EKPO-EBELN, LW_EKPO-EBELP , LW_EKPO-LGORT , LW_EKPO-MEINS ,

LW_EKPO-MENGE, EKPO-WERKS, LW_EKKN-AUFNR, LW_EKKN-EBELN, LW_EKKN-EBELP,

LW_EKKN-KOSTL )

FROM ( EKKO

INNER JOIN EKPO

ON EKPOEBELN = EKKOEBELN

AND EKPOEBELP = EKKOLPONR

LEFT OUTER JOIN EKKN

ON EKKNEBELN = EKPOEBELN

AND EKKNEBELP = EKPOEBELP )

WHERE EKKO~EBELN IN EBELN

AND EKKO~LIFNR IN LIFNR

AND EKPO~EBELP IN EBELP

AND EKPO~WERKS IN WERKS.

MOVE-CORRESPONDING LW_EKKO TO INT.

MOVE-CORRESPONDING LW_EKPO TO INT.

MOVE-CORRESPONDING LW_EKKN TO INT.

APPEND INT.

ENDSELECT.

7 REPLIES 7
Read only

Former Member
0 Likes
1,116

not possible. you can better loop through the result table and make the selection on ekkn table and fill the corresponding fields accordingly if exist

loop at INT.

select single * from ekkn where EBELN EQ INT-EBELN and EBELP EQ INT-EBELP.

if sy-subrc = 0.

MOVE-CORRESPONDING EKKN TO INT.

modify INT.

endloop

Read only

Former Member
0 Likes
1,116

Hi ,

Don't use select ..endselect.

The performance of the program will get hampered,

so try to use loop ...and modify statement.

regards,

Santosh

Read only

varma_narayana
Active Contributor
0 Likes
1,116

hi..

Point1: Dont use SELECT.. ENDSELECT with APPEND . It will give poor performance.

So change it using INTO CORRESPONDING FIELDS OF TABLE ITAB.

Declare the itab accordingly.

Point 2: You can check the SELECT-OPTIONS using WHERE Clause .

SELECT EKKOBUKRS EKKOEBELN EKKOLIFNR EKKOLPONR EKPO~EBELN

EKPOEBELP EKPOLGORT EKPOMEINS EKPOMENGE EKPO~WERKS

EKKNAUFNR EKKNEBELN EKKNEBELP EKKNKOSTL

INTO corresponding fields of table INT

FROM EKKO

INNER JOIN EKPO

ON EKPOEBELN = EKKOEBELN

AND EKPOEBELP = EKKOLPONR

LEFT OUTER JOIN EKKN

ON EKKNEBELN = EKPOEBELN

AND EKKNEBELP = EKPOEBELP

WHERE EKKO~EBELN IN EBELN

AND EKKO~LIFNR IN LIFNR

AND EKPO~EBELP IN EBELP

AND EKPO~WERKS IN s_WERKS. "Checking SELECT-OPTIONS

<b>Reward if Helpful.</b>

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
1,116

Unfortunately, it is not possible to include the table in WHERE clause if it was joined with a LEFT JOIN.

You might want to modify SELECT ... ENDSELECT to SELECT INTO TABLE ITAB, for example, and then do a separate SELECT:

SELECT ... FROM EKKN 
FOR ALL ENTRIES IN ITAB 
WHERE EBELN = ITAB-EBELN
AND EBELP = ITAB-EBELP

plus whatever additional selection criteria you might need.

Good luck!

Read only

Former Member
0 Likes
1,116

if the user chooses to use the select-option for the table which was outer-joined, it means that it should no longer be outer-joined for that instance.

what i do in such cases is create a seperate select which is activated by checking if the specific select-option has a value.

this would be something like:

select-options: s_ekkn (whatever variable you wish to test from EKKN).

if s_ekkn is initial.

*do the regular join with ekkn being outer joined

else.

*connect ekkn as an inner join and use s_ekkn in the WHERE condition).

endif.

Read only

0 Likes
1,116

Thanks Guys for all posts end coments, i rewarded 3 of you,

BR

Saso

Read only

Former Member
0 Likes
1,116

Thanks a lot!!