Você está na página 1de 6

LOOP EN CAMPOS DE PANTALLA...............................................................................

1
HACER OBLIGATORIOS O NO CAMPOS SEGÚN GRUPOS…..................................2
AYUDA DE SAP:...............................................................................................................3
MODIFY - Change the attributes of a screen field.............................................................5

LOOP EN CAMPOS DE PANTALLA

Instrucción: LOOP AT SCREEN.

* Abrimos / Cerramos el campo Material / HU segun datos


loop at screen.
case screen-group1.
* when 'MARA-MATNR'. "Material
* check mara-matnr is initial .
* screen-input = '1'. " abrir el campo para input
when '2'. " U.A.
* Se trata de Expobandejas?
check not inp_100 is initial.
* 1.- determianr si mat es expoBandeja
* consultar maestro de mat
select single meinh into marm-meinh from marm
where matnr = mara-matnr " mat dynpro
and meinh = 'EXB'. " UMalt = EXpoBandejas

if sy-subrc = 0.
screen-invisible = '0'.
screen-active = '1'.
if screen-name = 'INP_102'.
screen-input = '1'.
endif.
endif.
* screen-input = '0'. " cerrar campo para input
* when others. " para resto de campos cerrados si material initial
* if mara-matnr is initial.
* if screen-group1 <> '1'. " Botones son del grupo1 = 1
** solo cerrar campos <> pulsadores (F1,F2,...
* screen-input = 0.
* endif.
* endif.
endcase.
modify screen.
endloop.
HACER OBLIGATORIOS O NO CAMPOS SEGÚN GRUPOS…
PROCESS BEFORE OUTPUT.
MODULE STATUS_9000.
* Forzar campos obligatorios en función del grupo de cuentas del deudor
MODULE SET_OBLIGATORIOS.

PROCESS AFTER INPUT.


MODULE USER_COMMAND_9000.

it_zsd013 contiene el campo que define si un grupo es obligatorio o no y el grupo

*&---------------------------------------------------------------------*
*& Module SET_OBLIGATORIOS OUTPUT
*&---------------------------------------------------------------------*
* Forzar campos obligatorios en función del grupo de cuentas del deudor
*----------------------------------------------------------------------*
module SET_OBLIGATORIOS output.

DATA: it_zsd013 TYPE STANDARD TABLE OF ZSD013,


wa_zsd013 TYPE ZSD013.

SELECT *
INTO TABLE it_zsd013
FROM ZSD013.
IF sy-subrc <> 0.
ENDIF.

LOOP AT SCREEN.
* Para los campos que dependen del grupo de cuentas del deudor
CHECK SCREEN-GROUP1 IS NOT INITIAL.

READ TABLE it_ZSD013


INTO wa_zsd013
WITH KEY GRUPO = SCREEN-GROUP1.
IF sy-subrc = 0.
IF KNA1-KTOKD = wa_zsd013-KTOKD.
SCREEN-REQUIRED = '1'.
MODIFY SCREEN.
CONTINUE.
ENDIF.
ENDIF.
ENDLOOP.

endmodule. " SET_OBLIGATORIOS OUTPUT


AYUDA DE SAP:

LOOP - Loop on screen fields

Basic form
LOOP AT SCREEN.

Effect

All fields of the current screen are stored in the system table SCREEN with their attributes.
The LOOP AT SCREEN statement places this information in the header line of the system table.
If you want to change the attributes, you must put back the changed header line with MODIFY
SCREEN. However, you can only do this in the PBO module of a screen.
If you use this statement for step loop processing, the information (and any changes) apply only to
the current steploop line. Outside step loop processing, the information for a step loop field applies
to the complete column.
You can also modify fields in the loop processing of a table control using this loop statement. Unlike
a step loop, modifications before the loop have no effect, since the system gets the initial values for
the columns from the column table of the table view.
Step loop fields should never be changed after the corresponding step loop processing has been
performed.
You can use the CONTINUE statement to leave the current loop pass prematurely and continue with
the next loop pass.

Related

MODIFY SCREEN, LOOP AT itab

Additional help

Setting Attributes Dynamically

Additional help

Setting Attributes Dynamically

System Table SCREEN

The system table SCREEN contains information about the fields contained on the current screen.
You can read them using the LOOP AT SCREEN statement, and change them using MODIFY
SCREEN.

Overview of all SCREEN fields:


Field Length Type Meaning

SCREEN-NAME 30 C Field name


SCREEN-GROUP1 3 C Analysis of
Modif group 1
SCREEN-GROUP2 3 C Analysis of
Modif group 2
SCREEN-GROUP3 3 C Analysis of
Modif group 3
SCREEN-GROUP4 3 C Analysis of
Modif group 4
SCREEN-REQUIRED 1 C Required field
SCREEN-INPUT 1 C Field ready for input
SCREEN-OUTPUT 1 C Displayed field
SCREEN-INTENSIFIED 1 C Field intensified
SCREEN-INVISIBLE 1 C Field invisible
SCREEN-LENGTH 1 X Field length
SCREEN-ACTIVE 1 C Field active
MODIFY - Change the attributes of a screen field

Basic form
MODIFY SCREEN.

Effect

Changes the attributes belonging to the current screen field whilst processing with LOOP AT
SCREEN ... ENDLOOP.

The attributes of all fields of a screen are stored in the system table SCREEN. This can be edited line
by line using LOOP AT SCREEN ... ENDLOOP. Changes to the properties of the attributes of the
current screen field (= current line in the system table SCREEN) can be put into effect using MODIFY
SCREEN.

Assigning a Modication Group on the Selection


Screen

Addition

... MODIF ID modid

Effect

This addition assigns screen objects ( Comment, Underscore line, Parameter, ...) to a
modification group and hence allows dynamic modification of the selction screen display.

The modification group name modid must be specified directly and must be no longer than 3
characters. The addition MODIF ID assigns modid to the column SCREEN-GROUP1 of the
predefined internal table SCREEN. Parameters assigned to a modification group can be changed
together using the LOOP AT SCREEN and MODIFY SCREEN statements at the event AT
SELECTION SCREEN OUTPUT or in the subroutine PBO of the database program of the assigned
logical database.

You can use this addition with:

- SELECTION-SCREEN COMMENT
- SELECTION-SCREEN ULINE
- SELECTION-SCREEN PUSHBUTTON
- PARAMETERS
- SELECT-OPTIONS

In each case all relevant screen objects are assigned to the modification group.
Without the MODIF ID addition, the SCREEN-GROUP1 component is empty. The remaining three
fields for modification groups in the SCREEN table are populated by the runtime environmentand can
be analyzed:

 GROUP2 contains the value "DBS" for elements that are defined in a logical database.

 GROUP3 contains the following values depending on the screen element:

BLK for SELECTION-SCREEN ... BLOCK ...: Block


COF for SELECTION-SCREEN COMMENT ... FOR FIELD ...: Field-related comment
COM for SELECTION-SCREEN COMMENT: Comment
HGH for SELECTION-OPTIONS: Interval upper limit
ISX for PARAMETERS ... AS SEARCH PATTERN: Komplex selection
LOW for SELECTION-OPTIONS: Interval lower limit
OPU for SELECTION-OPTIONS: Selection option icons
PAR for PARAMETERS: Parameters
PBU for SELECTION-SCREEN PUSHBUTTON ...: Pushbutton
TAB for SELECTION-SCREEN TAB: Tab title
TOT for SELECTION-OPTIONS: Text of interval upper limit
TST for SELECTION-SCREEN ... TABBED ...: Tabstrip
TXT for PARAMETERS, SELECT-OPTIONS: Selection text
ULI for SELECTION-SCREEN ULINE: Horizontal Line
VPU for SELECT-OPTIONS: Pushbutton for multiple selection

 GROUP4 is intended solely for internal use.

Example

DATA SAPLANE_WA TYPE SAPLANE.


...
SELECTION-SCREEN COMMENT /1(60) TEXT-010.
...
SELECT-OPTIONS S_PTYPE FOR SAPLANE_WA-PLANETYPE MODIF ID ABC.
...
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'ABC' OR
SCREEN-GROUP3 = 'COM'.
SCREEN-INTENSIFIED = '1'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.

All screen objects (text, input fields, pushbuttons) belonging to the selection option S_PTYPE as well
as all comments defined with SELECTION-SCREEN COMMENT are set to the output format
INTENSIFIED.

Você também pode gostar