Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to genarate random no.s without any number range interval

Former Member
0 Kudos

Dear gurus,

   I have a smartform in which i need to generate random no.s  in respect to sales order no.

       So, when ever user will input 1 sales order no in the selection-screen in the smartform at output that no will be generated.

      the no will be changed if the sales order no will be changed....

         please help me out to solve the problem.

Thanks in advance......

7 REPLIES 7

kesavadas_thekkillath
Active Contributor
0 Kudos

What ever you are asking is not about random number generation. You just need to place the sale order provided in the selection screen to be printed in smartform. This is a basic question. Please search for the available information before posting.

former_member199126
Participant
0 Kudos

Try this FM This would be of help..

SXMS_CREATE_RANDOM_NUMBER

This generates a number,but in floting point as well as whole number.So after executing this FM. Search for . in the number and delete it.

Regards,

Karthik.

Aashish28
Contributor
0 Kudos

Hiii ,

           You can use CL_ABAP_RANDOM also or as per your requirement you can use other random

class also just search in SE24 *RAMDOM* .

Former Member
0 Kudos

Dear Mr.Kesabdas,

   My requiremnt is as i am giving the input SO no....when the output will come in the smartform an auto no will be genarate in respect to that SO no.

  Suppose SO No is----100.

So the auto genarate no will be 1.

    but if i again execute the same SO no the auto genarate no will not be changed....but if the SO no get changed as SO No -----200.

                                            then the auto genarate no will be 2.

This is my requiremnt which i need to done in a smartform....

So please help me out to solve this problem,if possible then please give me the code as well.

0 Kudos

Hi Abhishek,

I think  you should keep record of all input . If input comes then that input is checked against already present  inputs in maintained record structure. If that input is present in that then you will generate random number . You also maintain one counter (cnt) .  When new input comes other than in record then counter is incremented by one.

Code to generate random number.

DATA : MYAMOUNT LIKE BBSEG-WRBTR.

CALL FUNCTION 'RANDOM_AMOUNT'

  EXPORTING

     RND_MIN  = '1'

     RND_MAX  = '100'                

     VALCURR  = 'DEM'

  IMPORTING

     RND_AMOUNT = MYAMOUNT

   EXCEPTIONS

     OTHERS   = 1.

Thanks

Santosh


0 Kudos

Hi Abhishek,

Functionally am not sure, how this requirement is necessary.Every sales order no will be in sequence and unique.Is it just to keep a count of the no of sales orders generated?if you can explain the functional part maybe the members can help you provide with a better alternative.

As to your requirement below is a suggestion, which I feel should not be used since it is not the correct practice.You have to update a Z table whenever a print is issued from the form.

1. Create a Z table with fields sales order no and your Custom No.

2. While printing the particular Sales order No, check if it already exists in the Z table.

   If yes, print the same custom No corresponding to the Sales Order mainatined in the table.

3.If the sales order no to be printed is not available in Z table, fetch the maximum no which has been

  assigned to the last Sales order no.Increment by one and display it in smartform print.

  Also this new entry has to be inserted into the Z table only if a print is issued.

4.Check the exporting parameter of the smartform function module,

  job_output_info

5.

   IF gs_job_output_info-outputdone EQ 'X'. " print was issued
      READ TABLE gs_job_output_info-spoolids INTO gs_spoolid INDEX 1.
      IF gs_spoolid IS NOT INITIAL.
        PERFORM update_table.
      ENDIF.
   ENDIF.

7. In the above perform, update the sales order no and the new no printed on the smartform.

Regards,

Rijuraj.

0 Kudos

Hi Santosh,

   This i have used but it is not working for my requiremnt....could you tell me some other option?