The I/O routines in mainframe REXX and ooRexx on an intel chip must be 
different for many inherent reasons. We're talking records and blocks on the 
mainframe and byte streams on the PC for one thing.

Here is a working example of a rexx exec I run in a batch job. The files are 
allocated in the JCL so that part will not help you unless you choose that 
option. I just wanted to show you how to use an array to hold all your data 
from the file without loading and running the execio code in a loop. In this 
code you read the file once, and write the output file in one operation. The 
writing is done using the REXX QUEUE, another very powerful feature of REXX.

/* REXX */                                                                      
trace r                                                                         
ADDRESS TSO                                                                     
  "EXECIO * DISKR INDD (STEM lineread. FINIS)"                                  
IF RC ^= 0 THEN do                                                              
    SAY 'THERE IS A PROBLEM WITH YOUR  DATASET.' rc                             
    EXIT                                                                        
END                                                                             
SAY lineread.0 'RECORDS READ FROM input file'                                   
outline = ""                                                                    
system_id = "s_id"                                                              
interval_date = " date     "                                                    
interval_time = " time     "                                                    
total_dispatch_time_CP1A = "        cp1a"                                       
total_dispatch_time_CP1C = "        cp1c"                                       
total_dispatch_time_CP1D = "        cp1d"                                       
total_dispatch_time_CP1F = "        cp1f"                                       
total_dispatch_time_CP1H = "        cp1h"                                       
total_dispatch_time_CP1K = "        cp1k"                                       
total_dispatch_time_CP1L = "        cp1l"                                       
total_dispatch_time_CP1S = "        cp1s"                                       
total_dispatch_time_CP1U = "        cp1u"                                       
total_dispatch_time_CP1Z = "        cp1z"                                       
outline  =,                                                                     
   system_id || ", ",                                                           
   interval_date  || ", " || interval_time || ", " ||,                          
   total_dispatch_time_CP1A  || ", " ||,                                        
   total_dispatch_time_CP1C  || ", " ||,                                        
   total_dispatch_time_CP1D  || ", " ||,                                        
   total_dispatch_time_CP1F  || ", " ||,                                        
   total_dispatch_time_CP1H  || ", " ||,                                        
   total_dispatch_time_CP1K  || ", " ||,                                        
   total_dispatch_time_CP1L  || ", " ||,                                        
   total_dispatch_time_CP1S  || ", " ||,                                        
   total_dispatch_time_CP1U  || ", " ||,                                        
   total_dispatch_time_CP1Z /* end of building the outline. */                  
queue outline                                                                   
outline = ""                                                                    
DO I = 1 TO LINEREAD.0                                                          
    select                                                                      
        WHEN substr(LINEREAD.I,48,26) = 'P A R T I T I O N  D A T A' &,         
            system_id \= 's_id' then do                                         
            outline  =,                                                         
                system_id || ", ",                                              
                interval_date  || ", " || interval_time || ", " ||,             
                total_dispatch_time_CP1A  || ", " ||,                           
                total_dispatch_time_CP1C  || ", " ||,                           
                total_dispatch_time_CP1D  || ", " ||,                           
                total_dispatch_time_CP1F  || ", " ||,                           
                total_dispatch_time_CP1H  || ", " ||,                           
                total_dispatch_time_CP1K  || ", " ||,                           
                total_dispatch_time_CP1L  || ", " ||,                           
                total_dispatch_time_CP1S  || ", " ||,                           
                total_dispatch_time_CP1U  || ", " ||,                           
                total_dispatch_time_CP1Z /* end of building the outline. */     
            queue outline                                                       
            outline = ""                                                        
        end  /* do */                                                           
        WHEN SUBSTR(LINEREAD.I,6,14) = 'PARTITION NAME' THEN                    
            system_id = substr(lineread.i,40,4)                                 
        when SUBSTR(LINEREAD.I,64,7) = '  DATE ' THEN                           
            interval_date = substr(lineread.i,71,10)                            
        when SUBSTR(LINEREAD.I,64,7) = '  TIME ' THEN                           
            interval_time = substr(lineread.i,71,8)                             
        when substr(LINEREAD.I,2,4) = 'CP1Z' THEN                               
            total_dispatch_time_CP1Z  = substr(lineread.i,58,12)                
        when substr(LINEREAD.I,2,4) = 'CP1A' THEN                               
            total_dispatch_time_CP1A  = substr(lineread.i,58,12)                
        when substr(LINEREAD.I,2,4) = 'CP1C' THEN                               
            total_dispatch_time_CP1C  = substr(lineread.i,58,12)                
        when substr(LINEREAD.I,2,4) = 'CP1D' THEN                               
            total_dispatch_time_CP1D  = substr(lineread.i,58,12)                
        when substr(LINEREAD.I,2,4) = 'CP1F' THEN                               
            total_dispatch_time_CP1F  = substr(lineread.i,58,12)                
        when substr(LINEREAD.I,2,4) = 'CP1H' THEN                               
            total_dispatch_time_CP1H  = substr(lineread.i,58,12)                
        when substr(LINEREAD.I,2,4) = 'CP1K' THEN                               
            total_dispatch_time_CP1K  = substr(lineread.i,58,12)                
        when substr(LINEREAD.I,2,4) = 'CP1L' THEN                               
            total_dispatch_time_CP1L  = substr(lineread.i,58,12)                
        when substr(LINEREAD.I,2,4) = 'CP1S' THEN                               
            total_dispatch_time_CP1S  = substr(lineread.i,58,12)                
        when substr(LINEREAD.I,2,4) = 'CP1U' THEN                               
            total_dispatch_time_CP1U  = substr(lineread.i,58,12)                
        otherwise say "Skip--->" substr(lineread.i,1,122)                       
                                                                                
    END /* select  */                                                           
