Application Development and Automation 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: 
Read only

Select-options with two values

Former Member
0 Likes
8,212

Hi,

I need to create a select-option sentence containing only to string values. Until now, I had only used select-options with ranges but I need a select option with 'value1' and 'value2' only. I think it could be a general question but I don't know how to do this.

Can anybody tell me how to achieve this if possible?

Thanks in advance.

Regards.

1 ACCEPTED SOLUTION
Read only

Former Member
4,576

SELECT-OPTIONS : carrid for sflight-carrid DEFAULT 'AA' to 'LH'  OPTION  BT

                   SIGN  I.

For single field comparisons, Option can be EQ, NE, GE, GT, LE, LT, CP, or NP. The default value is EQ. For range selections, Option can be BT or NB. The default value is BT.

16 REPLIES 16
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
4,576

Hi David

Two values as including them excluding them? Search for restricting selection option Function module it will help you in solving the purpose..

Nabheet

Read only

0 Likes
4,576

Sorry, I haven't explained fine.

Actually, I want that the user could choose between two values X or Y.

My question is whether it can be done withouot having to define both values in a table. Is it possible to do this in an easy way'

Thanks.

Read only

sivaganesh_krishnan
Contributor
0 Likes
4,576

HI david,

For getting two distinct values ( not ranges) then you can write parameters and use it .

else

If you insist in using select-options then declare select options with no intervel .

code it as below,

BEGIN OF ty_select,                  "Structure for range table

               sign   TYPE char01,

               option TYPE char02,

               low    TYPE char40,

               high   TYPE char40,

            END OF ty_select.


DATA lt_date   TYPE STANDARD TABLE OF ty_select,

            lt_date1   TYPE STANDARD TABLE OF ty_select,

           lt_inq    TYPE STANDARD TABLE OF ty_select.

DATA lx_date    TYPE ty_select,

           lx_inq     TYPE ty_select.


lx_date-sign   = 'I'.

  lx_date-option = 'EQ'.

   lx_date-low    = selectoption-low.

append lx_date to lt_date.

clear lx_date.


lx_date-sign   = 'I'.

lx_date-option = 'EQ'.

   lx_date-low    = selectoption-high.

append lx_date to lt_date1.


You will find the values in lt_date and lt_date1 , you can use this in select statment using the keyword 'IN".


Regards,

Sivaganesh

Read only

0 Likes
4,576

Thanks for your answer.

I don't mind to use "parameters", what I really want is that when running the report the user could choose between two values, X or Y.

Is it possible to do with parameter sentence?

Read only

0 Likes
4,576

hi david,

what do you mean by choose between two values ???

Read only

Former Member
4,577

SELECT-OPTIONS : carrid for sflight-carrid DEFAULT 'AA' to 'LH'  OPTION  BT

                   SIGN  I.

For single field comparisons, Option can be EQ, NE, GE, GT, LE, LT, CP, or NP. The default value is EQ. For range selections, Option can be BT or NB. The default value is BT.

Read only

0 Likes
4,576

Thanks,

and, how is the syntax for a single field comparison (where only would be availabe those two values)?..

Read only

0 Likes
4,576

yes, as Farid said, you can check the select-options after user type something.

if s-low ne 'X' or s-high ne 'Y'. then give a message.

regards,

Archer

Read only

0 Likes
4,576

I think it will be better if u use Drop down input help with two values & put validation at selection screen

Read only

0 Likes
4,576

Thanks, I have done on this way.

What I don't know is how to paint the drop down inside the selection-screen. At this moment, the code is similar to this:

selection-screen: begin of block b1 with frame title text-001.

select-options: psoc for likp-vkorg no intervals no-extension default '3000'.

select-options: plot for lips-charg no intervals no-extension.

selection-screen: end of block b1.


AT SELECTION-SCREEN OUTPUT.

NAME = 'COLOR'.

VALUE-KEY = '1'.

VALUE-TEXT = 'COLOR1'.

APPEND VALUE TO LIST. VALUE-KEY = '2'.

