‎2008 Feb 03 2:09 PM
Hi everybody,
I am using a RFC and sending it some values to the imported variables.
In the code I want to use some select statement and a "where" condition that is followed by "like". In the value that I insert to the "like " I wish to use the value that was sent to the imported variable + the "%" sign (results should be all records that their relevant field starts with the value that I send to the imported variable).
For example:
SELECT * FROM <table_name> INTO table <my_table> WHERE <some_field> LIKE <my_imported_variable>%
This syntax fails. Can someone explain why and what is the right way?
Thanks,
Roy
‎2008 Feb 03 2:12 PM
Declare another variable; concatenate the '%' to the imported variable & then store it in this variable; use this new variable in your WHERE clause.
~Suresh
‎2008 Feb 03 2:20 PM
Thanks Suresh,
Can you give an example - how do I concatenate the variable with the char "%"?
‎2008 Feb 03 3:17 PM
Hi Roy check this code to create dynamic where clause.. like you wanted..
PARAMETERS: carr_id TYPE spfli-carrid,
conn_id TYPE spfli-connid.
DATA: where_clause TYPE STRING,
and(4),
wa_spfli TYPE spfli.
IF carr_id IS NOT INITIAL.
CONCATENATE 'CARRID = ''' carr_id '''' INTO where_clause.
and = ' AND'.
ENDIF.
IF conn_id IS NOT INITIAL.
CONCATENATE where_clause and ' CONNID = ''' conn_id ''''
INTO where_clause.
ENDIF.
SELECT * FROM spfli INTO wa_spfli WHERE (where_clause).
WRITE: / wa_spfli-carrid, wa_spfli-connid, wa_spfli-cityfrom,
wa_spfli-cityto, wa_spfli-deptime.
ENDSELECT.
‎2008 Feb 03 5:28 PM
Hi Roy,
Please try this logic.
This logic i have used for getting purchase orders from EKKO where Purchase order number starts only with '46'.
SELECT ebeln
ekorg
lifnr
INTO TABLE it_ekko
FROM ekko
WHERE EBELN like '46%'.
regards
Avi....