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: 

Auto Incrementing a field in a database table

Former Member
0 Kudos

Hello All,

I have created a database table for generating a unique ID, based on two key fields; Product and Area.

For a particular Product and Area,the ID generated should be unique, and it will be the third field of my table.

Is there any possible way by which i can generate the ID automatically,based on the Product And Area entered? The ID should also be automatically incremented based on the next entry.

Can anyone help me in resolving this problem?

Also, if i am deleting a particular Product and Area, will it be possible to remove the ID generated by it?

Thanks In Advance.

Shino.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Shino,

It feels like you've got two options, using a number range or a guid.

For a number range you'll need to create a new one in transaction SNUM, then in the program that updates your table call function module NUMBER_GET_NEXT to get the next free number in the range.

For the guid call function module GUID_CREATE. This will be a unique number but will not be incremented like the number range.

Regards,

Nick

5 REPLIES 5

Former Member
0 Kudos

Hi Shino,

It feels like you've got two options, using a number range or a guid.

For a number range you'll need to create a new one in transaction SNUM, then in the program that updates your table call function module NUMBER_GET_NEXT to get the next free number in the range.

For the guid call function module GUID_CREATE. This will be a unique number but will not be incremented like the number range.

Regards,

Nick

0 Kudos

Hello Nick,

Could you please make it little more clear how to use a number range in the table, as i dont have any program to update the database table.

Currently i am using se54 transaction for updating my table, and will it be possible to use the number range in this transaction?

Is there any possibility of using table control for this purpose?

It would be really helpful,if you explain it in steps.

Thanks And Regards,

Shino

0 Kudos

Hi,

If you are using a generated maintenance screen and populating the data manually your approach will need to be different.

It could be possible to use a user exit in the generated screen to populate your ID field, but you will face the risk that the user will be able to presumably over-type the ID or enter their own value.

Consider your overall requirement and design, it may be that a generated maintenance sceen is not the most suitable way to build this functionality.

Regards,

Nick

Former Member
0 Kudos

hi,

FM to increment the number is NUMBER_GET_NEXT. and if you can post your code then we can get a solution.

thanks,

anupama.

piyush_mathur
Active Participant
0 Kudos

Hi,

You can put the code under events in Table Maintenance Generator to generate the Unique Id in table while saving the records.

Thanks

Piyush