/* rexx */                                                                      
/*-------------------------------------------------------------------*/         
/*                                                                   */         
/*                        REXX Exec : FIXPREP                        */         
/*                                                                   */         
/*                      ***** Edit Macro *****                       */         
/*                                                                   */         
/*  Description : Apply fix to ISPPREPA Panel to save input and      */         
/*                output datasets.                                   */         
/*                                                                   */         
/*  Created on : 11 Sep 2023                                         */         
/*  Created by : Wendy Miller                                        */         
/*             : Userid MIT002                                       */         
/*             : Using ABBYDALE.DEVL.EMACS(FIXPREP)                  */         
/*                                                                   */         
/*  Called by : Nothing                                              */         
/*                                                                   */         
/*  Calls :                                                          */         
/*                                                                   */         
/*  Panels Used : ISPPREPA changed by this macro                     */         
/*                                                                   */         
/*  Change Activity :                                                */         
/*                                                                   */         
/*                ©Copyright of Abbydale Systems LLC.                */         
/*                                                                   */         
/*-------------------------------------------------------------------*/         
Parse Arg Help         /* Check for Help */                                     
If SYSVAR("SYSISPF")<>"ACTIVE" then do                                          
   Say "ISPF must be active to use "FIXPREP                                     
   exit(16)                                                                     
end                                                                             
Address ISREDIT "MACRO NOPROCESS"                                               
Address ISREDIT "(mac) = MACRO_LEVEL"                                           
if mac = "MAC" then do                                                          
   ZEDSMSG = 'Not run'                                                          
   ZEDLMSG = 'This is an edit macro. Invalid call'                              
   Address ISPEXEC "SETMSG MSG(ISRZ001)"                                        
   exit(16)                                                                     
end                                                                             
indsn = "ZPREPIN"                                                               
outdsn = "ZPREPOUT"                                                             
"ISREDIT FIND 'ZWINTTL' FIRST"    /* look for the string */                     
If rc = 0 then do                                                               
   Address ISREDIT "(CR, CC) = CURSOR"                                          
   Address ISREDIT "(Tri) = LINE" cr                                            
   if pos("ISPPREP",tri) > 0 then do                                            
      Address ISREDIT "(CR, CC) = CURSOR"                                       
      Address ISREDIT "(temp) = LINE" cr+1                                      
      if pos("VGET",temp) <> 0 then do                                          
         ZEDSMSG = 'Fix already on'                                             
         ZEDLMSG = 'Fix has already been applied. Return code 16'               
         Address ISPEXEC "SETMSG MSG(ISRZ001)"                                  
         exit(16)                                                               
      end                                                                       
      else do                                                                   
         gets = '"VGET ('indsn outdsn') PROFILE"'                               
         puts = '"VPUT ('indsn outdsn') PROFILE"'                               
         Address ISREDIT "LINE_AFTER" cr "=" gets                               
         Address ISREDIT "RESET FIND"                                           
         "ISREDIT FIND ')END' FIRST"                                            
         Address ISREDIT "(CR, CC) = CURSOR"                                    
         If rc = 0 then do                                                      
            Address ISREDIT "LINE_BEFORE" cr "=" puts                           
            ZEDSMSG = 'Fix applied'                                             
            ZEDLMSG = 'The fix was successfully applied'                        
            Address ISPEXEC "SETMSG MSG(ISRZ001)"                               
            exit(0)                                                             
         end                                                                    
      end                                                                       
   end                                                                          
end                                                                             
ZEDSMSG = 'Not PREP panel'                                                      
ZEDLMSG = 'The panel is not ISPPREPA. Return code 8'                            
Address ISPEXEC "SETMSG MSG(ISRZ001)"                                           
Address ISREDIT "RESET FIND"                                                    
exit(8)                                                                         
/*-------------------------------------------------------------------*/         
/*                          End of FIXPREP                           */         
/*-------------------------------------------------------------------*/         

