0

I am trying to build a REXX program to create a job with a passed element name within it. I originally had the program set up to receive the element name as a passed parameter, however, because I am running the REXX within an Endevor processor, I have to call the REXX differently and can't pass a parameter. I have set up the REXX to open a file where I have placed the element name. I then am trying to allocate the file, read it, and place the record (which has the element name) into a variable. I am getting a 'bad arithmetic conversion'. Doesn't Parm.0 have the value of the last record in the input file (if I have one record, then parm.0 would be equal to 1)? I am new to REXX and don't know how to set up the file read. Any help would be appreciated.

Here is the program:

/* REXX */                                                         
/*                                                                 
PARSE UPPER ARG ELEMENT                                            
*/                                                                 
TRACE !R                                                           
CALL GET_ELEMENT                                                   
QUOTE = "'"                                                        
QUEUE '//ENSETTV3 JOB ,TSDSMPR.27,                               ' 
QUEUE '//             CLASS=C,PRTY=1,                            ' 
QUEUE '//*            TYPRUN=HOLD,                               ' 
QUEUE '//             MSGLEVEL=1,                                ' 
QUEUE '//             MSGCLASS=P,                                ' 
QUEUE '//             NOTIFY=&SYSUID,                            ' 
QUEUE '//             REGION=4096K                               ' 
QUEUE '/*XEQ      N11                                            ' 
QUEUE '//DELETEIT EXEC PGM=IDCAMS                                ' 
QUEUE '//SYSPRINT DD  SYSOUT=*                                   ' 
QUEUE '//SYSIN    DD  *                                          ' 
QUEUE '  DEL-                                                    ' 
Q_LINE = 'SCM.XCST.T.XXXXX.LOADLIB('"ELEMENT"')-'                  
SAY Q_LINE                                                         
QUEUE Q_LINE                                                       
QUEUE '    PURGE                                                 ' 
QUEUE '  DEL-                                                    ' 
Q_LINE = 'SCM.XCST.T.XXXXX.LOADIMS('"ELEMENT"')-'                  
SAY Q_LINE                                                         
QUEUE Q_LINE                                                       
QUEUE '    PURGE                                                 '
QUEUE '/*                                                        '
QUEUE '//                                                        '
ADDRESS TSO "EXECIO" QUEUED() "DISKW OUTJCL (FINIS"               
EXIT(0)                                                           
                                                                  
GET_ELEMENT:                                                      
SAY 'GET_ELEMENT'                                                 
  DATASET_NAME = 'NDV.D000000.T000000.CONNCMD.FILE(ELEMENT)'      
   "ALLOC DD(PARMS) DA("DATASET_NAME") SHR REUS"                  
  'EXECIO * DISKR PARMS     (STEM PARM. FINIS'                    
    DO P = 1 TO PARM.0              /* !  P LOOP */               
      INTERPRET PARM.P                                          
      ELEMENT = PARM.P                                            
    END                                                           
RETURN 

                                                       

Here is what I am getting when I execute the REXX program:

      6 *-* CALL GET_ELEMENT                                                    
     34 *-*  GET_ELEMENT:                                                       
     35 *-*  SAY 'GET_ELEMENT'                                                  
        >>>    "GET_ELEMENT"                                                    
 GET_ELEMENT                                                                    
     36 *-*  DATASET_NAME = 'NDV.D000000.T000000.CONNCMD.FILE(ELEMENT)'         
        >>>    "NDV.D000000.T000000.CONNCMD.FILE(ELEMENT)"                      
     37 *-*  "ALLOC DD(PARMS) DA("DATASET_NAME") SHR REUS"                      
        >>>    "ALLOC DD(PARMS) DA(NDV.D000000.T000000.CONNCMD.FILE(ELEMENT)) SH
 R REUS"                                                                        
     38 *-*  'EXECIO * DISKR PARMS     (STEM PARM. FINIS'                       
        >>>    "EXECIO * DISKR PARMS     (STEM PARM. FINIS"                     
     39 *-*  DO P = 1 TO PARM.0              /* !  P LOOP */                    
        >>>    "1"                                                              
        >>>    "PARM.0"                                                         
     39 +++   DO P = 1 TO PARM.0              /* !  P LOOP */                   
      6 +++ CALL GET_ELEMENT                                                    
 IRX0041I Error running VOSBDELT, line 39: Bad arithmetic conversion     

   
                                                                    

