Allow interactive job to utilize batch CPU

Here you'll learn how to get interactive job to utilize the batch CPU.

Program A1, given program name and parameter, submit job to call A2, wait for completion using DTAQ QLIB/DTAQ (can be parameterized) and then pass back control to calling program with updated parameter. (The program assume default for parameters SYSLIBLCURLIB and INLLIBL of SBMJOB is *CURRENT)

Program A2, given program name, call the program (parameter value get from DTAQ). Afterward, acknowledge A1 and pass back parameter through DTAQ.

Program B, just a little program to manipulate DTAQ.

In future, instead of Call X parm(Y), change to Call A1 parm(X Y), then batch CPU will be utilized.


  
		
*--------------------------------------------------------------------*
* Program A1                                                         *
*--------------------------------------------------------------------*
        PGM        PARM(&PGID &PARM)                                   
                                                                        
        DCL        VAR(&PGID   ) TYPE(*CHAR) LEN(10)                   
        DCL        VAR(&PARM   ) TYPE(*CHAR) LEN(9999)                 
                                                                        
        DCL        VAR(&DTAQ   ) TYPE(*CHAR) LEN(10 ) VALUE('DTAQ')
        DCL        VAR(&QLIB   ) TYPE(*CHAR) LEN(10 ) VALUE('QLIB')                 
        DCL        VAR(&WAITSEC) TYPE(*DEC ) LEN(5 0) VALUE(99999)     
        DCL        VAR(&KVAL   ) TYPE(*CHAR) LEN(20)                   
        DCL        VAR(&JOBNBR ) TYPE(*CHAR) LEN(6)                    
                                                                        
        RTVJOBA    NBR(&JOBNBR)                                        
        CHGVAR     &KVAL  ('OUT' *CAT &JOBNBR)                          
        CALL       DTAQCL ('CLR' &DTAQ &QLIB &WAITSEC &KVAL &PARM)   
        CHGVAR     &KVAL  ('IN'  *CAT &JOBNBR)                           
        CALL       DTAQCL ('CLR' &DTAQ &QLIB &WAITSEC &KVAL &PARM)   
        CALL       DTAQCL ('SND' &DTAQ &QLIB &WAITSEC &KVAL &PARM)  
                                                                      
        SBMJOB     CMD(CALL PGM(A2) PARM(&JOBNBR &PGID)) JOBQ(QINTER) 
                                                                      
        CHGVAR     &KVAL  ('OUT' *CAT &JOBNBR)                         
        CALL       DTAQCL ('RCV' &DTAQ &QLIB &WAITSEC &KVAL &PARM)  
                                                                      
        ENDPGM         


*--------------------------------------------------------------------*
* Program A2                                                         *
*--------------------------------------------------------------------*
        PGM        PARM(&JOBNBR &PGID)                                
                                                                      
        DCL        VAR(&JOBNBR) TYPE(*CHAR) LEN(6)                    
        DCL        VAR(&PGID  ) TYPE(*CHAR) LEN(10)                   
                                                                      
        DCL        VAR(&PARM   ) TYPE(*CHAR) LEN(9999)                
        DCL        VAR(&DTAQ   ) TYPE(*CHAR) LEN(10) VALUE('DTAQ')
        DCL        VAR(&QLIB   ) TYPE(*CHAR) LEN(10) VALUE('QLIB')                 
        DCL        VAR(&WAITSEC) TYPE(*DEC ) LEN(5 0) VALUE(99999)    
        DCL        VAR(&KVAL   ) TYPE(*CHAR) LEN(20)                  
                                                                      
        CHGVAR     &KVAL  ('IN' *CAT &JOBNBR)                          
        CALL       DTAQCL ('RCV' &DTAQ &QLIB &WAITSEC &KVAL &PARM)  
                                                                      
        CALL       PGM(&PGID) PARM(&PARM)                             
                                                                      
        CHGVAR     &KVAL  ('OUT' *CAT &JOBNBR)                         
        CALL       DTAQCL ('SND' &DTAQ &QLIB &WAITSEC &KVAL &PARM)  
                                                                      
        ENDPGM                                                        


*--------------------------------------------------------------------*
* Program DTAQCL                                                     *
*--------------------------------------------------------------------*
        PGM        PARM(&ACTION &DTAQ &QLIB &WAITSEC &KVAL &PARM)  
                                                                   
        DCL        VAR(&ACTION ) TYPE(*CHAR) LEN(3)                
        DCL        VAR(&DTAQ   ) TYPE(*CHAR) LEN(10 )              
        DCL        VAR(&QLIB   ) TYPE(*CHAR) LEN(10 )              
        DCL        VAR(&WAITSEC) TYPE(*DEC ) LEN(5 0)              
        DCL        VAR(&KVAL   ) TYPE(*CHAR) LEN(20)               
        DCL        VAR(&PARM   ) TYPE(*CHAR) LEN(9999)             
                                                                   
        DCL        VAR(&FLEN   ) TYPE(*DEC ) LEN(5 0) VALUE(9999)  
        DCL        VAR(&OPER   ) TYPE(*CHAR) LEN(2)   VALUE('EQ')  
        DCL        VAR(&KLEN   ) TYPE(*DEC ) LEN(3 0) VALUE(20)    
        DCL        VAR(&SLEN   ) TYPE(*DEC ) LEN(3 0) VALUE(0)     
        DCL        VAR(&SVAL   ) TYPE(*CHAR) LEN(10)               
        DCL        VAR(&ERR    ) TYPE(*CHAR) LEN(16)               
        DCL        VAR(&X      ) TYPE(*DEC ) LEN(2 0)              
                                                                   
        IF         (&ACTION='CLR') THEN(GOTO CLRDTAQ)              
        IF         (&ACTION='RCV') THEN(GOTO RCVDTAQ)              
        IF         (&ACTION='SND') THEN(GOTO SNDDTAQ)              
        GOTO       ENDDTAQ                                         
                                                                   
CLRDTAQ:                                                           
        CALL       QCLRDTAQ (&DTAQ &QLIB &OPER &KLEN &KVAL &ERR)   
        GOTO       ENDDTAQ                                         
                                                                    
RCVDTAQ:                                                            
        CALL       QRCVDTAQ (&DTAQ &QLIB &FLEN &PARM +              
                     &WAITSEC &OPER &KLEN &KVAL &SLEN &SVAL)        
        GOTO       ENDDTAQ                                          
                                                                    
SNDDTAQ:                                                            
        CALL       QSNDDTAQ (&DTAQ &QLIB &FLEN &PARM &KLEN &KVAL)   
        GOTO       ENDDTAQ                                          
                                                                    
ENDDTAQ:                                                              
        ENDPGM   

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

This was first published in January 2002

Dig deeper on iSeries CL programming

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close