Showing posts with label EASYTRIEVE. Show all posts
Showing posts with label EASYTRIEVE. Show all posts

Saturday, 10 August 2013

Easytrieve Basic Conditions.


JOB Statement
The JOB statement defines and initiates processing activity. It also identifies the name of the automatic input file.

JOB   INPUT     file – name     NAME    job-name

Logic
Data selection and manipulation takes place in the logic section of an EASYTRIEVE PLUS program. Logic is coded immediately after the JOB statement.
IF Statement
Processing within a JOB activity is dependent on the conditional (IF) statements present in the program.

  • When an IF statement is present, each record read from the input file is processed against this condition.
  • Every IF statement must end with END-IF.


Example :

IF      DEPT    =     910
IF      NAME   =    ‘SMITH’
IF      AMT     GE  500

The value in another field:

IF      DIV        =    HOLD-DIV
IF      STATE   =   ‘GA’ ‘SC’ ‘TN’
IF      CLASS  =   ‘A’ THRU ‘E’
IF      AMT      NE     100   THRU    500
IF      DEPT   =  900  940   THRU   950   960   970  THRU  980

IF / ELSE
ELSE specifies alternative processing when the condition established by the IF statement is not met.
  • For true IF’s all commands up to the ELSE (or END-IF if no ELSE is present) are executed.
  • For false IF’s, commands between ELSE and END-IF are executed.
  • Following END-IF, processing continues regardless of the result of the IF.
Example

IF    DIV   =    ‘A’     THRU    ‘L’
          DEDUCTIONS   =   GROSS * .15
ELSE
         DEDUCTIONS    =   GROSS * .18
END-IF
Records with the DIV in the A through L range are processed according to the statement(s) between the IF and ELSE. For all records with DIV not in the range A through L , the statement(s) following ELSE is executed until END-IF is reached.



Assignment Statement
The assignment statement establishes a value in a field by copying the value from another field or literal. The assignment statement also accomplishes data conversion, such as packing or unpacking data.
Syntax

                          Field-name-2 
 Field-name   =     literal
                     EQ  arithmetic expression


Created with Artisteer

Sunday, 4 August 2013

Easytrieve Macros


Macros can be used for any or all parts of an EASYTRIEVE PLUS program. You can use macros to provide shortcuts for your end users in many ways. You can also use macros to simplify some of your programming routines.
Macro Applications
The following list is provided to give you ideas on how to use macros:
  • Data Dictionary – You can store file and field definitions for frequently requested files in a macro. This eliminates the need to code field definitions every time a file is used in an EASYTRIEVE PLUS program.
  • Commonly Used Routines - If you find that you have certain routines that are used regularly, they can be made into a macro and recoding of these routines can be avoided.
  • Report Templating – Regularly generated reports can be stored as a macro and recalled as needed.
  • Simulate Query – In this application an entire EASYTRIEVE PLUS program would be stored in a macro and the end user would code only a single line to produce a report.
  • Logic Templating – Frequently occurring logic patterns may be stored as macros for use in a variety of programs.
  • Simple Presentation of Data – Data description and record presentation from any file structure can be controlled. When this information is placed in a macro the complexity of data structures is hidden from the user.
  • Control Access to Data – You can limit the fields available for user processing by coding only the fields you want them to have accessible in the macros in the data dictionary.


Created with Artisteer

Creating Easytrieve Macros.


Creating Macros
There are two parts to every macro: a prototype statement and the macro code.
Prototype Statement
A prototype statement identifies the code which follows as a macro and sets up substitution parameters if they are to be used. You are required to code the prototype statement first in a macro.
MACRO [n] [positional] [keyword]
  • You use MACRO to identify the start of a macro.
  • Two types of parameter substitution are available positional and keyword.
Positional – Ordered
  • No default substitution
  • Must be supplied when invoking a macro or will be null (treated as nonexistent).
Keyword – Unordered
  • Must supply default values
  • Useful when default values are needed or for infrequently used parameters
  • May be supplied or allowed to default when invoking a macro
