Application Development and Automation 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: 
Read only

System generated number

Former Member
0 Likes
1,507

Hi all,

I m developing a module pool with z table 1 Header & 1 Item table. Now I would like to ask how I can get system generated number for the pk filed supose gate pass number and my filed type is char 10.

When user enter a new entry then system will auto generqte the gpass number .

so pls let me know if any one can help me to do this job.

Thanks in advance.

manju

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,323

Create a number range object using transaction SNRO. You can find all documentation needed on http://help.sap.com.

Regards.

John.

8 REPLIES 8
Read only

Former Member
0 Likes
1,324

Create a number range object using transaction SNRO. You can find all documentation needed on http://help.sap.com.

Regards.

John.

Read only

0 Likes
1,323

Hi John,

thnx for ur prompt reply. I hv gone thorugh the SNRO but how i know which object will be suitable to my requirement bcoz my filed type is char 10.

so pls let me know the right object or can i create a new one.

manju

Read only

former_member200872
Active Participant
0 Likes
1,323

Hi,

A simple solution could be using system date and time to generate a unique number.

Try this:

DATA: V_UNQ(14) TYPE C.

START-OF-SELECTION.

CONCATENATE SY-DATUM+4(4) SY-UZEIT INTO V_UNQ.

WRITE:/ 'Format is - MMDDHHMMSS : ', V_UNQ.

CONCATENATE SY-DATUM2(6) SY-UZEIT(4) INTO V_UNQ.

WRITE:/ 'Format is - YYMMDDHHMM : ', V_UNQ.

CONCATENATE SY-DATUM SY-UZEIT INTO V_UNQ.

WRITE:/ 'Format - YYYYMMDDHHMMSS - is always Unique', V_UNQ.

Regards,

Wajid Hussain P.

Read only

0 Likes
1,323

Thnx wajid for your prompt reply and idea abt unique number.

thnx once again.

bye

manju

Read only

Former Member
0 Likes
1,323

Hey Manju,

first pre determine what range your number should be having , like starting from 0000000001 like that or 1000000001 etc, after that :

Scenario 1 ( if you have to show the number as a field on the screen)

write a select query in the PBO of the screen as below

let the field name be gateno.

select max(gateno)

from <dbtab>

into < var1>.

this will fetch the last number and then you can increase it.

if syst-subrc is initial.

var1 = var1 + 1.

endif.

move the value of var1 to the screen field name.

Scenario 2 ( If you just need to update in the database table)

write the above select query in the PAI module of the screen when the user performs some action like SAVE.

Hope this helps,

reward if useful,

Regards ,

RK

Read only

0 Likes
1,323

HI RK,

THNX FOR REPLY I WAS DOING THE SAME AS U WRITTEN ONLY I DIDNT SPECIFY THE RANG SO IT WAS NOT GIVING LEADING ZEROS WHILE GENERATIN NUBER BUT NOW FROM UR EMAIL I HV DEFINE THE RANG SO IT'S WORKING FINE.

THNX.

Read only

0 Likes
1,323

Hi RK ,

thnx for yesterday solution.

I need your help again.......pls go through this

I m having a char field lenght 1 and input value with eithr 'O' or 'C' .

and another 2 text field for Vendor and Contractor name as a input.

so my Q is @ the time of creating gate pass entry

when user enter 'O' so contrator name text should be disable and when enter 'C' so vendor name should be disable or vice versa.

so what code i should write in module pool and where either in PBO or PAI.

Awaiting for response.

Thanks in Advance.

Manju

Read only

0 Likes
1,323

Hi,

When the display attributes of screen fields are to be changed, it has to be done in pbo.

Check the code given below.

Regards,

Wajid Hussain P.

  • * * * *

case p_text1.

when 'O'.

loop at screen .

if screen-name = 'P_CONTRACTOR'.

screen-input = 0.

else.

screen-input = 1.

endif.

modify screen.

endloop.

when 'C'.

if screen-name = 'P_VENDOR'.

screen-input = 0.

else.

screen-input = 1.

endif.

modify screen.

endcase.