cancel
Showing results for 
Search instead for 
Did you mean: 

How to form 'select statement' based on user Search in BSP page...??

Former Member
0 Kudos

Hi Good evening to all...

I have BSP page that contain search Fields..If user enter some  value in search fields, The  'SELECT' statement should form based on user input value..

ex:

user enter "Male" in Gender search field..The select statement should change like below..

SELECT * from ZDATABASEVIEW  into data_table where ZCAND_GENDER = 'Male'.

similarly for some more fields...

Please any one suggest me how to proceed...

I already searched some sdn forum discussion but i didn't get what i need..

thanks and regards

santhosh..

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi good morning ...

Thanks for your reply...

My questions is if suppose user want to search two fields  say like 'gender' and 'Location'.

Select statement will change to

SELECT * from ZDATABASEVIEW  into data_table where ZCAND_GENDER = 'Male' AND ZCAND_LOCATION = 'Bangalore'.

If suppose user want to search 3 fields From BSP page,select statement should contain 3 where conditions..

Like

SELECT * from ZDATABASEVIEW  into data_table where ZCAND_GENDER = 'Male' AND ZCAND_LOCATION = 'Bangalore' AND ZCAND_SKILLS = 'SAP'.

This select query should  change based on user  input values...

Please let me know how to proceed...

Thanks and regards

santhosh

Former Member
0 Kudos

Hi santhosh,

create check boxes for different options like male [] ,location[] ,SAP[] and in select statement  put if condition like;

if  male = X and  location = X

SELECT * from ZDATABASEVIEW  into data_table where ZCAND_GENDER = 'Male' AND ZCAND_LOCATION = 'Bangalore' this is one of the way.
else you can use dropdown box method.

CREATE DROPDOWN BOX WHICH CONTAINS THREE PLACES KOLKATA ,CHENNAI,mumbai..create global constants.

put condition if loc = gc_1.

l_loc = chennai.put else if etc...

SELECT * from ZDATABASEVIEW  into data_table where ZCAND_GENDER = l_gen AND ZCAND_LOCATION = l_loc.

I think it might be helpful,,

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

Thank you very much...Now its working Fine...

But i was tried another method code..

The code is here..

DATA:

     itab(1000)    TYPE c,

     data1(72)   TYPE c,

     data2(72)   TYPE c,

     data3(72)   TYPE c,

     data4(72)   TYPE c,

     data5(72)   TYPE c,

     data6(72)   TYPE c,

     data7(72)   TYPE c,

     data8(72)   TYPE c.

IF  data4 IS INITIAL.

     clear: data4.

    CONCATENATE 'ZCAND_FNAME = ''' w_zcand_fname '''' INTO data4.

     endif.

     IF  data5 IS INITIAL.

     clear: data5.

    CONCATENATE 'ZCAND_LNAME = ''' w_zcand_lname '''' INTO data5.

     endif.

    IF  data6 IS INITIAL.

     clear: data6.

    CONCATENATE 'ZCAND_AGE between ''' w_zcand_agefrom ''' AND ''' w_zcand_ageto '''' INTO data6.

     endif.

    IF  data7 IS INITIAL.

     clear: data7.

    CONCATENATE 'ZCAND_SKILLS like ''%' w_zcand_skills '%''' INTO data7.

     endif.

    IF  data8 IS INITIAL.

     clear: data8.

    CONCATENATE 'ZCAND_FUNCAREA like ''%' w_zcand_funcarea '%''' INTO data8.

     endif.

IF  data1 IS INITIAL.

clear: data1.

case w_zcand_gender.

when 'Male'.

  CONCATENATE 'ZCAND_GENDER = ''' w_zcand_gender '''' INTO data1.

when 'Female'.

CONCATENATE 'ZCAND_GENDER = ''' w_zcand_gender '''' INTO data1.

when others.

clear: data1.

endcase.

endif.

     IF  data2 IS INITIAL.

     clear: data2.

    CONCATENATE 'ZCAND_WORKEXP between ''' w_zcand_workexp '%''  AND ''' w_zcand_workto '%''' INTO data2.

     endif.

    IF  data3 IS INITIAL.

    clear: data3.

      CONCATENATE 'ZCAND_UGSPECIAL like  ''%' w_zcand_ugspecial '%''' INTO data3.

     endif.

IF NOT w_zcand_gender IS INITIAL.

CONCATENATE data1 itab

INTO itab SEPARATED BY space.

ENDIF.

IF NOT w_zcand_workexp IS INITIAL.

IF itab IS INITIAL.

CONCATENATE data2 itab

INTO itab SEPARATED BY space.

ELSE.

CONCATENATE itab 'AND' data2

INTO itab SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT w_zcand_ugspecial IS INITIAL.

IF itab IS INITIAL.

CONCATENATE data3 itab

INTO itab SEPARATED BY space.

ELSE.

CONCATENATE itab 'AND' data3

INTO itab SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT w_zcand_fname IS INITIAL.

IF itab IS INITIAL.

CONCATENATE data4 itab

INTO itab SEPARATED BY space.

ELSE.

CONCATENATE itab 'AND' data4

INTO itab SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT w_zcand_lname IS INITIAL.

IF itab IS INITIAL.

CONCATENATE data5 itab

INTO itab SEPARATED BY space.

ELSE.

CONCATENATE itab 'AND' data5

INTO itab SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT w_zcand_agefrom IS INITIAL.

IF itab IS INITIAL.

CONCATENATE data6 itab

INTO itab SEPARATED BY space.

ELSE.

CONCATENATE itab 'AND' data6

INTO itab SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT w_zcand_skills IS INITIAL.

IF itab IS INITIAL.

CONCATENATE data7 itab

INTO itab SEPARATED BY space.

ELSE.

CONCATENATE itab 'AND' data7

INTO itab SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT w_zcand_funcarea IS INITIAL.

IF itab IS INITIAL.

CONCATENATE data8 itab

INTO itab SEPARATED BY space.

ELSE.

CONCATENATE itab 'AND' data8

INTO itab SEPARATED BY space.

ENDIF.

ENDIF.

SELECT * FROM ZDATABASEVIEW INTO TABLE data_table

where (itab).

Former Member
0 Kudos

You are welcome..but it seems to be  huge logic..

Former Member
0 Kudos

You are welcome..but it seems to be  huge logic..

Former Member
0 Kudos

i got it.....you are welcome..

Former Member
0 Kudos

Hi ,

   I am not getting your idea.for example select query is based on value your input .if you enter male or female,it will take it as gender and it will excute select statement based on gender value.Else if  you have multiple selection options  based on user wish..you can use 'OR ' in select Query.for example if you want to get output based on either one of options like gender or domainSELECT * from ZDATABASEVIEW  into data_table where ZCAND_GENDER = 'gender' or ZCAND_domain='domain'.