*&---------------------------------------------------------------------*
*& Report ZPRUEBA
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
*& Report ZPRUEBA
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zprueba.
DATA: l_bloqueo TYPE c,
l_mantener TYPE c.
* Estructura para MATCHCODE
TYPES: BEGIN OF gty_match,
shlpname LIKE ddshretval-shlpname,
fieldname LIKE ddshretval-fieldname,
recordpos LIKE ddshretval-recordpos,
fieldval LIKE ddshretval-fieldval,
retfield LIKE ddshretval-retfield,
END OF gty_match.
* Estructura para Valores MATCHCODE
TYPES: BEGIN OF lty_guia,
nguia TYPE zmme_nrguia,
END OF lty_guia,
* Estructura para datos internos a llenar según lo que escoga en
* MATCHCODE
* El campo EBELN decidirá si mi segundo bloque de campos se habilitará
* o no
BEGIN OF lty_data,
nguia TYPE zmme_nrguia,
stcd1 TYPE stcd1,
placa TYPE c LENGTH 7,
ebeln TYPE ebeln,
END OF lty_data.
DATA: ltd_guia TYPE STANDARD TABLE OF lty_guia,
ltd_data TYPE STANDARD TABLE OF lty_data,
lwa_data TYPE lty_data.
DATA gtd_match TYPE TABLE OF gty_match.
* Tabla para actualizar valores DYNPRO
DATA: lf_hierid TYPE wrf_hier_cnt,
lt_dynpfields TYPE TABLE OF dynpread WITH HEADER LINE.
*BLOQUE 1
SELECTION-SCREEN BEGIN OF BLOCK b02 WITH FRAME TITLE TEXT-b02.
PARAMETERS: p_nguia TYPE zmmt_guia-nguia,
p_stcd1 TYPE zmmt_guia-stcd1 MODIF ID nd,
p_placa TYPE zmmt_guia-placa MODIF ID nd.
SELECTION-SCREEN END OF BLOCK b02.
*BLOQUE 2
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE TEXT-b02.
PARAMETERS: p_ebeln TYPE ebeln MODIF ID b1,
p_usnam TYPE usnam MODIF ID b1,
p_femod TYPE datum MODIF ID b1.
SELECTION-SCREEN END OF BLOCK b01.
*PBO
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
*L_BLOQUEO DOBLE FUNCION: SI ENCONTRO DATOS
IF l_bloqueo IS INITIAL.
IF screen-group1 EQ 'B1'.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDIF.
IF l_mantener IS NOT INITIAL.
IF screen-group1 EQ 'ND'.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDLOOP.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_nguia.
REFRESH: gtd_match.
SELECT nguia
INTO TABLE ltd_guia
FROM zmmt_guia
WHERE bukrs EQ 1000
AND pguia EQ 002.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'NGUIA'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_NGUIA'
window_title = 'Guia'
value_org = 'S'
TABLES
value_tab = ltd_guia
return_tab = gtd_match.
READ TABLE gtd_match ASSIGNING FIELD-SYMBOL(<g_match>) INDEX 1.
IF sy-subrc EQ 0.
p_nguia = <g_match>-fieldval.
*VARIABLE QUE MANTENDRA CAMPOS PRIMER BLOQUE NO EDITABLE
*AL HABER ENCONTRADO DATA
l_mantener = abap_true.
SELECT SINGLE nguia stcd1 placa ebeln
INTO lwa_data
FROM zmmt_guia
WHERE bukrs EQ 1000
AND pguia EQ 002
AND nguia EQ p_nguia.
IF sy-subrc IS INITIAL.
*SE PROCEDE A LLENAR EL RESTO DE CAMPOS DEL BLOQUE 1 PARA
*LLENARLO CON LOS VALORES ENCONTRADOS
lt_dynpfields-fieldname = 'P_STCD1'.
lt_dynpfields-fieldvalue = lwa_data-stcd1.
APPEND lt_dynpfields.
lt_dynpfields-fieldname = 'P_PLACA'.
lt_dynpfields-fieldvalue = lwa_data-placa.
APPEND lt_dynpfields.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = lt_dynpfields
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
undefind_error = 7
OTHERS = 8.
LOOP AT SCREEN.
IF screen-group1 EQ 'ND'.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
*EBELN FUNCIONARA COMO DISPARADOR DE ENCONTRAR LLENO
*ACTIVARA LOS DATOS DEL SEGUNDO BLOQUE
IF lwa_data-ebeln IS NOT INITIAL.
*FLAG PERMITIRA MANTENER DESBLOQUEADO SI ENCONTRO DATO EN EBEL,
*FALTA CASO CONTRARIO EN CASO NO ENCUENTRE.
l_bloqueo = abap_true.
LOOP AT SCREEN.
IF screen-group1 EQ 'B1'.
screen-input = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
lt_dynpfields-fieldname = 'P_EBELN'.
lt_dynpfields-fieldvalue = lwa_data-ebeln.
APPEND lt_dynpfields.
*SE AÑADE EL RESTO DE CAMPOS DEL BLOQUE 2 PARA QUE EN UNA SEGUNDA PASADA
*SE REFRESQUEN
lt_dynpfields-fieldname = 'P_USNAM'.
lt_dynpfields-fieldvalue = space.
APPEND lt_dynpfields.
lt_dynpfields-fieldname = 'P_FEMOD'.
lt_dynpfields-fieldvalue = space.
APPEND lt_dynpfields.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = lt_dynpfields
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
undefind_error = 7
OTHERS = 8.
ELSE.
CLEAR l_bloqueo.
LOOP AT SCREEN.
IF screen-group1 EQ 'B1'.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
lt_dynpfields-fieldname = 'P_EBELN'.
lt_dynpfields-fieldvalue = SPACE.
APPEND lt_dynpfields.
lt_dynpfields-fieldname = 'P_USNAM'.
lt_dynpfields-fieldvalue = space.
APPEND lt_dynpfields.
lt_dynpfields-fieldname = 'P_FEMOD'.
lt_dynpfields-fieldvalue = space.
APPEND lt_dynpfields.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = lt_dynpfields
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
undefind_error = 7
OTHERS = 8.
ENDIF.
ENDIF.
ENDIF.
No hay comentarios.:
Publicar un comentario