Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

screen looping

Former Member
0 Kudos
219

Hi all,

I want to know the various methods of using loop at screen. And in which case i should use it.

I am eager for the answers.

Plz experts help me out.

With regards,

Abir.

1 ACCEPTED SOLUTION

LucianoBentiveg
Active Contributor
0 Kudos
153

When you need to modify screen's elements attributes at runtime.

Regards.

11 REPLIES 11

LucianoBentiveg
Active Contributor
0 Kudos
154

When you need to modify screen's elements attributes at runtime.

Regards.

former_member181962
Active Contributor
0 Kudos
153

Loop at screen is generally used for dynamic screen modification.

There is only one way to loop at a screen and it is as simple as looping an internal table.

for eg:

loop at screen.

if screen-group1 = 'TEST'.

screen-invisible = 1.

modify screen.

ENDIF.

endloop.

rEGARDS,

Ravi

Former Member
0 Kudos
153

YOU CAN USE THE FOLLOWING.

LOOP AT SCREEN.

IF SCREEN-GROUP1 = 'G1'.

SCREEN-INVISIBLE = 0.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

Former Member
0 Kudos
153

Hi,

you can use the group-name for some screen elemnts, and can check

loop at screen.

if screen-group1 = 'g1'.

screen-input = 0.

endif.

modify screen.

endloop.

suresh_datti
Active Contributor
0 Kudos
153

It depends on what you want to accomplish.. you loop at screen for changing the screen field attributes ( like visible/invisible, display only / input etc ) either on the selection screen of a report or on the screen of a dialog program.

Regards,

Suresh Datti

Former Member
0 Kudos
153

LOOP AT SCREEN.

IF screen-name = 'PTH_PC'.

screen-input = '0'.

screen-output = '0'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

LOOP AT SCREEN.

IF screen-name = 'PTH_SER'.

screen-input = '0'.

screen-output = '1'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

This is One way to enable / disable screen fields using Loop at screen.

Rgds,

Mano Sri

Former Member
0 Kudos
153

There is only method of using loop at screen.

LOOP AT SCREEN.

< some logic >.

MODIFY SCREEN.

ENDLOOP.

You cannot specify where condition. neither can you use READ SCREEN.

Message was edited by: Sharath kumar R

former_member181962
Active Contributor
0 Kudos
153

This is what the sap documentation says:

<i><b>LOOP AT SCREEN

Syntax

LOOP AT SCREEN [INTO wa].

...

ENDLOOP.

Effect

The statements LOOP AT SCREEN ... ENDLOOP define a loop around a statement block. For every screen element of the current dynpro, to which a dynpro field is assigned, one loop pass is executed. After the LOOP statement either the predefined workarea screen or the workarea wa (when using INTO) contains the properties of the respective screen element. wa must have the same data type as screen.

While processing a table control or a step loop (that is, within a LOOP loop of the dynpro flow logic), for its screen elements the current properties are determined in the current row or group. Outside of the processing of a table control or step loop, for its screen elements the statically predefined properties of all rows or groups are determined.

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

Component Length Type Attribute Description

name 132 c Name Name

group1 3 c Group1 Modification group

group2 3 c Group2 Modification group

group3 3 c Group3 Modification group

group4 3 c Group4 Modification group

required 1 c Required-entry field Mandatory field

input 1 c Input input-enabled field

output 1 c Output display field

intensified 1 c Intensified intensified field

invisible 1 c Invisible invisible element

length 1 x visLength Field length

active 1 c Input/Output/Invisible active field

display_3d 1 c Two-dimensional Box

value_help 1 c Input help Input help key

request 1 c - Input exists

values_in_combo 1 c Dropdown listbox Value help exists

The component name in the loop contains the name of the current dynpro field. The components group1 to group4 can contain three-character IDs, which were assigned to the current screen element in its definition. These IDs allow you to combine the screen elements in up to four different modification groups. In the statement block after LOOP AT SCREEN, these can be queried in logical expressions in order to process several elements in the same way.

The other components of table screen represent the display properties of the current screen element. With the exception of length, they can contain 0 or 1, where 1 is "active" and 0 is "inactive".

Except active, all components of structure screen directly correspond to one attribute of the current screen element. The component active has no match in the attributes. If you change its content with MODIFY SCREEN, this affects the attributes Input, Output and Invisible and thus the components input, output and invisible of structure screen.

Notes