Example
A macro called PAYLIB exists in your library containing:
MACRO
      FILE PAYROLL
            NAME                1    20     A
            DEPT               21     2     A
            GROSS             23     4     P   2
            NET                27      4     P   2
  
DEDUCTIONS                W      4     P   2
Macro Invocation
Once you have created and stored a macro you can use it in any program.
%macro-name macro-parameter
  • The % (percent sign) directs EASYTRIEVE PLUS to retrieve a macro with the designated name.
  • Macro-parameters are the parameters you want to be substituted in the macro (positional or keyword).
How to Use in a program
The PAYLIB macro on the previous page is used in a program in this manner.

%PAYLIB
 JOB INPUT PAYROLL NAME DEDUCTRPT
  IF DEPT = 911 914 THRU 920
             DEDUCTIONS = GROSS - NET
             PRINT  MACRO-EXAMPLE
  REPORT MACRO-EXAMPLE
  SEQUENCE DEPT NAME
  TITLE 1 ‘EXAMPLE OF USING MACROS’
  TITLE 2 ‘IN A PROGRAM’
  LINE 1 DEPT NAME GROSS NET DEDUCTIONS
  • MACRO(no substitution parameters)
  • MACRO POS1 POS2(only positional parameters)
  • MACRO 0 KEY1 VALUE1 KEY2 VALUE2 (only keyword parameters)
  • MACRO 2 POS1 POS2 KEY1 VALUE1 (keyword and positional combined)


Created with Artisteer

Easytrieve Macro Sample Program.


Macro Example with Parameter Substitution
A macro, called CNTLRPT, exists in your library, containing:

  MACRO 2  CNTL-FLD  VALUE RANGE  ‘  ‘  HIGH-VALUE ‘  ‘
*
  IF &CNTL-FLD  =  &VALUE  &RANGE  &HIGH-VALUE
           PRINT        RPT1
 END-IF
*
 REPORT    RPT1
           SEQUENCE    &CNTL-FLD NAME
           CONTROL      &CNTL-FLD NEWPAGE
           TITLE 1           ‘CONTROL REPORT OF NAME WITHIN &CNTL-FLD’          +
                                  &CNTL-FLD
           LINE 1             &CNTL-FLD NAME GROSS-PAY NET-PAY
The ampersand
(&) tells EASYTRIEVE PLUS which values are to be passed to the macro.
To use CNTLRPT, code:
%PAYLIB
JOB   INPUT   PAYFILE   NAME   REGPROG
%CNTLRPT   REGION   516

OR

 %PAYLIB   JOB   INPUT   PAYFILE   NAME   REGPROG
 %CNTLRPT   REGION   516   RANGE   THRU   HIGH-VALUE   520

 OR

 %PAYLIB   JOB   INPUT   PAYFILE   NAME   REGPROG
 %CNTLRPT   REGION   ‘516   520   525   580’
Macro Examples
The following examples illustrates some of the uses of macros.
Commonly Used Routines
This macro provides for using SYSDATE for comparison with any other data in a file.
  MACRO USER-DATE
*
*        GET THE CURRENT DATE AND PUT INTO
*        USER FIELD (LESS SLASHES)
*        DEFINE GETDATE-DATE W 8 A
*
 DEFINE   GETDATE-FIRST6   GETDATE-DATE     6       N
 DEFINE   GETDATE-LAST5   GETDATE-DATE   +3   5  A
 DEFINE   GETDATE-LAST6   GETDATE-DATE   +2   6  A
 DEFINE   GETDATE-LAST3   GETDATE-DATE   +5   3  A
 DEFINE   GETDATE-LAST2   GETDATE-DATE   +6   2  A
*
 GETDATE-DATE    =   SYSDATE . *  MOVE   ALL   8
 GETDATE-LAST3  =   GETDATE-LAST2 . *  SHIFT  LEFT  OVER NEXT   / 
 GETDATE-LAST6  =   GETDATE-LAST5 . *  SHIFT  LEFT  OVER FIRST   /
 &USER-DATE        =   GETDATE-FIRST6 . *  MOVE  TO  USER  FIELD
*
The DEFINE Statement allows you to define to define data fields outside of the library.


