Application Development 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: 

Select statement with where clause in web dynpro application

Former Member
0 Kudos

I am developing a web dynpro application where i have several search parameters . i am trying to query the database and provide refined search results to a alv table based on the search parameters . i am unable to make multiple search parameters work and when i am leaving one search parameter blank and selecting others. . Can anyone provide me with example on how the select statement is written with where clause including multiple search parameters . i am new to web dynpro .. kindly help with this.

5 REPLIES 5

sahai
Contributor
0 Kudos

I am developing a web dynpro application where i have several search parameters . i am trying to query the database and provide refined search results to a alv table based on the search parameters . i am unable to make multiple search parameters work and when i am leaving one search parameter blank and selecting others. . Can anyone provide me with example on how the select statement is written with where clause including multiple search parameters . i am new to web dynpro .. kindly help with this.

hi,

there is no difference in the selection query, it will be the same as in normal abap. for your convinence i am sharing an example of selection query as below.

DATA LOC_MATNR TYPE MARA-MATNR.
SELECT MATNR FROM MARA INTO LOC_MATNR WHERE WERKS = 'EP02'.

Regards,

sahai.s

Former Member
0 Kudos

SELECT *

INTO CORRESPONDING FIELDS OF ls_role

FROM zgr_llt_table

FOR ALL ENTRIES IN itab

WHERE ( category = itab-category or category = ' ') and ( sow = itab-sow or sow = ' ' ) and ( phase = itab-phase or phase = ' ' )

and ( type1 = itab-type1 or type1 = ' ' ).

if i am not selecting any one of the field it is not executing .when i select all select fields then only its working.

can u tell me that solution for that problem

0 Kudos

SELECT *

> INTO CORRESPONDING FIELDS OF ls_role

> FROM zgr_llt_table

> FOR ALL ENTRIES IN itab

> WHERE ( category = itab-category or category = ' ') and ( sow = itab-sow or sow = ' ' ) and ( phase = itab-phase or phase = ' ' )

> and ( type1 = itab-type1 or type1 = ' ' ).

>

> if i am not selecting any one of the field it is not executing .when i select all select fields then only its working.

> can u tell me that solution for that problem

SELECT *
INTO CORRESPONDING FIELDS OF table ls_role       " here you have missed writing table ahead of ls_role
FROM zgr_llt_table
FOR ALL ENTRIES IN itab
WHERE ( category = itab-category or category = ' ') and ( sow = itab-sow or sow = ' ' ) and ( phase = itab-phase or phase = ' ' )
and ( type1 = itab-type1 or type1 = ' ' ).

check it out.....

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

There is nothing Web Dynpro specific about writing select statements. In fact you shouldn't even have SQL in your Web Dynpro Component, but in the underlying model. Your quesiton about Select statements is in fact a general ABAP question and belongs in the corresponding forum. I am moving this thread to ABAP General.

Former Member
0 Kudos

Ramana,

Use RANGES in the where stament so in case the field is empty, you select all the fields.

Something like this:


DATA: lr_category LIKE RANGE OF itab-category,
            ls_category LIKE LINE OF lr_category.

ls_category-sign = 'I'.
ls_category-option = 'EQ'.
loop at itab.
ls_category-low = itab-category.
insert ls_category into table lr_category.
* Add here other fields
endloop.


SELECT *
INTO CORRESPONDING FIELDS OF ls_role
FROM zgr_llt_table
FOR ALL ENTRIES IN itab
WHERE category IN lr_category.
* AND otherfield IN lr_otherfield.... etc....