Entering content frame

Setting Attributes Dynamically Locate the document in its SAP Library structure

Each field on a screen has a set of attributes that are fixed when you define the screen in the Screen Painter. During runtime of the ABAP program, a part of the attributes of every screen field can be read to a predefined structure screen using specific statements. These attributes can then modify the screen fields.

Structure ‘screen’

You do not have to declare this structure in your program. You can access screen during screen processing in dialog modules.

Component

Length

Type

Meaning

Attribute

surname

132

C

Name of the screen field

Name

group1

3

C

Modification group 1

Group 1

group2

3

C

Modification group 2

Group2

group3

3

C

Modification group 3

Group3

group4

3

C

Modification group 4

Group4

required

1

C

Field input is mandatory

Mandatory field

input

1

C

Field is ready for input

Entry

output

1

C

Field is for display only

The output is as follows:

intensified

1

C

Field is highlighted

Highlighted

invisible

1

C

Field is suppressed

Invisible

length

1

X

Field length

VisLg

active

1

C

Field is active

Input/Output/Invisible

display_3d

1

C

Three-dimensional box

Two-dimensional

value_help

1

C

Input help button display

Input helps

request

1

C

Input exists

-

The final column contains the corresponding attributes of the screen fields in the Screen Painter.

You can modify the structure screen in your ABAP program during the PBO event of a screen, to modify screen elements in the ABAP program. The modified elements override the static attributes of the screen fields for exactly a single screen call. The only allowed statements that you can use with screen are:

LOOP AT SCREEN.
...
  MODIFY SCREEN.

...
ENDLOOP.

LOOP AT SCREEN is an own statement, which is not to be confused with a loop over an internal table.

The component NAME contains the name of the screen field. The components GROUP1 to GROUP4 can contain any three-character code. These codes allow you to include screen fields in up to four modification groups. A screen field can belong to different modification groups. Modification groups are like an extra key field for the structure screen that allow you to change the attributes of all of the elements in a group simultaneously. You assign elements to modification groups statically in the Screen Painter, although you can overwrite them dynamically in a program.

The remaining components are for reading and activating or deactivating the display attributes of screen fields. For all components other than LENGTH, 1 means active and 0 means inactive.

ACTIVE, INPUT, OUTPUT, and INVISIBLE

There are certain hierarchy rules between the components ACTIVE, INPUT, OUTPUT, and INVISIBLE. They also have different effects depending on their respective static settings.

The ACTIVE component has no equivalent in the element attributes. Instead, it changes the components INPUT, OUTPUT, and INVISIBLE.

At the beginning of the PBO, ACTIVE is always set to 1, regardless of the static attribute settings. Setting ACTIVE to 0 automatically sets INPUT = 0, OUTPUT = 0, and INVISIBLE = 1. Any other changes to the settings of INPUT; OUTPUT, and INVISIBLE to the current screen element are ignored. Conversely, setting INPUT = 0, OUTPUT = 0, and INVISIBLE = 1 automatically sets ACTIVE to 0, and any further assignment to ACTIVE for the current screen element will be ignored. The setting ACTIVE = 1 has no other effect on the attributes. The only purpose of the ACTIVE component is to allow you to make a screen field inactive through a single assignment. You should particularly note that a module call linked to a FIELD statement in the screen flow logic is always executed, even when SCREEN-ACTIVE = 0 for the field in question. If you want to prevent a module from being processed for an inactive field, you must specify the FIELD- and MODULE statements separately.

There are eight possible combinations of ACTIVE, INPUT, OUTPUT, and INVISIBLE, that have the following effect on screen fields:

ACTIVE

INPUT

OUTPUT

INVISIBLE

Effect

1

1

1

0

Screen field is displayed, even if Invisible is set statically.

Field contents are displayed.

Ready for input, even if Input is not set statically. However, not ready for input if the Output only is set statically.

1

1

0

0

Screen field is displayed, even if Invisible is set statically, except when Output only is set statically.

Field contents are not displayed.

Ready for input, even if Input is not set statically.

1

0

1

0

Screen field is displayed, even if Invisible is set statically.

Field contents are displayed.

