Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

See more than one level deep for the tree visual of JCL #178

Closed
oliverswitzer opened this issue Mar 7, 2024 · 3 comments
Closed

See more than one level deep for the tree visual of JCL #178

oliverswitzer opened this issue Mar 7, 2024 · 3 comments

Comments

@oliverswitzer
Copy link

Hi,

I am wondering if it is at all possible to see more than one level deep for JCL files? Ie:

Imagining you have a JCL Proc named PROC001 that calls out to another PGM called FORMATPGM:

//PROC001  PROC                                                                 
//**********************************************************************        
//* S030 S040 - DELETE LAST RUN'S DATA FILES                                    
//**********************************************************************        
//*                                                                             
//S030     EXEC PGM=DELPROG,                                                    
//             PARM='GEN.CMP.DP.WEEKLY'                                    
//S040     EXEC PGM=DELPROG,                                                    
//             PARM='GEN.CMP.DP.WEEKLY'                                  
//*                                                                             
//**********************************************************************        
//* S050  - REFORMAT THE COMMA DELIMITED DP EXTRACT                 
//**********************************************************************        
//S050     EXEC PGM=FORMATPGM                                                    
//INP01    DD DSN=GEN.CMP.DS.FOO.WEEKLY,                                       
//            DISP=SHR                                                          
//OUT01    DD DSN=GEN.CMP.DP.WEEKLY.FALL,                                       
//            DISP=(NEW,CATLG,DELETE),                                          
//            UNIT=SYSDA,                                                       
//            SPACE=(CYL,(50,50),RLSE),                                         
//            RECFM=FB,LRECL=600,AVGREC=K                                       
//**********************************************************************        
//* S060  - REFORMAT THE COMMA DELIMITED DP EXTRACT               
//**********************************************************************        
//S060     EXEC PGM=FORMATPGM                                                    
//INP01    DD DSN=GEN.CMP.DS.BAR.WEEKLY,                                      
//            DISP=SHR                                                          
//OUT01    DD DSN=GEN.CMP.DP.WEEKLY.BAZ,                                     
//            DISP=(NEW,CATLG,DELETE),                                          
//            UNIT=SYSDA,                                                       
//            SPACE=(CYL,(50,50),RLSE),                                         
//            RECFM=FB,LRECL=600,AVGREC=K                                          

And the FORMATPGM file looks like the following:

      ******************************************************************        
      ******************************************************************        
       IDENTIFICATION DIVISION.                                                 
      ******************************************************************        
      ******************************************************************        
                                                                                
       PROGRAM-ID.     FORMATPGM.                                               
       AUTHOR.         AUTHOR NAME                                              
       INSTALLATION.   GENERIC ORGANIZATION.                                    
       DATE-WRITTEN.   MM/DD/YY.                                                
       DATE-COMPILED.                                                           
                                                                                
      ******************************************************************        
      * Changes and updates are noted here with generic descriptions.  *        
      ******************************************************************        
                                                                                
      ******************************************************************        
       ENVIRONMENT DIVISION.                                                    
      ******************************************************************        
                                                                                
      ******************************************************************        
       CONFIGURATION SECTION.                                                   
      ******************************************************************        
                                                                                
       SOURCE-COMPUTER.        GENERIC-COMPUTER.                                
       OBJECT-COMPUTER.        GENERIC-COMPUTER.                                
                                                                                
      ******************************************************************        
       INPUT-OUTPUT SECTION.                                                    
      ******************************************************************        
                                                                                
       FILE-CONTROL.                                                            
                                                                                
           SELECT INPUT-FILE                                                    
               ASSIGN TO INP01.                                                 
                                                                                
           SELECT OUTPUT-FILE                                                   
               ASSIGN TO OUT01.                                                 
                                                                                
      ******************************************************************        
       DATA DIVISION.                                                           
      ******************************************************************        
                                                                                
      ******************************************************************        
       FILE SECTION.                                                            
      ******************************************************************        
                                                                                
       FD  INPUT-FILE                                                           
           RECORDING MODE IS F                                                  
           LABEL RECORDS ARE STANDARD                                           
           BLOCK CONTAINS 0 RECORDS.                                            
                                                                                
       01  INPUT-FORMAT-RECORD       PIC X(600).                                
                                                                                
       FD  OUTPUT-FILE                                                          
           RECORDING MODE IS F                                                  
           LABEL RECORDS ARE STANDARD                                           
           BLOCK CONTAINS 0 RECORDS.                                            
                                                                                
       01  OUTPUT-FORMAT-RECORD      PIC X(600).                                
                                                                                
      ******************************************************************        
       WORKING-STORAGE SECTION.                                                 
      ******************************************************************        
                                                                                
       01  WS-PROGRAM-CONTROL.                                                  
           05  WS-END-OF-INPUT-FLAG      PIC X(01)  VALUE 'N'.                  
               88  WS-END-OF-INPUT                   VALUE 'Y'.                 
                                                                                
       01  WS-VARIABLES.                                                        
           05  WS-INPUT-DATA            PIC X(600).                            
                                                                                
       01  WS-OUTPUT-DATA.                                                      
           05  WS-DATA1                 PIC X(18).                             
           ...                          
           05  WS-DATA27                PIC X(18) VALUE SPACES.                 
      ******************************************************************        
      ******************************************************************        
       PROCEDURE DIVISION.                                                      
      ******************************************************************        
      ******************************************************************        
                                                                                
       MAIN-LOGIC.                                                              
           PERFORM INITIALIZE-PROCESS.                                          
           PERFORM PROCESS-LOOP UNTIL WS-END-OF-INPUT.                          
           PERFORM WRAP-UP.                                                     
           STOP RUN.                                                            
                                                                                
       INITIALIZE-PROCESS.                                                      
           OPEN INPUT INPUT-FILE.                                               
           OPEN OUTPUT OUTPUT-FILE.                                             
           PERFORM READ-INPUT-RECORD.                                           
                                                                                
       PROCESS-LOOP.                                                            
           UNSTRING WS-INPUT-DATA DELIMITED BY ","                              
               INTO WS-DATA1, ..., WS-DATA27.                                   
                                                                                
           INSPECT WS-OUTPUT-DATA REPLACING ALL X'0D' BY X'40'.                 
           WRITE OUTPUT-FORMAT-RECORD FROM WS-OUTPUT-DATA.                      
           PERFORM READ-INPUT-RECORD.                                           
                                                                                
       WRAP-UP.                                                                 
           CLOSE INPUT-FILE OUTPUT-FILE.                                        
                                                                                
       READ-INPUT-RECORD.                                                       
           READ INPUT-FILE INTO WS-INPUT-DATA                                   
             AT END SET WS-END-OF-INPUT TO TRUE.                                

