‎2007 Sep 27 1:01 PM
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.
‎2007 Sep 27 1:07 PM
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
‎2007 Sep 27 1:10 PM
Hi ,
Don't use select ..endselect.
The performance of the program will get hampered,
so try to use loop ...and modify statement.
regards,
Santosh
‎2007 Sep 27 1:14 PM
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>
‎2007 Sep 27 10:17 PM
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-EBELPplus whatever additional selection criteria you might need.
Good luck!
‎2007 Sep 27 10:26 PM
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.
‎2007 Oct 01 9:05 AM
Thanks Guys for all posts end coments, i rewarded 3 of you,
BR
Saso
‎2007 Oct 01 9:06 AM