Created with Artisteer

Easytrieve Basic Conditions.


JOB Statement
The JOB statement defines and initiates processing activity. It also identifies the name of the automatic input file.

JOB   INPUT     file – name     NAME    job-name

Logic
Data selection and manipulation takes place in the logic section of an EASYTRIEVE PLUS program. Logic is coded immediately after the JOB statement.
IF Statement
Processing within a JOB activity is dependent on the conditional (IF) statements present in the program.

  • When an IF statement is present, each record read from the input file is processed against this condition.
  • Every IF statement must end with END-IF.



Example :

IF      DEPT    =     910
IF      NAME   =    ‘SMITH’
IF      AMT     GE  500

The value in another field:

IF      DIV        =    HOLD-DIV
IF      STATE   =   ‘GA’ ‘SC’ ‘TN’
IF      CLASS  =   ‘A’ THRU ‘E’
IF      AMT      NE     100   THRU    500
IF      DEPT   =  900  940   THRU   950   960   970  THRU  980

IF / ELSE
ELSE specifies alternative processing when the condition established by the IF statement is not met.
  • For true IF’s all commands up to the ELSE (or END-IF if no ELSE is present) are executed.
  • For false IF’s, commands between ELSE and END-IF are executed.
  • Following END-IF, processing continues regardless of the result of the IF.
Example

IF    DIV   =    ‘A’     THRU    ‘L’
          DEDUCTIONS   =   GROSS * .15
ELSE
         DEDUCTIONS    =   GROSS * .18
END-IF
Records with the DIV in the A through L range are processed according to the statement(s) between the IF and ELSE. For all records with DIV not in the range A through L , the statement(s) following ELSE is executed until END-IF is reached.




Assignment Statement
The assignment statement establishes a value in a field by copying the value from another field or literal. The assignment statement also accomplishes data conversion, such as packing or unpacking data.
Syntax

                          Field-name-2 
 Field-name   =     literal
                     EQ  arithmetic expression


Created with Artisteer

Tuesday, 30 July 2013

Easytrieve Basic Reporting

Overview
This section covers the fundamentals of coding an EASYTRIEVE PLUS program. It starts with a brief discussion of conventions (rules) for syntax. Next, there is an explanation of the structure of an EASYTRIEVE PLUS program that outlines the function and configuration of its segments. Finally, the Library and Job Activity segments of an EASYTRIEVE PLUS program are discussed in detail.
Upon completion of this section you will be able to write an entire EASYTRIEVE PLUS program consisting of:
  • Coding the file definition statement.
  • Coding the field definition statements for each requested field.
  • Coding the JOB statement.
  • Coding the logic portion using IF statements to select data for a report.
  • Coding assignment, calculation, and PRINT statements to perform data movements for the report.
  • Coding the report statement.
  • Coding the report definition statements.
Syntax Conventions
Syntax refers to the relationships among the parts of a statement. Syntax refers to the way the parts must be structured, independent of what these parts say or mean.
Delimiters
B   A blank is the basic delimiter. Its purpose is to separate the parts of a statement.

( )   Parentheses indicate more than one sub-parameter. e.g., HEADING (‘EMP’ ‘NO’)

:     A colon is used to qualify non-unique field names. e.g., PERSNL:NAME

,     A comma is never needed, but is optionally used for readability.

 ‘ ‘    Single quotation marks enclose literals, e.g., ‘TEXAS’

.      A period indicates the end of a statement, e.g.,

                 IF DEPT = 910. * DEPT 910 IS ACCOUNTING

*      An asterisk indicates a comment if it is the first non-blank character on a statement.
       No comments are allowed between continuation lines.

Statement Continuation

 +   A plus sign indicates that the statement continues with the first non-blank character
      in the next Statement Area.

      TITLE ‘ABC + DEF’ Prints ABCDEF


Easytrieve Basic Report Field Defination

Field Definition Statement

A field definition specifies data fields within a record on a file.
  • Four parameters are always required: field-name, start-location, field-length, and data-type.
  • Additional parameters include the number of decimal positions for quantitative fields, HEADING and MASK.
Syntax

