Page 1 of 2

Code conversion issue while reading JCL using REXX

PostPosted: Fri Jun 19, 2020 10:19 pm
by vsgurunath
Hi Experts/Forum members,

For developing a REXX routine to process JCL statements to search and replace symbolic variables (with different masking format like 'YYDDD' for Julian date or 'YY-MM-DD' for Current Calendar date) in any position in the JCL statement. I have an indicator for such statements: '!' in column 66 with different codes for different date formats/values.

I will have to search for '!' to identify JCL statement with a date mask, say, 'YYDDD', then replace it with '20170' and write this JCL member into a different PDS for current day's test run.

Weirdly, when I used the REXX POS function
POS(needle,haystack[,startcix])
to search for '!' in column 66, the statement of some of the JCL members were internally converted into a different code format that left this check for '!' with incorrect result - returned as '0' even though I see '!' on that statement through 3.4 screen.

Example:
Original statement is
// OCYCLE=DXYYDDD1   CURRENT  DATE                               !AAA   00109001

TRACE result shows
// OCYCLE=DXYYDDD1?FCURRENT?CDATE?C!AAA?G00109001B//*àG00109101.


Please advise if there is any other alternative way/logic using which I can programmatically (REXX) correctly check for the code indicator on such JCL statements.

Thank you for your time and inputs,
Sivagurunathan V

Re: Code conversion issue while reading JCL using REXX

PostPosted: Fri Jun 19, 2020 10:32 pm
by Pedro
Can you clarify the origin of your JCL statement? Is it in an ISPF skeleton format?

Please use ISPF VIEW and issue the PROFILE command and show us the response.

Re: Code conversion issue while reading JCL using REXX

PostPosted: Fri Jun 19, 2020 10:33 pm
by sergeyken
Where is your code?

Re: Code conversion issue while reading JCL using REXX

PostPosted: Sat Jun 20, 2020 2:27 pm
by willy jensen
For checking a specific character in a specific position I would use the 'substr' function, i.e. if substr(rec,66,1)='!' then...
But your 'pos' should still work, so I too would like to see a snippet of your program.
Have you tried a trace around the code section?

Re: Code conversion issue while reading JCL using REXX

PostPosted: Sun Jun 21, 2020 2:58 am
by Pedro
It seems more like the data is not in the expected format.

Re: Code conversion issue while reading JCL using REXX

PostPosted: Mon Jun 22, 2020 8:29 pm
by vsgurunath
Thank you very much for your responses and my apologies for the delay. Didn't login during the weekend.

I must've gotten confused while posting this, after using different alternatives to fix/understand why such an issue was happening internally.
Seems i have used 'INDEX' and not 'POS'. Still it worked on 90% of the elements correctly and identified the indicator i was searching for.

First, answers to previously asked questions:
- The JCLs this exec is processing are manually-typed ones (not generated through Skeletons).
- This issue is not happening in all the JCL members. Only specific ones. I checked for non-readable characters using "f p'.'" command and didn't get any hit. Please let me know if I should check for more values or in a different way.

Herewith sharing the code and TRACE output I see in SYSOUT (I am executing the exec via batch):

Trace output (SYSTSPRT): The statements 120-122 are showing the issue I am trying to understand the reason for, with all your guidance.

118 *-*      DO B = 1 TO JCLSTEM.0                                          
119 *-*       CMD = "PARSE UPPER VAR JCLSTEM.B JCLSTMT"                    
    >L>         "PARSE UPPER VAR JCLSTEM.B JCLSTMT"                        
120 *-*       INTERPRET CMD                                                
    >V>         "PARSE UPPER VAR JCLSTEM.B JCLSTMT"                        
    *-*        PARSE UPPER VAR JCLSTEM.B JCLSTMT                            
    >C>          "JCLSTEM.10"                                              
    >>>          "// OCYCLE=DXYYDDD1?FCURRENT?CDATE?C!AAA?G00109001B//*.G00109101.                "
121 *-*       SYMBOLPOS  = INDEX(" !",JCLSTMT)                              
    >L>         " !"                                                        
    >V>         "// OCYCLE=DXYYDDD1?FCURRENT?CDATE?C!AAA?G00109001B//*.G00109101.                "
    >F>         "0"                                                        
122 *-*       COMMENTPOS = INDEX("//*",JCLSTMT)                            
    >L>         "//*"                                                      
    >V>         "// OCYCLE=DXYYDDD1?FCURRENT?CDATE?C!AAA?G00109001B//*.G00109101.                "
    >F>         "0"                                                        
123 *-*       IF COMMENTPOS = 0                                            
    >V>         "0"                                                        
    >L>         "0"                                                        
    >O>         "1"                                                        
    *-*        THEN                                                        
