11-03-2011 11:08 AM
Hi, all... Im generating pseudorandom number by my own functional module with this code. Problem is, that it always returns same number. when i test class CL_ABAP_RANDOM* (all these classes), it returns good numbers. Please, do you see some problems in my code? thanks a lot
FUNCTION y0bi_cm_sample_psrnd_num_get.
*"----------------------------------------------------------------------
*"*"Lokální rozhraní:
*" IMPORTING
*" REFERENCE(X_XTIMESTAMP) TYPE KENNZX OPTIONAL
*" EXPORTING
*" REFERENCE(Y_RANDOM_FLOAT) TYPE CL_ABAP_RANDOM_PACKED=>P31_0
*"----------------------------------------------------------------------
DATA: lr_random TYPE REF TO cl_abap_random_packed_dec14,
l_timestamp TYPE timestamp,
l_seed TYPE i.
GET TIME STAMP FIELD l_timestamp.
FREE: lr_random.
IF x_xtimestamp EQ 'X'.
l_seed = FRAC( l_timestamp ) * 1000000.
*TRY.
lr_random = cl_abap_random_packed_dec14=>create(
seed = l_seed
min = '0'
max = '1' ).
.
* CATCH cx_abap_random .
*ENDTRY.
ELSE.
lr_random = cl_abap_random_packed_dec14=>create(
min = '0'
max = '1' ).
ENDIF.
y_random_float = lr_random->get_next( ).
ENDFUNCTION.
11-03-2011 11:31 AM
Dear Filip Kouba
Use this on your data declaration: tzntstmpl
instead of this:
timestamp
So your code will become like this:
l_timestamp TYPE tzntstmpl,
Kind Regards
/Ricardo Quintas
11-03-2011 11:31 AM
Dear Filip Kouba
Use this on your data declaration: tzntstmpl
instead of this:
timestamp
So your code will become like this:
l_timestamp TYPE tzntstmpl,
Kind Regards
/Ricardo Quintas
11-03-2011 1:20 PM
thanx..the main problem was, that i used wrong data type with no decimals but same length )
11-03-2011 12:06 PM
Hi ,
Please see the coding in "RFTBB_MDG_CLASS" and you will get some idea.
I hope this will help you.
Regards,
Rahul Mahajan