Sunday, January 22, 2017

Structure Of An EasyTrieve Module

There are 3 distinct sections to be defined in an EasyTrieve module, the Environment, Library and Activity Sections.  There are no defined headings for these sections, the first occurrence of a statement valid for the next section implies that the previous section in complete.

A brief overview of each section is given below, along with an example of it’s use.  The Library and Activity sections will be covered in greater detail in the following sections.

The ENVIRONMENT Section

This section appears at the top of the module and controls the way in which EasyTrieve interacts with other programs and the user.

In the CDU, this section will contain only 1 statement, this is as follows:-

 000100 ****************
 000200 *   ENVIRONMENT SECTION                                                
 000300 ****************                                                       
 000400 LIST ON                                                                

The LIST command defines whether the contents of the EasyTrieve module should be displayed in the job when the JCL is run.  It is usually set to ON so that any problems with the code can be easily identified and corrected.

The LIBRARY Section

Following the Environment section, comes the Library section.  This section describes all of the data which is expected to come into the module, be written out of the module and all of the variables local to the module which are required during processing.

EasyTrieve has variable and type restrictions, variables must be declared in the Library section (before they are used) and must be defined as the correct type.

An example Library section is shown below:-

002196 *                                                                   
002200 FILE  OTFILE                                                        
002210   OT-RCD                   1  14   A                                
002300   OT-DUNS                  1   4   B                                
002310   OT-CTRY-CD               5   2   A                                
002320   OT-OOB-IND               7   1   A                                
002330   OT-RPT-TYP               8   1   A                                
002350   OT-LAST-UPD-DATE         9   6   N                                 
002400 *                                                                   
003200     W10-CASES-READ                 W   9   N MASK ( A 'ZZZ,ZZZ,ZZ9' )
003300     W10-CORRECT-COUNTRY            W   9   N MASK   A               
003301     W10-CASES-WRITTEN              W   9   N MASK   A               
003310     W10-CASES-EXCLUDED             W   9   N MASK   A               
003320     W10-CASES-INCLUDED             W   9   N MASK   A               
003321     W10-CASES-NOT-UPDATED          W   9   N MASK   A               
003330     W10-CASES-BASE-CAT-X           W   9   N MASK   A               
003340 *                                                                   
003350     W20-PARM-INFO                  W   4   A                         
003360     W20-PARM-LEN   W20-PARM-INFO       2   B  0                     
003370     W20-CTRY-CD    W20-PARM-INFO  +2   2   A                        
003400 *

The ACTIVITY Section

This is where the data processing takes place, files and databases are read, the data is manipulated and output to other files.

The term JOB should not be confused with the JOB card in JCL, any one EasyTrieve module may contain one or more JOB statements, each referring to a discrete set of programming actions.

A sample job section is shown below:-

JOB INPUT (INFILE)   FINISH(SIGN-OFF)                           
*                                                                
W10-RECORDS-IN = W10-RECORDS-IN + 1                            
                                                                  
IF IN-TELEPHONE-1 = '0'                                        
    VL-RCD    = IN-RCD                                          
    PUT VALFILE                                                  
    W10-VALID = W10-VALID + 1                                   
ELSE                                                           
    NV-RCD        = IN-RCD                                      
    PUT NVFILE                                                   
    PRINT REP-1                                                 
    W10-NOT-VALID = W10-NOT-VALID + 1                           
END-IF                                                         
*                                                                 
*================================================================*
SIGN-OFF.  PROC.                                                 
*                                                                
DISPLAY NEWPAGE COL 10 +                                        
          'PROGRAM : UK297PR1 FILE SPLIT  ' +                    
          '   DATE : ' SYSDATE


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.