I have provided the -include PATH.TO.FOLDER.CONTAINING.FORMATPGM in the command:

java -jar jcl/JCLParser.jar -include ../PATH.TO.FOLDER.CONTAINING.FORMATPGM -file ../PROCLIB/PROC001 -outtree PROC001.proclib.tsv -outcsv PROC001.proclib.csv  -logLevel FINEST -saveTemp

The output from running this, namely the PROC001.proclib.tsv, looks like the following:

   1   │ 
   2   │ PROC001
   3   │     S030    1   PGM DELPROG
   4   │     S040    2   PGM DELPROG
   5   │     S050    3   PGM FORMATPGM
   6   │     S060    4   PGM FORMATPGM

I was anticipating that FORMATPGM's definition would be parsed and unfurled in the tree as well, but it seems as though that may not be supported, at least for this given invocation of the JCL jar. Is there some way to get the parser to output an outtree that resolves the FORMATPGM tree, and any programs IT calls as well?

Thanks in advance!

@cschneid-the-elder
Copy link
Owner

Is there some way to get the parser to output an outtree that resolves the FORMATPGM tree, and any programs IT calls as well?

Sort of.

If you run your COBOL source code through the CallTree.jar in the mapa/cobol directory, you will get an output file detailing information about each COBOL program. You might also need the DB2zSQL.jar file.

The intended use of these delimited output files is they can be processed in any way you like. You could load them into a database and process them from there with SQL or you could just read the files and process those to produce whatever sort of output meets your needs.

So, you could process the JCL with JCLParser.jar, then process the COBOL with CallTree.jar, then put the two outputs together in a nice report or tree structure represented in a GUI with code you write.

@oliverswitzer
Copy link
Author

Ah this is great thank you! We may try to add this functionality from the csv files output or potentially intercepting the intermediary AST from ANTLR.

Re: the docs around -include / -includeList:

 -include <arg>       name of a single path in which to locate cataloged
                      procs and JCL INCLUDEs, takes precedence over the
                      includeList option
 -includeList <arg>   name of a comma-delimited file containing a list of
                      paths in which to locate cataloged procs and JCL
                      INCLUDEs and the PDS(E)s to which they correspond

These are required flags, so I'm wondering what the purpose of providing these are -- our initial assumption when reading these docs were that it would "resolve" program files and unfurl them under the call site of procs or programs in the csv / tsv output, but that doesn't appear to be happening at first glance / from your response. What does providing these flags do?

Thanks again for your prompt replies!

@cschneid-the-elder
Copy link
Owner

Those options are for specifying a directory or directories for resolving cataloged procedures and JCL INCLUDE statements. The former are the code run via an EXEC PROC= statement, the latter resolve to JCL fragments which IBM calls "include groups". My suggestion would be to map a directory to each PROCnn DD in the JES2 cataloged procedure and to each library mentioned in a JCLLIB statement in a job being analyzed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants