Call a user-defined exit program after a 2E generated physical file or program compilation
search cancel

Call a user-defined exit program after a 2E generated physical file or program compilation

book

Article ID: 281755

calendar_today

Updated On:

Products

CA 2E

Issue/Introduction

Can an user-defined exit program be called after a 2E generated physical file or program compilation?

Environment

CA 2E 8.7 and higher

Resolution

In summary, there are two ways to achieve the requirement

1, Alter the generation of the physical file by using option 'G' in 2E, edit the generated source by using P* and Y* compile directives after the Z* lines.

Any Y* or P* directives that appear before the first Z* directive will be processed before the source member is compiled.

Any Y* or P* directives that appear after the first Z* directive will be processed after the source member is compiled.

If multiple Z* directives appear in the source member separated by other compile preprocessor directives, the first Z* directive will determine the separation of pre-compilation and post-compilation commands (but all subsequent Z* directives will be processed as part of the compilation command).

Example:

Y* SNDMSG MSG('About to compile &N ...') TOUSR(*REQUESTER)
Z* CRTBNDRPG
Y* SNDMSG MSG('Compilation completed!') TOUSR(*REQUESTER)

Or

P* QGPL/PREEXITPGM
Z*
P* QGPL/POSTEXITPGM

Note: You can use substitution variables in compile preprocessor directives (i.e. &M is for Source member UUAJEFR)

2. Using the global control data area (YBRTPXA).

A new data area called YBRTPXA is shipped in CA 2E. It is a 42-byte character data area with the following format:


Bytes 1  -  10:          Pre-compilation exit program name (default: '*NONE') 
Bytes 11  -  20:     Pre-compilation exit program library (default: blank) 
Bytes 21  -  30:    Post-compilation exit program name (default: '*NONE') 
Bytes 31  -  40:    Post-compilation exit program library (default: blank) 
Byte 41:           Cancel compilation if error ('1'/'0') (default: '0') 
Byte 42:             Currently unused (default: blank)

NOTE: In our user-defined exit program we can use RTVJOBA to get the job name. You can use the CHKOBJ to check whether the object is a Program or a Physical file.

Example:


dspdtaara ybrtpxa  
           Value                                                   
Offset      *...+....1....+....2....+....3....+....4....+....5     
    0      '                    TESTCHGPF1#ABCDEGEN   '            
                                                                   
Configured the TESTCHGPF1 program and #ABCDEGEN in Bytes 21 to 40 of the YBRTPXA data area. As it is a global change for every function and access path object compilation in 2E, this post-compilation exit program (#ABCDEGEN/TESTCHGPF1) will be called.

PGM                                                          
             DCL        VAR(&JOBNAME) TYPE(*CHAR) LEN(10)    
             DCL        VAR(&ISFILE) TYPE(*CHAR) LEN(1)      
                                                             
             RTVJOBA    JOB(&JOBNAME)                        
                                                             
             CHGVAR     VAR(&ISFILE) VALUE(Y)                
             CHKOBJ     OBJ(&JOBNAME) OBJTYPE(*FILE)         
             MONMSG     MSGID(CPF0000) EXEC(DO)              
             CHGVAR     VAR(&ISFILE) VALUE(N)                
             ENDDO                                           
             IF         COND(&ISFILE = 'Y') THEN(DO)         
             CHGPF      FILE(#ABCDEGEN/UUACREP) MAXMBRS(5) + 
                          SIZE(2147483552)                   
             ENDDO                                           
ENDPGM                                                       

Additional Information