on 02-15-2012 3:21 PM
Hi Guys,
I am passing PI message ID to one of the field...but i need to pass only the numbers and it should be only 7 digits..
how can i convert the alphanumeric to only numeric number in PI and truncate to only 7.
your reply would really be appreciated.
Regards
Edited by: ayrahcaanilan on Feb 15, 2012 4:22 PM
Hi Ayrahcaanilan,
You can use
public static void main(String[] args) {
Random random = new Random();
String myRandomNo = "";
for (int i = 0; i < 7; i++) {
myRandomNo = myRandomNo + random.nextInt(10);
}
System.out.println(myRandomNo);
}
Java Random [Link|http://docs.oracle.com/javase/6/docs/api/java/util/Random.html] .
Regards,
Raghu_Vamsee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
>>>but i need to pass only the numbers and it should be only 7 digits..
but not put something completely different there ? a random number of 7 digits ?
PI message id without letters and truncated to 7 digits is not PI message ID anymore at all so why bother
Regards,
Michal Krawczyk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks michal..
i am using this logic to generate a random number.....i know i can get this by writing an UDF by taking time(milliscs) or date into consideration...infact i did.but we are facing some issues with that..so we want to avoid using time and date concept here.
Is there any other way to generate a random UNIQUE number?
regards
Hi,
>>>It depends o how frequently a new number gets created.If we assume you generate 1 new ID per second, then it takes approximately 326 years before you get a duplicate.
assuming - you keep track on the IDs right ?
I don't know how SAP's messageguid is being generated but I don't think it keeps track of all previous IDs right ?
Regards,
Michal Krawczyk
http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=50004015
Then you have to create a RFC wrapper around the function module GET_NUMBER_NEXT.
Use this article to see how you can call an RFC from graphical mapping:
Best Regards,
Ravi
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.