I want to create unique numbers with an AP REXX program?

Document ID : KB000039441
Last Modified Date : 14/02/2018
Show Technical Document Details

Introduction: 

This article concerns the creation of unique numbers with AP REXX programs.

Question: 

I have a REXX routine that builds a UNIQUE file that it will write to and then process. Problem is, this routine can be called more than once simultaneously and the file gets overwritten. How do I make sure that every time the REXX runs, it generates a unique filename?

Environment:  

Windows Server, Open Object REXX

Answer: 

Since your REXX routine can be called more than once simultaneously, I suggest that you use the SysQueryProcess(PID) utility which is available in Open Object REXX. Using this utility, you will get the process ID for each running REXX routine that you call. Your filenames can then be concatenated with this PID, which will be unique, especially when the routine is called more than once simultaneously.

Additional Information:

Please read the AP r11.4.x administration guide "Configuring Open Object REXX" to setup AP for using OO-REXX interpreter instead of the AP Embedded REXX interpreter:

Configuring Open Object REXX in AP