Page 1 of 1

REXX in batch and stand alone behaves differently.

Posted: Fri Dec 04, 2015 3:16 pm
by BappiL
Hi,

I am trying to run the following REXX using a JCL:

Code: Select all

/* REXX */                                          
"EXECIO * DISKR INFILE (STEM LINE1. FINIS"          
 J = 1                                              
DO J=1 TO LINE1.0                                  
   IF SUBSTR(LINE1.I,104,13) = 'ARCHIVE DATE:' THEN 
      DO                                            
      OUT1.J = SUBSTR(LINE1.I,104,25)              
      J=J+1                                        
      END                                          
   ELSE                                            
      J=J+1                                        
END                                                
SAY RC                                              
"EXECIO * DISKW OUTFILE (STEM OUT1. FINIS"          
"FREE F(INPF OUTPF)"                            
EXI
And the JCL is:

Code: Select all

/REXXJCL    EXEC PGM=IKJEFT01,DYNAMNBR=20                      
//SYSEXEC DD DSN=ABCD.DEFG.EXECPDS,DISP=SHR                  
//SYSPRINT DD SYSOUT=*                                        
//SYSTSPRT DD SYSOUT=*                                        
//INFILE DD DSN=ABCD.EFGH.FILE,DISP=SHR                      
//*UTFILE DD SYSOUT=*                                          
//OUTFILE DD DSN=ABCD.EFGH.OUTFILE,                          
//             DISP=(NEW,CATLG,DELETE),                        
//             SPACE=(CYL,(10,10),RLSE),                      
//             DCB=(RECFM=FBA,LRECL=133,BLKSIZE=1330,DSORG=PS) 
//SYSTSIN DD *                                                
PROFILE PREFIX(EFGH)                                        
%ABHIMAIL  
But nothing is written in output. I am getting empty output file. ABCD.EFGH.OUTFILE is empty. But when I run the EXEC individually the output comes as expected. Please help.

Re: REXX in batch and stand alone behaves differently.

Posted: Fri Dec 04, 2015 4:20 pm
by nicc
And what does your SYSTSPRT say?

Where do you initialise I as used in

Code: Select all

IF SUBSTR(LINE1.I...
and where do you increment it.

How does this differ from "stand alone" (whatever that means (foreground?) which you mention in your title?

Re: REXX in batch and stand alone behaves differently.

Posted: Fri Dec 04, 2015 4:26 pm
by enrico-sorichetti

Code: Select all

DO J=1 TO LINE1.0                                  
   IF SUBSTR(LINE1.I,
I did not comment because it looked liked a typo
( retyping rather than cut and paste )

Re: REXX in batch and stand alone behaves differently.

Posted: Fri Dec 04, 2015 4:30 pm
by nicc
Except he uses I twice. Once is forgivable but twice is "get a new job"

Re: REXX in batch and stand alone behaves differently.

Posted: Fri Dec 04, 2015 5:42 pm
by enrico-sorichetti
NOPE...
the typo was in the DO statement...
should have been

Code: Select all

DO i = .....
if the Do had been the right statement
the script would have skipped a line for each iteration

Code: Select all

J = j +1 

Re: REXX in batch and stand alone behaves differently.

Posted: Fri Dec 04, 2015 6:36 pm
by nicc
If it was a typo then he would have had an error in SYSTSPRT - if he cut and pasted from screen. If he did not cut and paste - what a wasted effort!

If his actual code was correct (do I = ...) and his first line of input was not required as output then I don't know what would have happened as OUT1 would have started at OUT1.2 at least, if not greater. What he should have done was not increment J if the input line was not required and set OUT1.0 with the value of J after all input had been processed and used OUT1.0 as the number of lines to write. OK - could have just used J but I prefer to set stem.0 and use that.

Re: REXX in batch and stand alone behaves differently.

Posted: Fri Dec 04, 2015 8:35 pm
by BappiL
Sorry for the typos. Please see the below code:

Code: Select all

/* REXX */                                          
"EXECIO * DISKR INFILE (STEM LINE1. FINIS"          
 J = 1                                              
DO J=1 TO LINE1.0                                  
   IF SUBSTR(LINE1.J,104,13) = 'ARCHIVE DATE:' THEN 
      DO                                            
      OUT1.J = SUBSTR(LINE1.J,104,25)              
      J=J+1                                        
      END                                          
   ELSE                                            
      J=J+1                                        
END                                                
SAY RC                                              
"EXECIO * DISKW OUTFILE (STEM OUT1. FINIS"          
"FREE F(INPF OUTPF)"                            
EXIT
Can the first post be corrected as well? I can't edit it now.

Re: REXX in batch and stand alone behaves differently.

Posted: Fri Dec 04, 2015 8:49 pm
by enrico-sorichetti
things are getting worse and worse

You are incrementing J twice
once in the do statement
once more with j = j + 1

so You are skipping all the odd lines