As of release 6.20, structure screen is described by data type SCREEN in the ABAP Dictionary. With release 6.10, it was determined by type syscr_screen of type group SYSCR. Before release 6.10, it was created system-internally with a bound data type.

The statement LOOP AT SCREEN behaves similarly to the statement LOOP in a loop on an internal table with header line, where instead of an internal table a system table is used.</b></i>

rahulkavuri
Active Contributor
0 Kudos
153

Whenever u want to display or change, disable some fields in the screen based on the radio button selected u can use Screen Looping... we use it when when we want to make some fields visible or make some fields active then too we use screen looping...

For example check this code

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS : P_FILE(25) TYPE C,
             O_FILE(25) TYPE C.

SELECTION-SCREEN END OF BLOCK B1.

*Selection Screen 2

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.

PARAMETERS: CAL_TRA RADIOBUTTON GROUP G1 USER-COMMAND FLAG,
            SESSION RADIOBUTTON GROUP G1 DEFAULT 'X'.

SELECTION-SCREEN END OF BLOCK B2.

*Selection Screen 3

SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.

PARAMETERS: MODE DEFAULT 'X' MODIF ID BL1,
            UPDATE DEFAULT 'X' MODIF ID BL1.

SELECTION-SCREEN END OF BLOCK B3.

*Selection Screen 4

SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-003.


PARAMETERS: SES_NAM TYPE APQI-GROUPID MODIF ID BL2,
            KEP_TRAS TYPE C DEFAULT 'X' MODIF ID BL2,
            LOC_DATE TYPE SY-DATUM MODIF ID BL2,
            USER TYPE SY-UNAME DEFAULT SY-UNAME MODIF ID BL2.

SELECTION-SCREEN END OF BLOCK B4.

************************************************************************
*                     At  Selection-Screen Output                      *
************************************************************************

AT SELECTION-SCREEN OUTPUT.


  IF CAL_TRA = 'X'.
    LOOP AT SCREEN.

      IF SCREEN-GROUP1 = 'BL1'.
        SCREEN-ACTIVE = '1'.
      ENDIF.

      IF SCREEN-GROUP1 = 'BL2'.
        SCREEN-ACTIVE = '0'.
      ENDIF.
      MODIFY SCREEN.
    ENDLOOP.
  ENDIF.

  IF SESSION = 'X'.

    LOOP AT SCREEN.
      IF SCREEN-GROUP1 = 'BL1'.
        SCREEN-ACTIVE = '0'.
      ENDIF.

      IF SCREEN-GROUP1 = 'BL2'.
        SCREEN-ACTIVE = '1'.
      ENDIF.

      MODIFY SCREEN.

    ENDLOOP.
  ENDIF.

we use this whenever we want to default one or both of the select field options

Check the code below

************************************************************************
*                       Selection-Screen                               *
************************************************************************

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS: S_VBELN FOR VBRK-VBELN,
                S_FKDAT FOR VBRK-FKDAT,
                S_MATNR FOR VBRP-MATNR.

SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.

PARAMETERS : LIST RADIOBUTTON GROUP G1,
             GRID  RADIOBUTTON GROUP G1 DEFAULT 'X'.


SELECTION-SCREEN END OF BLOCK B2.

************************************************************************
*****************            INITIALIZATION         ********************
************************************************************************

INITIALIZATION.

  STR_DATE = SY-DATUM - 200.
  S_FKDAT-LOW = STR_DATE.
  S_FKDAT-HIGH = SY-DATUM.
  S_FKDAT-SIGN = 'I'.
  APPEND S_FKDAT.

<b>Please award points if found helpful</b>

Former Member
0 Kudos
153

Loop at screen is used to modify the screen attributes at run time

chk out the table SCREEN for the attributes

former_member188685
Active Contributor
0 Kudos
153

Hi,

check this sample code...

REPORT  ZTEST_CHECK                             .


parameters: p_sale radiobutton group g1 user-command ABC default 'X',
            p_mate radiobutton group g1 .


parameters: p_vbeln like vbak-vbeln,
            p_matnr like mara-matnr.



at selection-screen output.

if p_sale = 'X'.

loop at screen.
if screen-name = 'P_MATNR'.
screen-input = 0.
endif.
modify screen.
endloop.
endif.
if p_mate = 'X'.
loop at screen.
if screen-name = 'P_VBELN'.
screen-input = 0.
endif.
modify screen.
endloop.
endif.

Regards

vijay