‎2008 Jul 23 11:00 AM
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
‎2008 Jul 23 11:10 AM
Create a number range object using transaction SNRO. You can find all documentation needed on http://help.sap.com.
Regards.
John.
‎2008 Jul 23 11:10 AM
Create a number range object using transaction SNRO. You can find all documentation needed on http://help.sap.com.
Regards.
John.
‎2008 Jul 23 12:48 PM
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
‎2008 Jul 23 11:20 AM
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.
‎2008 Jul 23 12:49 PM
Thnx wajid for your prompt reply and idea abt unique number.
thnx once again.
bye
manju
‎2008 Jul 23 1:00 PM
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
‎2008 Jul 23 2:13 PM
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.
‎2008 Jul 24 10:07 AM
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
‎2008 Jul 24 10:35 AM
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.