cancel
Showing results for 
Search instead for 
Did you mean: 

Generate Random Numbers

former_member187312
Participant
0 Kudos

Hi Experts,

Is there any standard library to generate random number ?

Regards,

Senz

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Senz

I think the only random thing that you can generate as for now is a UUID

this.myrandomUUID = UUID.Generate();

Or if you need a number you have to use some online services using a rest or soap call.

ChrisWarken
Participant

I used seconds of CurrentGlobalDateTime to replace uppercase letters in generated UUID.
Implemented it like that:

var nowTime = Context.GetCurrentGlobalDateTime();
var randomUUID = UUID.Generate().ToString();
var randomNumberString = randomUUID.ReplaceRegex("[A-Z]",nowTime.GetSecond());

After that you can parse it to a number and calculate modulo to e.g. get a number in a specific range

Answers (2)

Answers (2)

former_member216877
Participant
0 Kudos

Hii..

  Use FM QF05_RANDOM_INTEGER

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Debesh,

There is no backend access in the Cloud Application Studio. Especially not on ABAP function modules.

Sorry,

    Horst

former_member200567
Active Contributor
0 Kudos

Hi Senz,

There is one.

Best Regards,

Fred

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Fred,

My NumberRange lib generates consecutive numbers, not random ones.

Bye,

    Horst

former_member200567
Active Contributor
0 Kudos

Hi Horst,

Ah, yes. My mistake.

Best Regards,

Fred

former_member200567
Active Contributor
0 Kudos

Hi Senz,

Sorry, sorry.

NumberRange ReuseLibrary is not for Random Number.

My mistake.

Best Regards,

Fred