BSLJX05B TITLE 'JES2 Command Preprocessor Exit (EXIT # 5)'                      
***********************************************************************         
*                                                                     *         
* This exit preprocesses the JES2 release command for releasing the   *         
* /*AFTER condition on a JOB to enable it to run without running the  *         
* job specified on the /*AFTER card. Without this exit the JOB would  *         
* remain on the queue and never process unless the pre-req job ran.   *         
*                                                                     *         
*     NOTE -  This exit will not be taken if the current command      *         
*             being processed is the special start init command.      *         
*                                                                     *         
* Register usage (Entry/Exit) :                                       *         
*                                                                     *         
*    Reg       Value on entry                                         *         
*                                                                     *         
*    R0        0                                                      *         
*    R1        Address of parameter list                              *         
*    R2-R10    n/a                                                    *         
*    R11       Address of HCCT                                        *         
*    R12       n/a                                                    *         
*    R13       Address of available save area                         *         
*    R14       Return address                                         *         
*    R15       Entry address                                          *         
*                                                                     *         
*    Reg       Value on exit                                          *         
*                                                                     *         
*    R0-R14    Unchanged                                              *         
*    R15       Return code (0)                                        *         
*                                                                     *         
* PARAMETER LIST :                                                    *         
*                                                                     *         
*        (+0)   Type of processing indicator                          *         
*                0 - Caller ID job termination (JOB/STC/TSU/XBM is    *         
*                    Terminating)                                     *         
*                4 - Caller is return ID (SYSLOG is terminating)      *         
*                8 - Caller is HASPAM (JOBLET is terminating)         *         
*               12 - Caller is JOB select (JOB/STC/TSU unable to      *         
*                    obtain resource                                  *         
*               20 - Caller is HASPAM (JOBLET is unable to restart    *         
*                    JOB because resources cannot be obtained).       *         
*        (+1)   Reserved                                              *         
*        (+2)   Response byte (Composed of bits 0-7).                 *         
*                Bits 0-6 - Reserved for future use                   *         
*                Bit  7   - If 1, Suppress JES2 JOB termination msg.  *         
*                           If 0, Issue JES2 JOB termination msg.     *         
*        (+3)   Reserved                                              *         
*        (+4)   Address of SJB                                        *         
*        (+8)   Address of JCT or Zero                                *         
*                                                                     *         
* Return codes (R15 on exit) :                                        *         
*                                                                     *         
*         0 - Normal JES2 processing resumes                          *         
*         4 - Same as 0 Execpt no further exits are to be called      *         
*         8 - Perform $CRET Normal return -- (Deletes the command)    *         
*        12 - Issue $CRET OK message                                  *         
*        16 - Issue $CRET message -- Text in 'COMMAND' area message   *         
*                                    length in R0                     *         
*                                                                     *         
***********************************************************************         
         COPY  $HASPGBL            Include the JES2 Global values               
BSLJX05B $MODULE SYSP=(GEN,GEN,DATA,GEN,GEN),                          *        
               TITLE='JES2 Command Preprocessor Exit (Exit # 5)',      *        
               ENVIRON=JES2,                                           *        
               SDWA,                                                   *        
               $CATBERT,                                               *        
               $HCT,               Common storage communication table  *        
               $HCCT,              Common storage communication table  *        
               $ERA,                                                   *        
               $JQE,                                                   *        
               $PCE,                                                   *        
               $COMWORK,                                               *        
               $MIT,               Module information table            *        
               $QSE,                                                   *        
               $PRE,                                                   *        
               $HASPEQU,           HASP equates                        *        
               $USERCBS,                                               *        
               RMode=ANY           Load program above the line                  
         TITLE 'JES2 COMMAND PREPROCESSOR EXIT (EXIT # 5)'                      
EXIT05C  $ENTRY BASE=R12                                                        
         $SAVE                                                                  
         LR    R12,R15             Load base register (R12)                     
***********************************************************************         
*              Establish ESTAE Environment                            *         
***********************************************************************         
         L     R14,=A(XCOMRCVR)    R14 => Recovery entry point                  
        $ESTAE RECADDR=(R14)       Create ESTAE environment                     
         TM    COMGFLG1,COMG1SSI   Is this an SSI formatted command?            
         BO    X005RC00            Yes - go drop out of exit                    
***********************************************************************         
*      Move portion of command currently being processed into the     *         
*      PRE (Pretrack) for the processor recovery routine (XCOMRCVR)   *         
***********************************************************************         
         L     R14,PCEPRE          Get address of PCE                           
         USING PRE,R14             ... and establish addressability             
         MVC   PRETRACK(CCMDLN),COMMAND  Move the command to PRE                
         MVI   PRELOGLN,CCMDLN     Set length for LOGREC                        
         DROP  R14                 Kill addressability to PRE                   
         CLC   =C'AJ',COMVERB      Is it a release command?                     
         BE    ANAJ                Yes - Go and process the command             
***********************************************************************         
*        Return routines                                              *         
***********************************************************************         
X005RC00 DS    0H                                                               
         XR    R2,R2               Set RC=0                                     
         B     ESTAECAN            Branch to kill ESTAE                         
J005RC04 DS    0H                                                               
         LA    R2,4                Set RC=4                                     
         B     ESTAECAN            Branch to kill ESTAE                         
X005RC08 DS    0H                                                               
         LA    R2,8                Set RC=8                                     
         B     ESTAECAN            Branch to kill ESTAE                         
X005RC12 DS    0H                                                               
         LA    R2,12               Set RC=12                                    
         B     ESTAECAN            Branch to kill ESTAE                         
X005RC16 DS    0H                                                               
         LA    R2,16               Set RC=16                                    
         B     ESTAECAN            Branch to kill ESTAE                         
ESTAECAN DS    0H                  Cancel the ESTAE                             
         ICM   R3,B'1111',PCEPRE   Is there a PRE address?                      
         BZ    X005RTN             No - Skip the cancel of the ESTAE            
        $ESTAE CANCEL              Cancel ESTAE environment                     
X005RTN  DS    0H                                                               
        $RETURN RC=(R2)            Return to Mainline HASPCOMM                  
***********************************************************************         
*   C O M M A N D   E D I T   R O U T I N E   C O N S T A N T         *         
***********************************************************************         
CCMDLN   EQU   15                  Length of command to be moved                
***********************************************************************         
*        Release the AFTER condition command process                  *         
***********************************************************************         
ANAJ     DS    0H                  Process the $AJ command                      
         CLC   0(4,R5),0(R7)       Is there more than one operand?              
         BE    X005RC00            No - Get out and let JES handle it           
         L     R14,0(,R7)          Point to last operand                        
         CLC   =C'AFT',0(R14)      Does it say "AFT" ?                          
         BNE   X005RC00            No - Get out and let JES handle it           
         BCTR  R14,0               Back up to the comma                         
         SR    R7,R6               Adjust last operand pointer                  
         L     R1,PCELPSV          R1 => Current save area                      
         L     R1,PSVPREV-PSV(,R1) R1 => Previous save area                     
         ST    R7,PSVR7-PSV(,R1)   Save new pointer for JES to use              
         L     R1,0(,R5)           R1 -> 1ST Operand (Jnnn)                     
         XR    R0,R0               R0 = 0                                       
         LA    R1,1(,R1)           R1 -> Job number                             
CVBJOBNO DS    0H  <------------+                                               
         CLI   0(R1),C'0'         Test for numeric                             
         BL    X005RC00           If not numeric let JES process it            
         CLI   0(R1),C'9'         Test for numeric                             
         BH    X005RC00           If not numeric let JES process it            
         IC    R15,0(,R1)         Load this number                             
         N     R15,=X'0000000F'   Strip zone off it                            
         MH    R0,=H'10'          Multiply by 10                               
         AR    R0,R15             and add this digit                           
         LA    R1,1(,R1)          R1 -> next digit of JOB number               
         CR    R1,R14             Reached the end yet?                         
         BL    CVBJOBNO   ------+  No - Loop back                               
        $QLOC  (R0),X005RC00       Locate the JQE ...                           
        $QSUSE ,                   ... and get access to update it              
        $DOGJQE ACTION=(FETCH,UPDATE),JQE=(R1)                                  
         LR    R2,R0               Save the address of the JQA ...              
         USING JQE,R2              ... and address it                           
        $DOGBERT ACTION=GETOFFSET,                                     *        
               CBTYPE=JQE,                                             *        
               NAME=STQNAME,                                           *        
               ERRET=RETJQA00                                                   
         LA    R3,0(R1,R2)         Point to STQNAME extension ...               
         USING STQNAME,R3          ... and address it                           
         TM    UBRMFLAG,UBRAFT     Is the job waiting for /*AFTER?              
         BZ    RETJQA00            No - Let JES2 deal with it                   
*        IC    R0,JQEAFLG1                                                      
*        N     R0,=A(UBRAFT)                                                    
*        UNTIL (BCT,R0),DO                                                      
*        MVC   UBRAFTR(L'JQEDNAME-8),JQEDNAME+8                                 
         XC    UBRAFTR,UBRAFTR     Clear the AFTER Area                         
*        ENDDO                                                                  
         NI    UBRMFLAG,FF-UBRAFT  Turn off the /*AFTER condition               
         OI    JQEFLAG1,JQE1HLD1   Hold the JOB                                 
        $DOGJQE CBADDR=JQE,ACTION=RETURN  Return the JQE                        
         B     J005RC04            Go and let JES2 handle it                    
RETJQA00 DS    0H                                                               
        $DOGJQE CBADDR=JQE,ACTION=RETURN  Return the JQE                        
         DROP  R2,R3               Kill all addresses                           
         B     X005RC00            Go and let JES2 handle it                    
         LTORG                                                                  
***********************************************************************         
*                                                                     *         
*           XCOMRCVR - Processor recovery routine                     *         
*                                                                     *         
*        This routine will recover from program checks by discarding  *         
*        the command currently bienf processed and then branch to set *         
*        return code of 8 which will cause JES2 to ignore the command *         
*                                                                     *         
*        Registers upon Entry:                                        *         
*                                                                     *         
*            R0 - Same as at ABEND                                    *         
*            R1 - Pointer to ERA                                      *         
*      R2 - R10 - Same as at ABEND                                    *         
*           R11 - Pointer to HCT                                      *         
*           R13 - Pointer to PCE                                      *         
*           R14 - Return address                                      *         
*           R15 - Entry address                                       *         
*                                                                     *         
***********************************************************************         
XCOMRCVR $SAVE TRACE=YES           Save callers registers                       
         LR    R8,R15              Get address of recovery routine              
         DROP  R12                 Drop base addressability                     
         USING XCOMRCVR,R8         Establish recovery rotuine address           
         LR    R5,R1               Get address of ERA ...                       
         USING ERA,R5              ... and establish addressability             
         CLC   ERAESRG0,=F'12'     Is there a SDWA?                             
         BE    CPERC               No - Skip to CPER                            
         L     R3,ERASDWA          Get address of SDWA ...                      
         USING SDWA,R3             ... and establish addressability             
         L     R4,ERAPRE           Get address of PRE ...                       
         USING PRE,R4              ... and establish addressability             
***********************************************************************         
*        Test for program check  (SDWAPCHK)                           *         
***********************************************************************         
         TM    SDWAERRA,SDWAPCHK   Was this a program check?                    
         BZ    CPERC               No - Skip to CPER                            
         DROP  R3                  Kill Addressabilty to the SDWA               
***********************************************************************         
*        Now kill any multiple line WTO's in prpgress                 *         
***********************************************************************         
         TM    COMFLAG,CMBFLAGU    Test for UCMID .(own or other)               
         BZ    CSETMSG             Branch if other                              
         CLI   COMUCMA,0           Is this a multiline WTO?                     
         BZ    CSETMSG             No - Skip to CSETMSG                         
         OI    COMLINET,X'10'      Set end of line                              
         SLR   R0,R0               Set null message length                      
         BCTR  R0,0                Set length to -1 to Truncate MLWTO           
        $CWTO  L=(R0)              End any MLWTO in progress                    
         MVI   COMUCMA,X'00'       Clear UCM area so CMD terminated    +        
                                   message is not a multiline WTO               
***********************************************************************         
*        Inform operators that the command will be discarded          *         
*        'NETWORK COMMAND' will be used for SSI formatted commands.   *         
***********************************************************************         
CSETMSG  MVC   COMMAND(L'CMSGTXT),CMSGTXT   Move in message text                
         TM    COMINCON,X'80'      Is it a SSI Formatted command?               
         BZ    CPREMSG             No - Skip to CPREMSG                         
         MVC   COMMAND+L'CMSGTXT(CCMDLN),CNETCMD Move in text                   
         B     CMSGTOOP            Go to issue the message                      
CPREMSG  MVC   COMMAND+L'CMSGTXT(CCMDLN),PRETRACK Move in text                  
         DROP  R4                  Kill addressabilty for PRE                   
***********************************************************************         
*        Issue command terminated message to originating console      *         
*        and also to the master console                               *         
***********************************************************************         
CMSGTOOP $CWTO L=CMLENGTH,MSGID=691 Send message to original console            
        $WTO   COMMID,CMLENGTH+L'COMMID,JOB=NO, ... and to the master  +        
               ROUTE=$MAIN+$ERR,CLASS=$ALWAYS,PRI=$HI console too               
***********************************************************************         
*        Set up options (Resume or perculate) and return to caller    *         
***********************************************************************         
         MVC   ERAREG12,=A(EXIT05C)  Restoremainline base register              
         L     R14,=A(X005RC08)    R14 => Delete command return                 
        $SETRP RESUME=(R14)        Set resume address                           
         B     CRETURN             Now go to return                             
CPERC   $SETRP PERCOLATE           Set perculate option                         
CRETURN $RETURN TRACE=YES          Return to caller                             
         DROP  R5                  Kill ERA Addressability                      
***********************************************************************         
*        Constants for XCOMRCVR Processor recovery routine            *         
***********************************************************************         
CMSGTXT  DC    C'COMMAND TERMINATED - '                                         
CNETCMD  DC    C'NETWORK COMMAND'                                               
CMLENGTH EQU   L'CMSGTXT+CCMDLN    Total message length                         
         LTORG ,                                                                
        $MODEND ,                                                               
UCTDSECT DSECT                                                                  
         IEZBITS                                                                
         END ,                                                                  

