Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Why mod operator is invalid in the loop

Former Member
0 Likes
494

code :

TABLES spfli.

data c type i.

SELECT * FROM spfli.

c = ( sy-linno mod 2 ).

if c = 0.

format COLOR COL_TOTAL.

else.

format COLOR col_key.

endif.

WRITE : / sy-vline,(15) spfli-carrid,

sy-vline,(15)spfli-connid,

sy-vline.

ULINE AT /(37).

ENDSELECT.

Variable c is 0, never changed in the loop why ?

1 ACCEPTED SOLUTION
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
446

Hi,

Use it this way:-


data : itab type standard table of spfli with header line.

select * from splfi into table itab.

loop at itab.
  "write code here
endloop.

Hope this helps you.

Regards,

Tarun

code :

TABLES spfli.

data c type i.

SELECT * FROM spfli.

c = ( sy-linno mod 2 ).

if c = 0.

format COLOR COL_TOTAL.

else.

format COLOR col_key.

endif.

WRITE : / sy-vline,(15) spfli-carrid,

sy-vline,(15)spfli-connid,

sy-vline.

ULINE AT /(37).

ENDSELECT.

Variable c is 0, never changed in the loop why ?

2 REPLIES 2
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
447

Hi,

Use it this way:-


data : itab type standard table of spfli with header line.

select * from splfi into table itab.

loop at itab.
  "write code here
endloop.

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
446

I made a mistake ,in this code it has a ULINE AT /(37).

sy-linno is alway an even-numbered so sy-linno mod 2 is always 0

thanks.