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 generate a unique number for a field every time

sridhar_meesala
Active Contributor
0 Kudos

Hi every one,

I have a requirement where I have to generate a unique number every time, i.e. for an output only field (that is an account number field) I have given a number initially. So wnen ever an account is created this number is saved to the database table. Now again when I try to open a new account, autometically the account number has to be displayed by incrementing 1 to the previous number.

Please help me in doing this.

Thanks,

Sri...

2 REPLIES 2

Former Member
0 Kudos

hi,

go to t-code SNRO and create a number range from 0 to 99999999.

call the below fm in the report by passing the created number range name to fm to generate the new number every time..

see

NUMBER_GET_NEXT Get next free number in a range

CALL FUNCTION 'NUMBER_GET_NEXT'

EXPORTING

NR_RANGE_NR = '01'

OBJECT = 'YPOLLID' "number range name created in SNRO.

IMPORTING

NUMBER = LS_NUMBER. "new number with one increment..

or

you can try..

you can use following code.

select max( num ) from z_table into v_max_num.

v_max_num = v_max_num+1.

Regards,

prabhudas

Former Member
0 Kudos

HI,

Check FM NUMBER_GET_NEXT. For more help read the FM Documentation.