Application Development 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: 

how to add a column in alv grid report to show the serial no.

Former Member
0 Kudos

i need to add column to show the row no. of the report say as :

1

2

3

...

this has to be the first column

how to maintain a variable for this and how to use it??

please help

1 ACCEPTED SOLUTION

Former Member
0 Kudos

one simple way is in your final itab declare a slno type i field

data : begin of itab occurs 0,

slno type i,

<other fields>

end of itab.

after filling the data in itab.

loop at itab.

itab-slno = sy-tabix.

modify itab.

endloop.

in fieldcatalog also you have to define that slno field as the first column.

but it will change its order if you are sorting the output or filtering the output.

regards

shiba dutta

9 REPLIES 9

Former Member
0 Kudos

HI,

Declare a variable of type i as the first variable in your internal table .. and while populating the records into ur internalt able increment the counter an put that value in this first field.

Thanks

Mahesh

0 Kudos

pls support ur suggestion with example code..

how to print in grid ..how to pass the value .....where to increment...

pls help

0 Kudos

pls can you tell how to put the value in the field and where to initialize the variable???

0 Kudos

Mahesh,

can you pls help me with some sample code on this...i really need it urgently...

thank you

Former Member
0 Kudos

Hi,

In your final internal table, while processing the data increment the counter.

And fill this field in the field catalog and display using ALV.

Thanks,

Sri.

0 Kudos

can u pls help me with some lines of code..

im new n have no idea as to how to proceed

Former Member
0 Kudos

one simple way is in your final itab declare a slno type i field

data : begin of itab occurs 0,

slno type i,

<other fields>

end of itab.

after filling the data in itab.

loop at itab.

itab-slno = sy-tabix.

modify itab.

endloop.

in fieldcatalog also you have to define that slno field as the first column.

but it will change its order if you are sorting the output or filtering the output.

regards

shiba dutta

0 Kudos

thanks a lot..it worked

just one more thing..im not getting the heading of this column ..where to give that??

0 Kudos

i think in fieldcatalog of the alv you dint define the seltext_l

just define the fieldcatalog like this

fieldcat-fieldname = 'SLNO'.

fieldcat-col_pos = 1.

fieldcat-outputlen = 5.

fieldcat-seltext_l = 'S.No.'.

append fieldcat to ifieldcat

regards

shiba dutta