Showing posts with label Easytrieve. Show all posts
Showing posts with label Easytrieve. Show all posts

Wednesday, September 11, 2019

IF-ELSE, DO, CASE in Easytrieve

IF, ELSE-IF, ELSE & END-IF statements are available in Easytrieve. Relational operators are :

i)  EQ or =
ii) NE or »= or NQ
iii) LT or < or LS
iv) LE or <= or LQ
v) GT or > or GR
vi) GE or >= or GQ

To perform a set of statements n times, DO WHILE or DO UNTIL statement can be used.
Example :
I = 1
DO WHILE I < 10
I = I + 1
END-DO

CASE statement : CASE is similar to EVALUATE statement.

Example :
i)

CASE WS-NUM
WHEN 1
WS-DOB-CC EQ '18'
WHEN 0 2 -> OR need not be coded explicitly
WS-DOB-CC EQ '19'
WHEN 3
WS-DOB-CC EQ '20'
END-CASE

ii)

CASE WORK-GROSS
WHEN 0 THRU 1000
XMAS-BONUS = PAY-GROSS * 1.03
WHEN 1001 THRU 5000
XMAS-BONUS = PAY-GROSS * 1.05
OTHERWISE
XMAS-BONUS = PAY-GROSS * 1.10
END-CASE

MOVE statement in Easytrieve


  • Assignments(using EQ or =) assigns the value in right side to the variable inthe left side.

            Example : WS-FLAG EQ 'Y' or WS-FLAG = 'Y'

  • MOVE statement moves a string from one variable to another. MOVE statement does not transfer the value in Numeric form(even if it is used for numeric fields the value moved is in Character form). However, when we move ZEROES the value moved is Numeric.
  • MOVE LIKE statement copies fields with identical field names from one file to another.

          SYNTAX : MOVE LIKE <file1/rec1> to <file2/rec2>

Library section in Easytrieve

In Library Section Easytrieve have below statements

FILE statement - This statement describes the files accessed by the program.

Syntax: FILE <filename> <filetype> <devicetype> <recordformat>

Example: FILE INFILE      FB(80 0)

File Name: same as DD name in JCL (max length is 8 char)

File Type: specifies the type of file (by default it is sequential )

                             1) IS: Indexed Sequential Access Method
                             2) VS: Virtual Storage Access Method
                             3) ES: ESDS VSAM File

Device Type: This could be CARD, PUNCH, PRINTER and TAPE
                             (For Report we must use PRINTER option)

Record Format: This specificities the record format of the file.
                            F   : Fixed Unblocked
                            FB: Fixed Blocked
                            V   :Variable Unblocked
                            VB:Variable Blocked
                             U  :Undefined

Field Declarations: Field names can be a max of 40 characters. It can contain alphabets(A-Z and a-z), numbers(0-9) and all special characters except delimiters. A field name should contain atleast one alphabet or special char.


Working Storage Fields


Example1:  WS-NAME       W 10 A

Where  W: indicates it is working storage Variable
            10: it is the length of the WS-NAME field
            A: is the datatype if the WS-NAME field

Example2: WS-NAME       W 7 A VALUE 'RATNESH' (It is similar to COBOL)


  • Fields to be used within Report Section like page number etc., should be defined with type “S”
  • MASK can be used for editing characters(to be displayed in report)                
          MASK of 9 causes a digit to print.
          MASK of Z causes a digit to print (except for leading zeros).
          MASK of * causes an asterisk to replace leading zero digits.
          MASK of - causes a minus sign to print prior to the first non-zero digit of a negative number.
          MASK of $ causes a currency symbol to print prior to the first non-zero digit      

  • We can use DEFINE statement to declare fields.
          For Example DEFINE CURRENT-MONTH W 10 A VALUE 'JANUARY'   
  • We can Redefine fields/records by specifying the offset.                  
          Lets see the below example for Library Section: 

    FILE   INFILE      FB(80 0)

    INPUT-REC-STRC                      1  80 A
      INPUT-ID                          1  08 N
      INPUT-NAME.                       9  20 A
      INPUT-ADDRESS                     29 20 A
      INPUT-CONTACT.                    49 10 N
      FILLER                            59 21 A                              









What is an Easytrieve language?

Easytrieve is an information retrieval and data management system designed to simplify programming. Its English-like language and simple declarative statements provide the tools needed to produce comprehensive reports with ease.

Structure of an Easytrieve program


Easytrieve Contains 3 sections

ENVIRONMENT SECTION : Optional
LIBRARY SECTION             : Optional
ACTIVITY SECTION           : Mandatory



  1. Environment Section: Establishes parameters for the program. These parameters override standard Easytrieve options.
  2. Library Section: Describes datafiles and other fields(including working storage fields) to be used in the program.
  3. Active Section: There are 2 types of activities - JOB and SORT
  • JOB activities read from or write to files and manipulate data.
  • SORT activities create sequenced files.