Thursday, September 11, 2008

Dynamic selection screen with list box

By Joyjit Ghosh,
Kolkata, India.

Code:

*&---------------------------------------------------------------------*
*& Report Z_DYNAMIC_SCREEN
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT z_dynamic_screen.

TYPE-POOLS: vrm.

DATA: name TYPE vrm_id, list TYPE vrm_values, value LIKE LINE OF list.

TABLES: sscrfields.

* Selection screen

* List box
PARAMETERS: ps_parm AS LISTBOX VISIBLE LENGTH 10

USER-COMMAND abc.

* Radio buttons
PARAMETERS: rb1 RADIOBUTTON GROUP ab MODIF ID bl2,

rb2 RADIOBUTTON GROUP ab MODIF ID bl2,

rb3 RADIOBUTTON GROUP ab MODIF ID bl3.


INITIALIZATION.

* Populate list box values

name = 'PS_PARM'.

value-key = '1'. value-text = 'Line 1'. APPEND value TO list.

value-key = '2'. value-text = 'Line 2'. APPEND value TO list.


AT SELECTION-SCREEN OUTPUT.

* Set list box with value

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = name

values = list.


* Control the display of screen components

LOOP AT SCREEN.

IF ps_parm = 1.

IF screen-name = 'RB1' OR screen-name = 'RB2' .

screen-invisible = 0.

ELSEIF screen-name = 'RB3'.

screen-invisible = 1.

ENDIF.

MODIFY SCREEN.

ELSEIF ps_parm = 2.

IF screen-name = 'RB1' OR screen-name = 'RB2' .

screen-invisible = 1.

ELSEIF screen-name = 'RB3'.

screen-invisible = 0.

ENDIF.

MODIFY SCREEN.

ELSEIF ps_parm = space.

rb1 = 'X'.

clear: rb2,rb3.

IF screen-name = 'RB1' OR screen-name = 'RB2' OR

screen-name = 'RB3'.

screen-invisible = 0.

MODIFY SCREEN.

ENDIF.

ENDIF.

ENDLOOP.

AT SELECTION-SCREEN.

IF sscrfields-ucomm = 'ABC'.

ENDIF.

START-OF-SELECTION.

WRITE: / 'Parameter:', ps_parm.


Selection screen:

No comments: