© serviceprofessionalgmbh

Here we want to offer a remedy for an everlasting source of troub
le. Specially with embedding REXX programs under ENDEVOR you always get the same problems (sometimes REXX runs inside and sometimes outside of the processor):

Often it seems however you do it, you do it wrong. Here we offer a way of doing it which will always lead to the desired solution.
The assignment of a file is always done in the REXX program.

Depending on the environment this assignment will either be done directly via ALLOCATE (with IKJEFT01) or via BPXWDYN (with IRXJCL).
To find out which environment applies use the function SYSINFO (refer to Power of Rexx under Tips & Tricks)
/* REXX **************************************************************
*  Dynamische Zuweisung einer Datei auch unter IRXJCL                *
*********************************************************************/
ENV = sysinfo("PROGNAME")
/* Dateizuweisung ***************************************************/
if ENV <> "IRXJCL" then do
   "ALLOC DD(IN) DA(dateiname) SHR REUSE"
   Rx_RC = RC
end
else do
   Rx_RC = bpxwdyn("ALLOC FI(IN) DA(dateiname) SHR REUSE")
end
if Rx_RC <> 0 then do
   say "Allocate Fehler auf File IN, RC="Rx_RC
   return Rx_RC
end
/* Lesen der Datei ***************************************************/
"execio * diskr IN (finis stem file."
do I = 1 to FILE.0
   say FILE.I
end
if ENV <> "IRXJCL" then do
   "FREE DD(IN)"
   Rx_RC = RC
end
else Rx_RC = bpxwdyn("FREE FI(IN)")
exit Rx_RC
back to REXX in batch