Edited: I gave up trying to get the Do loop to work and instead just tried to work with line one of the input file, which I renamed to in_file.

I now have the following:

GET_ELEMENT:                                                   
SAY 'GET_ELEMENT'                                              
  DATASET_NAME = 'NDV.D000000.T000000.CONNCMD.FILE(ELEMENT)'   
  "ALLOC DD(INFILE) DA('"DATASET_NAME"') SHR REUS"             
  "EXECIO * DISKR INFILE    (FINIS STEM IN_FILE."              
/*  DO P = 1 TO IN_FILE.0         */                           
/*    INTERPRET IN_FILE.P         */                           
/*    ELEMENT = IN_FILE.P         */                           
/*  END                           */                           
  P = 1                                                        
  ELEMENT = LEFT(IN_FILE.P,8)                                  
  INTERPRET ELEMENT                                            
  "FREE FI(INFILE)"                                            
RETURN                                                         

This is what I get when I execute:

     6 *-* CALL GET_ELEMENT                                                    
    34 *-*  GET_ELEMENT:                                                       
    35 *-*  SAY 'GET_ELEMENT'                                                  
       >>>    "GET_ELEMENT"                                                    
GET_ELEMENT                                                                    
    36 *-*  DATASET_NAME = 'NDV.D000000.T000000.CONNCMD.FILE(ELEMENT)'         
       >>>    "NDV.D000000.T000000.CONNCMD.FILE(ELEMENT)"                      
    37 *-*  "ALLOC DD(INFILE) DA('"DATASET_NAME"') SHR REUS"                   
       >>>    "ALLOC DD(INFILE) DA('NDV.D000000.T000000.CONNCMD.FILE(ELEMENT)')
 SHR REUS"                                                                     
    38 *-*  "EXECIO * DISKR INFILE    (FINIS STEM IN_FILE."                    
       >>>    "EXECIO * DISKR INFILE    (FINIS STEM IN_FILE."                  
    39 *-*  /*  DO P = 1 TO IN_FILE.0         */                               
    40 *-*  /*    INTERPRET IN_FILE.P         */                               
    41 *-*  /*    ELEMENT = IN_FILE.P         */                               
    42 *-*  /*  END                           */                               
    43 *-*  P = 1                                                              
       >>>    "1"                                                              
    44 *-*  ELEMENT = LEFT(IN_FILE.P,8)                                        
       >>>    "IN_FILE."                                                       
    45 *-*  INTERPRET ELEMENT                                                  
       >>>    "IN_FILE."                                                       
       *-*   IN_FILE.                                                          
       >>>     "IN_FILE."                                                      
    46 *-*  "FREE FI(INFILE)"                                                  
       >>>    "FREE FI(INFILE)"                                                
    47 *-*  RETURN                                                             

Instead of showing the element name from line 1 of in_file, which happens to be 'zoscbl19', it instead shows 'in_file.' What am I doing wrong?


Edited again: I changed my function to the following. I no longer abend. I added "in_file. = ''" to clear out the value and set it to blanks. I also checked the return code after the execio and it is zero, so the read is working but it still doesn't actually return line 1's value of zoscbl19.

GET_ELEMENT:                                                 
SAY 'GET_ELEMENT'                                            
DATASET_NAME = 'NDV.D000000.T000000.CONNCMD.FILE(ELEMENT)'   
"ALLOC DD(INFILE) DA('"DATASET_NAME"') SHR REUS"             
IN_FILE. = ''                                                
"EXECIO * DISKR INFILE    (FINIS STEM IN_FILE."              
SAY RC                                                       
IF RC = 0 THEN                                               
  DO                                                         
    "FREE FI(INFILE)"                                        
    ELEMENT = LEFT(IN_FILE.1,8)                              
    SAY 'ELEMENT:' ELEMENT                                   
  END                                                        
ELSE                                                         
  SAY 'RETURN CODE IS ' RC                                   
RETURN                                                       

2 Answers2

0

You are reading the file into stem variable INFILE

"EXECIO * DISKR INFILE    (FINIS STEM IN_FILE." 

Then you try to access stem variable IN_FILE

