21/09/2010

UI Output Options with Local Class


REPORT ZADN_SAMPLE.

*----------------------------------------------------------------------*
* CLASS cl_UI_manager DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_ui_manager DEFINITION.

PUBLIC SECTION.

METHODS : constructor,
set_field_options IMPORTING p_name TYPE c
p_required TYPE c
p_input TYPE c
p_output TYPE c,
commit_ui_changes.

PRIVATE SECTION.

DATA : it_screen TYPE SORTED TABLE OF screen WITH UNIQUE KEY name.

ENDCLASS. "cl_UI_manager DEFINITION

*----------------------------------------------------------------------*
* CLASS cl_UI_manager IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_ui_manager IMPLEMENTATION.

METHOD constructor.

LOOP AT SCREEN.

INSERT screen INTO TABLE me->it_screen.

ENDLOOP.

ENDMETHOD. "constructor

METHOD set_field_options.

FIELD-SYMBOLS : <fs_screen> TYPE screen.

READ TABLE me->it_screen ASSIGNING <fs_screen> WITH KEY name = p_name.

IF <fs_screen> IS ASSIGNED.

<fs_screen>-required = p_required.
<fs_screen>-input = p_input.
<fs_screen>-output = p_output.

ENDIF.

ENDMETHOD. "set_field_options

METHOD commit_ui_changes.

FIELD-SYMBOLS : <fs_screen> TYPE screen.

LOOP AT SCREEN.

READ TABLE me->it_screen ASSIGNING <fs_screen> WITH KEY name = screen-name.

IF <fs_screen> IS ASSIGNED.

MODIFY SCREEN FROM <fs_screen>.

ENDIF.

ENDLOOP.

ENDMETHOD. "commit_UI_changes

ENDCLASS. "cl_UI_manager IMPLEMENTATION

DATA o_cl_ui_manager TYPE REF TO cl_ui_manager.

PARAMETERS : p_1 TYPE c LENGTH 10,
p_2 TYPE c LENGTH 10.

PARAMETERS : ch_1 RADIOBUTTON GROUP xc USER-COMMAND selec,
ch_2 RADIOBUTTON GROUP xc.

INITIALIZATION.

CREATE OBJECT o_cl_ui_manager.

AT SELECTION-SCREEN OUTPUT.

IF o_cl_ui_manager IS BOUND.

o_cl_ui_manager->set_field_options( p_name = 'P_1'
p_required = '0'
p_input = '0'
p_output = '1' ).

o_cl_ui_manager->set_field_options( p_name = 'P_2'
p_required = '1'
p_input = '1'
p_output = '1' ).

o_cl_ui_manager->commit_ui_changes( ).

ENDIF.

Nenhum comentário:

Postar um comentário