VALUE-TEXT = 'COLOR2'.

APPEND VALUE TO LIST.

CALL FUNCTION 'VRM_SET_VALUES' EXPORTING ID = NAME VALUES = LIST.

Any suggestion to improve the code?

Thanks.

Read only

0 Likes
4,576

David,

Do it like this.

selection-screen: begin of block b1 with frame title text-001.

select-options: psoc for likp-vkorg no intervals no-extension default '3000'.

select-options: plot for lips-charg no intervals no-extension.

PARAMETERS p_color AS LISTBOX VISIBLE LENGTH 10 USER-COMMAND list.

selection-screen: end of block b1.




AT SELECTION-SCREEN OUTPUT.

   perform fill_dropdown.



form fill_dropdown.
    DATA : name TYPE vrm_id,
   list TYPE vrm_values,
   value TYPE vrm_value.
   name = 'P_COLOR'" Name should be in UPPER CASE

   value-key = '1'.
   value-text = 'Color 1'.
   APPEND value TO list.
   value-key = '2'.
   value-text = 'Color 2'.
   APPEND value TO list.

   CALL FUNCTION 'VRM_SET_VALUES'
     EXPORTING
       id              = name
       values          = list
     EXCEPTIONS
       id_illegal_name = 0
       OTHERS          = 0.
endform.

Read only

0 Likes
4,576

Thanks everybody for your help.

Regards.

Read only

Saumitra_MT
Explorer
0 Likes
4,576

Hi David,

As i see your requirement you only have 2 values that need to be selected from the select options.

You can do this by passing the F4 help, Use 'AT SELECTION-SCREEN ON VALUE REQUEST FOR THE S_FIELD-LOW'.  " here S_FIELD-LOW is lower limit of select-options range table.

Under This event you can declare a subroutine and inside this you can use range tables for passing the value. Then call function 'F4IF_INT_TABLE_VALUE_REQUEST' for showing the value as F4 Help.

Pass only two values to populate the table.

However in my opinion if there are only two fields to choose from, make a selection screen block with text, asking to choose from one, and use a radio button group to chose from the option. and use constant fields to fetch value with the select query.

Regards,

Saumitra

Read only

Former Member
0 Likes
4,576

Execute this program..

TYPES:BEGIN OF ty_tab,

       value TYPE char10,

       END OF ty_tab.

DATA:it_tab TYPE TABLE OF ty_tab,

      x_tab TYPE ty_tab.

PARAMETERS: input(10) TYPE c.

AT SELECTION-SCREEN OUTPUT.

   LOOP AT SCREEN.

     IF screen-name = 'INPUT'  .

       screen-input = 0.

       MODIFY SCREEN.

     ENDIF.

   ENDLOOP.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR INPUT.

   CLEAR it_tab[].

   x_tab-value = 'Farid'.

   APPEND x_tab TO it_tab.

   x_tab-value = 'Hasan'.

   APPEND x_tab TO it_tab.

   CLEAR x_tab.

   CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

     EXPORTING

       retfield    = 'VALUE'

       dynpprog    = sy-cprog

       dynpnr      = sy-dynnr

       dynprofield = 'INPUT'

       value_org   = 'S'

       display     = 'F'

     TABLES

       value_tab   = it_tab[].

Read only

former_member185177
Contributor
0 Likes
4,576

Hi David,

1) Create a domain. store the values in that domain

2) use the domain in table.

3) Declare a variable with type (newly created domain used table)

4) Use the variable in select-options with no intervals.

5) Then user can able to select only one value.

Hope it helps you.

Regards,

Krishna Chaitanya.

Read only

ronaldo_aparecido
Contributor
0 Likes
4,576

Hi David

Krishna is correct you need a domain with value ranges.

Create a domain for that field and insert you values.

See this links: http://wiki.scn.sap.com/wiki/display/ABAP/Fetching+Value+Range+Text+from+Domain

Domains (SAP Library - BC - ABAP Dictionary)

I hope helped you.