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: 

Serial number in table control

sudhir_uppalapati
Participant
0 Kudos

Hi All,

I am using a table control wizard in which i have 3 fields. 2 fields will be filled by the user. I have a field in which the serial number has to be shown.

How to get the serial number automatically in table control.

4 REPLIES 4

former_member1245113
Active Contributor
0 Kudos

Hi,

Lets say you are using itab as your internal table in PAI and PBO

in PBO

module update_itab.

loop at itab with control tc

endloop.

in Program.

module update_itab

data : sr_no type i.

clear sr_no.

loop at itab.

itab-sr_no = sr_no + 1.

modify itab index sy-tabix. ---> this will update your itab with serial number

endloop.

endmodule

Cheers

Ram

Former Member
0 Kudos

Hi,

I suppose serial number would be a number that you ahve to automatically generate based on the number of entries on the table control , it would nto be saved in database then try like below:

PBO:

For the entries that you already are displaying on the screen you need to assign values to this before the data is displayed first time so here i am supposing that the internal table from which you are displaying has a field for serial number, so just before diplaying loop on the data and assign the serial numbers like below:



loop  on it_display.
 if not  it_display is initial.
 it_display-serialno = it_display-serialno + 1.
modify it_display index sy-tabix transporting serialno.
endif.
endloop.

PAI:

For the new entries as soon as the entries are made you need to generate the entries so do like below:


loop on it_dsplay.
chain.
field field1.
field field2.
.....
field serialno module generate_serialno on input.
endchain.
endloop.

module generate_serialno input.

here put your logic to get the next serial number you might have to save the last used serial number in a global variable.

REgards,

Himanshu

0 Kudos

Hi Himanshu,

The logic which u gave is not working.

Former Member
0 Kudos

add a integer field in the table control.

In pbo

loop at itab with control tc.

module display.

endloop.

module display output.

move itab to tcfields.

int-field = tc-current_line.

endloop.

No need to add a field in itab.