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

serial no

Former Member
0 Likes
435

Hi to all experts.

I have some data in itfinal table.

While printing this table data I want to add serial no at first column.

How can do this.

Plase give me sample code.

Thanks in advance an d reward also

Regard : deep

4 REPLIES 4
Read only

varma_narayana
Active Contributor
0 Likes
415

hI..

Loop at it_final into Wa_final.

WRITE:/ SY-TABIX,

WA_FINAL-FIELD1,

WA_FINAL-FIELD2.

endloop.

SY-tabix Stores the current loop pass in LOOP ENDLOOP

so you use it to display Serial no.

<b>Reward if Helpful</b>

Read only

Former Member
0 Likes
415

In the internal table that is being listed out, have a field at the beginning and call it as serial.

loop at itab.

itab-serial = sy-tabix .

modify itab.

clear itab.

endloop.

Regards

Read only

Former Member
0 Likes
415

Hi,

refer to the following code:

report ztx1104.

data: begin of it occurs 3,

f1(1),

f2(2),

end of it.

it-f1 = 'A'.

it-f2 = 'XX'.

append it to it. "appends header line IT to body IT

it-f1 = 'B'.

it-f2 = 'YY'.

append it. "same as line 8

it-f1 = 'C'.

append it. "the internal table now contains three rows.

sy-tabix = sy-subrc = 99.

loop at it. "same as: loop at it into it

write: / sy-tabix, it-f1, it-f2.

endloop.

write: / 'done. sy-tabix =', sy-tabix,

/ ' sy-subrc =', sy-subrc.

The code above produces this output:

1 A XX

2 B YY

3 C YY

done. sy-tabix = 99

sy-subrc = 0

Hope this hellps.

Reward if helpful.

regards,

Sipra

Read only

Former Member
0 Likes
415

loop at itab.

write: /10 sy-tabix,

20 itab-field1,

30 itab-field2...

endloop.

Regards,

Pavan