Tip

Allow interactive job to utilize 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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.