Easytrieve Training Presented by Annapoorna V Page 1 Benefits • CA-Easytrieve Plus is an information retrieval and data management system designed to simplify computer programming • Its English-like language and simple declarative statements provide the new user with the tools needed to produce comprehensive reports with ease. Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 2 Capabilities • File Processing – – – – Accepts any number of input files. Processes SAM, ISAM, VSAM, or IMS/DLI files. Allows various record formats. Searches files and performs logical data selection based on input or calculation. – Edits and updates files. – Matches an unlimited number of files. – Creates subfiles containing selected records from a master file. Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 3 Capabilities • Output – Outputs any number of files or reports on one pass of the input file(s). – Automatically formats output with all totals calculated internally. – Provides summary reports and output files with no limits on the number and size of control break fields or total fields. – Makes it easy for you to define and print specially formatted output, such as for W-2 forms, audit confirmations, labels, form letters, and preprinted forms. – Permits you to vary page sizes within a report, and insert additional header and footer information. – Enables you to write reports directly to microfiche. Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 4 Sections • Environment Section – PARM Statement • Library Section – Declarations • Job Activity Section – Procedure Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 5 Environment Definition Section • The environment definition section establishes parameters for the program. • It consists of the PARM statement used to establish a customized operating mode for the duration of your program. Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 6 Environment Section //WIP108A JOB (T,462),'EAR',CLASS=E,MSGCLASS=Y,REGION=0M, // NOTIFY=WIP108 TYPRUN=HOLD //* //STEP01 EXEC PGM=EZTPA00 //STEPLIB DD DSN=SYSTEMS.LINKLIB,DISP=SHR //EZTVFM DD DATACLAS=MB010,UNIT=SYSDA //SYSOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //REPORT01 DD SYSOUT=* //FILEIN DD DISP=SHR,DSN=WIP108.J3611.SYS007X.V157.D012002 //FILEOT DD DSN=WIP108.J3611.SYS007X.EXT61, // DISP=(OLD,CATLG,DELETE),DATACLAS=MB010, // DCB=(RECFM=FB,LRECL=180,BLKSIZE=0) //SYSIN DD * LIST ON PARM LIST (NOPARM NOFILE) FILE FILEIN . . Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 7 Library Definition Section • • • • The library definition section describes the data to be processed by the program. It describes data files and their associated fields, and any working storage requirements of the program. The library definition section is said to be optional because on rare occasions, a program might not be doing any input or output of files. However, in most cases use of the library definition section is required Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 8 Library Definition Section • In library section – All File Variables should have the Offset, Length and Data type – The end of a file declaration will be the next FILE definition or Activity statement or Working storage declaration – To include copy books %<copybookname> is used – If the declaration for one file needs to be replicated for second file then the COPY statement can be used. When reffered in the Activity section it should have the file scope terminator – All Working Storage variables have a ‘W’ followed by Length and Data type Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 9 Library Definition Section • In library section – Redefinition in working storage has reference to the group name. This reference is not needed for Redefinition in File variables – Initialization of the Working storage variables can be done by VALUE Keyword. Some of the predefined initialization are SPACE(S), ZERO etc. – HEADING is used to display Column Heading in the reports that are ‘Printed’ – If the Column Heading has to spread for more than one line then the text is put into single quotes separated by a space Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 10 Data Types |------------------------------------------------------------------------| | Type | Maximum Field Length (in bytes) | |--------------------|----------------------------------------------------| |A | 32,767 | | Alphanumeric | | |--------------------|----------------------------------------------------| | N Numeric | 18 | |--------------------|----------------------------------------------------| | P Packed | 10 | |--------------------|----------------------------------------------------| | U Unsign | 9 | | Packed | | |--------------------|-----------------------------------------------------| | B Binary | 4 | |-------------------------------------------------------------------------| Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 11 Library Section //SYSIN DD * FILE FILEIN File IN-REC Variables STATE * FILE FILEOT OUT-REC * FILE REPORT01 PRINTER * WS-ACCD-DT WS-ACCD-MM WS-ACCD-LIT1 * WS-PACK-AMT WS-AMT 1 2 180 A 2 A 1 180 A W 8 A + HEADING ('ACCIDENT' 'DATE') WS-ACCD-DT 2 A WS-ACCD-DT +2 1 A VALUE '-' Working Storage WS-PAID-DT W W 6 P 2 VALUE 0 7 N 2 VALUE 0 + HEADING ('PAID' 'AMOUNT') W 5 A VALUE '06-01' + HEADING ('PAID' 'DATE') Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 12 Field Declaration FILE FILEIN IN-REC 1 180 A STATE 2 2 A POL 4 9 A AMT 13 7 N AMT-ALPHA 13 7 A AMT-DIG-1 AMT-ALPHA AMT-SIGN AMT-ALPHA +1 AMT-DIG-3-7 AMT-ALPHA +2 * *OR CAN BE DECLARED AS * FILE FILEIN IN-REC * 180 A STATE * 2 A POL * 9 A AMT * 7 N AMT-ALPHA * 7 A AMT-DIG-1 AMT-ALPHA AMT-SIGN AMT-ALPHA +1 AMT-DIG-3-7 AMT-ALPHA +2 Easytrieve Plus Ver 1.0 HEADING ('STATE') HEADING ('POLICY') HEADING ('PAID' 'AMOUNT') 2 1 1 5 A A A HEADING ('STATE') HEADING ('POLICY') HEADING ('PAID' 'AMOUNT') 2 1 1 5 A A A Author : Annapoorna Venkateswaran Page 13 Field Declaration …Contd * FILE FILEIN * AMT 25 7 N 2 AMT1 25 7 N 2 AMT2 25 7 N 2 AMT3 25 7 N 2 45 7 N 2 . . AMT4 . * WORKING STORAGE * WS-PACK-AMT WS-AMT HEADING ('PAID' 'AMOUNT') MASK ‘ZZZ,Z9.99’ HEADING ('PAID' 'AMOUNT') MASK ‘ZZZ,Z9.99’ HEADING ('PAID' 'AMOUNT') MASK (G ‘$ZZ,ZZ9.99-’) HEADING ('PAID' 'AMOUNT') MASK (A BWZ ‘$$,$$9.99-’) + + + + MASK (A) W W 6 P 2 VALUE 0 7 N 2 VALUE 0 + HEADING ('PAID' 'AMOUNT') How do you define a static variable? Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 14 Declaration …Contd FILE FILE1 INREC 1 100 TRAIL 1 3 CLCL 20 2 AMT 25 7 BCO 40 2 CLMDIV 42 2 COMP 44 1 * *TEMPORARY FILE TO HOLD AILR * FILE FILE2 COPY FILE1 . A A A N 2 HEADING ('AMT') A HEADING ('BCO') A HEADING ('CLMSDIV') A HEADING ('COMPANY') DATA SORTED BY STATE CODE IF NOT EOF FILE2 IF FILE2:TRAIL = '&&&' '***' GOTO READ2 END-IF WS-CLCL = FILE2:CLCL Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 15 Activity Definition Section • • • • • • mandatory section of the program There are two types of activities -- JOB and SORT. Any number of JOB or SORT activities can be coded in any order. One or more procedures (PROCs) can be coded at the end of each activity. Procedures are separate modules of program code which we use to perform specific tasks REPORT sub activities are areas in a JOB activity where reports are described. REPORT sub activities (if any) can be coded after the PROCs at the end of each JOB activity. Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 16 Activity Section //SYSIN DD * LIST ON . . File <filename> . . WS-FIELD1 . . W 2 A ***SORT ACTIVITY * SORT SYS001 TO SYS002 USING(FIELD1) * ***JOB ACTIVITY * JOB INPUT SYS002 FINISH WRAP-UP * Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 17 Field and Label names •Field Names üA-Z,a-z,0-9, and any special character except ‘.’ üFirst character cannot be a special character üShould contain at least one non-numeric character üShould be unique •Label Names üFor JOBS,REPORTS, etc., üSize = 40 ; Any character except delimiter; Not all numbers •Literals üAlphabetic in single quote “’” ; Max of 254 characters; üNumeric – No quotes; Max of 18 digits; Fraction ; Sign üHexadecimal Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 18 Special Characters •Special Characters üStatement Delimiter ‘.’: End of Statement ; Not mandatory üBasic Delimiter – Space: End of a Token; Continuous spaces are treated as one üComma- Means nothing; just of Readability üApostrophe – contains Alphabetical literals ü‘+’/’-’ :Continuation characters; Should be the last nonblank character on that line ü‘+’ : Continuation should be on next line can start anywhere ü‘-’ : Continuation should be on the first position of the next line Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 19 Library SectionSection- File Definition • A FILE statement must be included for every file defined in the JCL DDNAME irrespective of whether they are input or output • Tables (Internal or External) declared using the FILE statement have the key word TABLE • Internal tables have the number of elements in the table mentioned • VSAM files have the VS keyword with. If opened for Update or Add then the details need to be mentioned in the FILE statement as UPDATE or ADD respectively • Reports declaration have the PRINTER keyword to indicate the same Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 20 File Statement //STEP01 //STEPLIB //EZTVFM //SYSOUT //SYSPRINT //REPORT01 //FILEA //FILEB //STATBL //SYS005 // // //SYSIN FILE . FILE ARG DESC . FILE . FILE . FILE . Easytrieve Plus EXEC PGM=EZTPA00 DD DSN=SYSTEMS.LINKLIB,DISP=SHR DD DATACLAS=MB010,UNIT=SYSDA DD SYSOUT=* DD SYSOUT=* DD SYSOUT=* DD DSN=FARM.LOSS.CUMUNAP.FIRE.CL,DISP=SHR DD DSN=FARM.LOSS.CUMUNAP.FIREOUT.CL,DISP=SHR DD DSN=SYS5.PROD.CONTROL(STATES),DISP=SHR DD DSN=WIP108.J3611.SYS007X.EXT61, DISP=(NEW,CATLG,DELETE),DATACLAS=MB010, DCB=(RECFM=FB,LRECL=180,BLKSIZE=0) DD * SYS005 STATBL TABLE 100 1 2 A 12 10 A REPORT01 PRINTER FILEA VS FILEB VS UPDATE Ver 1.0 Author : Annapoorna Venkateswaran Page 21 Activity Section – Job Statement • • • • • • • The JOB statement defines and initiates processing activity. Points to the input file which is used as the automatic input. There can be any number of JOB statements in a program Each of them will be executed in the order of the coding Each time a JOB starts the Automatic input file is opened by default and EOF is also handled implicitly by that statement End of input file in JOB statement indicates the end of that Activity If no input file is mentioned in the JOB statement then explicit STOP should be used to end that Activity and avoid infinite Loop Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 22 Job statement (contd) INPUT - Keyword • • • • The optional INPUT parameter identifies the automatic input to the activity. When specified, the opening of the file, checking for end of file, and reading are all controlled by CA-Easytrieve Plus. When you do not specify INPUT, CA-Easytrieve Plus automatically provides an input file. If a SORT activity immediately preceded the current JOB activity, the default input is the output file from that SORT activity. Otherwise, the default input is the first file named in the library section Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 23 Job statement (contd) <File-name> in the JOB statement • This identifies the automatic input file(s). • It can identify any file defined in the library section of the program eligible for sequential input processing <Null > • Code this subparameter to inhibit automatic input. Normally, a job is implicitly stopped when the automatic • input file(s) is exhausted. • However, if you code NULL, the program continues running until a STOP statement is executed. Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 24 Job statement (contd) NAME <job-name> - Keyword • • The optional NAME parameter names the JOB activity and is used only for documentation purposes. The job-name can be up to 40 characters long, can contain any character other than a delimiter, and begin with A-Z or 0-9; it cannot consist of all numeric characters. Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 25 Activity – JOB Simple Job Card JOB INPUT SYS002 NAME JOB1 OR Job with Initialization JOB INPUT SYS002 NAME JOB1 START INIT-PARA OR JOB INPUT SYS002 NAME JOB1 START INIT-PARA FINISH WRAP-UP OR JOB INPUT(FILEA KEY(KEYA) WRAP-UP Job + Initialize + final FILEB KEY(KEYB)) NAME JOB1 START INIT-PARA FINISH Key based multiple input files OR JOB INPUT NULL FINISH WRAP-UP Job with no specific input Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 26 Input/Output Specification • • • • CA-Easytrieve Plus provides three levels of input/output (I/O): Automatic Controlled Database. SAM file as both an input and an output file within the same JOB activity is not adviced. But is allowed for SORT activities. You can create SAM files in one activity and process them in subsequent activities. Only one CARD file is permitted in a CA-Easytrieve Plus program Note - The most complex level of input/output involves the use of databases. This is not discussed in this session. Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 27 Input/Output Specification Some of the statements which helps in Automatic I/O are • JOB - Specifies the Input file • PRINT - Initiates report output • DISPLAY - Specifies error messages on sysprint or specific file Controlled I/O • GET - Sequentially read from the input file • POINT – Used with VSAM keyed file to position the pointer to a particular record for subsequent sequential I/O • PUT - Adds records to the end of the file • READ – Follows a POINT and reads the pointed record • WRITE – Used to Update VSAM file Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 28 I/O Operation – Sequential File FILE FILEIN . . FILE FILEOUT . . JOB INPUT NULL FINISH WRAP-UP . GET FILEIN Needs to be IF EOF FILEIN Explicitly handled STOP by EZT END-IF . . WRAP-UP. PROC. .. . END-PROC Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 29 I/O Operation – Sequential File FILE FILEIN . . FILE FILEOUT . . JOB INPUT FILEIN FINISH WRAP-UP . . Not Required *GET FILEIN automatically *IF EOF FILEIN handled by EZT * STOP EXECUTE *END-IF . . WRAP-UP. PROC. .. . END-PROC Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 30 I/O Operation – Sequential File FILE FILEIN VAR1 VAR2 FILE FILEOUT OVAR1 . JOB INPUT FILEIN . IF EOF FILEIN STOP END-IF . PUT FILEOUT FROM . WRAP-UP. PROC. . . END-PROC Easytrieve Plus 3 15 3 100 A A 3 A 1 FINISH WRAP-UP FILEIN Ver 1.0 Author : Annapoorna Venkateswaran Page 31 Automatic I/O The DISPLAY statement sends a line to the printer as soon as the statement is executed. For this reason, you must take care how you use it in your program. By Default DISPLAY rights the details to SYSPRINT but can be redirected to any specific file which is declared with the PRINTER keyword DISPLAY is commonly used: • For error messages • Printing reports • For hexadecimal display of selected information Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 32 I/O Operation – Sequential File FILE FILEIN VAR1 VAR2 3 15 FILE FILEOUT OVAR1 1 3 100 A A 3 A JOB INPUT FILEIN FINISH WRAP-UP IF EOF FILEIN STOP END-IF OVAR1 = VAR1 DISPLAY ‘VALUE OF OVAR1: ‘ OVAR1 PUT FILEOUT WRAP-UP. PROC. . END-PROC Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 33 I/O Operation – VSAM //STEP01 EXEC PGM=EZTPA00 //STEPLIB DD DSN=SYSTEMS.LINKLIB,DISP=SHR . //CHKFILE DD DSN=FARM.LOSS.CUMUNAP.FIRE.CL,DISP=SHR //SYSIN DD * FILE CHKFILE VS . JOB FILE NULL POINT CHKFILE KEY KEY-DATA STATUS GET CHKFILE STATUS IF CHKFILE:FILE-STATUS = 0 AND WS-SSNO = CK-SSN + AND KEY-DATE = CK-PAYPER . WRITE CHKFILE UPDATE STATUS IF CHKFILE:FILE-STATUS = 0 GOTO JOB ELSE DISPLAY “ERROR” END-IF ELSE WRITE CHKFILE ADD STATUS IF CHKFILE:FILE-STATUS = 0 GOTO JOB ELSE DISPLAY “ERROR” END-IF END-IF Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 34 I/O Operation – VSAM //STEP01 EXEC PGM=EZTPA00 //STEPLIB DD DSN=SYSTEMS.LINKLIB,DISP=SHR . //CHKFILE DD DSN=FARM.LOSS.CUMUNAP.FIRE.CL,DISP=SHR //SYSIN DD * FILE CHKFILE VS . JOB FILE NULL READ CHKFILE KEY KEY-DATA STATUS IF CHKFILE:FILE-STATUS = 0 AND WS-SSNO = CK-SSN + AND KEY-DATE = CK-PAYPER . WRITE CHKFILE UPDATE STATUS IF CHKFILE:FILE-STATUS = 0 GOTO JOB ELSE DISPLAY “ERROR” END-IF ELSE WRITE CHKFILE ADD STATUS IF CHKFILE:FILE-STATUS = 0 GOTO JOB ELSE DISPLAY “ERROR” END-IF END-IF Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 35 I/O Operation – DISPLAY * DISPLAY SKIP 5 COL 42 'GRAND TOTAL' + COL 64 GCOUNT COL 76 GNCRNCNT COL 86 GNCRNWT * DISPLAY REPORT01 SKIP 5 COL 42 'YTD TOTALS' + COL 61 YTD-GCOUNT-OUT + COL 73 YTD-GNCRN-CNT-OUT + COL 86 YTD-GNCRNWT-OUT * DISPLAY NEWPAGE DISPLAY COL 002 SDATE + COL 020 COMP-NAME + COL 030 RUNDATE + COL 051 WHAT-DATA ' MERGE' + COL 100 'J8469-' PROC-NUMBER + COL 123 'PAGE' + COL 128 ' 1' * Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 36 Automatic I/O PRINT Statement • • • • • PRINT Keyword initiates report The format of the print statement is PRINT <report-name > The definition of the Report can be used to Sort the data being reported, have sub total, grand totals, Titles and formatting If the data to the report is NOT sorted using a SEQUENCE, the PRINT statement outputs data to a print file from which the report is produced immediately. If the data to the report is NOT sorted using a SEQUENCE, the PRINT statement outputs data to a work file which is spooled until the associated JOB activity processing is complete. Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 37 I/O Operation – PRINT JOB INPUT SYS003 START (GET-PARA) FINISH EOJ-PARA * GCOUNT = GCOUNT + TOTAL GNCRNCNT = GNCRNCNT + TOTALC NCRNWT = TOTALC * 100 / TOTAL PRINT LOSS-REPORT * REPORT LOSS-REPORT LINESIZE 133 PRINTER REPORT01 * TITLE 1 'NON-CRN FACTS LOSSES REPORT FOR THE WEEK ENDING' FDATE ' KA330CRN' * LINE SNAME SCODE TOTAL TOTALC NCRNWT * Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 38 + Decision and Branching Logic Decision taking instruction are – IF – ELSE(-IF) - END-IF Construct – DO - END-DO Construct Branching Instructions are – GOTO – Unconditional Branch to a Label or Activity – PERFORM – Branch to a para. Control returns to the point from where the statement was executed – STOP – Unconditional stop to the Activity Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 39 IF - Statement //SYSIN DD FILE FILEIN . . JOB INPUT FILEIN . . * IF ((INPUT_BCO1 ALPHABETIC OR INPUT_BCO1 NUMERIC) AND INPUT_BC01 NE SPACES AND INPUT_BCO1 NE ZEROES ) IF ACCT-CODE = ’30’ ’31’ ’32’ ’34’ THRU IF NUM-CODE = 1, 3, 5 THRU 8 … END-IF ELSE DISPLAY ‘IN ELSE PART’ END-IF END-IF . Easytrieve Plus Ver 1.0 + + + ’40’ Author : Annapoorna Venkateswaran Page 40 DO WHILE/ ENDEND-DO - Statement //SYSIN DD * FILE FILEIN . . JOB INPUT FILEIN . DO WHILE WS-EOF-SW = 'N' PERFORM READ-FILEIN DO WHILE CHANGE = 'Y' CHANGE = 'N' IF ….. CHANGE = ‘Y’ END-IF END-DO . END-DO READ-FILEIN. PROC. GET FILEIN IF EOF FILEIN WS-EOF-SW = 'Y' GOTO GET-OUT END-IF END-PROC Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 41 Logic & Processing Statements • Data Manipulation Assignment Statement • Simple Assignment For example HOLD-DIV = DIV • ROUNDED and INTEGER For example RCVFLD ROUNDED = SENDFLD • Move Statements Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 42 DATA MANIPULATION //SYSIN DD * FILE FILEIN . FILE FILEOUT * JOB INPUT FILEIN . MOVE RECIN TO OUTREC IF VEHYR1 NOT NUMERIC OVEHYR = IVEHYR PUT FILEC OR VEHYR2 NOT NUMERIC END-IF . . Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 43 DATA MANIPULATION //SYSIN DD * FILE FILEIN VAR1 1 4 VAR2 10 7 VAR3 15 20 . FILE FILEOUT VAR1 1 4 VAR3 10 3 * JOB INPUT FILEIN . MOVE LIKE FILEIN TO FILEOUT A A A A A PUT FILEOUT . . Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 44 DATA MANIPULATION * WS-VAR1 WS-VAR2 * JOB INPUT WS-VAR2 DISPLAY * WS-VAR2 DISPLAY * WS-VAR2 DISPLAY * WS-VAR2 DISPLAY * WS-VAR2 DISPLAY * WS-VAR2 DISPLAY * STOP Easytrieve Plus W W 5 5 N N 2 VALUE (99.99) 1 NULL INTEGER ROUNDED = WS-VAR1 'INTEGER ROUNDED : ' WS-VAR2 INTEGER TRUNCATED = WS-VAR1 'INTEGER TRUNCATED : ' WS-VAR2 INTEGER = WS-VAR1 'INTEGER : ' WS-VAR2 ROUNDED = WS-VAR1 'ROUNDED : ' WS-VAR2 TRUNCATED = WS-VAR1 'TRUNCATED : ' WS-VAR2 = WS-VAR1 'DIRECT : ' WS-VAR2 Ver 1.0 Author : Annapoorna Venkateswaran Page 45 DATA MANIPULATION RESULTS INTEGER ROUNDED INTEGER TRUNCATED INTEGER ROUNDED TRUNCATED DIRECT Easytrieve Plus : : : : : : Ver 1.0 100.0 99.0 99.0 100.0 99.9 99.9 Author : Annapoorna Venkateswaran Page 46 DATA MANIPULATION WS-VAR1 W 25 A VALUE 'THISISATESTPROGRAM' WS-VAR2 W 15 A WS-VAR3 W 15 A * JOB INPUT NULL * MOVE WS-VAR1 TO WS-VAR2 DISPLAY 'DIRECT :' WS-VAR2 * MOVE WS-VAR1 TO WS-VAR2 FILL '*' DISPLAY 'DIRECT FILL :' WS-VAR2 * MOVE WS-VAR1 5 TO WS-VAR2 FILL '*' DISPLAY 'LEN 5 FILL :' WS-VAR2 * MOVE SPACES TO WS-VAR2 MOVE WS-VAR1 5 TO WS-VAR2 3 DISPLAY 'LEN 5 TO 3 :' WS-VAR2 * MOVE WS-VAR1 TO WS-VAR2,WS-VAR3 DISPLAY 'DIRECT DUAL VAR2:' WS-VAR2 DISPLAY 'DIRECT DUAL VAR3:' WS-VAR3 * STOP Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 47 DATA MANIPULATION RESULTS DIRECT DIRECT FILL LEN 5 FILL LEN 5 TO 3 DIRECT DUAL VAR2 DIRECT DUAL VAR3 Easytrieve Plus :THISISATESTPROG :THISISATESTPROG :THIS ********** :THI : ???? : ???? Ver 1.0 Author : Annapoorna Venkateswaran Page 48 DATA MANIPULATION * WS-VAR1 W 5 N 0 VALUE 12 WS-VAR2 W 5 N 0 VALUE 10 WS-VAR3 W 5 N 0 VALUE 8 WS-VAR4 W 5 N 0 VALUE 6 WS-VAR5 W 5 N 0 VALUE 4 WS-TOTAL W 5 N 0 * JOB INPUT NULL WS-TOTAL = WS-VAR1 / WS-VAR5 + WS-VAR2 - WS-VAR3 * WS-VAR4 DISPLAY 'TOTAL PLAIN :' WS-TOTAL * WS-TOTAL = (WS-VAR1 / WS-VAR5) + WS-VAR2 - (WS-VAR3 * WS-VAR4) DISPLAY 'TOTAL PARANTHESES :' WS-TOTAL * WS-TOTAL = (WS-VAR1 / WS-VAR5) + (WS-VAR2 - WS-VAR3) * WS-VAR4 DISPLAY 'TOTAL PARANTHESES 2:' WS-TOTAL * STOP Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 49 DATA MANIPULATION RESULTS TOTAL PLAIN TOTAL PARANTHESES : : 3535- TOTAL PARANTHESES 2 : 15 Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 50 Report Processing • • • Report produces a formatted output as decided by the user by specifying in easy to understand language. The parameters are coded on the REPORT statement or they immediately follow the REPORT statement and are called report declaratives. The format of the report declaratives looks like Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 51 Report Processing • • • • • • • • REPORT – Keyword identifies the beginning of the report definition and should be before the next activity start SEQUENCE – Used to Sort the data before it is actually printed into the report CONTROL – Used to break based on some key field in the report. Data to be printed needs to be sorted either through a SEQUENCE or SORT to make the result more meaningful SUM – Used to sum up the Statistical data in report TITLE - Keyword used to define the details which will be report heading and printed at the beginning of every page. There can be more than one title for a report HEADING – Column Heading (already discussed). The heading in the report overwrites the one in the declaration LINE – Defines the detail line of the report Only REPORT and LINE are mandatory for a report definition. The rest are not and the order of usage should be as explained Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 52 Report - Basic //REPORT01 DD SYSOUT=* //SYS001 //SYSIN * DD DD DISP=SHR,DSN=WIP108.OFFSHORE.WKSITE.EZP1(DATA) * FILE SYS001 KEY1 1 5 A NAME 7 5 A SUB 14 7 A MARKS 23 3 N * FILE REPORT01 PRINTER * * JOB INPUT SYS001 FINISH WRAP-UP * PRINT REPORT01 * WRAP-UP. PROC. DISPLAY ' END OF PROCESS ' END-PROC * REPORT REPORT01 LINESIZE 080 PRINTER REPORT01 SEQUENCE KEY1 TITLE 1 'TEST REPORT ' LINE KEY1 NAME SUB MARKS * Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 53 Report - Basic 07/12/04 1 TEST REPORT KEY1 00001 00001 00001 00001 00002 00002 00002 00002 00002 00002 00002 00002 00002 00003 00004 00005 Easytrieve Plus Ver 1.0 NAME Name1 Name1 Name1 Name1 Name1 Name1 Name0 Name0 Name0 Name1 Name2 Name2 Name2 Name1 Name2 Name3 SUB history geog. science maths history geog. history geog. science science history geog. science history geog. science PAGE MARKS 040 050 100 100 040 050 040 050 100 100 040 050 100 040 050 100 Author : Annapoorna Venkateswaran Page 54 Report – Multiple Title lines and Heading option FILE SYS001 KEY1 1 5 A HEADING ('STUDENT' 'NO.') NAME 7 5 A HEADING ('NAME') SUB 14 7 A MARKS 23 3 N 0 * FILE REPORT01 PRINTER * JOB INPUT SYS001 FINISH WRAP-UP * PRINT REPORT01 * WRAP-UP. PROC. DISPLAY ' END OF PROCESS ' END-PROC * REPORT REPORT01 LINESIZE 080 PRINTER REPORT01 SEQUENCE KEY1 TITLE 1 'TEST REPORT ' TITLE 2 'SAMPLE TITLE' HEADING NAME ('STUDENT' 'NAME') HEADING SUB ('SUBJECT' ) LINE 1 KEY1 NAME SUB MARKS Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 55 Report 07/13/04 STUDENT NO. 00001 00001 00001 00001 00002 00002 00002 00002 00002 00002 00002 00002 00002 00003 00004 00005 Easytrieve Plus Ver 1.0 TEST REPORT SAMPLE TITLE STUDENT NAME SUBJECT Name1 history Name1 geog. Name1 science Name1 maths Name1 history Name1 geog. Name0 history Name0 geog. Name0 science Name1 science Name2 history Name2 geog. Name2 science Name1 history Name2 geog. Name3 science PAGE 1 MARKS 40 50 100 100 40 50 40 50 100 100 40 50 100 40 50 100 Author : Annapoorna Venkateswaran Page 56 Report Processing CONTROL Keyword • Makes sense if the data in the Report is sorted • Used to print subtotals • Every field in the Control statement should be referred in the LINE • Prints the key value by default only for the first record and when there is a control break. Not present with other detail records DTLCTL Option in the REPORT statement • It is used with the CONTROL statement and decides on where the key values should be printed • EVERY Option – Displays the control key values with every details record • NONE Option – Displays the control keys only when the Control break happens. None of the detail record has the key • FIRST Option – Displays the control for the First detail record and when there is a control break. This is the default Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 57 Report - Control //REPORT01 DD SYSOUT=* //SYS001 //SYSIN * DD DD DISP=SHR,DSN=WIP108.OFFSHORE.WKSITE.EZP1(DATA) * FILE SYS001 KEY1 1 5 A NAME 7 5 A SUB 14 7 A MARKS 23 3 N * FILE REPORT01 PRINTER * JOB INPUT SYS001 FINISH WRAP-UP * PRINT REPORT01 * WRAP-UP. PROC. DISPLAY ' END OF PROCESS ' END-PROC * REPORT REPORT01 LINESIZE 080 PRINTER REPORT01 SEQUENCE KEY1 CONTROL KEY1 TITLE 1 'TEST REPORT ' LINE KEY1 NAME SUB MARKS * Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 58 Report - Control 07/12/04 TEST REPORT KEY1 00001 00001 00002 00002 00003 00003 00004 00004 00005 00005 Easytrieve Plus Ver 1.0 PAGE NAME Name1 Name1 Name1 Name1 SUB history geog. science maths MARKS 040 050 100 100 Name1 Name1 Name0 Name0 Name0 Name1 Name2 Name2 Name2 history geog. history geog. science science history geog. science 040 050 040 050 100 100 040 050 100 Name1 history 040 Name2 geog. 050 Name3 science 100 Author : Annapoorna Venkateswaran 1 Page 59 Report - DTLCTL * REPORT REPORT01 LINESIZE 080 PRINTER REPORT01 SEQUENCE KEY1 CONTROL KEY1 TITLE 1 'TEST REPORT ' LINE KEY1 NAME SUB MARKS * REPORT REPORT01 LINESIZE 080 DTLCTL FIRST PRINTER REPORT01 SEQUENCE KEY1 CONTROL KEY1 TITLE 1 'TEST REPORT ' LINE KEY1 NAME SUB MARKS * REPORT REPORT02 LINESIZE 080 DTLCTL NONE PRINTER REPORT01 SEQUENCE KEY1 CONTROL KEY1 TITLE 1 'TEST REPORT ' LINE KEY1 NAME SUB MARKS * REPORT REPORT03 LINESIZE 080 DTLCTL EVERY PRINTER REPORT01 SEQUENCE KEY1 CONTROL KEY1 TITLE 1 'TEST REPORT ' LINE KEY1 NAME SUB MARKS * Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 60 Report – DTLCTL - FIRST 07/12/04 TEST REPORT KEY1 00001 00001 00002 00002 00003 00003 00004 00004 00005 00005 Easytrieve Plus Ver 1.0 PAGE NAME Name1 Name1 Name1 Name1 SUB history geog. science maths MARKS 040 050 100 100 Name1 Name1 Name0 Name0 Name0 Name1 Name2 Name2 Name2 history geog. history geog. science science history geog. science 040 050 040 050 100 100 040 050 100 Name1 history 040 Name2 geog. 050 Name3 science 100 Author : Annapoorna Venkateswaran 1 Page 61 Report – DTLCTL - EVERY 07/12/04 1 TEST REPORT KEY1 00001 00001 00001 00001 00001 00002 00002 00002 00002 00002 00002 00002 00002 00002 00002 00003 00003 00004 00004 00005 00005 Easytrieve Plus Ver 1.0 PAGE NAME Name1 Name1 Name1 Name1 SUB history geog. science maths MARKS 40 50 100 100 Name1 Name1 Name0 Name0 Name0 Name1 Name2 Name2 Name2 history geog. history geog. science science history geog. science 40 50 40 50 100 100 40 50 100 Name1 history 40 Name2 geog. 50 Name3 science 100 Author : Annapoorna Venkateswaran Page 62 Report – DTLCTL - NONE 07/12/04 KEY1 TEST REPORT NAME SUB Name1 history Name1 geog. Name1 science Name1 maths PAGE MARKS 40 50 100 100 00001 Name1 Name1 Name0 Name0 Name0 Name1 Name2 Name2 Name2 history geog. history geog. science science history geog. science 40 50 40 50 100 100 40 50 100 Name1 history 40 Name2 geog. 50 Name3 science 00002 00003 00004 100 00005 Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 63 1 Report Processing SUMCTL Option in the REPORT statement • It is used with the CONTROL statement and decides on where the key values should be printed • HIAR Option – Displays the control key values in a hierarchical order (order of declaration in the Control Statement). I.e. When there is a break in the second level both the first and second key are displayed for the control break. When there is a break in the first key only the first key values are displayed for the control break • ALL Option – Displays all the control key when there is a Control break. • NONE Option – None of the control keys are displayed when there is a control break. In short no sub total is printed • TAG Option – Displays the control key field name (or heading for that column) as a sub total row heading. Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 64 Report – SUMCTL * REPORT REPORT01 LINESIZE SEQUENCE KEY1 NAME CONTROL KEY1 NAME TITLE 1 'TEST REPORT ' LINE KEY1 NAME SUB MARKS * REPORT REPORT02 LINESIZE SEQUENCE KEY1 NAME CONTROL KEY1 NAME TITLE 1 'TEST REPORT ' LINE KEY1 NAME SUB MARKS * REPORT REPORT03 LINESIZE SEQUENCE KEY1 CONTROL KEY1 TITLE 1 'TEST REPORT ' LINE KEY1 NAME SUB MARKS * REPORT REPORT04 LINESIZE SEQUENCE KEY1 CONTROL KEY1 TITLE 1 'TEST REPORT ' LINE KEY1 NAME SUB MARKS Easytrieve Plus 080 SUMCTL ALL PRINTER REPORT01 080 SUMCTL HIAR PRINTER REPORT01 080 SUMCTL NONE PRINTER REPORT01 080 SUMCTL TAG PRINTER REPORT01 Ver 1.0 Author : Annapoorna Venkateswaran Page 65 Report – SUMCTL - ALL 07/13/04 KEY1 00001 00001 00001 00002 00002 00002 00002 00002 00002 00002 Easytrieve Plus Ver 1.0 TEST REPORT NAME SUB Name1 history geog. science maths Name1 Name1 Name0 history geog. science Name0 Name1 history geog. science Name1 Name2 history geog. science Name2 Name2 PAGE 1 MARKS 40 50 100 100 290 290 40 50 100 190 40 50 100 190 40 50 100 190 570 Author : Annapoorna Venkateswaran Page 66 Report – SUMCTL - HIAR 07/13/04 Easytrieve Plus TEST REPORT KEY1 00001 NAME Name1 00001 00001 00002 Name1 00002 00002 Name0 Name1 00002 00002 Name1 Name2 00002 00002 Name2 Ver 1.0 Name0 SUB history geog. science maths history geog. science history geog. science history geog. science PAGE 1 MARKS 40 50 100 100 290 290 40 50 100 190 40 50 100 190 40 50 100 190 570 Author : Annapoorna Venkateswaran Page 67 Report – SUMCTL - NONE 07/13/04 Easytrieve Plus TEST REPORT KEY1 00001 NAME Name1 Name1 Name1 Name1 SUB history geog. science maths 00002 Name1 Name1 Name0 Name0 Name0 Name1 Name2 Name2 Name2 history geog. history geog. science science history geog. science Ver 1.0 PAGE 1 MARKS 40 50 100 100 290 40 50 40 50 100 100 40 50 100 570 Author : Annapoorna Venkateswaran Page 68 Report – SUMCTL - TAG 07/13/04 TEST REPORT KEY1 00001 NAME Name1 Name1 Name1 Name1 KEY1 TOTAL 00002 Name1 Name1 Name0 Name0 Name0 Name1 Name2 Name2 Name2 KEY1 TOTAL 00003 Name1 KEY1 TOTAL Easytrieve Plus Ver 1.0 SUB history geog. science maths history geog. history geog. science science history geog. science history PAGE 1 MARKS 40 50 100 100 290 40 50 40 50 100 100 40 50 100 570 40 40 Author : Annapoorna Venkateswaran Page 69 Report Processing SUMMARY option on the REPORT definition • • • • Imagine only the control break lines in the report without the detail lines. SUMMARY does that All the Statistical Field details and the Key fields in the Control statement will be printed on each line . The non-control Key fields can be displayed by using SUMCTL DTLCPY on the REPORT line SUMFILE option of SUMMARY writes the output to a non-printer report output where each record is a subtotal details. It has every control key value with the statistical fields sub totals and a count indicating how many records were summarized for the total. Note – DTLCPY gives only the Non Key values of the last record that was written to the report before Control key value changed and caused Control Break to be triggered SUM is another option (mutually exclusive with SUMMARY) where the Statistical fields sub total can be obtained for each control break Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 70 Report - SUMMARY * REPORT REPORT01 LINESIZE 080 SUMMARY PRINTER REPORT01 SEQUENCE KEY1 NAME CONTROL KEY1 TITLE 1 'TEST REPORT ' LINE KEY1 NAME MARKS * REPORT REPORT01 LINESIZE 080 SUMMARY SUMCTL DTLCOPY PRINTER REPORT01 SEQUENCE KEY1 NAME CONTROL KEY1 TITLE 1 'TEST REPORT ' LINE KEY1 NAME MARKS * REPORT REPORT01 LINESIZE 080 PRINTER REPORT01 SEQUENCE KEY1 NAME CONTROL KEY1 SUM MARKS TITLE 1 'TEST REPORT ' LINE KEY1 NAME MARKS Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 71 Report Result of Summary 07/13/04 TEST REPORT KEY1 NAME 00001 00002 00003 00004 00005 PAGE 1 PAGE 1 MARKS 290 570 40 50 100 1050 Result of Summary with SUMCTL DTLCOPY 07/13/04 Easytrieve Plus TEST KEY1 00001 00002 00003 00004 00005 Ver 1.0 REPORT NAME Name1 Name2 Name1 Name2 Name3 MARKS 290 570 40 50 100 1050 Author : Annapoorna Venkateswaran Page 72 Report Result of SUM 07/13/04 Easytrieve Plus TEST REPORT KEY1 NAME 00001 Name1 Name1 Name1 Name1 00001 00002 Name0 Name0 Name0 Name1 Name1 Name1 Name2 Name2 Name2 00002 Ver 1.0 PAGE 1 MARKS 40 50 100 100 290 40 50 100 40 50 100 40 50 100 570 Author : Annapoorna Venkateswaran Page 73 Report – SUMFILE //SUMFIL DD DSN=WIP108.TRAIN.SUMFILE, // DISP=(NEW,CATLG,DELETE), // RECFM=FB,LRECL=80,DATACLAS=MB001,DSORG=PS //SYSIN DD * * FILE SUMFIL KEY1-S 1 5 A NAME-S 6 5 A COUNT-S 11 10 P 0 MARKS-S 21 10 P 2 * REPORT REPORT01 LINESIZE 080 PRINTER REPORT01 SUMMARY SUMFILE SUMFIL SEQUENCE KEY1 NAME CONTROL KEY1 NAME TITLE 1 'TEST REPORT ' LINE 1 KEY1 NAME MARKS TALLY * Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 74 Report Summary Report 07/13/04 KEY1 00001 00001 00002 00002 00002 00002 00003 00003 00004 00004 00005 00005 TEST REPORT NAME MARKS Name1 290 290 Name0 190 Name1 190 Name2 190 570 Name1 40 40 Name2 50 50 Name3 100 100 1050 PAGE 1 TALLY 4 4 3 3 3 9 1 1 1 1 1 1 16 Summary file ----+----1----+----2----+----3----+----4--00001Name1.........<.......... FFFFFD898F00000000040000000020 0000151451000000000C000000009C ----------------------------00002Name0.................... FFFFFD898F00000000030000000010 0000251450000000000C000000009C Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 75 Report – User defined positioning By default EZP centers the report details and takes care of page break, date and time display and page number To have a user defined layout for the report we can use the following • NOHEADING – No column headings are printed in the report. We should have the HEADING line in the report definition if this is used • NOPAGE – No page number will be printed • NODATE – No Run-date or System date will be printed • NOADJUST – The report will not be automatically aligned. Alignment is done using the COL keyword for each and every field on the LINE • NOSPREAD – By default between 2 columns in the report there are 3 spaces. To overwrite this for the overall report this keyword is used • PAGESIZE – By default there are 50-55 lines per page. This keyword is used to overwrite this • TALLYSIZE – If the Tally keyword is used and there are huge number of records then TALLYSIZE is used to define the length of the count field to avoid truncation. Note – If there are multiple LINE in one report then second line fields can be positioned with respect to the first line fields using the POS keyword. This is applicable only from the Second Line on wards Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 76 Report FILE SYS001 KEY1 1 5 A HEADING ('STUDENT' 'NO.') NAME 7 5 A HEADING ('NAME') SUB 14 7 A MARKS 23 3 N 0 * FILE REPORT01 PRINTER * JOB INPUT SYS001 FINISH WRAP-UP * PRINT REPORT01 * WRAP-UP. PROC. DISPLAY ' END OF PROCESS ' END-PROC * REPORT REPORT01 LINESIZE 080 PRINTER REPORT01 NOHEADING PAGESIZE 10 + NODATE NOPAGE SEQUENCE KEY1 TITLE 1 'TEST REPORT ' TITLE 2 'SAMPLE TITLE' LINE 1 KEY1 NAME SUB MARKS Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 77 Report 00001 00001 00001 00001 00002 00002 00002 00002 00002 00002 00002 00002 00002 00003 00004 00005 Easytrieve Plus Ver 1.0 TEST REPORT SAMPLE TITLE Name1 history Name1 geog. Name1 science Name1 maths Name1 history Name1 geog. TEST REPORT SAMPLE TITLE Name0 history Name0 geog. Name0 science Name1 science Name2 history Name2 geog. TEST REPORT SAMPLE TITLE Name2 science Name1 history Name2 geog. Name3 science 40 50 100 100 40 50 40 50 100 100 40 50 100 40 50 100 Author : Annapoorna Venkateswaran Page 78 Report – Special Procs Before-Break. Proc. • This proc basically is used to do some special processing or display some special information in the report before the control break details are displayed in the report After-Break. Proc. • This proc basically is used to do some special processing or display some special information in the report after the control break details are displayed in the report After-Line. Proc. • This proc basically is used to do some special processing or display some special information in the report after every line. Termination. Proc. • This proc basically is used to do some special processing or display some special information in the end of report Note – • These para names are system defined and hence user defined procs cannot have the same name • A control break in the outermost key field (last) in the control statement is referred to as level 1 inside this proc and as it moves towards the first field in the control statement the level number increases Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 79 Report – NOADJUST / POS * REPORT REPORT01 LINESIZE 080 PRINTER REPORT01 NOADJUST SEQUENCE KEY1 NAME CONTROL KEY1 TITLE 1 COL 15 'TEST REPORT ' LINE COL 10 KEY1 COL 20 NAME COL 30 MARKS * REPORT REPORT01 LINESIZE 080 PRINTER REPORT01 SEQUENCE KEY1 NAME CONTROL KEY1 TITLE 1 'TEST REPORT ' LINE 1 KEY1 NAME SUB MARKS LINE 2 POS 2 SUB LINE 3 POS 3 MARKS * TERMINATION. PROC. DISPLAY 'THIS IS END OF REPORT' DISPLAY ' IN TERMINATION PROC' END-PROC * Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 80 Report Report with NOADJUST ---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+---807/13/04 TEST REPORT PAGE 1 KEY1 NAME MARKS 00001 Name1 40 Name1 50 Name1 100 Name1 100 00001 290 00002 Name0 40 Name0 50 Name0 100 Name1 40 Name1 50 Name1 100 Name2 40 Name2 50 Name2 100 00002 570 Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 81 Report Report with POS and TERMINATION PROC 07/13/04 KEY1 00001 TEST REPORT NAME SUB Name1 history history 40 Name1 geog. geog. 50 Name1 science science 100 Name1 maths maths 100 00001 PAGE 1 MARKS 40 50 100 100 290 290 . . . THIS IS END OF REPORT IN TERMINATION PROC Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 82 Report – BEFORE BEFORE--BREAK REPORT REPORT01 LINESIZE 080 PRINTER REPORT01 SEQUENCE KEY1 NAME CONTROL FINAL KEY1 NAME NOPRINT TITLE 1 'TEST REPORT ' LINE 1 KEY1 NAME MARKS TALLY * BEFORE-BREAK. PROC. IF LEVEL = 1 DISPLAY +10 'LEVEL 1:' POS 2 NAME END-IF IF LEVEL = 2 DISPLAY +10 'LEVEL 2:' POS 1 KEY1 END-IF IF LEVEL = 3 DISPLAY +10 'FINAL' END-IF END-PROC * Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 83 Report – BEFORE BEFORE--BREAK Report for BEFORE-BREAK KEY1 00002 NAME Name0 00002 00002 Name0 Name0 Name1 00002 00002 Name1 Name1 Name2 LEVEL 1: LEVEL 1: LEVEL 1: LEVEL 2: 00002 00002 00002 00003 MARKS 40 50 100 TALLY 190 40 50 100 3 190 40 50 100 3 Name2 Name2 190 3 570 40 9 Name1 1050 16 . . FINAL Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 84 Report – AFTER AFTER--BREAK Report for AFTER-BREAK KEY1 00002 NAME Name0 00002 Name0 Name0 Name1 LEVEL 1: 00002 00002 LEVEL 1: 00002 00002 LEVEL 1: LEVEL 2: 00002 00002 00003 00003 LEVEL 1: LEVEL 2: Name1 Name1 Name2 Name2 Name2 Name1 Name1 Name1 00003 00003 MARKS 40 50 100 190 TALLY 3 40 50 100 190 3 40 50 100 190 3 570 9 40 40 1 40 1 1050 16 . . FINAL Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 85 Report – AFTER AFTER--LINE REPORT REPORT01 LINESIZE 080 PRINTER REPORT01 SEQUENCE KEY1 NAME TITLE 1 'TEST REPORT ' LINE 1 KEY1 NAME MARKS * AFTER-LINE. PROC. IF MARKS = 100 DISPLAY +10 'CENTUM SCORED - CONGRATS!!!' END-IF END-PROC Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 86 Report – AFTER AFTER--LINE 07/13/04 CENTUM SCORED CENTUM SCORED - CENTUM SCORED - CENTUM SCORED - CENTUM SCORED - CENTUM SCORED - Easytrieve Plus TEST REPORT KEY1 NAME MARKS 00001 Name1 40 00001 Name1 50 00001 Name1 100 CONGRATS!!! 00001 Name1 100 CONGRATS!!! 00002 Name0 40 00002 Name0 50 00002 Name0 100 CONGRATS!!! 00002 Name1 40 00002 Name1 50 00002 Name1 100 CONGRATS!!! 00002 Name2 40 00002 Name2 50 00002 Name2 100 CONGRATS!!! 00003 Name1 40 00004 Name2 50 00005 Name3 100 CONGRATS!!! Ver 1.0 Author : Annapoorna Venkateswaran PAGE 1 Page 87 Activity Section – Sort Statement SORT statement • Is an activity statement like JOB • Sorts the input file based on the mentioned key to the output file • Selection before sorting (similar to input procedure) can be defined in a para and invoked by using the BEFORE keyword in the SORT statement • The input and the output file names can be same • There can be more than one key fields • Default sort order is Ascending and can be changed to Descending by ‘D’ keyword after every key in the SORT statement Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 88 SORT * SORT SYS001 USING (ID-KEY1 * SORT SYS002 USING (PD-KEY1 * SORT SYS002 USING (PD-KEY4 * SORT SYS002 USING (PD-KEY4 * PARA1. PROC. IF ACCT-CODE = ’31’ SELECT END-IF END-PROC Easytrieve Plus ID-KEY2 ID-KEY3) TO FILEA PD-KEY2 PD-KEY3) TO FILEB PD-KEY2 PD-KEY3) TO FILEC PD-KEY2 PD-KEY3) TO FILED BEFORE PARA1 Ver 1.0 Author : Annapoorna Venkateswaran Page 89 Tables and Arrays TABLES • Tables can be defined inside the program or be developed using the file in the JCL during run time • The one defined inside the program is identified by INSTREAM key word and has an ENDTABLE to indicate end of elements in the table • External table has a count giving what is the possible elements in the table which will be treated as the maximum size of the table • ARG and DESC are 2 mandatory key words for the table • ARG is the key of the table and DESC is the required data corresponding to the key that needs to be fetched • There should not be any duplicates in the key field as it will give run-time error • SEARCH is used to find a key value in the table. If match is there then DESC field is populated with the corresponding values ARRAYS • These are declared using the OCCUR keyword and index is defined by the INDEX keyword in the declaration itself • The array index starts with count value of ‘1’ Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 90 TABLE - INSTREAM FILE MON-TAB TABLE INSTREAM ARG 1 2 A DESC 4 3 A Should 01 JAN be 02 FEB sorted 03 MAR 04 APR 05 MAY 06 JUN 07 JUL 08 AUG 09 SEP 10 OCT 11 NOV 12 DEC ENDTABLE * JOB INPUT FILEA START START-PROC FINISH FINPROC . . IF PARM-MONTH < '13' AND PARM-MONTH > '00' SEARCH MON-TAB WITH PARM-MONTH GIVING MONTH-NAME ELSE MONTH = CURR-MM SEARCH MON-TAB WITH MONTH GIVING MONTH-NAME END-IF Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 91 TABLE - External //TEMPWRK3 DD DSN=&&UNIQUE, // DISP=OLD //SYSIN DD * * FILE TEMPWRK3 TABLE 100 ARG DESC * . JOB INPUT FILEIN . . 37 46 2 2 A A SEARCH TEMPWRK3 WITH INPUT_CLM_DIV GIVING NEW-BCO . IF NEW-BCO NE ' ' PRINT LOSS-REPORT-5 INPUT_BCO = NEW-BCO ELSE PRINT LOSS-REPORT-6 END-IF Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 92 TABLE - External //TEMPWRK3 DD DSN=&&UNIQUE, // DISP=OLD //SYSIN DD * * FILE TEMPWRK3 TABLE 100 ARG DESC * . JOB INPUT FILEIN . . 37 46 2 2 A A SEARCH TEMPWRK3 WITH INPUT_CLM_DIV GIVING NEW-BCO . IF NEW-BCO NE ' ' PRINT LOSS-REPORT-5 INPUT_BCO = NEW-BCO ELSE PRINT LOSS-REPORT-6 END-IF Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 93 OCCURS PARM LIST FILE * FILE REPORT01 PRINTER * WS-TEXT W 10 A VALUE 'THISOCCURS' WS-RED WS-TEXT 1 A OCCURS 10 INDEX WS-IDX * JOB INPUT NULL * WS-IDX = 1 DO WHILE WS-IDX LE 10 DISPLAY 'TEXT' WS-IDX ':' WS-RED(WS-IDX) WS-IDX = WS-IDX + 1 END-DO STOP * WRAP-UP. PROC. DISPLAY ' END OF PROCESS ' END-PROC Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 94 OCCURS - Result Result TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT Easytrieve Plus 1 2 3 4 5 6 7 8 9 10 :T :H :I :S :O :C :C :U :R :S Ver 1.0 Author : Annapoorna Venkateswaran Page 95 CASE / ENDEND-CASE • This is similar to the EVALUATE statement in COBOL but not so elaborate • For Syntax is CASE – WHEN – END-CASE • There can be any number of WHEN inside a CASE. • The end of one WHEN is identified by the next WHEN or END-CASE statement • If the field being evaluated is alphanumeric then the value is put inside single quotes in the WHEN statement Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 96 CASE / ENDEND-CASE - Statement JOB INPUT NULL * WS-IDX = 1 DO WHILE WS-IDX LE 10 CASE WS-IDX WHEN 1 THRU 3 DISPLAY 'CASE 1 WHEN 9 DISPLAY 'CASE 2 OTHERWISE DISPLAY 'OTHER END-CASE WS-IDX = WS-IDX + 1 END-DO STOP * WRAP-UP. PROC. DISPLAY ' END OF PROCESS Easytrieve Plus Ver 1.0 - TEXT' WS-IDX ':' WS-RED(WS-IDX) - TEXT' WS-IDX ':' WS-RED(WS-IDX) - TEXT' WS-IDX ':' WS-RED(WS-IDX) ' Author : Annapoorna Venkateswaran Page 97 CASE / ENDEND-CASE – Result Result CASE 1 CASE 1 CASE 1 OTHER OTHER OTHER OTHER OTHER CASE 2 OTHER - Easytrieve Plus TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT 1 2 3 4 5 6 7 8 9 10 :T :H :I :S :O :C :C :U :R :S Ver 1.0 Author : Annapoorna Venkateswaran Page 98 MATCH MATCHED helps in •Match records in 2 or more files based on a key field •Best suited for Master file – Transaction file matching Must do for MATCHED •Must have One Master file and atleast one Transaction file •It is advised to have a Unique key for the Master file •Both files should be sorted prior to MATCH with the same key field •The first file in the JOB is the Master file and the following are transaction file •End of Master file indicates the end of job •Key should be mentioned in the JOB statement Don’t of MATCHED •Duplicates in the Master file may not give in required results •Having more than 2 transaction file may cause confusion Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 99 MATCH Pseudo code for MATCHED Mechanism Reads the first record of Master file and transaction file(s) If key matches Read the transaction Else If master key less than transaction key Read master key else Read transaction Key Point of Caution In the “NOT MATCHED” Block only variable of the file with key value less will be accessible. If you try to access the other file variables it will result in “Invalid File Reference” Error. To identify the active file in the “NOT MATCHED” Block use the following Syntax -- If Transaction-File indicates that Transaction key is less than Master key Syntax -- If Master-File indicates that Master key is less than Transaction key Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 100 MATCH //MAST DD DISP=SHR,DSN=WIP108.OFFSHORE.WKSITE.EZP1(MAST) //TRAN DD DISP=SHR,DSN=WIP108.OFFSHORE.WKSITE.EZP1(TRANS) //SYSIN DD * PARM LIST FILE * FILE MAST MKEY 1 1 A MDESC 2 6 A * FILE TRAN TKEY 1 1 A TDESC 2 6 A * JOB INPUT(MAST KEY(MKEY) + TRAN KEY(TKEY)) FINISH WRAP-UP IF MATCHED MAST TRAN IF NOT DUPLICATE TRAN DISPLAY 'MAST:' MKEY MDESC +2 'TRAN:' TKEY TDESC ELSE DISPLAY 'MAST:' MKEY MDESC +2 'DUP TRAN:' TKEY TDESC END-IF ELSE IF MAST DISPLAY 'ONLY MAST:' MKEY MDESC END-IF IF TRAN DISPLAY 'ONLY TRAN:' TKEY TDESC END-IF END-IF Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 101 MATCH – Result Results MAST:1 MAST1 TRAN:1 TRAN1 ONLY TRAN:2 TRAN2 ONLY TRAN:3 TRAN3 ONLY TRAN:3 TRAN3 ONLY TRAN:4 TRAN4 MAST:5 MAST5 DUP TRAN:5 TRAN5 MAST:5 MAST5 DUP TRAN:5 TRAN5 ONLY MAST:9 MAST9 Results – Input WIP108.OFFSHORE.WKSITE.EZP1(MAST1) MAST:1 MAST1 TRAN:1 TRAN1 ONLY TRAN:2 TRAN2 ONLY TRAN:3 TRAN3 ONLY TRAN:3 TRAN3 ONLY TRAN:4 TRAN4 MAST:5 MAST5 DUP TRAN:5 TRAN5 MAST:5 MAST5 DUP TRAN:5 TRAN5 ONLY MAST:5 MAST5 ONLY MAST:9 MAST9 Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 102 Miscellaneous RESET – If more than one activity (especially JOB) exist and if a same working storage field is used in both the activity then the latest updated value from the first JOB is carried out to the Second JOB. To avoid this we can use the RESET key word in the declaration of the variable. This will initialize the variable to hold the details defined in the VALUE keyword PARM – To access the PARM from the JCL, Easytrieve has an system defined program EZTPX01. It takes the length of the parameter (Binary data type) to be received and the variable into which the parm details need to be copied. If the first parameter is not populated or erroneously populated then it gets updated with the number of bytes actually read by the called macro. MACRO – For including copy books in Easytrieve the ‘%’ symbol is used. The library where the copy book is present should be referred to by the //MACRO statement in the JCL RECORD-COUNT & RECORD-LENGTH – Returns the number of records and length of the referred file. Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 103 Misc. - RESET * WS-TEMP W 20 A VALUE 'INITIAL VALUE ***' WS-TEMP1 W 20 A VALUE 'INITIAL VALUE 1 ' RESET * JOB INPUT NULL * DISPLAY 'FIRST EXECUTION' DISPLAY 'WS-TEMP :' WS-TEMP DISPLAY 'WS-TEMP1:' WS-TEMP1 WS-TEMP = 'CHANGED VALUE' WS-TEMP1 = WS-TEMP DISPLAY 'AFTER MANIPULATION ' DISPLAY 'WS-TEMP :' WS-TEMP DISPLAY 'WS-TEMP1:' WS-TEMP1 STOP * JOB INPUT NULL * DISPLAY 'SECOND EXECUTION' DISPLAY 'WS-TEMP :' WS-TEMP DISPLAY 'WS-TEMP1:' WS-TEMP1 STOP * Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 104 Misc. - RESET Result * FIRST EXECUTION WS-TEMP :INITIAL VALUE *** WS-TEMP1:INITIAL VALUE 1 * AFTER MANIPULATION WS-TEMP :CHANGED VALUE WS-TEMP1:CHANGED VALUE * SECOND EXECUTION WS-TEMP :CHANGED VALUE WS-TEMP1:INITIAL VALUE 1 Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 105 INCLUDE – MACRO //EZPLUS1 //STEPLIB // //SYSPRINT //EZTVFM //MACRO //INDD //MAILTAB //OUTDD // //SYSIN * FILE INDD . * * %EDATESCT * Easytrieve Plus EXEC PGM=EZTPA00 DD DSN=SYSTEMS.LINKLIB,DISP=SHR DD DSN=SYS5.PROD.LINKLIB,DISP=SHR DD SYSOUT=* DD DATACLAS=MB001 DD DSN=SYS5.PROD.EZPMACRO,DISP=SHR DD DSN=WIP284.AGNT.JA600.AGTMFDSK,DISP=SHR DD DSN=FARM.AGNT.JA600.MAILID.SORTOUT,DISP=SHR DD DSN=WIP284.AGNT.U062201.OUT, DISP=(,CATLG,DELETE),DATACLAS=MB001,RECFM=FB,LRECL=460 DD * Ver 1.0 Author : Annapoorna Venkateswaran Page 106 Misc. - PARM //J1011A EXEC PGM=J1011PRA,PARM='1' //STEPLIB DD DSN=SYSTEMS.LINKLIB,DISP=SHR // DD DSN=SYS5.PROD.LINKLIB,DISP=SHR // DD DSN=SYS3.STAG.LINKLIB,DISP=SHR // DD DSN=SYS3.PROD.LINKLIB,DISP=SHR //EZTFM DD SPACE=(CYL,(1,1)),UNIT=SYSDA //EZTVFM DD SPACE=(CYL,(10,10)),UNIT=SYSDA //SYSPRINT DD SYSOUT=Y . DEFINE + PARM_INFO S 03 A PARM_LTH PARM_INFO 02 B PARM_IN PARM_INFO +2 01 A * JOB INPUT FILEA START INIT-PARA FINISH WRAP-UP INIT-PARA. PROC * PARM_LTH = 1 CALL EZTPX01 USING(PARM-REGISTER PARM_INFO) * SYS4-SNO = PARM_IN IF PARM_IN = '1' SYS4-DESC = 'CURRENT ROLLBACK TOTALS END-IF Easytrieve Plus Ver 1.0 ' Author : Annapoorna Venkateswaran Page 107 Misc. – SYSDATE/TIME JOB INPUT NULL * WS-DATE = SYSDATE DISPLAY 'SYSDATE :' WS-DATE * WS-DATE = SYSDATE-LONG DISPLAY 'SYSDATE-LONG :' WS-DATE * WS-TIME = SYSTIME DISPLAY 'SYSTIME :' WS-TIME * STOP * WRAP-UP. PROC. DISPLAY ' END OF PROCESS ' END-PROC * Results SYSDATE :07/14/04 SYSDATE-LONG :07/14/2004 SYSTIME : 5.22.50 Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 108 In Stream Execution //<userid>BC JOB CCSP,‘xxx yyyy',MSGCLASS=Y,CLASS=6, // NOTIFY=&SYSUID //************************************************************ //STEP01 EXEC PGM=EZTPA00 //EZTFM DD SPACE=(CYL,(1,1)),UNIT=SYSDA //EZTVFM DD SPACE=(CYL,(10,10)),UNIT=SYSDA //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSUDUMP DD SYSOUT=* //FILEA DD DSN=&HIG1.&HIG2.IN,DISP=SHR //FILEB DD DSN=&HIG1.&HIG2.OUT, // DISP=(,CATLG,DELETE),UNIT=SYSDA, // DATACLAS=MB001, // DCB=(RECFM=FB,LRECL=280) //************************************************************ //SYSIN DD * . <EZP program> Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 109 Procedural Execution //<userid>BC JOB CCSP,‘xxx yyyy',MSGCLASS=Y,CLASS=6, // NOTIFY=&SYSUID //************************************************************ //JA736RPT EXEC PGM=JA736RPT //********************************************************** //STEPLIB DD DSN=SYS5.PROD.LINKLIB,DISP=SHR // DD DSN=SYS3.STAG.LINKLIB,DISP=SHR // DD DSN=SYS3.PROD.LINKLIB,DISP=SHR //EZTFM DD SPACE=(CYL,(1,1)),DATACLAS=MB010 //EZTVFM DD SPACE=(CYL,(10,10)),DATACLAS=MB010 //FILEA DD DSN=&HIG1.&HIG2.IN,DISP=SHR //FILEB DD DSN=&HIG1.&HIG2.OUT, // DISP=(,CATLG,DELETE),UNIT=SYSDA, // DATACLAS=MB001, // DCB=(RECFM=VB,LRECL=280) /* Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 110 Appendix – A Sample Input data considered for all reports Menu Utilities Compilers Help BROWSE WIP108.OFFSHORE.WKSITE.EZP1(DATA) - 01.05 Line 00000000 Col Command ===> Scroll == ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-********************************* Top of Data ************************** 00002 Name2 history 00000 00002 Name2 geog. 05000 00002 Name2 science 10000 00001 Name1 history 04000 00001 Name1 geog. 05000 00001 Name1 science 10000 00001 Name1 maths 10000 00002 Name1 history 04000 00002 Name1 geog. 05000 00002 Name0 history 04000 00002 Name0 geog. 05000 00002 Name0 science 10000 00003 Name1 history 04000 00004 Name2 geog. 05000 00005 Name3 science 10000 ******************************** Bottom of Data ************************ Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 111 Appendix – B Sample Input data considered for Matched BROWSE WIP108.OFFSHORE.WKSITE.EZP1(MAST) - 01.02 Line 00000000 Col Command ===> Scroll == ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-********************************* Top of Data ************************** 1 MAST1 5 MAST5 9 MAST9 ******************************** Bottom of Data ************************ BROWSE WIP108.OFFSHORE.WKSITE.EZP1(TRANS) - 01.01 Line 00000000 Col Command ===> Scroll == ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-********************************* Top of Data ************************** 1 TRAN1 2 TRAN2 3 TRAN31 3 TRAN32 4 TRAN4 5 TRAN51 5 TRAN52 ******************************** Bottom of Data ************************ Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 112 Appendix – B (..contd) BROWSE WIP108.OFFSHORE.WKSITE.EZP1(MAST1) - 01.00 Line 00000000 Col Command ===> Scroll == ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-********************************* Top of Data ************************** 1 MAST1 5 MAST5 5 MAST5 9 MAST9 ******************************** Bottom of Data ************************ Easytrieve Plus Ver 1.0 Author : Annapoorna Venkateswaran Page 113