Field-name      start-location         field-length    data-type    +
[ decimal-positions]         [HEADING ‘literal’ ]                          +
[ MASK { [letter] [BWZ] [‘literal’] } ]

Field-name
You create a field-name or adapt the field name in a record layout for your EASYTRIEVE PLUS program.
  • Field-names must be unique within a file.
  • The name can be 1 to 40 alphanumeric characters.
  • Special characters can be used, but not delimiters.
Start-location
The start location is the beginning location of a field in the record relative to the first position.
  • Start location can be explicitly defined based on position one of the record:

   NAME                   17        16         A
   ADDRESS            37        39         A
   PAY-NET              90         4          P      2
Field-length
You specify the length of a field in bytes (characters and / or spaces).

Data-type
You describe the type of data a field contains by coding the letter for that type after the field-length. There are five data-types.

              Type                               Max. Length ( bytes )

A          Alphanumeric                     32,767
N          Numeric                                 18
P          Packed                                   10
U          Unsigned Packed                     9
B          Binary                                      4
Decimal-positions
By specifying decimal-positions, you:
  • Identify a field to EASYTRIEVE PLUS as being quantitative.
  • Identify the field(s) to be automatically totaled when specified in a CONTROL report.
  • Allow for proper placement of commas and decimals with leading zeros suppressed when the field is printed.
Four types of data can have decimal positions:
                 N                    Numeric
                 P                    Packed
                 B                    Binary
                 U                    Unsigned Packed
Specify the decimal-positions by coding an integer (0 through 18) after the data-type. For example,
AMOUNT                40        5       N      2

Is a five-byte numeric field with two decimal positions.


Monday, 29 July 2013

Easytrieve Basic Report Edit Field Definition.



Easytrieve.
Easytrieve Basic Report Edit Field Definition


HEADING Parameter

You use the HEADING parameter to specify an alternative column heading for a field. (The default column heading is the field-name.)

  • Place the alternate column heading within single quotation marks. For example,
CL-NAME               5       20       A      HEADING ‘CLIENT NAME’

Produce the column heading
          
  CLIENT NAME    

MASK

An edit mask is a pattern of characters specifying how non-alphanumeric data is to be printed. Alphanumeric fields cannot be edited. An edit mask is created using combinations of the following characters:

9     Formats digits.
Z     Suppresses Leading zeroes.
*     Replaces leading zeroes with an asterisk.
-     Prints a minus sign prior to the first non-zero digit of a
      negative number
$    Prints a currency symbol prior to the first non-zero digit.

Each digit in the field must be designated in the mask. Any character which follows the last character of the edit mask is printed if the field is negative.

Example
              Mask             Field         Result
              ------------ ------------ ------------
              $$, $$9        01234       $1,234

Defining Edit Masks

You can define standard edit masks when your system is installed.

       MASK                                     USE
 ‘(999) 999-9999’                 Telephone Number
 ‘999-99-9999’                    Social Security number

 ‘Z9 / 99 / 99’                   Date
 ‘$$, $$$, $$9.99                 CREDIT’ Money (with floating $)

 ‘*, ***, ***, 999.99-‘           Protected Check Amount
 ‘--, ---, -9.99’                 Negative Number

Syntax

[     MASK   [letter]   [BWZ]    [‘literal’]       ]
  • MASK is the EASYTRIEVE PLUS keyword.
  • Letter names the edit mask to follow. Once a mask is defined, it need not be defined again; simply use the letter.
  • BWZ (blank when zero) specifies that a field should not be printed if the entire field contains zeroes. BWZ must be coded whenever needed.
  • Literal is the format of the mask using the characters indicated on the previous page.
Redefining a Field

Sometimes it is necessary to break a field into several parts in order to get the exact information for your report. A birth date, for example, may have been originally entered as one field in a record. Now you want to access this information by either the month, day, or year. With EASYTRIEVE PLUS you can redefine that field in the following manner:

DATE-OF-BIRTH             103         6            N
    MONTH                 103         2            N
    DAY                   105         2            N
    YEAR                  107         2            N