124 *-*        DO                  
125 *-*         IF SYMBOLPOS = 65  
    >V>           "0"              
    >L>           "65"            
    >O>           "0"              
132 *-*        END                
133 *-*       JCLSTMT     = " "    
    >L>         " "                
134 *-*       SYMBOLPOS   = 0      
    >L>         "0"                
135 *-*       COMMENTPOS  = 0      
    >L>         "0"                
136 *-*       JCLBANGCODE = " "    
    >L>         " "                
137 *-*      END                  
118 *-*      DO B = 1 TO JCLSTEM.0
139 *-*      TRACE OFF            


REXX Code:
I realize i have complicated a bit around the "CMD" and "INTERPRET" commands while trying to process the statements a different way using forum searches.

/* PROCESS THE JCL MEMBER FOR UPDATING BANG CODES */      
PROCESS_JCL_MEMBER:                                        
                                                           
  SAY 'PROCESSING JCL MEMBER #' RIGHT(JCLCTR2,4,0) JCLNAME
                                                           
  /* READ THE JCL MEMBER */                                
  ADDRESS TSO                                              
  "ALLOC DA('"IPJCLPDS||"("||JCLNAME")') F(JCLMEM) SHR REU"
  "EXECIO * DISKR JCLMEM(STEM JCLSTEM. FINIS"              
  "FREE FI(JCLMEM)"                                        
                                                           
SYMBOLPOS  = 0                                                    
COMMENTPOS = 0                                                    
JCLBANGCODE = " "                                                  
                                                                   
IF JCLNAME = 'PAM296QF' | JCLNAME = 'PAM296QE' THEN                
   DO                                                              
      TRACE I                                                      
   END                                                            
                                                                   
DO B = 1 TO JCLSTEM.0                                              
   CMD = "PARSE UPPER VAR JCLSTEM.B JCLSTMT"                      
   INTERPRET CMD                                                  
   SYMBOLPOS  = INDEX(" !",JCLSTMT)                                
   COMMENTPOS = INDEX("//*",JCLSTMT)                              
   IF COMMENTPOS = 0 THEN                                          
      DO                                                          
         IF SYMBOLPOS = 65 THEN                                    
            DO                                                    
               SAY 'JCL' JCLSTMT                                  
               JCLBANGCODE = STRIP(SUBSTR(JCLSTMT,SYMBOLPOS + 1,5))
               SAY JCLBANGCODE                                    
      /*         CALL FETCH_BANG_CODE */
              END                      
        END                            
     JCLSTMT     = " "                  
     SYMBOLPOS   = 0                    
     COMMENTPOS  = 0                    
     JCLBANGCODE = " "                  
  END                                  
                                       
  TRACE OFF                            
RETURN
 


Please let me know if this makes any sense to you. I wish to ensure that the tool doesn't encounter this scenario as we're planning to schedule this as a batch.

Re: Code conversion issue while reading JCL using REXX

PostPosted: Mon Jun 22, 2020 9:38 pm
by willy jensen
It is overly complicated. If all you want to do is to test if '!' is found in col 66 then I suggest that you do somthing like:
DO B = 1 TO JCLSTEM.0
   if substr(jclstem.b,66,1)='!' then do
     ....
   end
 END

I don't see the reason for up-casing, at least not for testing the exclamation mark.
Your test is not for '!' in col 66, it is for ' !' in col 65-66, which probably is why it works sometimes but not all the time.

Re: Code conversion issue while reading JCL using REXX

PostPosted: Mon Jun 22, 2020 11:30 pm
by Pedro
This issue is not happening in all the JCL members. Only specific ones.

You do not have a rexx problem... the problem you have is that the data is not in the format that you expect it to be in. Clearly, the data is previously stored in same way that is not known to us.

Please use ISPF VIEW for the data and scroll to the " OCYCLE=DXYYDDD1" line and issue the PROFILE command and show us the screen capture. I do not believe your 'original statement' from your post.

Example:
Original statement is
// OCYCLE=DXYYDDD1   CURRENT  DATE                               !AAA   00109001


TRACE result shows
// OCYCLE=DXYYDDD1?FCURRENT?CDATE?C!AAA?G00109001B//*àG00109101.


My recommendation is the edit those members and manually fix them the match the format you expect.

Re: Code conversion issue while reading JCL using REXX

PostPosted: Tue Jun 23, 2020 1:34 am
by sergeyken
In other words: the input data pretending to be JCL, are actually not in JCL format!

Re: Code conversion issue while reading JCL using REXX

PostPosted: Wed Jun 24, 2020 1:57 pm
by enrico-sorichetti
looks like ISPF packed data to me

edit the ones giving the error and use the command
PACK OFF