2007 Sep 28 2:15 PM
Hi all,
I have to create a ztable with a field id that will be a auto counter when execute maintenance transaction for the ztable. Can anyone help me?
Regards.
2007 Sep 28 3:16 PM
If you want the number to always be unique, create a number range object and use function number_get_next to get the next number.
If using standard table maintenance, put code for this in a maintenance event (probably 01) and mod the screen field to make it display only.
Andrew
Hi all,
I have to create a ztable with a field id that will be a auto counter when execute maintenance transaction for the ztable. Can anyone help me?
Regards.
2007 Sep 28 2:59 PM
Hi.
In fact, you cannot create an "auto-counter" field as in mySQL for example. You will have to handle that field writing code. I suggest you create a new dialog program to handle this, so that you can also handle the delete and the insert functions etc.
Regards,
George
2007 Sep 28 3:16 PM
If you want the number to always be unique, create a number range object and use function number_get_next to get the next number.
If using standard table maintenance, put code for this in a maintenance event (probably 01) and mod the screen field to make it display only.
Andrew
2007 Sep 28 6:22 PM
Hi, thanks for replies.
But i found one solution, can anyone sugest better?
I edited the function group generated by the se11 (maintenance). At the pai in the first screen i use a select max( filed ) o a variable.
At the pai in the second screen i copy and change a standard module, adding a statement MOVE var to ztable-field.
It works
2007 Sep 29 2:22 AM
Disadvantage of changing the generated maintenance is that if anyone adds fields to the table or makes other changes in future and re-generates the maintenance dialog, then your changes will be wiped.
Events in the generated mantenance do not get over-written when you re-generate and are thus a bit safer. (Menu path Environment->Modification->Events when in table maintenance generator screen - documentation in help is quite good).
The select max( field ) statement may return the same number to different users using the transacion at the same time unless the table is enqueued and locked first. Inside the generated maintenance this is not an issue as it locks the table and will not allow two users to update. However, if you also use this logic in your own program code you need to make sure no one else is updating at the same time.
Andrew
2007 Sep 28 9:08 PM
Hi Rodrigo,
Try it.
go to Function Group at SE80 and add a Include PBO-Module.
then
in PROCESS BEFORE OUTPUT. ( at all Screen's )
add a module at last line of Output. ( Can be the same for all Screen's )
ex:
module ZFGTESTEO.
create this module at Include created above (double click in) and put this code.
IF SY-UCOMM = 'NEWL' OR ( sy-ucomm = 'NEXT' AND NOT <TABLE1> <> 0 ).
DATA: temp LIKE ZTABLE.
temp = total+3(10) + 1.
<TABLE1>+3(10) = temp.
ENDIF.
Regards,
Allan Cristian
2007 Oct 17 5:48 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |