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: 

string operations in SELECT WHERE clause

Former Member
0 Kudos

Hi,

PARAMETERS: P_MAKTX TYPE MAKT-MAKTX.

Lets say the user inputs "Pump". I want the program to search the text "pump" in all makt-maktx and display the result.

Could someone tell me how to write the select statement.

SELECT * from MAKT into table IT_MAKT where MAKTX ??? P_MAKTX.

Please advise.

Regards,

Shobhit

5 REPLIES 5

former_member181962
Active Contributor
0 Kudos

Hi Shobit,

use the like addition,

PARAMETERS srch_str(20) TYPE c.

CONCATENATE '%' srch_str '%' INTO srch_str.

DATA text_tab TYPE TABLE OF doktl.

SELECT *

FROM doktl

INTO TABLE text_tab

WHERE doktext LIKE srch_str.

In your case it would be

CONCATENATE '%' P_MAKTX '%' INTO P_MAKTX.

SELECT * from MAKT into table IT_MAKT where MAKTX like P_MAKTX.

regards,

Ravi

Message was edited by: Ravi Kanth Talagana

Message was edited by: Ravi Kanth Talagana

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Try this....

This is an example for using the parameter. You could use a select-option instead.



report zrich_0001
       no standard page heading.


data: imakt type table of makt with header line.

parameters: p_maktx type makt-maktx.


ranges: r_maktx for imakt-maktx.

r_maktx-sign = 'I'.
r_maktx-option = 'CP'.
concatenate '*' p_maktx '*' into r_maktx-low.
condense r_maktx-low.
append r_maktx.

select * into corresponding fields of table imakt
         from makt
              where maktx in r_maktx
                and spras = sy-langu.

loop at imakt.
  write:/ imakt-matnr, imakt-maktx.

endloop.


Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Duplicate

Regards,

Rich Heilman

Former Member
0 Kudos

Just remember that this is case sensitive, so instead, use the MAKTG field which has the uppercase equivalent description. You can change your user input also into uppercase and use the code that others mentioned here.

Srinivas

0 Kudos

Please make sure to award points for helpful answers and if you problem is solved, mark you post as solved. Thanks.

Regards,

Rich Heilman