0% found this document useful (0 votes)
101 views6 pages

CL Screen Breaker

This document defines a class called LCL_SCREEN_BREAKER that provides methods for manipulating and managing SAP screen fields and objects. The class stores the current screen fields in internal tables and allows setting properties like visibility, input/output status, and required fields. It also supports getting, setting, and restoring screen field values and default properties.

Uploaded by

lbab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views6 pages

CL Screen Breaker

This document defines a class called LCL_SCREEN_BREAKER that provides methods for manipulating and managing SAP screen fields and objects. The class stores the current screen fields in internal tables and allows setting properties like visibility, input/output status, and required fields. It also supports getting, setting, and restoring screen field values and default properties.

Uploaded by

lbab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

*&---------------------------------------------------------------------*

*& Include ZCL_SCREEN_BREAKER


*&---------------------------------------------------------------------*

*----------------------------------------------------------------------*
* CLASS lcl_screen_breaker DEFINITION
*----------------------------------------------------------------------*
* (c) 2010 Karol Seman & Fabio Luiz Esperati Pagoti
*----------------------------------------------------------------------*
CLASS lcl_screen_breaker DEFINITION.
PUBLIC SECTION.
METHODS activate_screen.

METHODS restore_default.

METHODS constructor.

METHODS store_current_screen.

METHODS set_current_screen_as_default.

METHODS get_object
IMPORTING
value(i_field_name) TYPE screen-name
RETURNING value(es_screen) TYPE screen
EXCEPTIONS
not_found.

METHODS set_object
IMPORTING
value(is_screen) TYPE screen
EXCEPTIONS
not_found.

METHODS set_input
IMPORTING
value(i_field_name) TYPE screen-name
EXCEPTIONS
not_found.

METHODS set_output
IMPORTING
value(i_field_name) TYPE screen-name
EXCEPTIONS
not_found.

METHODS set_invisible
IMPORTING
value(i_field_name) TYPE screen-name
EXCEPTIONS
not_found.

METHODS set_visible
IMPORTING
value(i_field_name) TYPE screen-name
EXCEPTIONS
not_found.

METHODS set_mandatory
IMPORTING
value(i_field_name) TYPE screen-name
EXCEPTIONS
not_found.

METHODS set_optional
IMPORTING
value(i_field_name) TYPE screen-name
EXCEPTIONS
not_found.

METHODS set_as_pass
IMPORTING
value(i_field_name) TYPE screen-name
EXCEPTIONS
not_found.

PRIVATE SECTION.
DATA: ascreen TYPE STANDARD TABLE OF screen WITH KEY name. " actual/active
screen
DATA: dscreen TYPE STANDARD TABLE OF screen WITH KEY name. " default screen (as
was defined in the code)
ENDCLASS. "cl_dynpro_handler DEFINITION

*----------------------------------------------------------------------*
* CLASS lcl_screen_breaker IMPLEMENTATION
*----------------------------------------------------------------------*
* (c) 2010 Karol Seman & Fabio Luiz Esperati Pagoti
*----------------------------------------------------------------------*
CLASS lcl_screen_breaker IMPLEMENTATION.

*----------------------------------------------------------------------*
* METHOD get_object
*----------------------------------------------------------------------*
* Returns all settings of specified object
*----------------------------------------------------------------------*
METHOD get_object.
READ TABLE me->ascreen INTO es_screen
WITH TABLE KEY name = i_field_name.

IF sy-subrc <> 0.
RAISE not_found.
ENDIF.
ENDMETHOD. "get_object

*----------------------------------------------------------------------*
* METHOD set_object
*----------------------------------------------------------------------*
* Overwrites specified object with new values
*----------------------------------------------------------------------*
METHOD set_object.
FIELD-SYMBOLS: <fs_screen> TYPE screen.

READ TABLE me->ascreen ASSIGNING <fs_screen>


WITH TABLE KEY name = screen-name.

IF sy-subrc <> 0.
RAISE not_found.
ENDIF.
<fs_screen> = is_screen.
ENDMETHOD. "set_object

*----------------------------------------------------------------------*
* METHOD set_current_screen_as_default
*----------------------------------------------------------------------*
* Get currently displayed screen and store it as default screen
* for next usage
*----------------------------------------------------------------------*
METHOD set_current_screen_as_default.
CLEAR me->dscreen.
LOOP AT SCREEN.
APPEND screen TO me->dscreen.
ENDLOOP.
ENDMETHOD. "set_current_screen_as_default

*----------------------------------------------------------------------*
* METHOD store_current_screen
*----------------------------------------------------------------------*
* Store actually displayed screen into internal tables for next usage
*----------------------------------------------------------------------*
METHOD store_current_screen.
CLEAR me->ascreen.
LOOP AT SCREEN.
APPEND screen TO me->ascreen.
ENDLOOP.

me->dscreen = me->ascreen.
ENDMETHOD. "store_current_screen

*----------------------------------------------------------------------*
* METHOD constructor
*----------------------------------------------------------------------*
* Creation of the object - initialize screen tables from system
*----------------------------------------------------------------------*
METHOD constructor.
store_current_screen( ).
ENDMETHOD. "constructor