ELEMENT = LEFT(IN_FILE.P,8)            

change to

ELEMENT = LEFT(INFILE.P,8)            

Other issue

Q_LINE = 'SCM.XCST.T.XXXXX.LOADLIB('"ELEMENT"')-'      

is probably wrong it should either be

Q_LINE = 'SCM.XCST.T.XXXXX.LOADLIB('ELEMENT')-'   

or Q_LINE = "'SCM.XCST.T.XXXXX.LOADLIB("ELEMENT")-'

similarly

Q_LINE = 'SCM.XCST.T.XXXXX.LOADIMS('"ELEMENT"')-'               
Bruce Martin
  • 10,358
  • 1
  • 27
  • 38
  • 1
    No with regrds to infile and in_file. INFILE is the DDNAME being read and in_file. is the stem into which the data is being read. What is wrong is that the return code from the EXECIO is not being checked so we do not know if it even executed properly - it didn't as there is no stem created. – NicC Jul 31 '20 at 09:59
  • I changed the function to check the return code, which comes back as 0. I also added "in_file. = ''" before the execio, to blank out in_file. I am able to execute the rexx however it has blanks where the element value, which is zoscbl19, should be, so the read still isn't working. – Monica Collins Jul 31 '20 at 17:25
  • Are you sure that the dataset(member) that you are browsing with ISPF is the same as the one specified in the program, It actually looks as though the dataset name is a temporary one - is it? Another thing you can try is to run the exexc in batch and use JCL to allocate the dataset (remove/comment out the code in the exec). – NicC Jul 31 '20 at 21:12
  • I have tried 'element = left(infile.1,8)' and 'element = left(in_file.1,8)' and both display 'infile.1' and 'in_file,1' and not what is actually in the record. That is the correct dataset and it has a record in it, with a value. – Monica Collins Aug 03 '20 at 15:01
  • Are you sure that you have signed out of Endevor then browsed/viewed that dataset(member)? The fact that EXECIO gives an RC=0 and no data suggests that the member is empty when the exec is running. A wrong dataset name or member name would give errors but an empty one should not error. As an extra diagnostic you should display in_file.0 – NicC Aug 04 '20 at 10:10
0

I haven't followed all of the edits to your code, so I'm not sure what you are doing wrong, but for reading a member from a PDS in REXX this works (I've just run it):

/* REXX */                                    
                                              
INPUT_FILE = 'JOCS065.STEVE.DATA(ELEMENT)'    
"ALLOC DD(INPUT) DS('"INPUT_FILE"') SHR"      
"EXECIO * DISKR INPUT (STEM input_fi. FINIS)" 
                                              
do i = 1 to input_fi.0                        
  say input_fi.i                              
  end                                         
                                              
"FREE DD(INPUT)"                              
                                              
exit  

STEVE.DATA is a pretty normal PDS - LRECL 80, RECFM FB - with a member 'ELEMENT' containing a single line:

VIEW       JOCS065.STEVE.DATA(ELEMENT) - 01.00                     Columns 00001 00080 
Command ===>                                                          Scroll ===> CSR  
****** ********************************* Top of Data **********************************
000001 MEMBER1                                                                         
****** ******************************** Bottom of Data ********************************

When EXecuted, it simply prints:

MEMBER1    
 

Edit:

I've just run your last code, substituting in my own input file:

/* REXX */

GET_ELEMENT:                                     
SAY 'GET_ELEMENT'                                
DATASET_NAME = 'JOCS065.STEVE.DATA(ELEMENT)'     
"ALLOC DD(INFILE) DA('"DATASET_NAME"') SHR REUS" 
IN_FILE. = ''                                    
"EXECIO * DISKR INFILE    (FINIS STEM IN_FILE."  
SAY RC                                           
IF RC = 0 THEN                                   
  DO                                             
    "FREE FI(INFILE)"                            
    ELEMENT = LEFT(IN_FILE.1,8)                  
    SAY 'ELEMENT:' ELEMENT                       
  END                                            
ELSE                                             
  SAY 'RETURN CODE IS ' RC                       
RETURN       

and I get:

GET_ELEMENT     
0               
ELEMENT: MEMBER1

which is the data in (ELEMENT).

Steve Ives
  • 7,894
  • 3
  • 24
  • 55