Saturday, January 14, 2012

Do enddo statements in sap abap with example program


REPORT demo_flow_control_do .

* simple do

DO.

  WRITE sy-index.
  IF sy-index = 3.
    EXIT.
  ENDIF.
ENDDO.

SKIP.
ULINE.

* do n times

DO 2 TIMES.
  WRITE sy-index.
  SKIP.
  DO 3 TIMES.
    WRITE sy-index.
  ENDDO.
  SKIP.
ENDDO.

SKIP.
ULINE.

* varying

DATA: BEGIN OF text,
        word1(4) TYPE c VALUE 'This',
        word2(4) TYPE c VALUE 'is',
        word3(4) TYPE c VALUE 'a',
        word4(4) TYPE c VALUE 'loop',
      END OF text.

DATA: string1(4) TYPE c, string2(4) TYPE c.

DO 4 TIMES VARYING string1 FROM text-word1 NEXT text-word2.
  WRITE string1.
  IF string1 = 'is'.
    string1 = 'was'.
  ENDIF.
ENDDO.

SKIP.

DO 2 TIMES VARYING string1 FROM text-word1 NEXT text-word3
           VARYING string2 FROM text-word2 NEXT text-word4.
  WRITE: string1, string2.
ENDDO.

1 comment:

  1. Thanks for sharing valuable information through your post. The information provided is of great use.
    SAP ABAP TRAINING IN HYDERABAD

    ReplyDelete