*----------------------------------------------------------------------*
* METHOD set_input
*----------------------------------------------------------------------*
* Set field as input/output
*----------------------------------------------------------------------*
METHOD set_input.
FIELD-SYMBOLS: <fs_screen> TYPE screen.

READ TABLE me->ascreen ASSIGNING <fs_screen>


WITH TABLE KEY name = i_field_name.
IF <fs_screen> IS ASSIGNED.
<fs_screen>-input = 1.
<fs_screen>-output = 1.
<fs_screen>-display_3d = 1.
<fs_screen>-invisible = 0.
<fs_screen>-active = 1.
ELSE.
RAISE not_found.
ENDIF.
ENDMETHOD. "set_input

*----------------------------------------------------------------------*
* METHOD set_invisible
*----------------------------------------------------------------------*
* Hide the field from the screen - variable can be used in the code
* but is not visible in the screen
*----------------------------------------------------------------------*
METHOD set_invisible.
FIELD-SYMBOLS: <fs_screen> TYPE screen.

READ TABLE me->ascreen ASSIGNING <fs_screen>


WITH TABLE KEY name = i_field_name.
IF <fs_screen> IS ASSIGNED.
<fs_screen>-active = 0.
ELSE.
RAISE not_found.
ENDIF.
ENDMETHOD. "set_invisible

*----------------------------------------------------------------------*
* METHOD set_visible
*----------------------------------------------------------------------*
* Unhide the field in the screen - field is again visible and usable
* in the screen
*----------------------------------------------------------------------*
METHOD set_visible.
FIELD-SYMBOLS: <fs_screen> TYPE screen.

READ TABLE me->ascreen ASSIGNING <fs_screen>


WITH TABLE KEY name = i_field_name.
IF <fs_screen> IS ASSIGNED.
<fs_screen>-active = 1.
ELSE.
RAISE not_found.
ENDIF.
ENDMETHOD. "set_visible

*----------------------------------------------------------------------*
* METHOD set_output
*----------------------------------------------------------------------*
* Set the field as output only - value in the field is read-only
*----------------------------------------------------------------------*
METHOD set_output.
FIELD-SYMBOLS: <fs_screen> TYPE screen.

READ TABLE me->ascreen ASSIGNING <fs_screen>


WITH TABLE KEY name = i_field_name.
IF <fs_screen> IS ASSIGNED.
<fs_screen>-input = 0.
<fs_screen>-output = 1.
<fs_screen>-display_3d = 1.
<fs_screen>-invisible = 0.
<fs_screen>-active = 1.
ELSE.
RAISE not_found.
ENDIF.
ENDMETHOD. "set_output
*----------------------------------------------------------------------*
* METHOD set_mandatory
*----------------------------------------------------------------------*
* Set the field as mandatory - input value is required
*----------------------------------------------------------------------*
METHOD set_mandatory.
FIELD-SYMBOLS: <fs_screen> TYPE screen.

READ TABLE me->ascreen ASSIGNING <fs_screen>


WITH TABLE KEY name = i_field_name.
IF <fs_screen> IS ASSIGNED.
<fs_screen>-active = 1.
<fs_screen>-input = 1.
<fs_screen>-required = 1.
ELSE.
RAISE not_found.
ENDIF.
ENDMETHOD. "set_mandatory

*----------------------------------------------------------------------*
* METHOD set_as_pass
*----------------------------------------------------------------------*
* Set the field as "password" - stars displayed instead of text
*----------------------------------------------------------------------*
METHOD set_as_pass.
FIELD-SYMBOLS: <fs_screen> TYPE screen.

READ TABLE me->ascreen ASSIGNING <fs_screen>


WITH TABLE KEY name = i_field_name.
IF <fs_screen> IS ASSIGNED.
<fs_screen>-invisible = 1.
ELSE.
RAISE not_found.
ENDIF.
ENDMETHOD. "set_as_pass

*----------------------------------------------------------------------*
* METHOD set_optional
*----------------------------------------------------------------------*
* Set the field as optional - input value is not required
*----------------------------------------------------------------------*
METHOD set_optional.
FIELD-SYMBOLS: <fs_screen> TYPE screen.

READ TABLE me->ascreen ASSIGNING <fs_screen>


WITH TABLE KEY name = i_field_name.
IF <fs_screen> IS ASSIGNED.
<fs_screen>-required = 0.
ELSE.
RAISE not_found.
ENDIF.
ENDMETHOD. "set_optional

*----------------------------------------------------------------------*
* METHOD activate_screen
*----------------------------------------------------------------------*
* Overwrite currently displayed screen with user settings
*----------------------------------------------------------------------*
METHOD activate_screen.
FIELD-SYMBOLS <fs_screen> TYPE screen.

LOOP AT SCREEN.
READ TABLE me->ascreen ASSIGNING <fs_screen>
WITH TABLE KEY name = screen-name.
IF sy-subrc IS INITIAL.
MODIFY SCREEN FROM <fs_screen>.
ENDIF.
ENDLOOP.
ENDMETHOD. "commit_screen

*----------------------------------------------------------------------*
* METHOD restore_default
*----------------------------------------------------------------------*
* Loose user settings and come back to the origins
*----------------------------------------------------------------------*
METHOD restore_default.
me->ascreen = me->dscreen.
ENDMETHOD. "restore_default

ENDCLASS. "lcl_screen_breaker IMPLEMENTATION

You might also like