2008 Jul 16 10:41 AM
hi all,
how to generate random numbers. is there any function module to generate it. pls tell me.
hi all,
how to generate random numbers. is there any function module to generate it. pls tell me.
2008 Jul 16 10:43 AM
2008 Jul 16 10:43 AM
2008 Jul 16 10:44 AM
I always wonder, what is the business scenario in SAP, where you need random numbers? Or you develope game in ABAP?
2008 Jul 16 10:51 AM
Yes Eric,
I really used(!) this FM - QF05_RANDOM_INTEGER only for answering questions in SDN forum and never in my programs.
Sandeep, what are you doing with this FM. Please let us know its usage.
//Kothand
2008 Jul 16 10:47 AM
Hi,
you can use FM 'QF05_RANDOM_INTEGER'
DATA:
number TYPE i.
CALL FUNCTION 'QF05_RANDOM_INTEGER'
EXPORTING
ran_int_max = 1000
ran_int_min = 1
IMPORTING
ran_int = number
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
WRITE 😕 'Next available number is: ', number.
Hope this is useful to you.
Reward points if it is useful.
Thanks,
phani Diwakar.
2008 Jul 16 10:47 AM
Hi
Try with this one :
REPORT ZRANDOM.
DATA RANINT LIKE QF00-RAN_INT.
PARAMETERS: P_MAX LIKE QF00-RAN_INT DEFAULT 100,
P_MIN LIKE QF00-RAN_INT DEFAULT 1,
P_TIMES TYPE I DEFAULT 10.
WRITE:/ 'RANDOM NUMBER'.
ULINE.
DO P_TIMES TIMES.
CALL FUNCTION 'QF05_RANDOM_INTEGER'
EXPORTING
RAN_INT_MAX = P_MAX
RAN_INT_MIN = P_MIN
IMPORTING
RAN_INT = RANINT
EXCEPTIONS
INVALID_INPUT = 1
OTHERS = 2.
IF SY-SUBRC EQ 0.
WRITE:/ RANINT.
ELSE.
WRITE:/ 'UNABLE TO GENERATE RANDOM NUMBER'.
ENDIF.
ENDDO.
With Regards
Nikunj shah
2008 Jul 16 10:47 AM
2008 Jul 16 10:50 AM
Hi Sandeep,
I think u can use the function module: GUID_CREATE.
check this it may be of som euse.
Regards
Abhilash.
2008 Jul 16 11:12 AM
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |