In this article we are going to explain some of the expressions used in Easytrieve. The basics have already been explained in Easytrieve – Basic Description and Explanation.

We will use the same basic program used in the previous post of Easytrieve. That is,

FILE PERSNL FB(150 1800)

NAME   17           8              A

EMP#    9              5              N

DEPT      1              3              N

GROSS  30           4              P             2

JOB INPUT PERSNL NAME SAMPLE

CONDITIONAL EXPRESSION:

Consider that you want calculate Netpay and Deduction. The deduction will happen only if Gross amount is greater than 500. The code will be written as

FILE PERSNL FB(150 1800)

NAME   17           8              A

EMP#    9              5              N

DEPT      1              3              N

GROSS  30           4              P             2

NETPAY                  W          4              P             2

DED        W            4              P             2

JOB INPUT PERSNL NAME SAMPLE

IF GROSS GE 500

DED = 0.28 * GROSS

NETPAY = GROSS – DED

ELSE

NETPAY = GROSS

END-IF

PRINT PAY-RPT

REPORT PAY-RPT LINESIZE 80

TITLE 01 ‘EMPLOYE REPORT’

LINE 01 DEPT NAME EMP# GROSS NETPAY DED

This is an example of If Condition. It can be of the following types.

If field one (EQ /NQ /GT / GE/LT/LE) field two

Can be compares with series of values.

Example:

If STATE = ‘GA’ ‘SC’ ‘TN’

If ALPHABET = ‘A’ THRU ‘G’

If SALARY NE 100 THRU 500

If CLASS = 900 940 THRU 960 970 980 THRU 990

If field NOT NUMERIC

If field SPACE (SPACES)

If field ALPHABETIC

If field ZERO/ZEROS/ZEROES

LOGICAL EXPRESSION:

Easytrieve uses both ‘AND’ and ‘OR’ logical expressions.

Example

IF ALPHABET = ‘A’ THRU ‘F’ AND SALARY GE 1000

IF ALPHABET = ‘A’ THRU ‘F’ AND SALARY LE 1000 OR STATE = ‘TN’

In the second example the condition becomes true if either State is ‘TN or if the alphabet is between A and F and Salary is less than or equal to 1000.

MASK:

MASK is used to edit the format in which output appears.

Example

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

NETPAY                  W          4              P             2              MASK A

DED        W            4              P             2              MASK(A BWZ)

In the above example MASK(A ‘$,$$9.99’) shows that the GROSS amount will be preceded with a $ symbol and each preceding zero will be replaced with $, that is floating $ sign. ‘A’ is the name of the MASK.

To repeat the same mask in any other field, we can define using the mask name as in Netpay. BWZ means ‘Blank When Zero’ This is used to suppress all zero values.

Gross Amount                                   After applying MASK

014725                                                  $147.25

000255                                                  $2.55

146285                                                  $1,462.85

HEADING:

Heading can be used to rename the heading of a field.

Example:

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

Single quote indicates that the heading has to be stacked one word over other, as

EMPLOYEE

NUM

REPORT DEFINITION STATEMENTS:

Report definition statements are used to define the content of report, specified in the order it must appear in a report declaration. There are mainly six report definition statements.

  • SEQUENCE

To sort in ascending or descending order based on a field.

  • CONTROL

To create a control break on a specified column called control field. It automatically totals all quantitative fields at the time of control break and grand total at the end.

  • SUM

The SUM statement overwrites the CONTROL statement in taking the quantitative sum of all the fields. When SUM is used, only the sum of specified field is taken.

  • TITLE

TITLE specifies the name of the report

  • HEADING

It is used to give different names to the field similar to HEADING parameter used in Define Statements.

  • LINE

LINE contains the name of the field in the order in which it has to be displayed in the report.

Example

FILE PERSNL FB(150 1800)

NAME   17           8              A

EMP#    9              5              N

DEPT      1              3              N

GROSS  30           4              P             2

NETPAY                  W          4              P             2

DED        W            4              P             2

JOB INPUT PERSNL NAME SAMPLE

IF GROSS GE 500

DED = 0.28 * GROSS

NETPAY = GROSS – DED

ELSE

NETPAY = GROSS

END-IF

PRINT PAY-RPT

REPORT PAY-RPT LINESIZE 80

SEQUENCE DEPT

CONTROL DEPT

SUM GROSS

TITLE 01 ‘EMPLOYE REPORT’

HEADING NAME (‘EMPLIYEE’ ‘NAME’)

LINE 01 DEPT NAME EMP# GROSS NETPAY DED

easytrieve 2

 

Easytrieve – Expressions with Examples
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *