09-08-2009 7:53 AM
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.
09-08-2009 8:04 AM
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
09-08-2009 8:08 AM
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
09-08-2009 10:12 AM
09-09-2009 3:34 AM
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.