Tags

, , , , , , ,

Easytrieve has 3 sections all together

1)    Environment Section (Optional)

The environment definition section establishes parameters for the program. This section lets you override standard CA-Easytrieve/Plus options and to choose a mode of operation.

2)    Library Section (Optional)

The library definition section describes the data the program is to process. It describes data files and their associated fields and any working storage requirements of the program.

3)    Activity Sections (Required)

The activity definition section is the only mandatory section of your program. There are two types of activities—JOB and SORT. You can code any number of JOB or SORT activities in any order.

_ JOB activities read information from files, examine and manipulate data, write information to files, and initiate printed reports.

_ SORT activities create sequenced files. (Files with records in alphabetical or numerical order.)

Provided below is a sample program. We will discuss each part of it for good understanding.

FILE PERSNL FB (150 1800)

NAME                     17        8        A

EMP#                        9        5        N                    (HEADING (‘EMPLOYEE’ ‘NUMBER’)

DEPT                       98        3        N

GROSS                    94        4        P        2           MASK (A ‘$$,$$9.99’)

NET-PAY                  W        4        P        2          MASK A

DEDUCTIONS          W        4        P        2          MASK (A BWZ)

JOB INPUT PERSNL NAME FIRST-PROGRAM

IF GROSS GE 500

     DEDUCTIONS = .28 * GROSS

     NET-PAY = GROSS—DEDUCTIONS

ELSE

     NET-PAY = GROSS

     DEDUCTIONS = 0

END-IF

PRINT PAY-RPT

REPORT PAY-RPT LINESIZE 80

SEQUENCE DEPT

CONTROL DEPT

SUM GROSS

TITLE 01 ‘PERSONNEL REPORT EXAMPLE-1’

HEADING NAME (‘EMPLOYEE’ ‘NAME’)

LINE DEPT NAME EMP# GROSS NET-PAY DEDUCTIONS

We do not have any Environment section here.

We are starting with Library section.

FILE STATEMENT

In here, files that are going to be used in the program should be declared by using keyword FILE.

FILE PERSNL FB (150 1800)

PERSNL is the name of the file. And its details FB (150 1800) are not mandatory.

DEFINE STATEMENT

FIELD-NAME         START   END   DATA-TYPE   DECIMAL       EXTRAS

NAME                      17         8              A

EMP#                        9          5              N                                 (HEADING (‘EMPLOYEE’ ‘NUMBER’)

DEPT                        98         3              N

GROSS                     94         4              P                 2               MASK (A ‘$$,$$9.99’)

NET-PAY                  W          4              P                2                MASK A

DEDUCTIONS          W          4              P                 2               MASK (A BWZ)

Above NAME declaration is similar to

DEFINE NAME                              17      8        A

DEFINE keyword is optional. But if we want to declare any variable in the middle of program logic (ACTIVITY section), we can do so, by using the keyword DEFINE and the letter W (working storage variable) at the start position as shown above for NET-PAY.

Note: It is not necessary to declare all the fields in your input file. We can just declare the fields we require and in the order we require.

Different data types that are available are

A – Alphanumeric (Max Len : 32,767)

N – Numeric (Max Len : 18)

P – Packed decimal (Max Len : 10)

U – Unsign packed (Max Len : 9)

B – Binary (4)

We can also mention the decimal places if we have as mentioned for GROSS.

And for REPORT purpose, if we want mask (display in better format) then we can use MASK as below.

GROSS                  94       4        P                  2        MASK (A ‘$$,$$9.99’)

NET-PAY                W       4        P                  2        MASK A

DEDUCTIONS        W       4        P                  2        MASK (A BWZ)

For GROSS, we are trying to report the field as $$,$$9.99. This MASK can also be given a name as “A” as mentioned above. So it can be used for other data names as well. And BWZ means “Blank When Zeroes” for the field DEDUCTIONS.

To give a better name for the field, we can make use of HEADING.

EMP#                     9        5        N                           (HEADING (‘EMPLOYEE’ ‘NUMBER’)

Here as we have mentioned ‘EMPLOYEE’ ‘NUMBER’ in single quotes. We would get report with ‘EMPLOYEE’ in first line and ‘NUMBER’ in second line just below it.

 ACTIVITY SECTION

JOB STATEMENT

JOB INPUT PERSNL NAME FIRST-PROGRAM

 In above statement, just mentioning JOB is mandatory. And if we have any input files to be used for processing, then we must mention those files here. SO here we have mentioned the file PERSNL after the keyword INPUT. Next to provide a name for the job, we have NAME followed by its name FIRST-PROGRAM.

If we have just one input file as in this example, JOB automatically uses it for any operations.

Next, different logics like IF… END-IF, DO WHILE, PERFORM can be used to process data in the INPUT files. ‘IF’ statement is mentioned below for your reference.

IF GROSS GE 500

    DEDUCTIONS = .28 * GROSS

    NET-PAY = GROSS—DEDUCTIONS

ELSE

    NET-PAY = GROSS

    DEDUCTIONS = 0

END-IF

PRINT STATEMENT

PRINT PAY-RPT

PRINT statement activates report statements that result in a printed report.

