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: 

About select options

Former Member
0 Kudos
175

Hi frnz, in one requirement, use will enter some values in select-options, the system has to see whether the entered value's pattern exists in the database.

For example if user enters "PRODMAT" then system should search in mara table whether any mara-matnr CP 'PRODMAT*', ie begins with entered value. if yes, should give next possible matnr value to create material. If user enters multiple values also system should do the same thing. Pls help me with some coding.

Thanks in advance.

1 ACCEPTED SOLUTION

former_member667836
Active Participant
0 Kudos
150

Hi Suresh,

Use Like Operator in the SELECT statement

eg:

select * from table where name like 'abc%'.

Message Edited

Shibu

11 REPLIES 11

former_member667836
Active Participant
0 Kudos
151

Hi Suresh,

Use Like Operator in the SELECT statement

eg:

select * from table where name like 'abc%'.

Message Edited

Shibu

0 Kudos
150

Hi Shibu..

It is working with parameter, is not working with select-option. Pls give me some piece of code if possible.

What I used was

"<u>select * from mara into table it_mara where matnr like p_matnr."</u>

Pls help me in modifying this in to select options.

0 Kudos
150

Try:


tables: mara.
select-options s_matnr for mara-matnr.
select * from mara into table it_mara where matnr in s_matnr

Rob

0 Kudos
150

Hi, this will select the exact entries which are there in select-options. It is needed to select matnr starting with the prefix entered in select option. Pls try.

0 Kudos
150

Not if the user enters PRODMAT* in the select-option.

Rob

0 Kudos
150

OK - I see what you want to do. Try:

REPORT ztest MESSAGE-ID 00.

TABLES: mara.
DATA: it_mara TYPE TABLE OF mara WITH HEADER LINE.
PARAMETER p_matnr LIKE mara-matnr OBLIGATORY.
RANGES: r_matnr FOR mara-matnr.

MOVE 'CP'     TO r_matnr-option.
MOVE 'I'      TO r_matnr-sign.
CONCATENATE p_matnr '*' INTO r_matnr-low.
APPEND r_matnr.

SELECT * FROM mara INTO TABLE it_mara WHERE matnr IN r_matnr.

Rob

0 Kudos
150

Thanks Rob,

but I am affraid RANGES will not prompt any select-option to user to enter his values. The requirement is, program should prompt select-options to user, user enters multiple single entries or range of values in select-options, program should see mara table for possible matnr with all prefixes entered by the user in select-option, should fetch last one with that prefix and display next available matnr which he can create.

for ex. user is entering AA, BB, CC, DD in select options, it should see matnr starting with AA, BB, CC, DD in table mara and go to last entry with AA BB CC DD and give last entry+1 to user. If AA10 is last entry in mara then AA11 should be displayed, if BB12 is last entry, BB13 should be displayed...

Pls give some suggestions.

Suresh.

0 Kudos
150

What happens if the user enters a range of materials?

Rob

0 Kudos
150

User is restricted to enter only short range. Like range containing 5-6 entries. Or else the user enters multiple single entries.

Suresh.

0 Kudos
150

Try like this, but be aware of the fact that having select options, user can use NE, NP, exclude range, exclude single value etc. You may want the user to be restricted to only EQ and BT.

TABLES: mara.

SELECT-OPTIONS: s_matnr FOR mara-matnr.

RANGES: r_matnr FOR mara-matnr.

START-OF-SELECTION.

  LOOP AT s_matnr.
    r_matnr = s_matnr.
    IF r_matnr-low IS NOT INITIAL.
      CONCATENATE r_matnr-low '*' INTO r_matnr-low.
    ENDIF.
    IF r_matnr-high IS NOT INITIAL.
      CONCATENATE r_matnr-high '*' INTO r_matnr-high.
    ENDIF.
    r_matnr-option = 'CP'.
    APPEND r_matnr.
  ENDLOOP.

  SELECT * FROM mara WHERE matnr IN r_matnr.

0 Kudos
150

Thanks, thanks a million. For some time our server was not working, so I delayed.

Its working as per my requirement. Thanks again.