Archive for the 'Dialog' Category

SAP: Selection-Screen as subscreen in dialog programming

There would be a time that you will have a certain selection-screen that is being used in more than one dynpro in your program. Instead of coding it for each dynpro, you could just create a subscreen on every dynpro and call the same selection-screen. In this way, you only have one code block for your selection-screen but able to display it on any dynpro you want within your program.

To do this, first create a subscreen area through the screen painter. As an example, let’s name this subscreen area as SUB_1. Now let say we want to call the selection-screen below into our subscreen area SUB_101.

  SELECTION-SCREEN BEGIN OF SCREEN 101 AS SUBSCREEN.
    SELECT-OPTIONS: p_comp FOR bseg-bukrs OBLIGATORY,
    p_cust FOR kna1-kunnr.
  SELECTION-SCREEN END OF SCREEN 101.

When calling a subscreen, we must call it in both the PBO and PAI sections of the flow logic of our main screen. The CALL SUBSCREEN statement tells the system to execute the PBO and PAI processing blocks for the subscreen as components of the PBO and PAI of the main screen. Please Refer to the code below.

  PROCESS BEFORE OUTPUT.
    MODULE STATUS_100.
    CALL SUBSCREEN SUB_101 INCLUDING sy-repid ‘101′.

  PROCESS AFTER INPUT.
    CALL SUBSCREEN SUB_1.
    MODULE USER_COMMAND_100.

SAP: Setting Attributes of Screen Objects Dynamically

In visual basic, you could easily change any property of a specific control dynamically. We could also do that in ABAP. The sample code below will show you the basics on how to loop on all objects in a screen and change its property at runtime.

Let say we have a set of textbox in our screen that contains details of a single customer from table KNA1(General Data in Customer Master). Now we want to disable all textboxes that has already a value on it so that empty textboxes are the only editable field in the screen. To do this, we need to create a code on PBO(Process Before Output) module that will loop on all objects in the screen.

But before we proceed with the coding, we have to specify a MODIF ID or Modification Group ID. This will enable us to modify object before the selection screen is displayed, using the statement MODIFY SCREEN. The name of the modification group ID must be directly specified and can have a maximum length of three characters. There are two ways to set the mod ID of an object.

One is through code:

PARAMETERS: p_sample TYPE c LENGTH 10 MODIF ID GR1.

In this sample code, we set the mod ID of p_sample to “GR1″

Another way is through screen painter:

On the screen painter, select a specific object on the screen and then go to its attributes(double click or press F2). A window will appear showing the attributes of the object. You will see 4 textboxes in a row which is indicated as Groups. Type-in GR1 in the first textbox. Close the attributes window and click save.

We could now create the codes that will loop on all objects in a screen. In our case, we only want to loop on all textboxes in a screen so set the mod ID of all textboxes to GR1.

FIELD-SYMBOLS : <FS> TYPE ANY.

LOOP AT SCREEN.
  IF SCREEN-GROUP1 = ‘GR1′.
    ASSIGN (SCREEN-NAME) TO <FS>.
    IF <FS> IS NOT INITIAL.
      SCREEN-INPUT    = ‘0′.
    ENDIF.
  ENDIF.
  MODIFY SCREEN.
ENDLOOP.

Using the code above, one loop pass is executed for every screen element of the current dynpro. SCREEN-NAME is the name of the element, SCREEN-GROUP1 refers to the modification group of the element, and SCREEN-INPUT is the input property of the element. MODIFY SCREEN affects the attributes input, output and invisible.

The table below shows the components of screen and their assignment to the field properties in the dynpro.

Component

Length

Type

Meaning

Attribute

name

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

-