/* REXX */                                                                      
/*                                       */                                     
/* AUTHOR: Mark Zelden                   */                                     
/*                                       */                                     
/* Last update:  05/15/2002              */                                     
/*****************************************************************/             
/*  XEDIT - EDIT a data set from anywhere.                       */             
/*                                                               */             
/*  Best used when set up in the ISPF command table with an      */             
/*  abbreviation of "XE".                                        */             
/*    VERB      T   ACTION                                       */             
/*    XEDIT     2   SELECT CMD(%XEDIT &ZPARM) NEWAPPL(ISR)       */             
/*                                                               */             
/*  Fully qualified data set names are now optional, regardless  */             
/*  of the TSO PROFILE PREFIX setting. PREFIX.DATA.SET.NAME will */             
/*  be tried first, then DATA.SET.NAME for data sets that are    */             
/*  not fully qualified.                                         */             
/*                                                               */             
/*****************************************************************/             
/* COMMAND SYNTAX:                                               */             
/*                                                               */             
/*  XE DATA.SET.NAME  <volser>    (VOLSER is optional)           */             
/*                                                               */             
/*  XE 'MY.PDS(ABC*)'                                            */             
/*  XE PDS.NOTCAT USER01                                         */             
/*                                                               */             
/*  If not set up as an ISPF command, then you can still         */             
/*  invoke the exec by typing:   TSO %XEDIT DATA.SET.NAME        */             
/*****************************************************************/             
Parse UPPER ARG DSN VOL                                                         
                                                                                
If DSN= '' then do                          /* no DSN specified      */         
  say 'Please enter positional parameter dsn -' /* prompt for dsn    */         
  parse upper pull DSN                      /* get dsn response      */         
End                                                                             
                                                                                
Address ISPEXEC                                                                 
"CONTROL ERRORS RETURN"                                                         
"VGET ZPCFMCN PROFILE"                                                          
If ZPCFMCN = '/' then CONF = 'YES'                                              
 else CONF = 'NO'                                                               
/************************************/                                          
/* check if EDIT RECOVERY is needed */                                          
/************************************/                                          
EDITOK = 'NOTOK'                                                                
Do while EDITOK = 'NOTOK'                                                       
  "EDREC QUERY"                                                                 
  If RC = 4 then do                                                             
    "DISPLAY PANEL(ISREDM02)"                                                   
    DISPRC = RC                                                                 
    "VGET ZVERB"                                                                
     If DISPRC = 0 then do                                                      
       If ZEDCMD = '' then "EDREC PROCESS PASSWORD(" || PSWD || ")"             
       If ZEDCMD = 'C' then "EDREC CANCEL"                                      
       If ZEDCMD = 'D' then "EDREC DEFER"                                       
     End                                                                        
     Else if DISPRC = 8 & ZVERB = 'CANCEL' then "EDREC CANCEL"                  
     Else EXIT 0                                                                
  End                                                                           
  Else EDITOK = 'OK'                                                            
End                                                                             
RC = 0                                                                          
/************************************/                                          
/* end of RECOVERY CHECK            */                                          
/************************************/                                          
"EDIT DATASET("DSN") VOLUME("VOL")" ,       /* try userid.DSN first  */         
"CONFIRM("CONF")"                                                               
If RC = 4 then RC = 0                                                           
If RC <> 0 then do                          /* not found - try again */         
   DSN =  Strip(Translate(DSN,"","'"))      /* remove quotes if used */         
  "EDIT DATASET('"DSN"') VOLUME("VOL")" ,   /* try DSN specified     */         
  "CONFIRM("CONF")"                                                             
End                                                                             
If RC = 4 then RC = 0                                                           
If RC <> 0 then "SETMSG MSG("ZERRMSG")"     /* not found - issue msg */         