‎2007 Sep 06 6:21 AM
Hi All,
I am trying to form a dynamic where clause using values entered on a selection screen. I want that if a new entry is added in the selection screen the where clause can also be modified dynamically without any change in coding. The only change required should be addition of select-option statement in the selection screen declaration.
Thanks in advance.
Anju
‎2007 Sep 06 6:27 AM
Hi,
you can use the
tables: mara.
select-options: s_matnr for mara-matnr.
select * from mara into table itab where matnr in s_matnr.
select-options will have a structure like this
sign
option
low
high
this will behave just like an internal table with header line
you can get the records with in those ranges or out of that range also
thanks & regards,
Venkatesh
‎2007 Sep 06 6:36 AM
Anju,
The values you enter in the selection screen would be directly reflected in the where clause once you aplly the following syntax as below.
select-options: s_f1 for f1.
select f1
f2
f3
from DB-Table
into Int-table
where f1 IN s_f1.
Hope the above syntax will resolve your quiry.
Regards,
Rama Murthy.P
‎2007 Sep 06 6:40 AM
Hi Anju,
I feel your question is regarding addition or removal of select-options on the screen...
and rest all should happed automatically, just like it happens in SE11 and SE16.. we can select the fields for selection screen and then the report comes accordingly.. right?
Thanks and Best Regards,
Vikas Bittera.
‎2007 Sep 06 6:44 AM
Hi,
Suppose ur code is like below:
tables: mara.
data: begin of itab,
matnr like mara-matnr,
maktx like makt-maktx,
end of itab.
Start-of-selection.
select-options: mat_no like mara-matnr.
end-of-selection.
select maramatnr maktmaktx into corresponding fields of table itab
from mara inner join makt on maramatnr = maktmatnr
where mara~matnr in mat_no.
Here when u run ur prog it will ask for the material no.
U will enter the material no. then it will dynamically affect the
coding which is already written.
The code will fetch the material no and its description form the
table mara and makt only for those material which u have fill in the
select option at run time.
‎2007 Sep 06 6:50 AM
refer below example
L_COND_SYNTAX = 'd2ext_status = l_status and d2ext_date ne c_intdate and '
& 'd2~ext_uploaded = space'.
SELECT D1TKNUM D1SHTYP D1TPLST D1ERNAM D1ERDAT D1BFART
D1VSART D1ROUTE D1SIGNI D1EXTI1 D1~TPBEZ
D1DATBG D1UATBG D1TDLNR D2VBELN D2~POSNR
D2EXT_FAILED D2EXT_COUNT D2EXT_DATE D2EXT_TIME
D2EXT_REP_DATE D2EXT_REP_TIME
D2EXT_RES_DATE D2EXT_RES_TIME D2~EXT_ERR_TYPE
INTO TABLE PA_GT_SHIP_HEADER
FROM VTTK AS D1 INNER JOIN RIOZTM_DELSTAT AS D2
ON D1TKNUM = D2TKNUM
WHERE
D1~TKNUM IN S_TKNUM AND
D1~SHTYP IN S_SHTYP AND
AND
<b>(L_COND_SYNTAX).</b>
Plz note the backet in L_COND_SYNTAX.
Reward points if helpful
‎2007 Sep 06 7:02 AM
HI,
do like this.
tables:mara.
data:BEGIN OF itab occurs 0,
field type screen-name,
END OF itab.
data:condition type string value 'mandt = ''800'''.
data:sel_opt(15),temp(15).
FIELD-SYMBOLS:<fs> type any.
SELECT-OPTIONS:matnr for mara-matnr.
SELECT-OPTIONS:ernam for mara-ernam.
AT SELECTION-SCREEN.
LOOP AT screen.
itab-field = screen-name.
append itab.
ENDLOOP.
START-OF-SELECTION.
LOOP AT itab where field cs '-LOW'.
split itab at '-' into sel_opt temp.
<b> ASSIGN (sel_opt) to <fs>.
IF <fs> is not INITIAL.
concatenate condition 'AND' sel_opt 'in' sel_opt into condition separated by space.
ENDIF.</b>
ENDLOOP.
<b>reward if helpful</b>
rgds,
bharat.
‎2007 Sep 06 7:05 AM
Thanks all but my query is that when I add a new field on the selection screen the where clause need not be updated every time. It needs to take care of all the filled screen fields on its own.
‎2007 Sep 06 7:10 AM
HI,
see the highlighted part of my previous post.
it will check whether the select-options are filled or not also.
first i am assigning the value of select-option to a field-symbol and i am checking whether it is initial or not and then i am concatenating it to the where clause.
<b>reward if helpful</b>
rgds,
bharat.
‎2009 Jan 06 11:04 AM