Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Report Z_check

Hi Experts,

I am learning Abap objets, could someone help me in understanding the output of the below program... I was expecting to have 1,3,5,7,9,11,13 as answers but I got 1,3,5,7,9,1,3. I don't understand why I have 1 and 3 at the end instead of 11 and 13.

REPORT z_check.

CLASS demo DEFINITION.

PUBLIC SECTION.

CLASS-METHODS main.

ENDCLASS.

CLASS demo IMPLEMENTATION.

METHOD main.

DATA: is_zero TYPE i,

n_index TYPE n.

DO 13 TIMES.

is_zero = sy-index MOD 2.

CHECK is_zero = 1.

n_index = sy-index.

MESSAGE n_index TYPE 'I'.

ENDDO.

ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.

demo=>main( ).

Thanks

Former Member
Former Member replied

Hi,

REPORT z_check.

CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.

CLASS demo IMPLEMENTATION.
METHOD main.
DATA: is_zero TYPE i,
n_index(2)TYPE n.      --> Increase the length of the field to 2 then you can see 11,13 else the value is getting truncated.
DO 13 TIMES.
is_zero = sy-index MOD 2.
CHECK is_zero = 1.
n_index = sy-index.
MESSAGE n_index TYPE 'I'.
ENDDO.
ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
demo=>main( ).

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question