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: 

Change select-options at runtime

Former Member
0 Kudos

Hi all,

I want change the behavior of a select-options field at runtime.

e. g.

At the beginning of the program the intervals are enabled.

After the user pushes a radiobutton the select-options field should be changed to no-intervals.

How can I change the select-options field at runtime?

regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

You may try with

AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
     IF screen-group1 = 'MOD'.
*   select-option with intervals.
     ELSE
*   select-option with no intervals.
     ENDIF.
MODIFY SCREEN.
ENDLOOP.

You may check the sample code for the same in the below link.

http://www.sapdev.co.uk/reporting/selscr/but_buttons.htm

3 REPLIES 3

Former Member
0 Kudos

Hi,

You may try with

AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
     IF screen-group1 = 'MOD'.
*   select-option with intervals.
     ELSE
*   select-option with no intervals.
     ENDIF.
MODIFY SCREEN.
ENDLOOP.

You may check the sample code for the same in the below link.

http://www.sapdev.co.uk/reporting/selscr/but_buttons.htm

former_member182040
Active Contributor
0 Kudos

Run the following Example:


TABLES: vbak, ltak.
DATA:err_sw.
PARAMETERS: rb1 RADIOBUTTON GROUP rb1 USER-COMMAND sel DEFAULT 'X'.
PARAMETERS: rb2 RADIOBUTTON GROUP rb1.

SELECTION-SCREEN: SKIP 1.

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
SELECT-OPTIONS: sauart FOR vbak-auart DEFAULT 'ZRE' NO INTERVALS MODIF ID rb1.
SELECT-OPTIONS: sdate FOR vbak-erdat MODIF ID rb1.
SELECTION-SCREEN: END OF BLOCK b1.

SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02.
SELECT-OPTIONS: stanum FOR ltak-tanum MODIF ID rb2.
SELECT-OPTIONS: sbdatu FOR ltak-bdatu MODIF ID rb2.
SELECTION-SCREEN: END OF BLOCK b2.

AT SELECTION-SCREEN OUTPUT.
IF rb1 = 'X'.
PERFORM hide_rb2_options.
ELSE.
PERFORM hide_rb1_options.
ENDIF.

INITIALIZATION.

START-OF-SELECTION.
CLEAR err_sw.
IF rb1 = 'X'.
IF sauart IS INITIAL
OR sdate IS INITIAL.
MESSAGE i208(00) WITH 'not entered'.
err_sw = 'X'.
ENDIF.
ELSE.
IF stanum IS INITIAL
OR sbdatu IS INITIAL.
MESSAGE i208(00) WITH 'not entered'.
err_sw = 'X'.
ENDIF.
ENDIF.

CHECK err_sw NE 'X'.

WRITE:/ 'Hi!'.

*&---------------------------------------------------------------------*
*& Form hide_rb2_options
*&---------------------------------------------------------------------*
FORM hide_rb2_options.
LOOP AT SCREEN.
CASE screen-group1.
WHEN 'RB1'.
screen-active = 1.
MODIFY SCREEN.
WHEN 'RB2'.
screen-active = 0.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
ENDFORM. " hide_rb2_options
*&---------------------------------------------------------------------*
*& Form hide_rb1_options
*&---------------------------------------------------------------------*
FORM hide_rb1_options.
LOOP AT SCREEN.
CASE screen-group1.
WHEN 'RB2'.
screen-active = 1.
MODIFY SCREEN.
WHEN 'RB1'.
screen-active = 0.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.

ENDFORM. " hide_rb1_options

SuhaSaha
Advisor
Advisor
0 Kudos

Hello,

You can try this workaround though:

DATA: v_bukrs TYPE bukrs,
      r_bukrs TYPE RANGE OF bukrs.

PARAMETERS: rb1 RADIOBUTTON GROUP g1 USER-COMMAND cmd DEFAULT 'X',
            rb2 RADIOBUTTON GROUP g1.
SELECT-OPTIONS: s_bukrs1 FOR v_bukrs MODIF ID m1,
                s_bukrs2 FOR v_bukrs NO INTERVALS MODIF ID m2.

AT SELECTION-SCREEN OUTPUT.

  IF rb1 = 'X'.
    LOOP AT SCREEN.
      IF screen-group1 = 'M2'.
        screen-output = '0'.
        screen-active = '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ELSE.
    LOOP AT SCREEN.
      IF screen-group1 = 'M1'.
        screen-output = '0'.
        screen-active = '0'.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
  ENDIF.

  START-OF-SELECTION.

  IF s_bukrs1[] IS NOT INITIAL.
    r_bukrs = s_bukrs1[].
  ELSEIF s_bukrs1[] IS NOT INITIAL.
    r_bukrs = s_bukrs2[].
  ENDIF.

* For further processing use R_BUKRS instead of screen elements!!!

I thought the function SELECT_OPTIONS_RESTRICT should help, but as per the documentation it won't:

The latest you can call it is in the PBO of the first selection screen to be displayed. If you call it any later, the exception TOO_LATE occurs.

Hope this helps.

BR,

Suhas