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 like string in parameter

Former Member
0 Likes
2,550

Hi All

i want to fetch data

as per vendor name

from lfa1

according to input given by user in parameter

if user doesnt remember full name of vendor.

SELECT-OPTIONS comcode FOR wa_vendet-bukrs OBLIGATORY.

PARAMETERS venname LIKE wa_vendet-name1.

select----

WHERE abukrs IN comcode AND bname1 LIKE venname.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,496

Hi

You can write you Select as -

Get your Parameter value in a variable of type c.

Also, you will have to prefix and suffix '%' to the search string.

CONCATENATE '%' P_VALUE '%' INTO L_TMP.

So your Select query becomes

select----

WHERE abukrs IN comcode AND bname1 LIKE L_TMP.

Regards,

Rupesh

3 REPLIES 3
Read only

Former Member
0 Likes
1,497

Hi

You can write you Select as -

Get your Parameter value in a variable of type c.

Also, you will have to prefix and suffix '%' to the search string.

CONCATENATE '%' P_VALUE '%' INTO L_TMP.

So your Select query becomes

select----

WHERE abukrs IN comcode AND bname1 LIKE L_TMP.

Regards,

Rupesh

Read only

Former Member
0 Likes
1,496

Hi,

here is a sample for searching name1 and street in LFA1 :

report  zsbabl_lfa1.
                                                                                types: begin of xl,
         lifnr     type lfa1-lifnr,
         name1     type lfa1-name1,
         stras     type lfa1-stras,
       end   of xl.
                                                                                data:  xsl type xl.
                                                                                parameters: xp_name1          type  lfa1-name1 default 'In*'.
parameters: xp_stras          type  lfa1-stras default '*Se*'.
                                                                                start-of-selection.
                                                                                translate  xp_name1        to  upper case.
     translate  xp_name1     using  '*%'.
     translate  xp_stras        to  upper case.
     translate  xp_stras     using  '*%'.
                                                                                EXEC SQL                     PERFORMING  list.
       SELECT LIFNR, NAME1, STRAS
                              INTO  :xsl
                              FROM  LFA1
       WHERE  UPPER( NAME1 )  LIKE  :xp_name1
       AND    UPPER( STRAS )  LIKE  :xp_stras
     ENDEXEC.
                                                                                END-OF-SELECTION.

FORM list.
                                                                                WRITE:                   /1  xsl-lifnr,
                                    xsl-name1,
                                    xsl-stras.
                                                                                ENDFORM.

We needed this not knowing the names are written in upper and lower case combinations.

The mixed search in only possible in native SQL UPPER CASE search.

Regards,

Klaus

____________________________________________________________________________________________________________________________________

Edited by: Klaus Babl on Mar 21, 2011 7:24 AM

Read only

Former Member
0 Likes
1,496

Just a suggestion, why not make sure the vendor name is valid before you do any selection? Parameter with input help maybe.