DATE-OF-BIRTH | _ | 0 | 2 | 1 | 0 | 5 | 5 | _ | _ | _ | _ |
 position 103 105 107

 Start-location of New Fields
In this exhibit, the MONTH (02) starts in position 103 and occupies position 103 and 104. The DAY starts in 105 and occupies positions 105 and 106. Finally, YEAR starts in 107 and occupies 107 and 108.lves setting aside as an area of storage as a place to keep calculations or other information that is to be created during the running of an EASYTRIEVE PLUS program.

  • Define working storage by specifying W as the start location.
  • The values stored in this field are associated with each individual record.
Example

GROSS          30         4     N   2
NET            34         4     N   2
WORK-DEDUCT    W          4     N   2  HEADING ‘DEDUCTIONS’


Easytrieve Basic Report Calculation

Calculations

There are four arithmetic operations in EASYTRIEVE PLUS :
*         multiplication
/         division
+        addition
 -        subtraction


Multiplication and division are performed before addition and subtraction in order from left to right. There must be a space before and after the arithmetic operators.

Parentheses in Calculations

Parentheses can be used to override this normal order of operation. Any level of parentheses nesting is allowed. (Operation proceeds from the innermost level to the outermost.)

RESULTS = GROSS - AMT * 1.3

 is the same as:

RESULT = GROSS - (AMT * 1.3)

but different from:

RESULT = (GROSS – AMT) * 1.3

Rounding in Calculations

To round calculations, add a ‘rounding factor’. The ‘rounding factor’ is composed of a decimal point followed by a zero digit for each decimal position in the receiving field followed by the digit 5.

      NEWFLD         W      4     P     2
JOB    INPUT    PERSNL    NAME    PAY1
     NEWFLD   =   (GROSS  *  1.87)  +   .005
PRINT
  • The PRINT statement makes data available for output to a report.
PRINT report-name

Example

IF REG = 25
    PRINT RPT1
END-IF
Only records with a 25 in the REG field are output to the report.


Easytrieve Sorting.

SORT

SORT is an activity that sequences an input file on fields specified as keys. SORT uses the interface to your system sort. You can sort on as many fields as your system allows.
SORT file-name-1     TO       file-name-2               +
           USING    (field-name [D] …)                       +
           NAME sort-name
         
          [ BEFORE proc-name ]

File-name-1 is the input file to be sorted.

File-name-2 is the output file.

USING field-name identifies those fields from file-name-1 that you use as sort keys. Specify sort keys in major to minor order.

D optionally sorts the field contents in descending order (default = ascending order).

NAME sort-name identifies the sort activity for documentation purposes.

Example

FILE PERSNL FB ( 150 1800 )
           NAME              1      10       A
           DEPT              11       5       N
           GROSS-PAY 16       4       P    2
FILE PAY-SORT FB ( 150 1800 )
      SORT PERSNL TO PAY-SORT               +
                USING ( DEPT GROSS-PAY )      +
                NAME SORT-EXAMPLE-1

SORT Procedure

You use SORT procedure to select only certain records for sorting and / or to modify the contents of records before a sort.
  • A SORT procedure immediately follows the SORT statement.
  • You invoke a SORT procedure with the BEFORE parameter.
  • The SORT procedure executes for each record from file-name-1 prior to passing the record to the sort.
Example
This example illustrates the use of the SORT activity and SORT procedures.

FILE PERSNL FB (150 1800)
          NAME 1 10 A
          DEPT 11 5 N
          GROSS-PAY 16 4 P 2
FILE PAYSORT F(19) VIRTUAL
          SORT-NAME 1 10 A
          SORT-DEPT 11 5 N
          SORT-GROSS-PAY 16 4 P 2
JOB INPUT PERSNL NAME ACT-1
          PRINT RPT1
REPORT
       LINE 1 NAME DEPT GROSS-PAY
SORT PERSNL TO PAYSORT USING (SORT-DEPT + SORT-GROSS-PAY D) BEFORE SELECT-SORT NAME SORT-ACT
SELECT-SORT. PROC
         IF SORT-GROSS-PAY GE 500
                   SELECT
         END-IF
