cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic create Number for Primary Key

Former Member
0 Kudos

Hello,

I have a little Problem. I hope my Description is not sooo worse.

In my Table ZPROFESSOR i have a Field called PROFID.

My goal is to create a Primary Key-Number for that field.

So i created a Numberrange (SNRO) and whit Numberintervalls.

And then i combinate them with my Table.

SE11-> TTabellenpflegegenerator->

Umfeld->Modifikation->Zeitpunkte

i used the Event 05 (New Entrys)

And there i embeddet the coding to create a Atonumber for my PROFID Field.

I Used the Funktions:

CALL FUNCTION 'NUMBER_RANGE_ENQUEUE'

CALL FUNCTION 'NUMBER_GET_NEXT'

CALL FUNCTION 'NUMBER_RANGE_DEQUEUE'

If i make a new entry in my Table ZPROFESSOR over SE16 the Number was created.


So until this Step everything was exactly as it used to be.

But now i wanted to create new Data in ZPROFESSOR over my WebDynpro  coding.

I wrote soming like:

INSERT ZPROFESSOR from LS_ZPROFESSOR.

A new entry in my Table ZPROFESSOR was created, but without my Key-Field PROFID, the Key-Field is emty!!!

i asume that the Event 05 (defined in my Table ZPROFESSOR) has not been triggert by an WebDynpro coding.

I hope understand my Problem.

Please Help me.

Kind Regards

Tobias K.

ps: plz look at the attachments


Accepted Solutions (1)

Accepted Solutions (1)

m_aravindan
Active Participant
0 Kudos

Hi Tobias,

                 Since you are using webdynpro , your coding in the table maintaenece generator wont work. so, while inserting the data throguh webdynpro , use the function module

CALL FUNCTION 'NUMBER_GET_NEXT'

to get the next avilable number from SNRO and then insert it into your custom table..

Regards

Aravindan

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Tobias,

  Table maintainence events will work when you want to do some action on table so if you want to maintain table entries programatically then you need to call FM 'NUMBER_GET_NEXT' to generate a new number and then update/modify tables entries with this.

Hope this helps.

Regards,

Deepti

Former Member
0 Kudos

Hi,

i dont understand wy the event did not triggert. because i createt an entry. so the table entry has been changed.....

this is strange 4 me.

Regards,

tkubler

Former Member
0 Kudos

Hi,

Did you check the below statement in the runtime. Are you sure LS_ZPROFESSOR-PROFID is containing value generated from the function module get_number_next.

INSERT ZPROFESSOR from LS_ZPROFESSOR.

Please post your code.

Best regards,

Arun Krishnamoorthy

Former Member
0 Kudos

Hi,

Aravindan was right.

the howl thing with the tabelgenerator was not needet....lol

this code worked fine...

*Daten Speichern
DATA: I_INTNR type ZPROFESSOR-PROFID.

CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
NR_RANGE_NR = '01'
OBJECT = 'ZWD_BBVPRO'
IMPORTING
NUMBER = I_INTNR " Number generated by Range Generator Object
EXCEPTIONS
INTERVAL_NOT_FOUND = 1
NUMBER_RANGE_NOT_INTERN = 2
OBJECT_NOT_FOUND = 3
QUANTITY_IS_0 = 4
QUANTITY_IS_NOT_1 = 5
INTERVAL_OVERFLOW = 6
BUFFER_OVERFLOW = 7
OTHERS = 8.


LS_ZPROFESSOR-PROFID = I_INTNR.

INSERT ZPROFESSOR from LS_ZPROFESSOR.