How can I "hard code" a header into my output using EASYTRIEVE as part of a JCL file?

567 Views Asked by At

My goal is to have three headers appear at the top of my output. The headers will be "Title", "Genre", and "Rating". The JCL file inputs data from a dataset, a list of movies, their genres (which are numbered and later translated into words using IF logic), and the ratings (using packed data). I am not supposed to use any programs like SORT. My solution needs to be "hard coded".

I expect the results to look like this: snapshot of the expected results

The actual results look like this:

snapshot of the actual results

The job submits successfully, without any error. However, the JCL file does not produce the desired output.

I understand that the JCL file is following a list of instructions for each record from the data set, and looping over the instructions for each record, which is why the Title, Genre, and Ratings headers repeat. I've tried using "GOTO" and labels to alter where the loop resumes from, so that the JCL file only executes the header parameters on the first execution. Unfortunately, it doesn't seem to work.

I linked screenshots of my JCL file below. As you can see, I redefined my OHEAD variable to be blank (' '), which prevents the headers from overlapping the movie data. If I could find a way to have the JCL instructions loop, and restart from AFTER the first "OHEAD" statement, then I would only need to define OHEAD once. Conceptually, that's what I'm trying to do.

I started training on JCL a few days ago, so I appreciate your patience and any input you can offer.

JCL file screenshot 1

JCL file screenshot 2

JCL file screenshot 3

JCL file screenshot 4

JCL file screenshot 5

I copied the JCL file text below.

000001 //DSINC01C JOB (0000,1178),'TRAINING',NOTIFY=DSINC01,
000002 //             MSGCLASS=E                            
000003 //*                                                  
000004 //* DELETE STEP FOR EASIER RE-RUNS                   
000005 //*                                                  
000006 //S01      EXEC PGM=IDCAMS,REGION=40M                
000007 //SYSPRINT DD SYSOUT=*                               
000008 //SYSIN    DD *                                      
000009  DELETE DSINC01.TRAINING.OUTPUT                      
000010  IF MAXCC=8 THEN SET MAXCC = 0                       
000011 /*                                                   
000012 //*                                                  
000013 //* EASYTRIEVE STEP                                  
000014 //*                                                  
000015 //S02     EXEC PGM=EZTPA00,REGION=4M                 
000016 //SYSLIB   DD DSN=ALCHAN.TEST.EMAC,DISP=SHR          
000017 //         DD DSN=SYS3.EASYPLUS.CAIMAC,DISP=SHR      
000018 //FILEI    DD DISP=SHR,DSN=DSINC01.TRAINING.MDATA       
000019 //FILEO    DD DSN=DSINC01.TRAINING.OUTPUT,              
000020 //            DISP=(,CATLG),                            
000021 //            UNIT=PUBLIC,SPACE=(CYL,(500,250),RLSE),   
000022 //            DCB=(LRECL=80,RECFM=FB,BLKSIZE=0,DSORG=PS)
000023 //EZTVFM   DD  UNIT=WORK,SPACE=(CYL,(10,5))             
000024 //SORTWK01 DD  UNIT=WORK,SPACE=(CYL,(10,5))             
000025 //SORTWK02 DD  UNIT=WORK,SPACE=(CYL,(1,1))              
000026 //SORTWK03 DD  UNIT=WORK,SPACE=(CYL,(1,1))              
000027 //SYSOUT   DD  SYSOUT=*                                 
000028 //SYSPRINT DD  SYSOUT=*                                 
000029 //SYSLIZ   DD  SYSOUT=*                                 
000030 //SYSLZ1   DD  SYSOUT=*                                 
000031 //SYUDUMP  DD  SYSOUT=*                                 
000032 //*                                                     
000033 //SYSIN     DD *                                        
000034 FILE SYSLIZ PRINTER                                     
000035 *
000036 * INPUT FILE LAYOUT                                                  
000037 *                                                                    
000038 FILE FILEI                                                           
000039  IMNAME          1     40 A                                          
000040  IMGENRE         41    1  N                                          
000041  IMRATE          42    2  P                                          
000042 * OUTPUT FILE LAYOUT                                                 
000043 *                                                                    
000044 FILE FILEO                                                           
000045  OHEAD          1      80 A                                          
000046  OMNAME         1      30 A                                          
000047  OMGENRE        32     7  A                                          
000048  OMRATE         40     3  N                                          
000049 *--------------------------------------------------------------------
000050 * MAIN LINE                                                          
000051 *--------------------------------------------------------------------
000052 JOB INPUT FILEI NAME DATA                                            
000053  OHEAD = 'TITLE                          GENRE   RATING'             
000054  PUT FILEO
000055  OHEAD = '        '              
000056  OMNAME = IMNAME        
000057  OMGENRE = '      '     
000058   IF IMGENRE = 1        
000059      OMGENRE = 'FANTASY'
000060   END-IF                
000061   IF IMGENRE = 2        
000062      OMGENRE = 'ACTION' 
000063   END-IF                
000064   IF IMGENRE = 3        
000065      OMGENRE = 'COMEDY' 
000066   END-IF                
000067   IF IMGENRE = 4        
000068      OMGENRE = 'HORROR' 
000069   END-IF                
000070   IF IMGENRE = 5        
000071      OMGENRE = 'DRAMA'  
000072   END-IF                
000073  OMRATE = IMRATE
000074  PUT FILEO      
000075  GO TO JOB      
000076 /*  
2

There are 2 best solutions below

0
On

Your header prints every time because you printed it inside of JOB INPUT FILEI. Instead, move this logic to a JOB INPUT NULL proc (or write a STARTER proc for this). Then it will only run when the program is launched.

5
On

Copying just the Easytrieve code, add a label, and change the GO TO.

Edited: I modified the Easytrieve again. I don't know if this will work, as I don't have a mainframe to test with.

Get an online Easytrieve manual and learn the language.

000034 FILE SYSLIZ PRINTER                                     
000035 *
000036 * INPUT FILE LAYOUT                                                  
000037 *                                                                    
000038 FILE FILEI                                                           
000039  IMNAME          1     40 A                                          
000040  IMGENRE         41    1  N                                          
000041  IMRATE          42    2  P                                          
000042 * OUTPUT FILE LAYOUT                                                 
000043 *                                                                    
000044 FILE FILEO                                                           
000045  OHEAD          1      80 A                                          
000046  OMNAME         1      30 A                                          
000047  OMGENRE        32     7  A                                          
000048  OMRATE         40     3  N                                          
000049 *--------------------------------------------------------------------
000050 * MAIN LINE                                                          
000051 *--------------------------------------------------------------------
000052 JOB INPUT FILEI NAME DATA                                            
000053  OHEAD = 'TITLE                          GENRE   RATING'             
000054  PUT FILEO
        GET FILEI
        DO WHILE NOT EOF FILEI
000055    OHEAD = '        '              
000056    OMNAME = IMNAME        
000057    OMGENRE = '      '     
000058    IF IMGENRE = 1        
000059      OMGENRE = 'FANTASY'
000060    END-IF                
000061    IF IMGENRE = 2        
000062      OMGENRE = 'ACTION' 
000063    END-IF                
000064    IF IMGENRE = 3        
000065      OMGENRE = 'COMEDY' 
000066    END-IF                
000067    IF IMGENRE = 4        
000068      OMGENRE = 'HORROR' 
000069    END-IF                
000070    IF IMGENRE = 5        
000071      OMGENRE = 'DRAMA'  
000072    END-IF                
000073    OMRATE = IMRATE
000074    PUT FILEO 
000075    GET FILEI     
000076  END-DO     
000077 /*