END-PROC
JOB INPUT PAYSORT NAME SORT-PROC-EX
** Logic **


GET Statement

The GET statement retrieves the next record of the named file into the file input area.
GET file-name

file-name - identifies the input file

(EOF) - Test for end-of-file (EOF) when using the GET command.

Example FILE MASTER FB ( 150 1800 )
         EMP#         9       5        N
         NAME      17     16        A
         GROSS   94       4        P      2
JOB INPUT NULL NAME READ-SEQ-MAN
GET MASTER
           IF EOF MASTER
                  STOP
           END-IF
          IF GROSS > 500
               PRINT RPT1
          END-IF
REPORT RPT1
        LINE 1 EMP# NAME GROSS

* You use NULL in the JOB statement to inhibit automatic input.

PUT Statement

The PUT statement outputs a file sequentially.
Example 1

FILE PERSNL FB ( 150 1800 )
       EMP#          9      5     N
       NAME       17     16    A
       GROSS     94      4     P   2
FILE NEWPAY2 F(20) VIRTUAL RETAIN
       NAME          1     16    A
       GROSS     17       4     P  2
JOB INPUT PERSNL NAME PUT-EXAMPLE
       ** Logic **
MOVE LIKE PERSNL TO NEWPAY2
PUT NEWPAY2


Easytrieve Library.

EasytrieveLibrary

FILE Statement

The FILE statement describes an input or output file and is coded in the Library section of an EASYTRIEVE PLUS program. The syntax of the FILE statement is determined by the type of system you are using to run EASYTRIVE PLUS programs.




Virtual File Manager (VFM)

VFM provides an easy method for establishing temporary work files without special job control or file allocation statements. VFM is a sequential access method for program work files. It dynamically allocates space in memory for work files when sequencing a report or when producing multiple reports.
  • When a virtual file is read back into the program, space is released and becomes available for reuse unless you code RETAIN on the statement.
  • If the area in memory (default is 16k) is exhausted, VFM writes the excess data to a single spill area on disk.
              FILE    file-name    F  (lrecl)    VIRTUAL   [ RETAIN ]

F (lrecl) designates the record length.

VIRTUAL causes the file to be created and maintained by the VFM.

RETAIN causes VFM files to be retained for the duration of the EASYTRIEVE PLUS program execution.

COPY Statement

The COPY statement duplicates the field definitions of a named file. You can code an unlimited number of COPY statements for any one file.

COPY { file-name }
When the same field-name is used in more than one file in the same activity, you must qualify duplicate field-names by adding the file-name as a prefix separated by a colon.
Example

FILE INONE
         FLD-ONE            10      1      A
         FLD-TWO           11      3      N
FILE INTWO
-->     COPY       INONE
JOB  INPUT   INTWO     NAME    COPY-EXAMPLE
        IF  INTWO:  FLD-ONE
** Logic **

EXIT parameter

The EXIT parameter on the FILE statement invokes a user routine for every input or output operation for that file.
  • You use EXIT to access a routine that converts non-standard data files that EASYTRIEVE PLUS does not process directly.
  • EXIT is not valid for VFM or IMS / DLI. (IMS / DLI information is contained in APPENDIX D of this Student Guide.)
FILE   file-name    [EXIT (program-name [NR]                   +
          USING ( field-name … )         [ MODIFY ] ) ]

NR has meaning only in DOS; NR indicates that the program is non-relocatable.

USING specifies the parameters to be passed.

MODIFY specifies that the exit can inspect and modify each record after input or before output.


Easytrieve Advance Topic File Handling.

VSAM File Creation (Loading)

The FILE statement and the PUT statement are used to create (load) VSAM files. The PUT statement provides for sequential file output to VSAM files.

FILE MASTER FB ( 150 1800 )
             EMP#           9       5     N
             NAME        17     16    A
             GROSS      94      4     P  2
FILE OUTMAST VS ( CREATE RESET )
         JOB INPUT MASTER NAME CREATE-VSAM
          PUT OUTMAST FROM MASTER STATUS
          IF OUTMAST: FILE-STATUS NOT ZERO
          DISPLAY ‘LOAD ERROR STATAUS IS : ‘       +
                          OUTMAST : FILE-STATUS
         STOP
