Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

1.

- CÓDIGO MODULARIZADO
*&---------------------------------------------------------------------*
*& Report ZREGISTRO
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZREGISTRO.

INCLUDE zregistro_top. "INCLUDE para variables globales


INCLUDE zregistro_sel. "INCLUDE para pantallas de selección
INCLUDE zregistro_iniciar_f01. "INCLUDE contiene subrutina PERFORM

INITIALIZATION.
PERFORM iniciar_variable. "PERFORM, include zregistro_iniciar_f01

START-OF-SELECTION.
PERFORM OBTENER_DATOS. "PERFORM, include zregistro_iniciar_f01

2.- CONTENIDO INCLUDE ZREGISTRO_TOP (Creado para


declaración de variables)

*&---------------------------------------------------------------------*
*& Include ZREGISTRO_TOP
*&---------------------------------------------------------------------*

data gwa_registro TYPE zregistro.


3.- CONTENIDO INCLUDE ZREGISTRO_SEL (Creado para
Pantallas de Selección)

*&---------------------------------------------------------------------*
*& Include ZREGISTRO_SEL
*&---------------------------------------------------------------------*

SELECTION-SCREEN begin of block block1 WITH FRAME TITLE text-b01.


SELECTION-SCREEN SKIP.

SELECTION-SCREEN begin of block block2 WITH FRAME TITLE text-b02.


SELECTION-SCREEN SKIP.

PARAMETERS: p_create RADIOBUTTON GROUP crud,


p_read RADIOBUTTON GROUP crud,
p_modi RADIOBUTTON GROUP crud,
p_dele RADIOBUTTON GROUP crud.

SELECTION-SCREEN end OF BLOCK block2.

SELECTION-SCREEN begin of block block3 WITH FRAME TITLE text-b03.


SELECTION-SCREEN SKIP.

PARAMETERS: p_name TYPE c LENGTH 20,


p_last TYPE c LENGTH 20,
p_rut TYPE c LENGTH 20,
p_fecha type sydatum.

SELECTION-SCREEN end OF BLOCK block3.

SELECTION-SCREEN SKIP.
SELECTION-SCREEN end OF BLOCK block1.
4.- CONTENIDO INCLUDE ZREGISTRO_INICIAR_F01 (Contiene
Subrutinas PERFORM)

*----------------------------------------------------------------------*
***INCLUDE ZREGISTRO_INICIAR_F01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form INICIAR_VARIABLE
*&---------------------------------------------------------------------*

FORM INICIAR_VARIABLE.

p_fecha = sy-datum.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form OBTENER DATOS
*&---------------------------------------------------------------------*

FORM OBTENER_DATOS.

if p_read eq abap_true or
p_modi eq abap_true or
p_dele eq abap_true.

select single * from zregistro


into gwa_registro
where p_rut eq p_rut.

endif.

*CREAR
case abap_true.
when p_create.
gwa_registro-p_rut = p_rut.
gwa_registro-p_last = p_last.
gwa_registro-p_name = p_name.

insert zregistro from gwa_registro.

if sy-subrc eq 0.
MESSAGE i003(ZMM1).
else.
MESSAGE i004(ZMM1).
endif.

*VISUALIZAR
when p_read.
if sy-subrc eq 0.
write: /'Rut :',gwa_registro-p_rut,
/'Nombre :',gwa_registro-p_name,
/'Apellido:',gwa_registro-p_last.
else.
MESSAGE i012(ZMM1).
endif.

*MODIFICAR
when p_modi.

gwa_registro-p_rut = p_rut.
gwa_registro-p_name = p_name.
gwa_registro-p_last = p_last.

modify zregistro from gwa_registro.

if sy-subrc eq 0.
MESSAGE i010(ZMM1).
else.
MESSAGE i011(ZMM1).
endif.

*DELETE
WHEN p_dele. "Eliminar Registro
IF sy-subrc EQ 0.
DELETE zregistro FROM gwa_registro.

IF sy-subrc EQ 0.
MESSAGE i008(zmm1).
ELSE.
MESSAGE i009(zmm1).
ENDIF.

ENDIF.

endcase.

ENDFORM.

You might also like