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: 

SELECT USING PATTERN FOR SELECT OPTIONS

Former Member
0 Kudos

Hi All,

  I want to select data from database table using pattern for select option. kindly help me to solve.

Ex.

DATA: SO_PRCTR FOR CEPC-PRCTR.

select prctr from cepc into table t_prctr

   where prctr in so_prctr.

Value of so_prctr = 79* to 81*.

Thanks & Regards,

SABAREESH

6 REPLIES 6

0 Kudos

You have to use this:

DATA: gv_prctr TYPE cepc-prctr.

SELECT-OPTIONS: so_prctr FOR gv_prctr.

select prctr from cepc into table t_prctr

   where prctr in so_prctr.

The data has to be filled like a parameter when you execute the program, but you can inizialice on the INITIALIZATION event like this:


data: gs_so_prctr LIKE LINE OF so_prctr.


gs_so_prctr-option = 'EQ'.

gs_so_prctr-sign = 'I'.

gs_so_prctr-low = your data.

append gs_so_prctr TO so_prctr.


Regards,

Alberto.

Former Member
0 Kudos

Hi,

Please try below logic.

select-options: so_prctr for cepc-prctr.

initialization.

so_prctr-low = '79*'.

so_prctr-high = '81*'.

so_prctr-option = 'BT'.

so_prctr-sign = 'I'.

append so_prctr.

start-of-selection.

select prctr from cepc into table t_prctr

   where prctr in so_prctr.

Thanks,

Sree

Former Member
0 Kudos

Hi Sabareeshwaran,

Alternatively, you can fill your select-option with the sign 'I' and the option 'CP', something like:

SO_PRCTR-SIGN       = 'I'.

SO_PRCTR-OPTION  = 'CP'.

SO_PRCTR-LOW        = your_pattern.


Hope this helps.

former_member210770
Active Participant
0 Kudos

select-options : s_ebeln for ekko-ebeln.

           s_ebeln TYPE mmpur_t_ebeln,

        

suppose you have passed S_ebeln-low = 79 and S_ebeln-high = 81.

start-of-selection.

DATA : lt_ekko TYPE STANDARD TABLE OF ekko,

           lw_ekko TYPE ekko,

           l_ebeln TYPE mmpur_t_ebeln,

           w_ebeln LIKE LINE OF s_ebeln.

CONCATENATE s_ebeln-low  '*'  into w_ebeln-low.  "79*

CONCATENATE s_ebeln-high  '*'  into w_ebeln-high "81*

w_ebeln-sign = 'I'.

w_ebeln-option = 'BT'.

APPEND w_ebeln TO l_ebeln.

  SELECT * FROM ekko

           INTO TABLE lt_ekko

           WHERE ebeln IN l_ebeln.

Hope it will Useful.

Thanks and Regards,

Sagar

former_member226225
Contributor
0 Kudos

Hi Sabareesh,

you can use the below code.

INITILIZATION.

so_prctr-low = '79*'.

so_prctr-high = '81*'.

so_prctr-sign = 'I'.

so_prctr-option  = 'CP'.

append so_prctr.

START-OF-SELECTION.

select * from (tablename) into (itab) where prctr in so_prctr.

please check.

Thanks & Regards,

Raghunadh Kodali

Former Member
0 Kudos

Hi Sabareeshwaran,

As you are checking the range of values which contains pattern so you cannot include 'BT' as option in range table.And you need to use CP as option in range table.But whereas CP cannot check the range of values .It can check only single value.

Here is the below code.

DATA : gt_cepc TYPE TABLE OF cepc,

        rt_prctr TYPE RANGE OF prctr,

        rw_prctr LIKE LINE OF rt_prctr.

rw_prctr-sign   = 'I'.

rw_prctr-option = 'CP'.

rw_prctr-low    = '+82*'.

rw_prctr-high   = ' '.

APPEND rw_prctr TO rt_prctr.

CLEAR  rw_prctr.

SELECT * FROM

          cepc

          INTO TABLE gt_cepc

          WHERE prctr IN rt_prctr.

Regards.

Sridhar.A