END-IF
         PRINT RPT1
REPORT RPT1
         LINE 1 EMP# NAME GROSS

STATUS

When you specify STATUS, VSAM return codes are returned to the system defined field FILE-STATUS.

FILE-STATUS
FILE-STATUS is a system defined field which you can test to identify the result of a VSAM input / output operation.

Easytrieve Advance Topic Activity

CALL Statement

The CALL statement invokes an external subprogram. Usually, the CALLed program is an existing program in another language that performs an unsupported function.

CALL program-name [NR] USING ( field-name … )

MOVE Statement

You use the MOVE statement to transfer data from one location to another. MOVE is useful for moving data without conversion and for moving character strings with variable lengths.
  • You can move a field or a literal to a field or move a file to a file.
  • A sending field longer than a receiving field is truncated on the right.
  • A longer receiving field is padded on the right with spaces or an alternate fill character.
  • Spaces or zeroes can be moved to one or many fields.
MOVE NAME 20 TO HOLD-NAME
MOVE NAME CTR TO HOLD-NAME FILL ‘*’
MOVE SPACES TO NAME, HOLD-NAME, HOLD-DIV

MOVE LIKE file-name-1 TO file-name-2

MOVE LIKE

MOVE LIKE moves the value of fields with identical names from one file to another while converting numeric data-types from one format to another.
  • The rules for the assignment statement also apply to MOVE LIKE.
  • Because the same field-name can be used in more than one file, you must qualify duplicate field-names by prefixing the field-name with the file-name and a colon.
User Procedures (PROCs)
A user PROC is a group of user-written EASYTRIEVE PLUS statements designed to accomplish a task. You use a user PROC when identical logic is needed in several places in the activity.
A user PROC must be invoked in the activity with a PERFORM statement.
PERFORM proc-name

 proc-name. PROC
       ** Logic **
END-PROC


Proc-name

Proc-name is the same name as in the PERFORM statement and is followed by a period, a space, and the keyword PROC.

END-PROC

Every PROC must have an END-PROC. At END-PROC, control returned to the statement following the PERFORM statement that invoked the PROC

START / FINISH parameters

You use the optional START and FINISH parameters of the JOB statement to automatically incorporate procedures into processing activities.
JOB input file-name [ NAME job-name ] + [ START proc-name ] [FINISH proc-name]

START parameter

You use START to identify a procedure to be executed during initiation of the JOB activity.
  • The procedure is invoked automatically after the file are opened and prior to the first input record.
  • A typical START procedure might initialize working storage fields or establish a position in a keyed sequenced file.
FINISH parameter

You use FINISH to identify a procedure to be executed during the normal termination of the JOB activity.
  • The procedure is invoked after the last input record is processed and before the files are closed.
  • A typical FINISH procedure displays control information accumulated during execution of the JOB activity.
  • A FINISH proc is invoked if a STOP is encountered but it is not invoked if a STOP EXECUTE is encountered.
GOTO Statement

You use the GOTO statement to modify the natural top-to-bottom logic flow in a program.
GOTO JOB transfers control to the top of current JOB activity.
Example

JOB INPUT PERSNL NAME DIV-LIST
     IF DIV = ‘A’
  ---->          GOTO JOB
    END-IF
    IF DIV = ‘B’
  ---->         GOTO CHECK-REG-RTN
     END-IF
       ** Logic **
   CHECK-REG-RETURN

DO WHILE / END-DO Statements

You use the DO WHILE and END-DO statements to provide a controlled loop for repetitive program logic.
  • The logic between DO WHILE and END-DO is executed until the conditional expression on the DO WHILE statement is false.
  • Conditional expressions follow the rules of IF statements.
JOB INPUT PERSNL NAME DO-EX-1
CTR = 0
DO WHILE CTR LT 10
           CTR = CTR + 1
            ** Logic **
END-DO
IF …
Nesting Example

You can nest DO WHILE statements. (The inner logic loop must be completely within the outer logic loop.)




New In-feed ads