Skip to Content
avatar image
Former Member

How to display records accordingly while using asterisk in input

Say,

In a database table I have a field named "site" which contains the following records.

972

345

240

950


so there are four entries.

Now my parameter is

SELECT-OPTIONS: s_site FOR string NO INTERVALS.


If I give the input as only asterisk


i.e. s_site = *


then all the records must display.


on the other hand if I give the input like this,


i.e. s_site = 9*


then it must display all the records starting with 9


In this case the answer must be: 972 and 950.

Can someone help me with the logic or syntax please.



Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 21, 2015 at 07:46 AM

    Hi, will be handled automatically by the WHERE condition of the SELECT statement.

    Try this: SELECT * FROM dbtable WHERE site IN s_site.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 21, 2015 at 08:38 AM

    Thank you so much guys. I'll try it and revert back

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      run the following code..

      both the logics mentioned above are working fine,.

      select-option internal table OPTION field will have value 'CP' i.e contain pattern

      REPORT ZTEST.

      TABLES:MARA.




      DATA: IT_FLIGHT TYPE TABLE OF MARA.

      DATA: IT_FLIGHT1 TYPE TABLE OF MARA.

      SELECT-OPTIONS: S_MTART FOR MARA-MTART NO INTERVALS NO-EXTENSION.

      PARAMETERS: P_MTART TYPE MARA-MTART.



      TRANSLATE P_MTART TO UPPER CASE.



      REPLACE ALL OCCURRENCES OF '*' IN P_MTART WITH '%'.


      case 1: for select options
      SELECT * FROM MARA

      INTO TABLE IT_FLIGHT UP TO 10 ROWS

      *WHERE MTART LIKE SVAR.

      WHERE MTART IN S_MTART.

      case 2 for parameters

      SELECT * FROM MARA

      INTO TABLE IT_FLIGHT1 UP TO 10 ROWS

      WHERE MTART LIKE P_MTART.


      BREAK-POINT.

      thanks!!