Está en la página 1de 2

REPORT Z_OTRO.

*&---------------------------------------------------------------------*
*& Report Z_PRUEBA_ABAP2_6
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

*Declaracin de variables
DATA: v_clase(2) TYPE c VALUE 'CA'.

************************************************************************
******************* Estructura de las Conciones ************************
************************************************************************
*IF <condicion>. "Condicion 1
* declaraciones.
*ELSEIF <condicion>. "Condicion 2
* declaraciones.
*ELSE. "Condicion n
* declaraciones.
*ENDIF.
*
*CASE campo.
* WHEN valor1. "Condicion 1
* declaraciones.
* WHEN valor2. "Condicion 2
* declaraciones.
* WHEN OTHERS. "Condicion n
* declaraciones.
*ENDCASE.

************************************************************************
******************* Estructura de los Bucles ***************************
************************************************************************
*LOOP AT tabla.
* declaraciones.
*ENDLOOP.
*
*
*DO n TIMES.
* declaraciones.
*ENDDO.
*
*WHILE condicion.
* declaraciones.
*ENDWHILE.

************************************************************************
****************************** Ejemplos ********************************
************************************************************************
CHECK sy-subrc EQ 0.

IF v_clase EQ 'CA'.
EXIT.
ENDIF.

DO 4 TIMES.
IF sy-subrc EQ 4.
CONTINUE.
ENDIF.

ENDDO.

IF sy-subrc NE 0. "NE es equivalente a <>


STOP.
ENDIF.

IF v_clase EQ 'DT'. "EQ es equivalente a =


LEAVE.
ENDIF.

***Ciclo Infinito**
Do.

ENDDO.

***Loop on change of***


CLEAR: it_ekpoh, wa_ekpo.
REFRESH it_ekpoh.

LOOP AT it_ekpo INTO wa_ekpo.


ON CHANGE OF wa_ekpo-EBELN OR wa_ekpo-EBELP. " Entra cuando el material cambia
MOVE-CORRESPONDING wa_ekpo TO wa_ekpoh.
wa_ekpoh-EBELN = wa_ekpo-EBELN.
APPEND wa_ekpoh TO it_ekpoh.
ENDON.
ENDLOOP.

DATA: v_nro_vuelta TYPE i.

CLEAR v_nro_vuelta.

DO 10 TIMES.

IF v_nro_vuelta = 5.
EXIT.
ELSE.
ADD 1 TO v_nro_vuelta.
ENDIF.

ENDDO.

WRITE:/'El numero de vuelta final del ciclo fue: ', v_nro_vuelta.

También podría gustarte