Once all the conditions are executed on a record that has been read, then we need to print it in the report. For this we make use of PRINT statement, which actually refers to one of the REPORT statements. In the above example, PAY-RPT is the REPROT name that we are referring. So after the PRINT statement executes, the control goes to the REPORT PAY-RPT statement for creating the report. If we skip the report name, then the first report in the program will be executed.

REPORT STATEMENT

REPORT PAY-RPT LINESIZE 80

SEQUENCE DEPT

CONTROL DEPT

SUM GROSS

TITLE 01 ‘PERSONNEL REPORT EXAMPLE-1’

HEADING NAME (‘EMPLOYEE’ ‘NAME’)

LINE DEPT NAME EMP# GROSS NET-PAY DEDUCTIONS

A report declaration consists of a series of statements that define the format and content of a

report. These statements consist of the REPORT statement, report definition statements, and report procedures. A linesize of 80 restricts report output to 80 characters per printed line.

 There are six report definition statements in CA-Easytrieve/Plus. When used, they must occur after the REPORT statement and in a specified order as follows:

_ SEQUENCE

_ CONTROL

_ SUM

_ TITLE

_ HEADING

_ LINE

A clever CA-Easytrieve/Plus user came up with a useful mnemonic device for remembering these statements and their order:

Sisters   Can   Sometimes   Tell   Horrible   Lies

SEQUENCE STATEMENT

SEQUENCE DEPT

The SEQUENCE statement sorts your report on a specified key in ascending or descending order. Ascending order is the default for the SEQUENCE statement. For descending order, you just put a D after the field name separated by a space.

CONTROL STATEMENT

CONTROL DEPT

The CONTROL statement creates a control break on a specified field (called the control field). It automatically totals all quantitative fields (fields with decimal positions) at the time of the control break and grand totals at the end of the report.

SUM STATEMENT

SUM GROSS

The SUM statement specifies the quantitative fields you want totaled on a control break. When used, any fields not specified on the SUM statement are not totaled. So we can override the CONTROL statement here by saying what quantitative fields need to added up.

TITLE STATEMENT

TITLE 01 ‘PERSONNEL REPORT EXAMPLE-1’

The TITLE statement gives us the title of our report. You can omit the title number when you have only one title; it simply defaults to 01. When you have more than one title (and TITLE statement), you must number them in ascending order. The system date and the page number automatically print on the same line.

HEADING STATEMENT

HEADING NAME (‘EMPLOYEE’ ‘NAME’)

The HEADING statement, like the HEADING parameter of the DEFINE statement, prints user-defined column headings for specified fields. (It overrides the HEADING parameter of the DEFINE statement if one already exists for the field you are describing.)

LINE STATEMENT

LINE DEPT NAME EMP# GROSS NET-PAY DEDUCTIONS

The LINE statement defines the contents of a printed line (detail line) in your report. The LINE statement is the only report definition statement you are required to include in your report declaration. Without it, CA-Easytrieve/Plus has no idea what detail information you want printed on your report or the order in which you want it printed.

MACRO

FILE PERSNL FB(150 1800)

                                                               }

%PERSNL                                          } macro

} invocation

A CA-Easytrieve/Plus macro is simply a portion of a program that you store somewhere for repeated use. It could be a file definition that you want to use in more than one program without typing it more than once, or it could be a piece of program logic or a report declaration that you use often in different programs.

The main goal of a macro is to save you from duplicating your effort. In our example program, we could place all of the field definitions for the PERSNL file in a CA-Easytrieve/Plus macro. From there, many programs could access them.

To do this, you store the code you want saved in the designated macro storage area at your site. The first line of any macro you save must consist of the word MACRO. The storage facility you have at your site also requires that you give the macro a name.

Once your macro is stored and has a name, you just call it into your program whenever you need it by specifying the name preceded by a percent symbol (%).

If you would like to Earn Free Stocks, Credit card Points and Bank account Bonuses, Please visit My Finance Blog

You may also like to look at:

Important SQL CODES and ABEND CODES
SORT JOIN – TO JOIN TWO FILES BASED ON A KEY
KNOW YOUR MAINFRAME
REXX – INITIAL SETUP
EASYTRIEVE – A023 ABEND
EASYTRIEVE – SORT and FILE COMPARISION
EASYTRIEVE – Special-name Report Procedures
EASYTRIEVE – REPORT STAEMENT
EASYTRIEVE – Sample Program – Table And Search
EASYTRIEVE – Sample Program – Display Totals and Summary
EASYTRIEVE – Sample Program – Display Employee Data
CA-Easytrieve/Plus – Basics
REXX TOOL # 02 – FSAVE – Save member opened in VIEW mode
REXX TOOL # 01 – O – Open Any Mainframe Element from any ISPF Screen
REXX – INDEX, POS, SUBSTR, COMPARE
REXX – READ THE DSN PROVIDED AS DD IN JCL
REXX – SEND MULTIPLE ARGUMENTS THROUGH JCL
REXX – HOW TO COMPILE YOUR REXX EXEC
REXX – CHANGE UPPER TO LOWER CASE
REXX – GET LAST 4 DAYS FROM GIVEN DATE
REXX – PANEL Definition
REXX – READ, CREATE AND WRITE DATA TO A DATASET
REXX TOOL TO SUBSTITUTE SYMBOLICS IN A PROC
Advertisement