Comenzaremos viendo como añadir una ayuda de busqyeda en un determinado campo de nuestra pantalla de selección:
* Oper
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_oprtor.
PERFORM help_f4_oper USING
p_oprtor.
* Flot
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_float.
PERFORM help_f4_flot USING
p_float.
Donde el FORM es el siguiente:
*&---------------------------------------------------------------------*
*& Form
HELP_F4_OPER
*&---------------------------------------------------------------------*
*
Muestra una ventana con los posibles valores para el operador
*
dando la posibilidad de seleccionar uno de ellos. Devuelve en el
*
parámetro el valor seleccionado
*----------------------------------------------------------------------*
*
-->P_OPRTOR Oper
seleccionado
*----------------------------------------------------------------------*
FORM help_f4_oper USING
p_oprtor.
* Insertamos en la tabla de campos los
atributos del campo a mostrar
REFRESH: i_fields, i_valores.
CLEAR: i_fields, i_valores.
i_fields-tabname = 'CAWN'.
i_fields-fieldname = 'ATWRT'.
i_fields-selectflag = 'X'.
APPEND i_fields.
CLEAR i_fields.
i_fields-tabname = 'CAWNT'.
i_fields-fieldname = 'ATWTB'.
i_fields-selectflag = 'X'.
APPEND i_fields.
* Seleccionamos los distintos valores
para el campo operador
SELECT atwrt atzhl
INTO CORRESPONDING FIELDS OF
cawn
FROM cawn
WHERE atinn = gv_atinn_o.
SELECT SINGLE atwtb
INTO i_valores-valor
FROM cawnt
WHERE atinn = gv_atinn_o
AND atzhl = cawn-atzhl
AND spras = sy-langu.
APPEND i_valores.
CLEAR i_valores.
i_valores-valor = cawn-atwrt.
APPEND i_valores.
CLEAR i_valores.
ENDSELECT.
CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE'
EXPORTING
fieldname = 'CAWNT'
tabname = 'ATWTB'
IMPORTING
select_value = p_oprtor
TABLES
fields = i_fields
valuetab = i_valores
* EXCEPTIONS
* FIELD_NOT_IN_DDIC = 1
* MORE_THEN_ONE_SELECTFIELD = 2
* NO_SELECTFIELD = 3
*
OTHERS
= 4
ENDFORM. " HELP_F4_OPER
*-- Estructuras para matchcodes
* Tabla interna para almacenar los campos
y atributos a visualizar
DATA BEGIN OF i_fields OCCURS 1.
INCLUDE STRUCTURE
help_value.
DATA END OF i_fields.
* Tabla interna par almacenar el valor
de los campos a mostrar
DATA: BEGIN OF i_valores OCCURS 0,
valor(50) TYPE c,
END OF i_valores.
Si queremos tomar en la ayuda de búsqueda
alguno de los parámetros de la pantalla de selección debemos utilizar la
siguiente función:
DATA DYFIELDS LIKE DYNPREAD
OCCURS 1 WITH HEADER LINE.
CLEAR: DYFIELDS[], DYFIELDS.
DYFIELDS-FIELDNAME = 'P_TPLNR'.
APPEND DYFIELDS.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = SY-CPROG
DYNUMB = SY-DYNNR
* TRANSLATE_TO_UPPER = ' '
* REQUEST = ' '
* PERFORM_CONVERSION_EXITS = ' '
* PERFORM_INPUT_CONVERSION = ' '
* DETERMINE_LOOP_INDEX = ' '
TABLES
DYNPFIELDS = DYFIELDS
* EXCEPTIONS
* INVALID_ABAPWORKAREA = 1
* INVALID_DYNPROFIELD = 2
* INVALID_DYNPRONAME = 3
* INVALID_DYNPRONUMMER = 4
* INVALID_REQUEST = 5
* NO_FIELDDESCRIPTION = 6
* INVALID_PARAMETER = 7
* UNDEFIND_ERROR = 8
* DOUBLE_CONVERSION = 9
* STEPL_NOT_FOUND = 10
*
OTHERS =
11.
READ TABLE DYFIELDS INDEX 1.
Para controlar eventos sobre los
controles:
*-----------------------------------------------------------------------
* AT SELECTION-SCREEN OUTPUT
*-----------------------------------------------------------------------
AT SELECTION-SCREEN OUTPUT.
PERFORM pantalla_seleccion.
*-----------------------------------------------------------------------
* AT SELECTION-SCREEN
*-----------------------------------------------------------------------
AT SELECTION-SCREEN.
PERFORM pantalla_seleccion.
****OPER
IF NOT p_oprtor IS INITIAL.
IF NOT p_mpd IS INITIAL.
CLEAR p_oprtor.
ELSE.
TRANSLATE p_oprtor TO UPPER
CASE.
SELECT SINGLE atwrt INTO
cawn-atwrt
FROM cawn
WHERE atwrt =
p_oprtor
AND atinn =
gv_atinn_oaci.
IF sy-subrc <> 0.
MESSAGE e246 WITH
p_oprtor.
ENDIF.
ENDIF.
ELSEIF NOT p_mp IS INITIAL.
MESSAGE E001(ZIMPD) WITH
'Operador'.
ENDIF.
****FLOT
IF NOT p_flot IS INITIAL.
TRANSLATE p_floats TO UPPER
CASE.
SELECT SINGLE atwrt INTO
cawn-atwrt
FROM cawn
WHERE atwrt = p_flot
AND atinn =
gv_atinn_cgrup_flot.
IF sy-subrc <> 0.
MESSAGE e174.
ENDIF.
ENDIF.
Donde el Form:
*&---------------------------------------------------------------------*
*& Form pantalla_seleccion
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
form pantalla_seleccion .
IF NOT p_mpd IS INITIAL.
clear p_oprtor.
IF SCREEN-NAME = 'P_OPRTOR'.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSEIF NOT p_mp is initial.
IF p_oprtor IS INITIAL.
p_oprtor = gc_oper_ibe.
ENDIF.
IF SCREEN-NAME = 'P_OPRTOR'.
SCREEN-INPUT = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
endform. " pantalla_seleccion
Como siempre, cualquier comentario, sugerencia o duda hacermela llegar.
No hay comentarios:
Publicar un comentario