Not ready for input, even if Input is set statically.

1

0

0

0

Screen field is displayed, even if Invisible is set statically, except when Output only is set statically.

Field contents are not displayed.

Not ready for input, even if Input is set statically.

1

1

1

1

Screen field is displayed, even if Invisible is set statically, except when Output only is set statically.

Field contents are not displayed.

Ready for input, even if Input is not set statically. User input is masked by asterisks (*).

1

1

0

1

Screen field is displayed, even if Invisible is set statically, except when Output only is set statically.

Output is masked by asterisks (*).

Ready for input, even if Input is not set statically. User input is masked by asterisks (*).

1

0

1

1

Screen field inactive.

Screen field is not displayed, regardless of the static attributes.

0

0

0

1

Screen field inactive.

Screen field is not displayed, regardless of the static attributes.

If a field is statically-defined as Output only, setting INPUT = 1 has no effect. INPUT is always 0 for these fields. Masking user input by asterisks (*) can be used for entering user passwords.

If a whole line becomes invisible when you make fields invisible, the screen is automatically made smaller. You can, however, switch off this attribute in the static screen attributes by selecting Switch off runtime compression.

REQUIRED

When you set REQUIRED = 1, a field that is ready for input is made mandatory. Users can only leave the screen when all mandatory fields contain an entry. Function codes with type E and modules with the AT EXIT-COMMANDaddition.

DISPLAY_3D

When you set DISPLAY_3D = 0, the three-dimensional frame for input/output fields is removed. You cannot use DISPLAY_3D = 1 to create a three-dimensional effect for text fields or screen fields with the Output only attribute.

VALUE_HELP

Setting VALUE_HELP to 0 or 1 switches the input help button off and on respectively.

INTENSIFIED

If you set INTENSIFIED = 1, the field contents of input fields are changed from black to red. The contents of output fields are changed from black to blue.

LENGTH

You can set the LENGTH component to a value shorter than the statically-defined output length (vislength) for input/output fields and Output only fields. This allows you to shorten their output length. You cannot shorten other screen elements, or lengthen any screen elements.

REQUEST

Setting REQUEST = 1 for a field that is ready for input has the same effect in the PAI event as if the user had changed the field contents. This means that a conditional module call using ON REQUEST or ON CHAIN-REQUEST would be executed regardless of whether the user really changed the field. REQUEST is automatically reset to 0.

Example

This example shows the basic form of a screen modification. An illustration of all possible modifications shows the program DEMO_DYNPRO_MODIFY_SCREEN.

Example

Dynamic screen modifications.

REPORT demo_dynpro_modify_simple.

DATA: ok_code TYPE sy-ucomm,
      save_ok TYPE sy-ucomm.

DATA flag(1) TYPE c.

CALL SCREEN 100.

MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SCREEN_100'.
  LOOP AT SCREEN.
    IF screen-group1 = 'MOD'.
      IF flag = ' '.
        screen-input = '0'.
      ELSEIF flag = 'X'.
        screen-input = '1'.
      ENDIF.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.
ENDMODULE.

MODULE cancel.
  LEAVE PROGRAM.
ENDMODULE.

MODULE user_command_0100 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'TOGGLE'.
      IF flag = ' '.
        flag = 'X'.
      
ELSEIF flag = 'X'.
        flag = ' '.
      ENDIF.
  ENDCASE.
ENDMODULE.

The next screen (statically defined) for screen 100 is itself, and it has the following layout:

This graphic is explained in the accompanying text

The input/output fields have been accepted by the structure DEMO_CONN of the ABAP dictionary. The four input/output fields at the bottom are assigned to the modification group MOD.

The screen flow logic is as follows:

PROCESS BEFORE OUTPUT.
  
MODULE status_0100.

PROCESS AFTER INPUT.
  MODULE cancel AT EXIT-COMMAND.
  
MODULE user_command_0100.

In the GUI status SCREEN_100, the function code TOGGLE is linked with a pushbutton.

When calling the program, the four input/output fields at the bottom are not displayed as ready-for-input, because the variable flag initially contains a blank. The user can switch on/off the ready-for-input status using TOGGLE.

 

 

Leaving content frame