END I                                                                           
    "EXECIO * DISKW OUTFILE (FINIS"                                             
     IF RC = 0 THEN SAY 'RETURN FROM WRITE IS FINE ===' RC                      
     else IF RC = 1 THEN SAY 'WROTE OVER EXISTING MEMBER.'                      
          else SAY 'RETURN FROM WRITE IS NOT GOOD' RC                           
EXIT                                                                            

PS: You may want to check out Netrexx (also written by Cowlishaw). It's very 
REXX-like and generates java byte code that can run on a pc and a mainframe and 
any platform that supports the JVM, Java Virtual Machine. To be clear: the very 
same .class file can be executed with "java moduleName.class" from the windows 
command line and an OMVS terminal.


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf 
Of Graham Hobbs
Sent: Wednesday, March 27, 2013 9:34 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: PDS processing in REXX

Hello,
OK to ask for some help please, or where might I go?:-) Am not a sysprog, hope 
to be back on a z/OS machine in a short while, have to convert several ooREXX's 
to mainframe acceptability so, to save some mainframe time $'s, if I may, will 
ask neophyte questions (have googled); that said ..

.. this REXX CJM1 will run from TSO/ISPF Option 6 and is:

/* REXX CJM1 */
   CALL PARA1
   CALL PARA2
   CALL PARA3
   EXIT

/* this needs to delete an empty or non-empty PDS from existence, do I need to 
allocate etc, or will the following work? */
PARA1:
   F1 = '"ENCORE.CBL.SOURCE"'
   "DELETE "'F1'""   /* TRYING TO GET MY HEAD AROUND THESE QUOTE'Y THINGS */
   RC_REASON = 'DELETE 'F1; CALL RETCODE
   RETURN

/* this needs to
1. create a new PDS if it's not there
2. empty it if it is there
*/
PARA2:
   F2 = '"CONRAD.TEST.CPYBKS"'
   "ALLOC DA("'F2'") NEW REUSE RECFM(F B) LRECL(80)",
   "DIR(255) SPACE(50,10) TRACKS UNIT(SYSDA)"
   RC_REASON = 'ALLOC I 'F2; CALL RETCODE
   /* WISE TO FREE THIS FIRST?; IF ALLOC FAILS, CAN I ASSUME FILE NOT THERE */
   RETURN

/* this needs to read and print a PDS member; is there a 'not so crude' way */
PARA3:
   F3 = '"SUPPORT.FILE.PDS(FDQKVS)"'
   "ALLOC DDNAME(INFILE1) DSN("'F3'") SHR REUSE"
   RC_REASON = 'ALLOC I 'F3; CALL RETCODE
   /* WISE TO FREE THIS FIRST?; IF ALLOC FAILS, CAN I ASSUME FILE NOT THERE */
   F3_EOF = 'NO'
   DO WHILE F3_EOF = 'NO'
      "EXECIO 1 DISKR INFILE1"
      IF RC = 0 THEN DO
         PULL WS_INB
         SAY SUBSTR(WS_INB,1,79)
      END
      ELSE DO
         F3_EOF = 'YES'
      END
   END
   "EXECIO 0 DISKR INFILE1 (FINIS"
   RC_REASON = 'FINIS 'F3; CALL RETCODE
   "FREE DDNAME(INFILE1)"
   RC_REASON = 'FREE 'F3; CALL RETCODE
   RETURN

RETCODE:
   IF RC \= 0 THEN DO
      SAY 'E: 'RC_REASON' PROBLEM'; EXIT
   END
   ELSE DO
      SAY 'I: 'RC_REASON' OK'
   END
   RETURN

.. thanks in advance,
Graham Hobbs

PS. Not being 'deep' .. why is I/O coding different between mainframe and 
ooREXX? Did it have to be?

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to