/*  REXX  */          
parse arg input                                                                 
                                                                                
"del 'user01.gtfsvc.csv'"                    /* Delete and reallocate output file  */
"alloc fi(csvout) da('user01.gtfsvc.csv') unit(sysda) space(15 15)",
      "track new catalog lrecl(60) blksize(18000) recfm(f b) release"                                                                                
csvout.1 = "SVC,Job Name,PSW,TCB"            /*  Write column headers  */
"execio 1 diskw csvout (stem csvout."                                           
                                                                                
"EXECIO 1 DISKR gtfin (stem gtfin."          /*  Top of input loop  */
do while(rc = 0)                                                                
   if index(gtfin.1, 'SVC.....') > 0 then,   /*  Beginning of an entry */                                     
      do                                                                        
         firstWord = 2                                                          
         if word(gtfin.1, 1) = '1' then,     /*  Deal with page ejects */   
            do                                                                  
               firstWord = 3                                                    
            end                                                                 
         svc = word(gtfin.1, firstWord)      /*  Get SVC, job name and PSW  */
         jobname = word(gtfin.1, firstWord+6)                                   
         psw = word(gtfin.1, firstWord + 8) || ' ' || word(gtfin.1, firstWord+9)
         "EXECIO 1 DISKR gtfin (stem gtfin." /*  Get next line for TCB address  */                                    
         if word(gtfin.1, 1) = '1' then,     /*  Again with the page ejects?  */                                        
            do                                                                  
               tcb = word(gtfin.1, 3)                                           
            end                                                                 
         else,                                                                  
            do                                                                  
               tcb = word(gtfin.1, 2)                                           
            end                                                                 
         csvout.1 = svc || ',' || jobname || ',' || psw || ',' tcb              
         "execio 1 diskw csvout (stem csvout." /*  Build and write output  */
      end                                                                       
   "EXECIO 1 DISKR gtfin (stem gtfin."         /*  Get next line  */
end                                                                             
                                                                                
queue                                          /*  It's all over, go home  */
address tso                                                                     
"execio * diskr gtfin (finis)"                                                  
"execio * diskW csvout (finis)"                                                 
"free fi(csvout)"                          


This was first published in March 2010

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.