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: 

Automatic counter in database

former_member659396
Participant
0 Kudos
365

Dear friends

I am doing module pool programming and i am saving data in database table through screen..

I have to give counter to that saved data..

Following is my logic to give counter to database table...

where i have to define it in PBO or PAI

SELECT SINGLE ZRD_HDRID INTO P FROM ZRD_ORDTYP

WHERE ZRD_HDRID = ( SELECT MAX( ZRD_HDRID ) FROM ZRD_ORDTYP ) .

LOOP AT WA_ORDTYP.

P = 0.

P = P + 1.

WA_ORDTYP-ZRD_HDRID = P.

ENDLOOP.

modify zrd_ordtyp from wa_ordtyp

Please Help me

Regards

Rohan

6 REPLIES 6

Former Member
0 Kudos
57

Hi,

If your requirement is to use serial number as primary key in your table

then better to use number range for this...

If your requirement is other than serial number then please clarify...

Regards,

Meet

0 Kudos
57

How to give that number range

0 Kudos
57

HI,

For number range you need to create Z number range from SNRO transaction,

then use that in your code..

At the time of inserting data in Z table, you need to call FM : 'NUMBER_GET_NEXT'

it will give you next number to the maximum number of you \r number range..

steps are below...

create number range using SNRO transaction

then call Fm 'NUMBER_GET_NEXT' before inserting data in tabel.

it will give you nex number, use it as your serial number.

insert data using that number..

hope it will help you..

Regards,

Meet

Former Member
0 Kudos
57

Hi

You will save the data along with the counter in PAI.

Because it will be executed after you insert the values and hit a button.

Hope this helps

Regards,

Jayanthi.K

former_member659396
Participant
0 Kudos
57

zxd

0 Kudos
57

You don't have to leave nonsense when marking as answered, the comment field is optional.

Thomas