Ca Easytrieve
Ca Easytrieve
Programmer Guide
This documentation and related computer software program (hereinafter referred to as the “Documentation”) is for
the end user’s informational purposes only and is subject to change or withdrawal by Computer Associates
International, Inc. (“CA”) at any time.
This documentation may not be copied, transferred, reproduced, disclosed or duplicated, in whole or in part, without
the prior written consent of CA. This documentation is proprietary information of CA and protected by the copyright
laws of the United States and international treaties.
Notwithstanding the foregoing, licensed users may print a reasonable number of copies of this documentation for
their own internal use, provided that all CA copyright notices and legends are affixed to each reproduced copy. Only
authorized employees, consultants, or agents of the user who are bound by the confidentiality provisions of the
license for the software are permitted to have access to such copies.
This right to print copies is limited to the period during which the license for the product remains in full force and
effect. Should the license terminate for any reason, it shall be the user’s responsibility to return to CA the reproduced
copies or to certify to CA that same have been destroyed.
To the extent permitted by applicable law, CA provides this documentation “as is” without warranty of any kind,
including without limitation, any implied warranties of merchantability, fitness for a particular purpose or
noninfringement. In no event will CA be liable to the end user or any third party for any loss or damage, direct or
indirect, from the use of this documentation, including without limitation, lost profits, business interruption,
goodwill, or lost data, even if CA is expressly advised of such loss or damage.
The use of any product referenced in this documentation and this documentation is governed by the end user’s
applicable license agreement.
The manufacturer of this documentation is Computer Associates International, Inc.
Provided with “Restricted Rights” as set forth in 48 C.F.R. Section 12.212, 48 C.F.R. Sections 52.227-19(c)(1) and (2) or
DFARS Section 252.227-7013(c)(1)(ii) or applicable successor provisions.
Chapter 1: Overview
Introduction .................................................................................. 1-1
About This Guide ............................................................................. 1-1
Organization ............................................................................. 1-2
Other CA-Easytrieve Publications .............................................................. 1-3
Related Publications .......................................................................... 1-4
Documentation Conventions ................................................................... 1-5
Summary of Revisions ......................................................................... 1-5
CA-Easytrieve/Online Enhancements from CA-Easytrieve Plus ................................ 1-5
CA-Easytrieve/Workstation Enhancements from CA-Easytrieve Plus/PC ....................... 1-6
CA-Easytrieve/Online 1.1 Enhancements .................................................... 1-8
CA-Easytrieve/Online 1.4 Enhancements .................................................... 1-9
CA-Easytrieve/Workstation 1.2 Enhancements .............................................. 1-11
CA-Easytrieve 1.3 for UNIX Enhancements .................................................. 1-11
CA-Easytrieve 1.4 for UNIX Enhancements .................................................. 1-12
Contents iii
Subscripts ............................................................................... 2-10
Varying Length Fields .................................................................... 2-10
Displaying Varying Length Fields ..................................................... 2-11
Assigning and Moving Varying Length Fields .......................................... 2-11
Comparing Varying Length Fields ..................................................... 2-12
Declaring Screen Item Attributes .............................................................. 2-12
Declaring Input Edit Patterns ................................................................. 2-13
Declaring Subprogram Linkage ............................................................... 2-13
Literal and Data Formatting Rules ............................................................. 2-13
ASCII and EBCDIC Alphanumeric Literals ................................................. 2-14
Hexadecimal Literals ..................................................................... 2-14
UNIX Data Format ....................................................................... 2-14
Format and Conversion Rules (Workstation Only) .......................................... 2-14
Format Relationship Rules (Workstation Only).............................................. 2-15
Format and Conversion Rules (Mainframe Only) ............................................ 2-18
Format Relationship Rules (Mainframe Only) ............................................... 2-20
DBCS Format Literals .................................................................... 2-22
MIXED Format Literals ................................................................... 2-22
Controlling Program Flow .................................................................... 2-22
Activities ................................................................................ 2-23
Program Flow........................................................................ 2-23
Screen Flow.......................................................................... 2-24
Job Flow ............................................................................. 2-24
Sort Flow ............................................................................ 2-25
Units of Work/Commit Processing ........................................................ 2-25
Automatic Commit Processing ........................................................ 2-26
Controlled Commit Processing ........................................................ 2-26
Recoverable Resources ................................................................ 2-27
Decision and Branching Logic ............................................................. 2-29
Conditional Expressions .............................................................. 2-30
Double Byte Character Set Support..................................................... 2-31
Assignments and Moves...................................................................... 2-31
Arithmetic Expressions ................................................................... 2-32
Operators ........................................................................... 2-32
Parentheses .......................................................................... 2-33
Evaluations .......................................................................... 2-33
Assignment Statement .................................................................... 2-35
EBCDIC To DBCS Conversion (Mainframe Only) ........................................ 2-36
Format 1 (Normal Assignment) ........................................................ 2-36
Examples ............................................................................ 2-39
Format 2 (Logical Expression) ......................................................... 2-40
Contents iv
Example ............................................................................. 2-41
MOVE Statement ........................................................................ 2-41
MOVE LIKE Statement ................................................................... 2-42
Table Processing ............................................................................. 2-42
Defining Tables .......................................................................... 2-42
Searching Tables ......................................................................... 2-44
Array Processing ............................................................................ 2-44
Bounds Checking ........................................................................ 2-45
Indexing ................................................................................ 2-45
Single Dimension Arrays ................................................................. 2-45
Multiple Dimension Arrays ............................................................... 2-46
Subscripts ............................................................................... 2-48
Subscripting a One-Dimensional Array .................................................... 2-49
Subscripting a Two-Dimensional Array .................................................... 2-49
Subscripting a Three-Dimensional Array ................................................... 2-50
Segmented Data ......................................................................... 2-51
Data Strings ............................................................................. 2-53
Interprogram Linkage ........................................................................ 2-54
CALL Statement on the Mainframe ........................................................ 2-55
Program Linking ..................................................................... 2-55
Storage Management ................................................................. 2-56
Linkage (Register Usage) Conventions ................................................. 2-57
Assembler Subprogram Linkage ....................................................... 2-57
COBOL Subprogram Linkage ......................................................... 2-58
Parameter Lists ...................................................................... 2-59
Parameter List Format ................................................................ 2-59
Error Condition Handling ............................................................. 2-59
CALL Statement on the Workstation ....................................................... 2-60
Program Linking ..................................................................... 2-60
Storage Management ................................................................. 2-60
Linkage Conventions ................................................................. 2-60
Error Condition Handling ............................................................. 2-65
CALL Statement in UNIX ................................................................. 2-65
Program Linking ..................................................................... 2-65
Storage Management ................................................................. 2-66
Linkage Conventions ................................................................. 2-66
Error Condition Handling ............................................................. 2-70
LINK Statement.......................................................................... 2-71
LINK vs. CALL ...................................................................... 2-71
Commands Issued by the Child Program ............................................... 2-71
USING Parameter .................................................................... 2-71
Contents v
GIVING Parameter ................................................................... 2-72
Operating System Implementation ..................................................... 2-73
TRANSFER Statement .................................................................... 2-75
Commands Issued by the Target Program .............................................. 2-75
Operating System Implementations .................................................... 2-76
CA-Easytrieve/ESP Interactive Execution .............................................. 2-77
Coding Efficient CA-Easytrieve Programs ...................................................... 2-77
Data Usage .............................................................................. 2-77
Table Processing ......................................................................... 2-78
Compiler Site and Program Options ....................................................... 2-78
Report Processing ........................................................................ 2-79
Coding Programs That Run Under CICS ....................................................... 2-79
Contents vi
Automatic Processing ................................................................. 3-11
Controlled Processing ................................................................ 3-11
CARD Input ......................................................................... 3-11
SEQUENTIAL Output .................................................................... 3-12
Fixed-length File Creation ............................................................. 3-12
Variable-length File Creation .......................................................... 3-12
VSAM File Creation .................................................................. 3-12
PUNCH Files ........................................................................ 3-13
Virtual File Manager ......................................................................... 3-13
INDEXED Files .............................................................................. 3-14
INDEXED Sequential Input ............................................................... 3-14
POINTing to a Specific Record ......................................................... 3-14
Skip-Sequential Processing ............................................................ 3-15
Random Input ....................................................................... 3-15
Adding Records to an INDEXED File ...................................................... 3-15
Adding a Single Record ............................................................... 3-16
Mass-Sequential Record Insertion ...................................................... 3-16
File Creation ............................................................................. 3-16
Deleting a Record ........................................................................ 3-16
Updating a Record ....................................................................... 3-17
RELATIVE Files ............................................................................. 3-17
RELATIVE File Sequential Input........................................................... 3-17
POINTing to a Specific Record ......................................................... 3-18
Skip-Sequential Processing ............................................................ 3-18
Random Input ........................................................................... 3-18
Adding Records to a RELATIVE file ....................................................... 3-19
Record Addition ..................................................................... 3-19
File Creation ......................................................................... 3-19
Deleting a Record ........................................................................ 3-19
Updating a Record ....................................................................... 3-20
Sorting Files ................................................................................. 3-20
SORT Activity Example ............................................................... 3-21
Sort Procedures .......................................................................... 3-21
Sorting a Selected Portion of a File ......................................................... 3-22
Synchronized File Processing ................................................................. 3-22
Synchronized File Input .................................................................. 3-23
Example ............................................................................. 3-23
Record Availability ................................................................... 3-24
Special IF Statements ..................................................................... 3-25
MATCHED .......................................................................... 3-25
File Existence ........................................................................ 3-26
Contents vii
DUPLICATE, FIRST-DUP, and LAST-DUP ............................................. 3-26
Updating a Master File ................................................................... 3-27
Single File Keyed Processing .............................................................. 3-27
PRINTER Files .............................................................................. 3-28
Defining a PRINTER File ................................................................. 3-28
SYSPRINT ........................................................................... 3-29
Workstation Files ............................................................................ 3-29
Coding FILE Statements .................................................................. 3-29
SYSTEM Parameter ................................................................... 3-29
File Type ............................................................................ 3-30
Record Format ....................................................................... 3-30
Logical Record Length ................................................................ 3-31
File Code System ..................................................................... 3-31
Allowed Field Types.................................................................. 3-31
Supported File Structures ................................................................. 3-32
Sequential ........................................................................... 3-32
Indexed Sequential (FABS ISAM) ...................................................... 3-32
Relative (Random-access) ............................................................. 3-32
BTRIEVE ............................................................................ 3-33
DBASE (xBASE) ...................................................................... 3-33
LOTUS .............................................................................. 3-34
CA-SuperCalc ....................................................................... 3-35
Comma-Delimited.................................................................... 3-35
Host Mainframe ...................................................................... 3-36
UNIX Files .................................................................................. 3-37
File Type ................................................................................ 3-37
Record Format ........................................................................... 3-37
Logical Record Length .................................................................... 3-37
C-ISAM ................................................................................. 3-38
Contents viii
SQL/DS .............................................................................. 4-6
CA-Datacom/PC ...................................................................... 4-6
CA-Datacom/DB...................................................................... 4-7
CA-IDMS ............................................................................. 4-7
CA-Ingres ............................................................................ 4-7
ORACLE ............................................................................. 4-7
Library Section Definition ..................................................................... 4-7
SQL Catalog INCLUDE Facility ............................................................ 4-8
Processing NULLable Fields ............................................................... 4-8
Manual NULL Processing .............................................................. 4-9
SQL Data Types........................................................................... 4-9
Decimal Data Types .................................................................. 4-12
SQL Syntax Checking ................................................................. 4-12
System-Defined File Fields ................................................................ 4-13
RECORD-COUNT.................................................................... 4-13
RECORD-LENGTH .................................................................. 4-13
EOF Processing .......................................................................... 4-13
SQL Communications Area Fields ......................................................... 4-13
Sample Database ......................................................................... 4-16
Working Storage Definitions .......................................................... 4-16
CA-Easytrieve SQL Files...................................................................... 4-17
Processing Requirements ................................................................. 4-17
Operation ............................................................................... 4-18
Input Processing ......................................................................... 4-18
Automatic Processing ................................................................. 4-18
Controlled Processing ................................................................ 4-20
Update Processing ....................................................................... 4-22
Controlled Processing ................................................................ 4-22
Automatic Processing ................................................................. 4-22
Deleting from an SQL File ............................................................. 4-23
Inserting an SQL Row ................................................................ 4-23
Automatic Retrieval without a File ............................................................ 4-23
Processing Requirements ................................................................. 4-23
Operation ............................................................................... 4-24
Retrieving All Columns................................................................... 4-24
Selected Columns ........................................................................ 4-25
Multiple Tables .......................................................................... 4-25
Native SQL Processing ....................................................................... 4-25
Processing Requirements ................................................................. 4-25
Operation ............................................................................... 4-26
Supported Commands.................................................................... 4-26
Contents ix
DB2 ................................................................................. 4-26
SQL/DS ............................................................................. 4-26
CA-Datacom/PC ..................................................................... 4-27
CA-Ingres ........................................................................... 4-27
ORACLE ............................................................................ 4-27
Unsupported SQL Commands ............................................................ 4-27
Retrieving All Columns................................................................... 4-28
Reassign Departments ................................................................ 4-28
Update Phone Numbers .............................................................. 4-29
Using Table Name as Host Variable with Indicator Array ................................ 4-30
Data Types Supported on the Workstation ..................................................... 4-30
Contents x
Automatic Input of Logical Records .................................................... 5-17
WHERE Clause ...................................................................... 5-17
Examples ............................................................................ 5-17
Controlled Processing .................................................................... 5-21
IDMS Statement ...................................................................... 5-22
Controlled Processing Examples ....................................................... 5-23
Contents xi
Report Formats ........................................................................... 7-5
Standard Format ...................................................................... 7-5
Label Format ......................................................................... 7-6
REPORT Statement........................................................................ 7-7
Report Definition Structure ................................................................ 7-7
Report Definition Statements ........................................................... 7-7
System-Defined Fields ..................................................................... 7-8
LINE-COUNT ........................................................................ 7-8
LINE-NUMBER ....................................................................... 7-8
PAGE-COUNT........................................................................ 7-8
PAGE-NUMBER ...................................................................... 7-8
TALLY ............................................................................... 7-8
LEVEL ............................................................................... 7-8
BREAK-LEVEL ....................................................................... 7-8
Standard Reports ............................................................................. 7-9
Titles .................................................................................... 7-9
Overriding Defaults .................................................................. 7-10
Examples ............................................................................ 7-10
Headings ................................................................................ 7-11
Line Group .............................................................................. 7-12
Line Item Positioning ..................................................................... 7-12
Special Positioning ....................................................................... 7-13
Pre-printed Form Production .............................................................. 7-14
SPREAD Parameter ...................................................................... 7-15
Label Reports................................................................................ 7-15
CONTROL Statement .................................................................... 7-16
Sequenced Reports ........................................................................... 7-17
CONTROL Reports .......................................................................... 7-17
Terminology............................................................................. 7-18
Data Reference ........................................................................... 7-18
TALLY .................................................................................. 7-19
LEVEL .................................................................................. 7-19
BREAK-LEVEL .......................................................................... 7-20
Control Report Contents .................................................................. 7-21
DTLCTL ................................................................................ 7-23
SUMCTL ................................................................................ 7-24
TAG ................................................................................ 7-26
DTLCOPY ............................................................................... 7-27
DTLCOPYALL ....................................................................... 7-28
Control Field Values in Titles.............................................................. 7-28
Overflow of Total Values ................................................................. 7-29
Contents xii
Controlling Overflow..................................................................... 7-30
Summary File ............................................................................ 7-32
SUMFILE Example ................................................................... 7-33
Report Procedures ........................................................................... 7-33
Special-name Report Procedures .......................................................... 7-34
Coding Techniques....................................................................... 7-35
Field Reference....................................................................... 7-36
Static Working Storage ................................................................... 7-36
REPORT-INPUT ......................................................................... 7-37
BEFORE-LINE and AFTER-LINE .......................................................... 7-38
BEFORE-BREAK ......................................................................... 7-39
AFTER-BREAK .......................................................................... 7-40
ENDPAGE .............................................................................. 7-41
TERMINATION ......................................................................... 7-42
Routing Printer Output ....................................................................... 7-43
Reporting to the Terminal ................................................................. 7-44
Extended Reporting .......................................................................... 7-46
Reporting Environment Example .......................................................... 7-47
Program Example .................................................................... 7-47
Printer Support .......................................................................... 7-48
Printer Identification ................................................................. 7-49
Font Identification .................................................................... 7-49
CA-Easytrieve Printer Definitions ......................................................... 7-50
Page Mode Printers ................................................................... 7-50
Line Compatibility Mode Printers ...................................................... 7-54
XEROX Printers ...................................................................... 7-55
Contents xiii
System-Defined Fields ..................................................................... 8-6
KEY-PRESSED ........................................................................ 8-6
TERM-COLUMNS .................................................................... 8-6
TERM-ROWS ......................................................................... 8-7
TERM-NAME......................................................................... 8-7
SYSUSERID .......................................................................... 8-7
Screen Title Area.............................................................................. 8-7
Title Rules ................................................................................ 8-7
Title Examples ............................................................................ 8-8
Default Centering and Attributes ....................................................... 8-8
Explicit Locations and Attributes ....................................................... 8-9
Screen Work Area ............................................................................ 8-9
Item Location ............................................................................. 8-9
Location Examples ................................................................... 8-10
Attribute Examples ................................................................... 8-11
Formatting an Item for Display................................................................ 8-11
Filling an Item for Display ................................................................ 8-12
Filling with Underscores .............................................................. 8-12
Filling with NULLs ................................................................... 8-12
Justifying a Field’s Contents ............................................................... 8-13
Using Edit Masks for Display ............................................................. 8-13
Mask Example ....................................................................... 8-14
Hexadecimal Mask Example .......................................................... 8-14
Automatic Editing of Input ............................................................... 8-14
UPPERCASE ............................................................................ 8-15
MASK .................................................................................. 8-15
PATTERN ............................................................................... 8-16
Valid PATTERN Characters ........................................................... 8-17
Building Patterns ..................................................................... 8-18
Character Sets........................................................................ 8-20
Internal Operation of Patterns ......................................................... 8-22
Additional Considerations ............................................................ 8-24
VALUE ................................................................................. 8-25
Edit Error Messages ...................................................................... 8-25
Cursor Placement ........................................................................ 8-26
Cursor Placement Hierarchy .......................................................... 8-26
Repeating Rows of Data .................................................................. 8-27
A Simple REPEAT Example ........................................................... 8-27
Two-dimensional Arrays .............................................................. 8-28
Screen Message Area ......................................................................... 8-28
Message Area Location ................................................................... 8-29
Contents xiv
Message Attributes ....................................................................... 8-29
Message Text ............................................................................ 8-29
Screen Function Key Area .................................................................... 8-29
Location ................................................................................ 8-30
Attributes ............................................................................... 8-30
Screen Key Processing ........................................................................ 8-30
3270 Display Station Keys ................................................................. 8-31
Screen Procedures ........................................................................... 8-31
INITIATION ......................................................................... 8-32
BEFORE-SCREEN .................................................................... 8-33
AFTER-SCREEN ..................................................................... 8-33
TERMINATION ..................................................................... 8-33
Programmer-Defined Procedures .......................................................... 8-33
Branch Actions .......................................................................... 8-33
GOTO SCREEN ...................................................................... 8-34
REFRESH ........................................................................... 8-34
RESHOW............................................................................ 8-35
EXIT ................................................................................ 8-36
CICS Pseudo-conversational Programs ..................................................... 8-36
Sending Messages ........................................................................ 8-36
Using Message Levels ................................................................ 8-37
Determining the Cursor Location .......................................................... 8-38
Testing for Field Modification ............................................................. 8-38
Setting Errors ............................................................................ 8-39
Commit Processing ........................................................................... 8-40
SCREEN COMMIT Parameter ............................................................. 8-40
Conversational Processing Example ........................................................ 8-41
Pseudo-Conversational Processing Example ................................................. 8-41
Concurrent Updates ...................................................................... 8-43
SQL Processing Example .................................................................. 8-44
Sample Screen Applications ................................................................... 8-45
Editing Data and Setting Errors ............................................................ 8-46
Using Dynamic Screen Attributes ........................................................... 8-46
Using a Menu ............................................................................ 8-47
Providing Help Screens ................................................................... 8-48
Field-specific Help ........................................................................ 8-50
Windowed Screens ....................................................................... 8-51
Action Bar Pull-Downs .................................................................... 8-52
Contents xv
Overview .................................................................................... 9-1
Basic Structure ............................................................................ 9-1
DRAW Statement Processing ............................................................... 9-2
Graph Format ............................................................................ 9-2
Title Area ............................................................................. 9-2
Work Area............................................................................ 9-2
Function Key Area .................................................................... 9-3
GRAPH Statement ........................................................................ 9-3
Graph Definition Statements ........................................................... 9-3
Processing a Graph ........................................................................... 9-4
Sample Graph Applications .................................................................... 9-5
Pie Chart ................................................................................. 9-5
Vertical Bar Chart ......................................................................... 9-6
Horizontal Bar Chart ...................................................................... 9-7
Line Chart ................................................................................ 9-8
Scatter Diagram ........................................................................... 9-9
Contents xvi
Glossary
Index
Contents xvii
Chapter
Overview
1
Introduction
CA-Easytrieve 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 and screens with ease, while its enhanced
facilities provide the experienced data processor with the capabilities to perform
complex programming tasks.
CA-Easytrieve operates on the IBM 370, 30xx, 43xx, and compatible processors in
the VM, MVS, and VSE environments. Under TSO, CMS, and CICS,
CA-Easytrieve runs interactively for data inquiry, analysis, and reporting. The
output can be either returned to your terminal screen or routed to a printer.
Overview 1–1
About This Guide
Use of this guide, along with the CA-Easytrieve Language Reference Guide, provides
you with the information needed to use CA-Easytrieve for all your programming
needs. For a tutorial approach to learning the basics of CA-Easytrieve, see the
CA-Easytrieve Introduction to the Language Guide.
Organization
Chapter 4, SQL Database Processing Describes the two methods available for
using CA-Easytrieve to retrieve and maintain data in an SQL database.
Chapter 9, Graph Processing Describes how to display and print graphs using
CA-Easytrieve.
Overview 1–2
Other CA-Easytrieve Publications
Chapter 10, System Services Describes how to use the CA-Easytrieve Macro
Facility.
Name Contents
CA-Easytrieve Language Describes the complete syntax of each CA-Easytrieve
Reference Guide statement, organized in easy-to-find alphabetical
order. Also provides lists of system-defined fields,
symbols, and reserved words, as well as information
for those sites converting to this version of
CA-Easytrieve.
CA-Easytrieve Introduction Provides new users with the information they need
to the Language Guide to become productive quickly. Includes a tutorial
and a format designed to make the material more
interesting and easy to comprehend.
CA-Easytrieve/Online User How to compile, link-edit, and execute
Guide CA-Easytrieve programs on the mainframe. Also,
how to compile and execute interactively using an
editor and how to use the CA-Easytrieve/Online
Screen and Report Painters.
CA-Easytrieve/Online Provides system administrators with the information
Administrator Guide needed to set up, customize, and administer a
CA-Easytrieve/Online system.
CA-Easytrieve/Online Describes installation of CA-Easytrieve/Online in all
Installation Guide environments. The most current step-by-step
procedures for installing CA-Easytrieve/Online in
your environment(s) can be found on the product
tape.
CA-Easytrieve/Online How to install and maintain CA-Easytrieve/Online
CA-Activator Supplement on your MVS system, using the Computer Associates
SMP/E software interface called CA-Activator.
CA-Easytrieve UNIX User Helps compile, link-edit, and execute CA-Easytrieve
Guide programs in the UNIX environment from the
Overview 1–3
Related Publications
Name Contents
operating system command line.
Related Publications
The following publications, produced by Computer Associates, are either
referenced in this publication or are recommended reading:
■ CA-Easytrieve/Workstation User Guide
■ CA-Easytrieve UNIX User Guide
■ CA-Ingres SQL Reference Guide
■ CA-PSI Subsystems DBCS Environment Guide
■ CA-PSI Subsystems Reporting Environment Guide
■ CA-Pan/SQL SQL Interface Installation Guide
■ CA-Datacom/PC MS-DOS Database and System Administration Guide
■ CA-Datacom/PC SQL Programming and Reference Guide
Overview 1–4
Documentation Conventions
Documentation Conventions
The following conventions are used throughout this guide for illustrative
purposes.
Notation Meaning
{braces} Mandatory choice of one of these entries.
[brackets] Optional entry or choice of one of these entries.
| (OR bar) Choice of one of these entries.
(parentheses) Multiple parameters must be enclosed in parentheses.
... Ellipses indicate you can code the immediately preceding
parameters multiple times.
BOLD Bold text in program code is used to highlight an example of
the use of a statement.
CAPS All capital letters indicate a CA-Easytrieve keyword, or
within text descriptions, indicate a name or field used in a
program example.
lowercase italics Lowercase italics represent variable information in statement
syntax.
Summary of Revisions
The following lists summarize the technical changes and enhancements provided
in version upgrades of CA-Easytrieve.
Overview 1–5
Summary of Revisions
Overview 1–6
Summary of Revisions
Overview 1–7
Summary of Revisions
Screens can now have a border built displayed around them, whether they are
full-screen applications or windows.
SET Statement The SET statement provides an easy method to change screen
attributes for a field or to indicate an erroneous field in your
screen procedures.
SCREEN Attributes The CURSOR attribute has been added to the default set of
attributes applied to fields in error. Existing users may want to
add the attribute in their site options.
GET PRIOR Statement The PRIOR parameter on the GET statement allows backwards
browses against VSAM files. In addition, you can load a
CA-Easytrieve virtual file and browse forward and backward
through the file.
Instream Macros The compiler now supports including macro definition as part of
the source program. This capability is particularly useful for
testing new macros prior to storing them in the macro library.
Overview 1–8
Summary of Revisions
Report Painter A Report Painter provides a visual method for creating and
maintaining report declarations. Screens and reports can be
painted online using the same easy-to-use interface.
Screen Painter A new Field Select window is available to display program fields
Enhancements for selection from other windows and lists.
CASE Statement The CASE statement now supports variable length fields. If
field-name is an alphanumeric literal, it no longer must be 254 or
fewer bytes in length.
A new PARM statement parameter, SQLSYNTAX, enables you to specify the level
of syntax checking performed on SQL statements in your CA-Easytrieve program.
Overview 1–9
Summary of Revisions
Synchronized File The Synchronized File Processing (SFP) facility is now available in
Processing CA-Easytrieve/Online.
File Exits You can now use the EXIT parameter of the FILE statement to
invoke subprograms written in other programming languages for
input/output related events.
Even Precision for You can use the EVEN parameter on the DEFINE statement to
Packed Fields indicate that a packed decimal field is to contain an even number
of digits.
MOVE LIKE Statement The MOVE LIKE statement now supports moving contents of
for Working Storage fields with identical names to and from working storage.
Static Call Support for The CALL parameter is now available on the PARM statement.
Subroutines CALL enables you to specify how subprograms referenced in
CALL statements are linked to your CA-Easytrieve program.
Year 2000 Support A SYSDATE-LONG field is now available that contains the
century. SHORTDATE and LONGDATE options have been
added to the REPORT statement to display the date with or
without the century.
A new Options Table entry has been added called LONGDTE. This specifies the
default date for reports.
Overview 1–10
Summary of Revisions
MOVE LIKE Statement The MOVE LIKE statement now supports moving contents of
for Working Storage fields with identical names to and from working storage.
CA-Easytrieve is now available for use in the HP-UX environment and operates on
the HP-9000 Series 700/800.
Oracle Processing The CA-Easytrieve SQL Interface now supports Oracle in the UNIX
environment.
C-ISAM Processing CA-Easytrieve now supports C-ISAM files as INDEXED file types.
Overview 1–11
Summary of Revisions
Year 2000 Support A SYSDATE-LONG field is now available that contains the century.
SHORTDATE and LONGDATE options have been added to the
REPORT statement to display the date with or without the century.
A new Options Table entry has been added called LONGDTE. This specifies the
default date for reports.
DB2 Processing The CA-Easytrieve SQL Interface now supports DB2 in the UNIX
environment.
Overview 1–12
Chapter
Environment Section
For example, you can specify that CA-Easytrieve record the statement numbers
of the statements being executed for display during an abnormal termination
(FLOW). Use of this option, however, does have a minor impact on processing
time. You can turn this option on or off in the environment section of each
CA-Easytrieve program.
See Coding Efficient CA-Easytrieve Programs later in this chapter for details on
how parameter settings affect your compilation.
Library Section
Activity Section
The executable statements that process your data are coded in one or more
activity sections. Executable statements in CA-Easytrieve can be procedural
statements or declarative statements.
The activity section is the only required section of your program. There are four
types of activities: PROGRAM, SCREEN, JOB, and SORT.
■ A PROGRAM activity is a simple top-down sequence of instructions. A
PROGRAM activity can be used to conditionally execute the other types of
activities using the EXECUTE statement.
■ SCREEN activities define screen-oriented transactions. Data can be
displayed to a terminal operator and received back into the program. Files
can be read and updated. A SCREEN activity can EXECUTE a JOB or SORT
activity to perform a special process such as printing a report.
■ JOB activities read information from files, examine and manipulate data,
write information to files, and initiate reports and graphs.
■ SORT activities create sequenced or ordered files.
You can code one or more procedures (PROCs) at the end of each activity.
Procedures are separate modules of program code you use to perform specific
tasks.
REPORT subactivities are areas in a JOB activity where reports are described.
You can code one or more REPORT subactivities after the PROCs (if any) at the
end of each JOB activity. You must code any PROCs used within a REPORT
subactivity (REPORT PROCs) immediately after the REPORT subactivity in
which you use them.
GRAPH subactivities are areas in a JOB activity where graphs are described.
One or more GRAPH subactivities can be coded after JOB procedures. You
cannot code procedures for a GRAPH subactivity.
The following exhibit shows some CA-Easytrieve keywords and other items in
the sections where they are usually located, and gives the general order of
CA-Easytrieve statements within a program.
Defining Files
Use the FILE statement to describe a file or a database. FILE statements must
describe all files and databases that your program references. FILE statements
are the first statements coded in the library section of a CA-Easytrieve program.
The FILE statement can differ greatly depending on the operating environment
and the type of file being processed. See the “File Processing” chapter for more
information.
Defining Fields
Use the DEFINE statement to define fields. The DEFINE statement specifies data
fields within a record or within working storage. You usually specify file fields
and work fields in your CA-Easytrieve library section, but you can also define
them within an activity as the following examples illustrate. The first example
shows fields defined in the library section:
When fields are defined within an activity, each field definition must start with
the DEFINE keyword and physically be defined before the field is referenced. In
the library section, use of the DEFINE keyword is optional.
If the same field is defined more than once, subsequent definitions are ignored,
that is, the first definition is used.
File Fields
File fields are normally defined immediately following the associated FILE
statement in the library section of a CA-Easytrieve program. Their rules of usage
are:
■ CA-Easytrieve accepts an unlimited number of fields for each file
(constrained by available memory).
■ Field names must be unique within a file.
■ You can define file fields anywhere in a CA-Easytrieve library or activity
section, except within a REPORT subactivity or a SCREEN declaration.
■ For more specific information about defining fields in a database file, see the
appropriate SQL or CA-IDMS guide.
You can specify two types of working storage fields: S (static) and W (work).
Each type is used in a different way, particularly when used in reporting.
Fields defined as type S are stored in a static working storage area and are not
copied onto report work files. All references to S fields in a report occur at the
time the report is actually formatted and printed.
Fields defined as type W are copied onto the report work files at the time a
PRINT statement is executed. A spooled report is not actually formatted and
printed at the same time the PRINT is executed. Therefore, the value of a W field
on a report is set at the time the report data is selected for printing, not at the
time it is printed.
With this in mind, you should use S (static) working storage fields for:
■ Temporary work fields for report procedures
■ Line annotations controlled from report procedures
■ Grand total values used to calculate percentages.
See the “Report Processing” chapter for examples of the use of W versus S fields.
Signed Fields
Unsigned Fields
Data Reference
Every data reference (file or field) in your program must be unique. You can
provide uniqueness in one of two ways:
■ Unique name — A name is unique if no other file or work field has that
name. For example, GROSS-PAY is unique if it appears as field-name in only
one DEFINE statement (and has never been copied to another file with a
COPY statement).
Default Qualification
If you are in the library section, the current FILE (if one is coded) and the WORK
file are searched for an occurrence of the field in question. If the field is not
found in either the current file or the WORK file, or if the field occurs in both the
current file and the WORK file, an error message is issued stating that additional
qualification is required.
If you are in a SORT or JOB activity, and you code an INPUT filename on a JOB
statement, the input file is searched for an occurrence of the field in question.
For synchronized file processing, all of the files coded on the INPUT parameter
of the JOB statement are checked for an occurrence of the field in question. If the
field occurs in exactly one of the input files, that field is used. If the field occurs
in more than one of the default files, an error message is issued stating that
additional qualification is required.
If the field does not occur in any of the default files, each of the remaining files
(including WORK) is searched for an occurrence of the field in question. If the
field occurs in exactly one of the remaining files, that field is used. If the field
occurs in more than one of the remaining files, an error message is issued stating
that additional qualification is required.
If you do not specify an INPUT parameter on the JOB statement, a default input
file is used. If the JOB activity immediately follows a SORT activity, the output
from the SORT activity is the default input file. If the JOB activity occurs at any
other point, the default input file is the first FILE coded that is not a TABLE file,
a PUNCH file, or a PRINTER file. Once a default input file is selected, default
qualification occurs as described above.
Indexing
Or:
MONTH-INDEX = 18
Subscripts
The use of subscripts removes the requirement of computing the index value;
CA-Easytrieve does this automatically. See Array Processing later in this chapter
for more information.
Because VARYING is used, this W type work field has two parts which are
internally defined as follows:
W 2 B 0 for the two-byte field length
W 248 A for the data
When this field is referenced in your statements, you can designate the entire
field including the length, by specifying FLDA. Or, you can specify only the
length portion or only the data portion of the field. For the W field defined
above:
FLDA:LENGTH references the binary portion only (bytes 1 and 2)
When you reference the entire field, CA-Easytrieve automatically uses the length
portion of the field when it acts on the field.
The display “window” for varying length fields is based on the maximum
length. However, the current value of the length portion determines how much
of the data portion is actually displayed in the window.
Normally, the length portion of the field is not displayed. But when DISPLAY
HEX is used, length as well as data are displayed. DISPLAY HEX displays
length and the full data field in hexadecimal and character format. For example:
Statements:
Results:
ABCD
CHAR ABCD
ZONE 00CCCC4
NUMB 0412340
Assignments are based on the current length of the data and the rules of
assignment. MOVEs default to the current length of the data. MOVE SPACES
moves blanks according to the maximum possible length of the varying length
field. For example:
Statements:
Results:
1. VALUE= LENGTH=
2. VALUE=12345678 LENGTH= 8
3. VALUE=12345 LENGTH= 5
4. VALUE=12345 LENGTH= 5
5. VALUE= LENGTH= 5
Note: If the sending field has length zero and the receiving field is a VARYING
field, the receiving field has a length of zero. If the sending field has length zero
and the receiving field is not a VARYING field, the receiving field is filled with
the fill character (blank for assigned, blank or specified fill character for MOVE).
Comparisons of varying length fields are based on the length of the data at the
time of the comparison.
See the “Screen Processing” chapter for details of the use of screen attributes.
These named input patterns can then be used in the PATTERN parameter of
multiple items on ROW statements in a SCREEN activity. CA-Easytrieve
automatically checks input data against the pattern and issues an appropriate
error message to the terminal user if the data does not conform to its specified
PATTERN.
Alphanumeric literals are words enclosed within single quotes, and can be 254
characters long. An alphanumeric literal can contain ASCII and EBCDIC
alphabetic characters A through Z, and numeric characters 0 through 9.
Whenever an alphanumeric literal contains an embedded single quote, you must
code two single quotes. For example, the literal O’KELLY is coded as:
'O''KELLY'
Hexadecimal Literals
Hexadecimal literals are words used to code values that contain characters not
available on standard data entry keyboards. Prefix the hexadecimal literal with
X’ (the letter X and a single quote), and terminate it with a single quote.
CA-Easytrieve compresses each pair of digits that you code within the single
quotes into one character. CA-Easytrieve permits only the digits 0 through 9 and
the letters A through F. The following hexadecimal literal defines two bytes of
binary zeros:
X'0000'
Each CA-Easytrieve statement has a subject element whose code system and data
format define the code system and data format of all the other elements that
appear on that statement. The following table lists the subject element of those
CA-Easytrieve statements that support the coding of literals. Those that do not
have a subject element are also included. They are indicated by the words not
applicable.
CA-Easytrieve processes EBCDIC and ASCII data formats, but does not support
all the possible relationships that can exist between these data formats. The
following table defines the relationships CA-Easytrieve supports. CA-Easytrieve
only supports the relationships defined in the table. Compilation errors occur if
you specify any unsupported relationships in your CA-Easytrieve program.
Each CA-Easytrieve statement has a subject element whose DBCS code system
and data format define the DBCS code system and data format of all the other
elements that appear on that statement.
The following table lists the subject elements of those CA-Easytrieve statements
that support the coding of literals. Those that do not have a subject element are
also included. They are indicated by the words not applicable.
Using the identified subject element of each CA-Easytrieve statement, the next
table defines the rules for determining the DBCS code system and data format
for a literal. If a literal is not in the required DBCS code system or data format,
CA-Easytrieve converts the literal to the correct DBCS code system and data
format during compilation.
In the following table, the code ASIS means that the data format (SBCS, MIXED,
or DBCS) of the literal coded in the CA-Easytrieve source is retained by the
CA-Easytrieve compiler (it is not converted).
CA-Easytrieve processes SBCS, MIXED, and DBCS data formats, but does not
support all the possible relationships that can exist between these data formats.
The following table defines the relationships CA-Easytrieve supports.
CA-Easytrieve does not support the relationships not defined in the table.
Compilation errors occur if you specify them in your CA-Easytrieve program.
DBCS format literals contain DBCS characters only. Enclose a DBCS format
literal within apostrophes. A DBCS format literal can be 254 bytes long,
including the shift codes. An example of a DBCS literal follows:
'[DBDBDBDBDBDB]'
The left bracket ([) and right bracket (]) indicate shift-out and shift-in codes.
MIXED format literals are words containing both SBCS and DBCS characters.
Enclose MIXED format literals within apostrophes. The presence of shift codes
identifies DBCS subfields. Shift codes also identify the code system of that DBCS
data. The word coded within the apostrophes (including the shift codes) cannot
exceed 254 bytes in length. A MIXED literal is defined in the following example:
'EEEE[DBDBDB]'
The left bracket ([) and right bracket (]) indicate shift-out and shift-in codes.
Activities
CA-Easytrieve activities resemble the steps of a batch job, but they are not
constrained by Job Control Language (JCL) and associated operating system
overhead. A CA-Easytrieve program consists of at least one of the four types of
CA-Easytrieve activities: PROGRAM, SCREEN, JOB, and SORT.
A PROGRAM activity is optional, but if used, only one PROGRAM activity can
be coded in a CA-Easytrieve program, and it must be coded before any other
activities. PROGRAM activities can control the entire program. If used, the
PROGRAM activity must EXECUTE the other types of activities when they are to
be initiated. When not coded, there is an implied PROGRAM activity that
initiates other activities as follows:
■ JOB and SORT activities are executed sequentially until a SCREEN activity is
detected.
■ The SCREEN activity is executed.
■ Any remaining activities must be executed by the first SCREEN activity.
Automatic sequential execution does not proceed beyond the first SCREEN
activity.
You can code one or more procedures (PROCs) at the end of each activity.
Procedures are local to the activity after which they are coded. You cannot
PERFORM procedures not associated with the activity in which the PERFORM is
coded.
You can code one or more REPORT or GRAPH subactivities after the PROCs at
the end of each JOB activity. You must code PROCs used within a REPORT
subactivity immediately after the REPORT subactivity in which you use them.
Program Flow
Screen Flow
The following shows the basic flow of a SCREEN activity. See the “Screen
Processing” chapter for more information.
RESET working storage
[PERFORM INITIATION]
SCREEN ...
RESET working storage
[PERFORM BEFORE-SCREEN]
1. Build screen using program fields,
pending messages, and cursor placement
2. Send the screen
3. Receive the screen
4. Edit the input data
5. Handle automatic actions
[PERFORM AFTER-SCREEN]
GOTO SCREEN
RESET working storage
[PERFORM TERMINATION]
Job Flow
The following shows the relationship between JOB activity statements and
shows implied statements attributed to JOB.
RESET working storage
[PERFORM start-proc]
JOB ... retrieve automatic input
IF EOF
RESET working storage Logic generated by JOB
[PERFORM finish-proc]
wrap-up REPORTS and GRAPHS
return to invoking activity
END-IF
IF ...
PERFORM proc-name
PRINT report-name JOB activity statements
DRAW graph-name
...
END-IF
CA-Easytrieve processes input records one at a time. You can use any valid
combination of CA-Easytrieve statements to examine and manipulate the input
record. CA-Easytrieve repeats the processing activity until the input is
exhausted or until you issue a STOP statement.
Sort Flow
ELSE
Step 6
pass record to SORT No BEFORE proc,
pass all to SORT
END-IF
Step 7
Retrieve next record from input file (file-a) Get next record from
input file
END-DO
Step 8
Perform SORT process (USING fld1, ...) Actually SORT the
records
JOB/SORT
To help you control the integrity of your files, databases, and other resources,
CA-Easytrieve performs commit processing. Commit processing issues commands
to the operating environment signifying the end of one unit of work and the start
of another. These commit points provide a point at which updates are committed
to the operating system. Changes that are not committed can be recovered or
rolled back.
Each CA-Easytrieve activity can be considered a logical unit of work. For each
activity statement, you can code a COMMIT parameter on the PROGRAM, JOB,
SCREEN, and SORT statements to control the way CA-Easytrieve automatically
issues commit points.
There are two times when CA-Easytrieve can automatically issue commit points:
■ Use the ACTIVITY | NOACTIVITY subparameter to indicate whether
CA-Easytrieve issues a commit point during the normal termination of an
activity.
– ACTIVITY - Tells CA-Easytrieve to commit during the activity’s normal
termination process. This is the default for PROGRAM activities, if not
specified.
– NOACTIVITY - Tells CA-Easytrieve not to commit during activity
termination. This is the default for JOB, SCREEN, and SORT activities, if
not specified.
■ Use the TERMINAL | NOTERMINAL subparameter to indicate whether
CA-Easytrieve issues a commit point during each terminal I/O operation
performed in the activity.
– TERMINAL - Tells CA-Easytrieve to commit during each terminal I/O.
This includes terminal I/O for SCREEN activities and also for the Report
Display Facility. In CICS, committing during terminal I/O runs your
program pseudo-conversationally. This is the default, if not specified.
– NOTERMINAL - Tells CA-Easytrieve not to commit during terminal
I/O. In CICS, this runs your program conversationally.
Note: Once an activity with NOTERMINAL specified starts, all child
activities execute with NOTERMINAL specified for them until the
parent activity terminates.
Note: When CA-Easytrieve determines that a program has been linked
to, the linked to program always behaves as if NOTERMINAL had been
specified, that is, the child program always executes in fully-
conversational mode. See Interprogram Linkage later in this chapter for
complete details of the LINK statement.
You can issue your own commit points and rollbacks as needed for your
application by using the COMMIT and ROLLBACK statements. These commits
and rollbacks are performed in addition to the commits and rollbacks
automatically issued as a result of the COMMIT parameter on the activity
statement.
Note: Controlled commits have no effect on whether programs run
conversationally or pseudo-conversationally in CICS.
Recoverable Resources
You must provide the necessary logic in your code to handle the above events.
CICS
In TSO and CMS, SQL databases are the only recoverable resources. In TSO,
CA-IDMS databases are also recoverable.
Each time a commit point is issued, SQL closes all cursors. You must provide the
necessary logic in your program to open and reposition the cursor as needed.
Exceptions can exist for specific SQL databases that maintain cursor positioning
across commits.
For DL/I files, issuing a commit point has no effect. In this case, DL/I
CHECKPOINT and RESTART functions should be used to manage logical units
of work. D/LI files do not lose positioning when a commit point is issued.
Workstation
UNIX
CASE IF
DO GOTO
EXECUTE PERFORM
PROC STOP
EXIT REFRESH
RESHOW
Conditional Expressions
The following are skeletal examples of each type of conditional expression used
in an IF statement:
Type Example
Field Relational IF field-1 = field-2
Field Series IF field-1 = field-2, field-3, field-4
Field Class IF field-1 ALPHABETIC
Field Bits IF field-1 ON X'0F4000'
File Presence IF EOF file-name
File Relational IF MATCHED file-1, file-2, file-3
Record Relational IF DUPLICATE file-name
See the CA-Easytrieve Language Reference Guide for more information on each of
these conditional expressions.
The following conditions provide support for DBCS and MIXED fields:
■ Field Relational
■ Field Series
■ Field Class
■ Field Bits
As with the data equations, when conversion from EBCDIC to DBCS format is
part of the conditional expression, CA-Easytrieve converts the EBCDIC data
using the technique defined below:
■ CA-Easytrieve converts lower case EBCDIC values into the applicable DBCS
Katakana characters.
■ CA-Easytrieve converts other valid EBCDIC characters into their equivalent
English values.
■ CA-Easytrieve converts invalid EBCDIC values into DBCS spaces.
Combined Conditions
Any of these conditions, simple and extended, can be combined using the logical
connectors AND or OR in any combination.
In the case of combined conditions, those connected by AND are evaluated first.
The connected condition is true only if all of the conditions are true. The
conditions connected by OR are then evaluated. The combined condition is true
if any of the connected conditions are true. You can use parentheses to override
the normal AND/OR relationships. The following table illustrates the results of
combining conditions with AND, OR, and parentheses. The values x, y, and z
represent any condition.
x y z x OR x AND x OR (x OR y)
y OR z y AND z y AND z AND z
Arithmetic Expressions
Operators
Symbol Operation
* multiplication
/ division
+ addition
- subtraction
11 + 40 - 48 / 16 + 4 Step 2
└────À────┘
11 + 40 - 3 + 4 Step 3
└────À──────┘
51 - 3 + 4 Step 4
└───────────À────────┘
48 + 4 Step 5
└────────À──────────┘
52
Parentheses
You can use parentheses to override the normal order of evaluation. Any level
of parenthesis nesting is allowed. CA-Easytrieve evaluates expressions within
parentheses first, proceeding from innermost parenthesis level to the outermost.
11 + 5 * ( -40 / 16 + 4) Step 2
└───────────À─────┘
11 + 5 * ( -2.5 + 4) Step 3
└────────────────À────┘
11 + 5 * 1.5 Step 4
└───────────À──────────────┘
11 + 7.5 Step 5
└─────────À───────────┘
18.5
Evaluations
the length and number of decimal places maintained during the calculation
(intermediate results) is determined for each operation according to the rules
shown in the following table.
If the length of the intermediate result has more than 30 digits, CA-Easytrieve
must truncate the excess digits. For addition, subtraction, and division, the
excess digits are always truncated from the left side of the result.
If the number of decimal places in the result is less than or equal to this
minimum, no digits are truncated from the right side of the result. Otherwise,
the number of digits truncated from the right is the smaller of:
■ The number of excess digits
Or:
■ The difference between the number of decimal places in the result and the
minimum.
When truncation occurs on the right, both the length and number of decimal
places in the result are reduced by the number of digits truncated. If there are
still excess digits after right truncation, these excess digits are truncated from the
left.
For example, assume that value-1 and value-2 both have a length of 18 digits and
both have 4 decimal places. Then, according to the previous rules table, the
result has a length of 36 digits and 8 decimal places. In this case, the number of
excess digits is 6. Then, for various values of the number of decimal places in
field-name-1, the result is truncated as shown in the next table:
Assignment Statement
The Assignment statement establishes a value in a field. The value can be a copy
of the data in another field or literal, or it can be the result of an arithmetic or
logical expression evaluation.
When conversion from EBCDIC to Double Byte Character Set format is required
for the Assignment statement, CA-Easytrieve converts the EBCDIC data using
the techniques defined below:
■ Converts lower case EBCDIC values into the applicable DBCS Katakana
characters.
■ Converts other valid EBCDIC characters into their equivalent English values.
■ Converts invalid EBCDIC values into DBCS spaces.
Receive-field-name Send-field-name
(Left-hand side) (Right-hand side) Resulting Value
Receive-field-name Send-field-name
(Left-hand side) (Right-hand side) Resulting Value
Numeric field Numeric field, Result is padded on left with zeros to fit the description
literal, or arithmetic of receive-field-name. If the value of the assignment is
expression too large to be stored in receive-field-name, it is truncated
as follows:
■ For Binary numbers (numbers expressed in Two's
Complement form), the sign and high order bits are
truncated from left as necessary, and the remaining
left-most bit becomes the new sign.
■ For Zoned Decimal, Packed Decimal, and Unsigned
Packed Decimal numbers (numbers expressed in
Sign-Magnitude form), the high order digits are
truncated from left as necessary. The result is
truncated on right if the number of decimal places
in receive-field-name is less than the right-hand side.
DECLARed attribute DECLARed attribute Receive-field name is replaced with the attributes
field field contained in send-field-name.
Nullable field NULL field Indicator for receive-field-name set to 1 (indicates NULL).
Not NULL field The assignment works as usual and the indicator for
receive-field-name is set to 0, indicating NOT NULL.
Literal Indicator for receive-field-name is set to 0.
Arithmetic A runtime error occurs.
expression with any
NULL operand
Arithmetic Indicator for receive-field-name is set to 0.
expression in which
all operands are
NOT NULL
Not nullable field NULL field A runtime error occurs.
DBCS field DBCS field Send-field-name is converted into the DBCS code
system of receive-field-name. The resulting value of
receive-field-name is padded on right with DBCS spaces
or truncated on right as necessary.
MIXED field Each EBCDIC byte of send-field-name is converted into
its equivalent DBCS value. Any DBCS data identified
by shift codes is converted to the DBCS code system of
receive-field-name. The shift codes are then removed.
The resulting value of receive-field-name is padded on
right with DBCS spaces or truncated on right as
necessary.
Receive-field-name Send-field-name
(Left-hand side) (Right-hand side) Resulting Value
Receive-field-name Send-field-name
(Left-hand side) (Right-hand side) Resulting Value
Examples
F1A W 4 A
F2A1 W 1 A VALUE 'A'
F2A2 W 6 A VALUE 'ABCDEF'
F2N1 W 2 N VALUE 12
F2N2 W 3 P 1 VALUE 1234.5
...
Resulting Value:
Note: For an example using varying length alphanumeric fields, see Field
Definition earlier in this chapter.
Format 1 (Normal Assignment, receive-field-name numeric)
Statements:
DEFINE F1N W 4 N 1
DEFINE F2N1 W 4 N 1 VALUE 1
DEFINE F2N2 W 4 N 1 VALUE 2
DEFINE F2N3 W 4 N 1 VALUE 3
JOB INPUT NULL NAME MYPROG
F1N = F2N1 + F2N2 + F2N3
DISPLAY SKIP 2 +
'F1N = F2N1 + F2N2 + F2N3 = ' F1N
F1N = F2N1 + F2N2 / F2N3
DISPLAY SKIP 2 +
'F1N = F2N1 + F2N2 / F2N3 = ' F1N
F1N = (F2N1 + F2N2) / F2N3
DISPLAY SKIP 2 +
'F1N = (F2N1 + F2N2) / F2N3 = ' F1N
F1N = ((F2N1 / F2N2) * 100) + .5
DISPLAY SKIP 2 +
'F1N = ((F2N1 / F2N2) * 100) + .5 = ' F1N
STOP
Results:
Resulting
Value
The rules for nullable fields are shown in the following table:
Receive-field-name Send-field-name
(Left-hand side) (Right-hand side) Resulting Value
Nullable field Nullable field but not The receiving field’s indicator is set to 0, indicating
NULL NOT NULL.
Not a nullable field The receiving field’s indicator is set to 0, indicating
NOT NULL.
Not nullable field NULL field A runtime error occurs.
Example
Results:
Resulting
Value
F1P = F2P AND X'FFFE' = 123C
MOVE Statement
MOVE transfers characters from one storage location to another. It is used for
moving data without conversion and for moving variable length data strings.
The following table illustrates the rules of the MOVE statement regarding
nullable fields:
Receive-field-name Send-field-name
(Left-hand side) (Right-hand side) Resulting Value
Nullable field Send-field name that is not Receiving field’s indicator is set to 0, indicating
nullable NOT NULL.
MOVE LIKE moves the contents of fields with identical names from one file to
another. Data movement and conversion follow the rules of the Assignment
statement.
Table Processing
A table is a collection of uniform data records that presents unique processing
opportunities. All tables have two parts:
1. The argument uniquely identifies a table entry.
2. The description is the remainder of the table entry.
Some typical examples of table usage include organization structures, parts lists
for assembly processes, and accounting chart-of-accounts.
The search of CA-Easytrieve table files is extremely efficient. Therefore, table use
is recommended for applications that need to validate encoded data and/or
retrieve code description.
Defining Tables
There are two types of tables that can be specified on the FILE statement:
1. Instream - (specified by the INSTREAM subparameter on the TABLE
parameter) directs CA-Easytrieve to look for table data within the program
immediately following the definition of the ARG and DESC fields for the
file. This table is established at the time the program is compiled. Its size is
limited only by the amount of available memory.
2. External - (INSTREAM is not specified) indicates that the table is located in a
file external to the program. This file must be sequentially accessible. An
external table is established just before use.
External tables that are also INDEXED files result in a random read to the file
using the search argument as the key. This results in added efficiency.
All data needed to create small tables (to be processed by the SEARCH
statement) can be entered instream along with CA-Easytrieve statements; that is,
the table data can immediately follow the library definition statements for the
table. The data is delimited by the ENDTABLE statement in the first eight
positions of a record.
Note: An instream table can be retrieved from a macro file. However, the macro
must contain the entire table definition (FILE statement through ENDTABLE).
The only way to modify an instream table is to recompile the program after
supplying new table data. However, you can modify external tables without
program change because CA-Easytrieve builds these tables dynamically prior to
each use.
The only fields defined for table files are ARG (argument) and DESC
(description). ARG defines the field used when searching the table. DESC
defines the field which contains the desired information. The maximum length
for an alphanumeric ARG or DESC field is 254 bytes.
The following illustrates a typical table file description. The resulting table
provides descriptions of a hypothetical high school curriculum:
1011 ENGLISH I }
1012 ENGLISH II } records from
... } CLASSES file
... }
Searching Tables
The SEARCH statement provides access to table information. You can code
SEARCH statements any place within a PROGRAM, SCREEN, or JOB activity,
and issue any number of SEARCHes against any number of tables. To test the
success of the SEARCH, use the file presence test: IF [NOT] file-name.
The following illustrates the retrieval of high school class descriptions based
upon class identification codes:
Statements:
DEFINE CODE W 4 A
DEFINE DESCRIPTION W 40 A
FILE CLASSES TABLE INSTREAM
ARG 1 4 A
DESC 10 40 A
1011 ENGLISH I
1012 ENGLISH II
1013 ENGLISH III
1014 ENGLISH IV
ENDTABLE
PROGRAM NAME MYPROG
MOVE '1012' TO CODE
SEARCH CLASSES WITH CODE, GIVING DESCRIPTION
IF CLASSES
DISPLAY DESCRIPTION
ELSE
DISPLAY 'CLASS NOT FOUND'
END-IF
Result:
ENGLISH II
Array Processing
An array is a series of consecutive memory locations in one or more dimensions.
You can process identical elements in arrays by using either index manipulation
or subscripting.
Bounds Checking
Indexing
Any data field definition can contain the INDEX attribute. An index can be used
to reference data fields that occur multiple times. If you do not use an index, you
must either use subscripts or assign individual field names to multiple field
occurrences.
The data field’s starting location is adjusted by the contents of its indexes to
determine the desired field occurrence. The INDEX index-name value is set to:
(desired occurrence number - 1) * (length of element)
DEFINE ARRAY-ELEMENT W 2 N
DEFINE MONTHS W 120 A VALUE +
'JANUARY +
FEBRUARY +
MARCH +
APRIL +
MAY +
JUNE +
JULY +
AUGUST +
SEPTEMBER +
OCTOBER +
NOVEMBER +
DECEMBER '
DEFINE MONTH MONTHS 10 A +
OCCURS (12) INDEX (MONTH-INDEX)
JOB INPUT NULL NAME MYPROG
ARRAY-ELEMENT = 11
MONTH-INDEX = (ARRAY-ELEMENT - 1) * 10
DISPLAY MONTH
STOP
Results:
NOVEMBER
The following table illustrates two arrays which are identical in size and usage,
but are defined very differently
90 10 NOVEMBER 90 10 NOVEMBER
90 20 DECEMBER 90 20 DECEMBER
In both cases, the sum of the indices determines which data occurrence is
referenced. Both MONTH and MONTH-CELL are ten-character fields with two
indexes. Both fields also occur twelve times. MONTH-INDEX-1 and
ROW-INDEX, and MONTH-INDEX-2 and COL-INDEX are considered similar
indexes.
You can define and access arrays of more than two dimensions by a simple
extension of the following examples.
↑ ↑ ↑
M M M
O O O
N N N
T T T
H H H
- - -
C C C
O O O
L L L
Result:
NOVEMBER
DEFINE QUARTER-ROW W 2 N
DEFINE MONTH-COL W 2 N
DEFINE MONTHS W 120 A VALUE +
'JANUARY +
FEBRUARY +
MARCH +
APRIL +
MAY +
JUNE +
JULY +
AUGUST +
SEPTEMBER +
OCTOBER +
NOVEMBER +
DECEMBER '
DEFINE MONTH MONTHS 10 A +
OCCURS (12)
DEFINE MONTH-ROW MONTH 30 A, +
OCCURS 4, INDEX (ROW-INDEX)
DEFINE MONTH-COLS MONTH-ROW 10 A, +
OCCURS 3, INDEX (COL-INDEX)
DEFINE MONTH-CELL MONTH-COLS 10 A
JOB INPUT NULL NAME MYPROG
QUARTER-ROW = 4
MONTH-COL = 2
ROW-INDEX = (QUARTER-ROW - 1) * 30
COL-INDEX = (MONTH-COL - 1) * 10
DISPLAY MONTH-CELL
STOP
↑ ↑ ↑
M M M
O O O
N N N
T T T
H H H
- - -
C C C
O O O
L L L
S S S
Results:
NOVEMBER
Subscripts
You can use subscripts with a field name in the following manner:
ELEMENT is VALUE is
MONTH(1) JANUARY
MONTH(2) FEBRUARY
MONTH(3) MARCH
... ...
MONTH(12) DECEMBER
For this array the maximum value that can be specified for the occurrence
number is 12.
The next table illustrates the relationship between the array element and the
corresponding array element value:
ELEMENT is VALUE is
ELEMENT(1,1) AA
ELEMENT(1,2) BB
ELEMENT(1,3) CC
ELEMENT(1,4) DD
ELEMENT(1,5) EE
ELEMENT(2,1) FF
... ...
ELEMENT(3,5) OO
DEFINE QUARTER-ROW W 2 N
DEFINE MONTH-COL W 2 N
DEFINE MONTHS W 120 A VALUE +
'JANUARY +
FEBRUARY +
MARCH +
APRIL +
MAY +
JUNE +
JULY +
AUGUST +
SEPTEMBER +
OCTOBER +
NOVEMBER +
DECEMBER '
DEFINE MONTH-ROW MONTHS 30 A, +
OCCURS 4
DEFINE MONTH-COLS MONTH-ROW 10 A, +
OCCURS 3
DEFINE MONTH-LET MONTH-COLS 1 A, +
OCCURS 10
DEFINE MONTH-CELL MONTH-LET 1 A
JOB INPUT NULL NAME MYPROG
* THIS PROGRAM DISPLAYS THE 3RD
* LETTER OF THE MONTH IN THE 4TH
* ROW, 2ND COLUMN (THE V IN NOVEMBER)
DISPLAY MONTH-CELL (4, 2, 3)
STOP
Results:
Segmented Data
One of the most common data structures is segmented data. Each record
contains a fixed portion of data and multiple occurrences of data segments. The
actual number of occurrences are not known until execution time. In COBOL,
these structures are known as variable-length table definitions and are defined
with an “occurs depending on” clause.
*
* SALARY HISTORY SEGMENTS
*
SALARY-HISTORY 30 16 A OCCURS 10
SALARY-AMOUNT 30 8 N 2 INDEX SALINDEX
SALARY-GRADE 38 2 N INDEX SALINDEX
SALARY-EFF-DATE 40 6 N INDEX SALINDEX
Because the starting location for each variable occurring segment is not known,
the first position after the fixed portion is used. Later, to access the data, the
length of the preceding segment(s) is added to the index to determine the
starting location of the next variable segment. The OCCURS parameter specifies
the maximum number of occurrences for each variable portion.
Data Strings
REVERSED-NAME DATA-NAME
GLORIA WIMN WIMN,GLORIA
NANCY BERG BERG,NANCY
GEORGE CORNING CORNING,GEORGE
MARY NAGLE NAGLE,MARY
Interprogram Linkage
The facilities of CA-Easytrieve provide all of the functions necessary to perform
standard input/output, data examination, and data manipulation.
■ The FILE EXIT and CALL statements enable you to invoke subprograms
written in other programming languages. All discussions of the CALL
statement also apply to FILE EXITs. (FILE EXITs are CALLs that are
controlled automatically by CA-Easytrieve.)
■ The LINK statement allows you to transfer control from the current program
(parent) to another program (child) and then return control to the parent
program.
■ The TRANSFER statement allows you to transfer execution to a target
program without returning to the invoking program.
Program Linking
Or:
DECLARE INTCALC PROGRAM DYNAMIC
The way that the CALLed program is bound is determined by the following, in
order:
1. If the program was declared on a DECLARE statement, the STATIC or
DYNAMIC keyword on the DECLARE statement determines how it is
bound.
2. If specified, the CALL parameter on the PARM statement supplies the
default for all CALLed programs in your CA-Easytrieve program.
CICS
In CICS, all dynamic programs are loaded by executing the CICS LOAD
command. The LOAD command dynamically places the program in storage and
returns the program’s entry point to CA-Easytrieve.
MVS
In MVS, all dynamic programs are loaded by invoking the LOAD function of the
operating system. The LOAD function dynamically places the program in
storage and returns the program’s entry point to CA-Easytrieve.
CA-Easytrieve loads the program as part of the initialization of the first activity
that references the program. If the current activity (the child activity) was
invoked with an EXECUTE statement from another activity (the parent activity),
and if both the child and parent activity reference the program, then
CA-Easytrieve loads the program during the initialization of the parent activity.
In addition, CA-Easytrieve does not delete the program until the termination of
the parent activity. Neither the initialization nor the termination of the child
activity has any effect on the program’s status.
Storage Management
Register Usage
REGISTER 1 Address of the parameter list
REGISTER 13 Address of an 18 fullword register save area
REGISTER 14 Address of where to return to within CA-Easytrieve
REGISTER 15 Address of the entry point in the subprogram
The subprogram must save the CA-Easytrieve registers in the save area
addressed by REGISTER 13 and must restore them prior to returning via
REGISTER 14. The 18 fullword register save area provided by CA-Easytrieve
must be maintained as illustrated in the following table:
In DOS/VSE, for the subroutine to act correctly as a called program, the linkage
control module ILBDMNS0 must be assembled as:
// EXEC ASSEMBLY
ILBDMNS0 CSECT
DC X'FF0000000000000000000000000000'
* Older versions of COBOL used an eight byte ILBDMNS0
* Check existing link maps to determine the length.
END
/*
Note: You cannot CALL and LINK to an OS/VS COBOL program in the same
activity.
Parameter Lists
The parameter list for both input/output and CALL exits (pointed to by register
1) passes information to the subprogram. Each entry in this contiguous group of
fullwords identifies one parameter. The end of the list is indicated by the
high-order bit of the high-order byte of the last entry being set to a one.
The parameter lists passed to subprograms for EXIT (FILE) and CALL are quite
similar. In fact, the list for CALL is identical to that associated with the USING
subparameter of EXIT. The only difference is that EXIT always passes at least
two parameters.
Note: If multiple fields are coded on the USING subparameter, and storage
areas overlap, results are unpredictable.
Program errors which occur in subprogram exits cause the abnormal termination
of CA-Easytrieve programs. Since these errors are occasionally difficult to
analyze within the complex environment of CA-Easytrieve, exits should be
tested first with simulation.
Program Linking
Called subprograms are statically linked with the CA-Easytrieve object module.
Storage Management
Called subprograms are free to use the INT 21H memory management services
48H (allocate) and 49H (free), the DosAllocSeq in MS-DOS or DosFreeSeq
functions in OS/2, or the malloc() and free() ‘C’ functions.
Linkage Conventions
The CALL statement can be used to call programs that conform to either the FAR
PASCAL or ‘C’ calling conventions. See the CA-Easytrieve/Workstation User Guide
for more information.
The FAR PASCAL calling convention is the calling convention normally used by
PC-based ASSEMBLER, BASIC, FORTRAN, and PASCAL programs. The FAR
PASCAL calling convention pushes the parameters onto the stack in the order in
which they are coded on the USING clause. The called procedure must pop the
parameters off of the stack before returning. This is the default calling
convention.
The ‘C’ calling convention is used by workstation ‘C’ programs and most
workstation COBOL programs. The ‘C’ calling convention pushes the
parameters onto the stack in the reverse order in which they are coded on the
USING clause. CA-Easytrieve pops the parameters off of the stack when the
procedure returns.
Stack Usage
For both the FAR PASCAL and ‘C’ calling conventions, the CALL statement
pushes a far pointer (segment and offset) of each parameter coded onto the stack
and expects that the called procedure is a far procedure. As such, the CALLed
function or procedure must be compiled with a LARGE MEMORY MODEL
specified.
The following diagram illustrates the contents of the stack for the CALL
statement:
---------- STACK ------
FAR PASCAL C
---------- ---
DEFINE FLDA W 5 A CS CS
DEFINE FLDB W 2 B IP IP
. SEG FLDA SEG FLDB
. OFF FLDA OFF FLDB
CALL TEST USING(FLDA FLDB) SEG FLDB SEG FLDA
OFF FLDB OFF FLDA
If RETURNS is coded on the CALL statement, the value of the accumulator (AX)
is placed into the RETURNS field. This is the standard return code convention.
You can use the EXIT parameter of the FILE statement to invoke subprograms
written in other programming languages for input/output related events. Code
the name of these subprograms on the EXIT parameter of the FILE statement in
the library of your program.
For input/output exits, the work area address and the control code address are
required parameters. The control code is a fullword used to indicate the
function to be performed by the exit. For example:
For MODIFY exits (subparameter of the FILE statement), the required two
parameters are record area address and work area address because the exit
receives all records after input and before output.
(MODIFY)
...
FILE USERFIL EXIT (ASMPGM MODIFY) WORKAREA(500)
...
Parameter List
address of record
address of work area
Program Linking
Or:
DECLARE INTCALC PROGRAM DYNAMIC
The way that the CALLed program is bound is determined by the following, in
order:
1. If the program was declared on a DECLARE statement, the STATIC or
DYNAMIC keyword on the DECLARE statement determines how it is
bound.
2. If specified, the CALL parameter on the PARM statement supplies the
default for all CALLed programs in your CA-Easytrieve program.
3. The default is determined by the environment. The default on the
mainframe is DYNAMIC. The default on the workstation and UNIX is
STATIC.
Storage Management
Called subprograms should use the malloc and free functions to allocate and free
storage. The subprogram should free any storage it has allocated.
Linkage Conventions
The CALL statement can be used to call programs that conform to the ‘C’ calling
conventions for the platform on which you are running CA-Easytrieve. See the
CA-Easytrieve for UNIX User Guide for more information.
You can use the EXIT parameter of the FILE statement to invoke subprograms
written in other programming languages for input/output related events. There
are two types of exits you can code:
■ Standard
■ Using the MODIFY subparameter.
Standard Exits
A standard exit should perform its own I/O. A standard exit function should
look like this:
unsigned long YourStandardExit(
long eOperation,
void * pRecord,
unsigned long * pcbRecord,
void * pKey,
unsigned long * pcbKey,
P_EZEXIT_FCB pFCB,
void * * pExitArgList
);
pRecord Is the pointer to the record buffer. On input operations, your exit
places data into this buffer from the file. On output, your exit writes the data
from the buffer to the file.
pcbRecord Is the pointer to the length of the record currently in the buffer. On
input operations, your exit must place the size of the record at this location.
pKey Is the pointer to the key. This field is valid only for operations that require
a key.
pExitArgList Is the pointer to the array of pointers to the fields in the USING list
of the EXIT phrase. The pointers are ordered as the fields in the USING list are
ordered.
Return Value The following list of constants enumerate the valid return values
and the meanings:
#define FC_NORMAL 0 /* The operation completed */
/* normally. */
#define FC_ENDFILE 4 /* The operation attempted to */
/* position the file past the */
/* last record in the file */
#define FC_RDUPREC 8 /* The key of the record just */
/* read matches the key of the */
/* next record in the file */
#define FC_WDUPREC 12 /* The operation attempted to */
/* insert a record whose key */
/* matches a record already in */
/* the file */
#define FC_NRFOUND 16 /* The key specified for the */
/* operation does not match */
/* the key of any record in */
/* the file */
#define FC_LOCKED 20 /* The operation attempted to */
/* retrieve a record that is */
/* locked by another user */
#define FC_IOERROR 24 /* The operation failed for some */
/* reason other than one of */
/* those given above */
The ANCHOR is a control block that the exit might want to allocate. (It is not
required.) Its purpose is to hold information that the exit needs from one
invocation of the exit to the next. The ANCHOR is chained off of the EXIT_FCB
(which follows).
Your exit is responsible for the creation, maintenance, and destruction of this
area.
typedef struct ANCHOR {
FILE * pFile;
/* More data could be placed here. Since there is no more data
* in this example, a better solution would be to use the pAnchor
* field in the EXIT_FCB as the file pointer.
*/
} ANCHOR, * P_ANCHOR;
The EXIT_FCB is a control block which is passed to the exit each time the exit is
called. The same instance of the EXIT_FCB is passed from the time the file is
opened to the time the file is closed for each operation on the file.
Hence, if your exit allocates its own control block (like the ANCHOR, shown
below), its address can be placed as the first item in the EXIT_FCB and retrieved
from the same place with each invocation of the exit. Remember to deallocate
the control block when the file is closed.
CA-Easytrieve creates, maintains, and destroys this control block. Your exit
should restrict itself solely to changing the pAnchor field.
The prototype for your MODIFY file exit should look like:
unsigned long YRMDEXIT(
void * pRecordArea,
void * pWorkArea,
unsigned long cbRecordLength,
where:
pcbWorkArea Points to the length of pWorkArea’s buffer. Once your exit has
placed the reformatted in the buffer, it must place the length of the reformatted
record at this field.
pExitArgList Is the pointer to the array of pointers to the fields in the USING list
of the EXIT phrase. The pointers are ordered as the fields in the USING list are
ordered.
Return Value This exit uses the same values as were defined for the standard file
exit.
If your exit processes variable length records, the RECORD-LENGTH field of the
file should be in the USING list. Your exit must place the correct value in the
USING list.
If your exit handles both input and output operations, you should place a field in
the USING list that can tell your exit what type of operation the exit must
perform.
LINK Statement
The LINK statement is used to invoke another program and then return
execution to the statement following the LINK statement in the original
(invoking) program. The program invoked can be written in any language that
is supported by the operating system in which the program is executing
(including CA-Easytrieve).
The LINK statement differs from the CALL statement in the following ways:
■ LINK creates a new program execution environment that bears a child
relationship to the program issuing the LINK command (the parent
program). A CALLed program executes in the same execution environment
as the program issuing the CALL command.
■ On the mainframe, a CALLed program uses the same linkage conventions in
all execution environments, LINK uses the linkage conventions of the
operating system in which the program is executing.
The child program can issue any command supported by the operating system.
In a CICS environment, the program can issue terminal I/O or display reports,
but only in a fully-conversational mode.
USING Parameter
A single parameter can be passed to the child program by specifying the USING
parameter. The parameter is passed to the child program by value, that is, the
parent program passes a copy of the value of the field or literal to the child
program. The child program cannot directly modify the value of the field or
literal. You specify the field to receive the parameter with the USING parameter
on the PROGRAM statement in the child program.
GIVING Parameter
You can allow the parent program to accept a return parameter from the child
program by specifying the GIVING parameter. You specify the field to be
returned in the GIVING parameter of the PROGRAM statement in the child
program. CA-Easytrieve returns a value to the parent program by writing the
return value into the same parameter area that was used by CA-Easytrieve to
pass the USING parameter to the child program.
When the child program terminates, the parameter is copied from the parameter
area to the variable specified in the GIVING parameter of the parent program.
Because a single parameter area is used for communications in both directions,
CA-Easytrieve determines the size of the parameter area by the larger of the
fields specified on the USING and GIVING parameters. If the child program
copies a return parameter into the parameter area with the PROGRAM GIVING
parameter, but there is no GIVING parameter specified in the parent program,
the returned parameter is ignored without any error indication.
Operating
System Command Parameters Passed By
CICS EXEC CICS LINK CICS communication
area
TSO MVS LINK SVC 6 Standard MVS/TSO
linkage conventions
CMS CMS LINK SVC 6 Standard CMS linkage
conventions
PC/DOS INTERRUPT 21H PSP command tail or
FUNCTION 4BH INT 60H
OS/2 DosExecPgm Command line or
shared segment
UNIX system (“routine_name
using_data”)
Note: When linking to an OS/VS COBOL program in TSO or CMS, the COBOL
program must be compiled with the NORES compile option. Also, you cannot
LINK and CALL an OS/VS COBOL program in the same activity.
Note: In CICS, the TRANSFER statement is more efficient than the LINK
statement. In TSO and CMS, the opposite is true.
Workstation
The /FR (Far Reference) compiler switch is required to compile the LINKed
program to CA-Easytrieve/Workstation if the PROGRAM statement has a
USING field that is longer than 100 bytes or is a P, B, U, I, S, or D type field.
If the program name contains all blanks, a command shell is brought up on top
of the parent process allowing the user to enter any valid DOS command. Type
EXIT to terminate the shell and return control to the CA-Easytrieve parent
program.
If the GIVING parameter is coded, the first item passed to the child process is the
address of the GIVING field of the parent process. The CA-Easytrieve child
program places the contents of the GIVING field specified on the program
statement into the GIVING field of the parent process. The GIVING parameter
should only be used with CA-Easytrieve child programs.
Note: The USING and GIVING parameters are limited to a maximum length of
100 characters, unless the child program was compiled with the /FR switch.
When the child process terminates with INT 21H function 4CH, or DosExit in
OS/2, control is returned to the parent process.
The LINK statement sends the program name and USING parameter as an
EBCDIC string to the host. Workstation execution continues immediately after
the send operation is complete. The GIVING parameter is not returned to the
workstation.
UNIX
TRANSFER Statement
The target program can issue any command supported by the operating system.
In a CICS environment, the program can issue terminal I/O or display reports in
a pseudo-conversational mode only if the program issuing the TRANSFER
command can operate pseudo-conversationally.
Complete termination of the current CA-Easytrieve program does not imply the
termination of the current logical unit of work. Although CA-Easytrieve
attempts to terminate the current program (for example, close files, complete
reports), it does not necessarily terminate all activities performed by the
operating system for the CA-Easytrieve program.
USING Parameter
A single parameter can be passed to the target program by specifying the USING
parameter. The parameter is passed to the target program by value, that is, the
invoking program passes a copy of the value of the field or literal to the target
program. The target program cannot directly modify the value of the field or
literal. You specify the field to receive the parameter with the USING parameter
on the PROGRAM statement in the target program.
Note: In CICS, the TRANSFER statement is more efficient than the LINK
statement. In TSO, CICS, and CMS, the opposite is true.
Workstation
The /FR (Far Reference) compiler switch is required to compile the LINKed
program to CA-Easytrieve/Workstation if the PROGRAM statement has a
USING field that is longer than 100 bytes or is a P, B, U, I, S, or D type field.
Note: The USING and GIVING parameters are limited to a maximum length of
100 characters, unless the child program was compiled with the /FR switch.
When the child process terminates with INT 21H function 4CH in PC/DOS, or
DosExit in OS/2, control is returned to the parent process. If the parent process
transfer buffer is empty, the parent process terminates via INT 21H function
4CH in PC/DOS, or DosExit in OS/2. If the parent process transfer command
buffer is not empty, the parent process executes the command in the transfer
buffer.
UNIX
Data Usage
Table Processing
■ Avoid using very large tables because they take more time to search and
require more storage than small tables.
■ The STATE site option and PARM statement parameter saves the statement
number of the statement currently being executed for display during an
abnormal termination. This option/parameter requires approximately six to
eight bytes of additional storage for each executable source line in your
program.
■ The FLOW site option and PARM statement parameter activates a trace of
statements being executed to be printed during an abnormal termination.
This option/parameter requires a subroutine to be invoked once for each
executable source line.
After you test your program, deactivate the FLOW trace, if possible, to
decrease execution time of your program.
■ The FLDCHK site option and PARM statement parameter validates all data
references during program execution. This option/parameter generates
additional CA-Easytrieve code.
After you test your program, deactivate the FLDCHK validation, if possible,
to decrease execution time of your program.
■ The VFM site option and PARM statement parameter specifies the amount of
storage available for the Virtual File Manager (VFM) buffer pool. Additional
storage can decrease execution time.
■ The BOUNCHK workstation option enables you to turn off bounds checking
for subscripted and indexed field references. You can also turn off bounds
checking with the /NB option during compilation.
Bounds checking generates a significant amount of additional code and
subroutine usage on the workstation. To decrease execution time and
storage consumption, deactivate bounds checking, if possible, after you test
your program.
Report Processing
File Processing
3
Overview
CA-Easytrieve provides all the facilities necessary to process your file or
database. Capabilities range from simple automatic input processing to complex
controlled database maintenance. CA-Easytrieve processes the following file
types:
■ Sequential
■ Indexed
■ Relative record
■ SQL, CA-IDMS, and IMS/DL/I databases
■ BTRIEVE
■ xBASE
■ Lotus
■ CA-SuperCalc
■ Comma-delimited
■ C-ISAM.
In addition, CA-Easytrieve provides its own sequential access method called the
Virtual File Manager (VFM). VFM processes all the work files needed by a
program.
This chapter describes the processing of sequential, indexed, and relative record
files. It also includes a discussion of printer files, and a discussion of workstation
file processing. See the “SQL Database Processing” chapter for a description of
SQL processing. See the “CA-IDMS Database Processing” chapter for a
description of CA-IDMS processing. See the “IMS/DL/I Database Processing”
chapter for a description of IMS/DL/I processing.
Following are items that apply to each type of file that CA-Easytrieve processes.
File Definition
The FILE statement describes your file. It provides a logical name for the file and
also the physical name of the file as known by the operating system. It can also
specify the file’s organization and characteristics. Following is an example of a
FILE statement:
(1) (2) (3) (4) (5) (6) (7)
FILE PERSONNEL-MASTER SYSNAME 'PERSNL' SEQUENTIAL FB(150 1800) SYSTEM (PC PATH +
'D:\DATA\PERSNL')
...
GET PERSONNEL-MASTER
(1)
JOB and SORT statements designate automatic input. SORT and the SUMFILE
parameter of the REPORT statement are the only automatic output functions.
All other output is, at least to some degree, under programmer control.
Input and output statements (DISPLAY, GET, CLOSE, POINT, PUT, READ, and
WRITE) designate controlled processing. You can code these statements in any
CA-Easytrieve processing activity, except SORTs, with or without automatic
input.
Following are the rules for using automatic and controlled file processing:
■ Controlled statements are not permitted in SORT or REPORT procedures.
■ The GET statement cannot reference an automatic input file within the same
JOB activity.
■ Controlled statements are not normally valid for automatic input files in the
JOB activity, with the following exceptions:
– The POINT statement can be used in conjunction with automatic input
for indexed and relative files. This allows for skip-sequential input
processing while under system control.
– The PUT and WRITE statements can be used for automatic input of an
indexed or relative file, except when using synchronized file processing.
WORKAREA Parameter
Normally, CA-Easytrieve allocates the data buffer of a file either during the
initiation of the activity that opens the file, or when the file is actually opened. If
you reference the fields in a file before the buffer is allocated, a runtime error is
issued indicating you have referenced a field in an unavailable file.
You can use the WORKAREA parameter on the FILE statement to allocate the
buffer during the initiation of the program. The fields in the file will then always
be available for reference during the execution of the program. These fields are
treated similarly to working storage fields, however, unlike working storage
fields, file fields are never initialized. If you reference these fields before a
successful input operation, you must initialize them.
Record Format
Fixed-length and variable-length records can be blocked. Block sizes are ignored
for Virtual File Manager (VFM) files and all files on the workstation.
All file formats must adhere to the standards established for processing by IBM
input/output control system routines. Records that deviate from the standards
for fixed-length or variable-length records can be processed only as
undefined-length records.
See Workstation Files later in this chapter, for more information on record
formats for workstation files.
See UNIX Files later in this chapter, for more information on record formats for
UNIX files.
Record Address
The address of a record points to the first data byte of the record. The
record-descriptor-word (RDW) of variable-length records is accessible only
through the system-defined RECORD-LENGTH field.
STATUS Parameter
The STATUS parameter can be optionally specified on the GET, POINT, READ,
PUT, and WRITE statements for files on which SEQUENTIAL, INDEXED, or
RELATIVE is specified on the FILE statement.
STATUS causes the file’s FILE-STATUS field to be set with the appropriate
return code. See System-Defined File Fields below to determine the meaning of
the contents of FILE-STATUS. Normally, a zero or non-zero test is sufficient.
FILE-STATUS is not defined if you do not specify the file type on the file
definition.
If you do not code STATUS and the operating system returns a non-zero status,
CA-Easytrieve issues an appropriate diagnostic message.
CA-Easytrieve automatically provides the special data fields listed below for
each of your files. These fields are stored as part of working storage but can be
qualified by file-name. As working storage fields, they are not subject to invalid
file reference errors.
RECORD-LENGTH
RECORD-LENGTH is a four-byte binary field used for all file types to determine
or establish the length of the current data record. For variable-length records,
this field contains only the length of the record’s data. CA-Easytrieve
automatically adjusts the field to account for the four-byte record-control-word
and four-byte block-control-word. For variable-length files, assign the length of
the record to the RECORD-LENGTH field before the PUT or WRITE statement is
executed.
RECORD-COUNT
FILE-STATUS
FILE-STATUS is a read-only, four-byte binary field that contains a code that tells
you the results of the most recent I/O operation on a file. See Appendix A,
“System-Defined Fields,” in the CA-Easytrieve Language Reference Guide for
FILE-STATUS codes and their meanings.
Error Conditions
Error conditions that are flagged during file processing activities generally fall
into one of the following three categories:
■ File OPEN errors - commonly caused by incorrect or missing JCL or
information (mainframe) or incorrect path information (workstation and
UNIX). The operating system detects these errors and terminates
CA-Easytrieve processing.
■ Invalid file reference errors - caused by statements that refer to data from a
file which does not have a current record, for example, after end-of-file or
record not found. CA-Easytrieve issues a diagnostic message for these errors
when the FLDCHK option is in effect.
■ Improper handling of nonzero STATUS conditions - (returned from
statements such as READ.) You are responsible for correctly resolving these
conditions. (See System-Defined File Fields above for information on
FILE-STATUS.)
Note: Referencing data in a file after any output operation is undefined and
results are unpredictable unless you code WORKAREA on the FILE statement.
Opening Files
During the initiation of an activity, CA-Easytrieve opens all files used in the
activity (except for those specified with the DEFER parameter) that are not
already open. DEFERed files are opened when the first input/output statement
is issued for them. Files that are already open when an activity begins remain
open with the same file characteristics.
Closing Files
CA-Easytrieve automatically closes all files that were opened by the activity at
the end of each activity. You can also manually close a file by executing a
CLOSE statement for the file. The next I/O statement using the file
automatically reopens the file. Automatic input and output files cannot be
manually closed.
Note: If you close an output file without executing a PUT statement, null files
are created, unless you code DEFER on the FILE statement. Closing a DEFERed
file leaves the file undefined.
CA-Easytrieve makes certain assumptions about the use of each file in an activity
by scanning the I/O statements coded in the activity. (This is assuming that all
statement syntax is valid.) One of these assumptions is the file’s processing
mode. The processing mode dictates whether the file is opened for read or write
access. CA-Easytrieve file processing modes are:
■ Input - indicates that only GET, POINT, and READ statements are coded in
the activity that opened the file.
■ Create - indicates that the file has CREATE specified on the FILE statement
and that a PUT statement is coded in the activity. If you coded RESET on the
FILE statement, CA-Easytrieve attempts to reload an existing file.
■ Output - indicates that UPDATE is specified on the FILE statement and PUT
or WRITE ADD statements are coded in the activity.
The other assumption CA-Easytrieve makes about a file is the file’s access mode.
CA-Easytrieve always opens a file for dynamic access. This allows records to be
read either sequentially or directly as follows:
■ Sequential - indicates that records are accessed in a sequence determined by
the file type as follows:
– For file type SEQUENTIAL, the records are accessed in the sequence in
which the records were added to the file.
– For file type INDEXED, the records are accessed in the sequence defined
by the key of the associated data set.
– For file type RELATIVE, the records are accessed in ascending sequence
of relative record numbers.
Sequential access allows the use of the GET, PUT, and WRITE UPDATE
statements. If the file type is INDEXED or RELATIVE, sequential access also
allows the use of the WRITE DELETE statement.
■ Direct - indicates that records are accessed in a sequence determined by the
program. Each statement that accesses a record specifies the key of the
record to be accessed as follows:
– For file type SEQUENTIAL, direct access is not allowed.
– For file type INDEXED, the key value must be an alphanumeric item
whose length is equal to the key length specified for the associated data
set.
– For file type RELATIVE, the key value is a 4-byte binary integer that
specifies a relative record number.
Direct access allows the use of the READ, WRITE ADD, WRITE DELETE,
and WRITE UPDATE statements.
Note: You can use the PRIOR parameter on the GET statement to perform a
backward browse.
Hold/Release Processing
CA-Easytrieve automatically issues a hold for a record when the FILE statement
specifies UPDATE. You can override this by specifying HOLD or NOHOLD on
your READ and GET statements.
When CA-Easytrieve holds a record for update, it establishes the intent to update
a record with the operating system. This intent does not mean you are obligated
to actually perform the update. It just holds the position in the file and may also
lock the record (CICS and workstation LANs). Locks are automatically released
when the update operation completes or a commit point is taken.
You can manually release the hold on any file with the RELEASE statement.
In CICS, the default action for a READ statement is HOLD when you specify
UPDATE on the FILE statement. The default action for a GET statement and for
automatic input is NOHOLD. CICS does not allow you to browse a file for
update.
Workstation LANs
SEQUENTIAL Files
CA-Easytrieve supports the access of all sequential files that the operating
environment in which CA-Easytrieve is running also supports. When also
supported by the operating environment, CA-Easytrieve supports all of the
following sequential access methods:
■ Queued Sequential Access Method (QSAM).
■ Virtual Storage Access Method Entry Sequenced Data Set (VSAM ESDS).
■ CARD and PUNCH files (not valid in CICS).
■ CA-Easytrieve’s Virtual File Manager.
■ Workstation fixed and variable-length text files, DBASE, LOTUS,
CA-SuperCalc, comma-delimited files, and mainframe EBCDIC files through
HLLAPI.
■ In UNIX, variable-length text files and fixed-length record files are
supported.
■ When you do not code a file type on the FILE statement, SEQUENTIAL is the
default. CARD, PUNCH, and VIRTUAL files imply a SEQUENTIAL file
type.
Note: When SEQUENTIAL is not specified for a sequential file, the
FILE-STATUS field is not available for the file.
■ You cannot process the same SEQUENTIAL file as both an input and an
output file within the same activity.
■ You can create SEQUENTIAL files in one activity and process them by
subsequent activities.
■ CA-Easytrieve permits only one CARD file in a program.
SEQUENTIAL Input
Automatic Processing
Controlled Processing
CARD Input
In TSO or CMS, you can process one of the input files through the system input
stream (SYSIN) by defining the file with a device type of CARD. On the
workstation, CARD files are 80-byte card images.
In UNIX, the device type of CARD is equal to stdin. The file is treated as a
variable-length text file.
Note: Unless redirected, stdin reads input from the terminal device.
FILE CARDFILE CARD
FIELD 1 5 A
JOB INPUT CARDFILE NAME MYPROG
DISPLAY FIELD
SEQUENTIAL Output
You can create output files using controlled processing with the PUT statement.
The FILE statement and the PUT statement are used to create (load) VSAM ESDS
files. You can reference a newly created file in subsequent activities by coding
another FILE statement with a different file name, but with JCL pointing to the
same physical file. The example below illustrates reloading a fixed-length ESDS
file.
You can create INDEXED and RELATIVE files using a similar technique. The
data set must be defined as reusable to use the RESET option on the FILE
statement.
FILE ESDS SEQUENTIAL CREATE RESET
%PERSNL
FILE PERSNL FB(150 1800)
COPY ESDS
JOB INPUT PERSNL NAME MYPROG
PUNCH Files
Except for the PUNCH parameter, CA-Easytrieve treats PUNCH files the same
as any other 80-byte SEQUENTIAL file. The next example illustrates PUNCH
file output:
FILE INFILE
FIELD 1 5 A
FILE OUTFILE PUNCH
FIELD 1 5 A
JOB INPUT INFILE NAME MYPROG
PUT OUTFILE FROM INFILE
In MVS, the PUNCH parameter is not required, due to its device independence.
Simply define an output SEQUENTIAL file as fixed-length 80 characters and
assign it to the proper SYSOUT class via the DD card. If you code the PUNCH
parameter, MVS routes the output to the DD, SYSPUNCH.
As a virtual file is read back into the program, the space it occupied is released
and the area can be immediately reused. You can, however, retain VFM files for
subsequent CA-Easytrieve activities.
The following example illustrates a typical use of the VFM access method:
FILE PERSNL FB(150 1800)
%PERSNL
FILE SORTFILE VIRTUAL F(150)
COPY PERSNL
SORT PERSNL TO SORTFILE USING PAY-NET NAME MYSORT
JOB INPUT SORTFILE NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1
LINE EMPNAME PAY-NET
INDEXED Files
CA-Easytrieve supports both sequential and random (direct) processing of
INDEXED files. INDEXED files use a key that is contained in each record.
Sequential processing retrieves records sequenced by the key. When also
supported by the operating environment, CA-Easytrieve supports the following
index access methods:
■ Virtual Storage Access Method Keyed Sequenced Data Set (VSAM KSDS)
■ Workstation Fast Access Btree Structure (FABS) ISAM files
■ Workstation BTRIEVE files (fixed format only)
■ UNIX C-ISAM files (fixed format, unique single keys only).
Skip-Sequential Processing
FILE VSAM INDEXED
%PERSNL
JOB INPUT VSAM NAME MYPROG
IF EMP# EQ 1000 THRU 1999
PERFORM POINT-VSAM
GOTO JOB
END-IF
PRINT REPORT1
*
POINT-VSAM. PROC
POINT VSAM GE '02000' STATUS
IF VSAM:FILE-STATUS NE 0
DISPLAY 'FILE-STATUS= ' FILE-STATUS
END-IF
END-PROC
*
REPORT REPORT1 LINESIZE 65
LINE EMP# EMPNAME
Random Input
INDEXED files can be read randomly (direct access mode) by the READ
statement. The next example illustrates reading an INDEXED file (PERSNL)
using keys contained in a SEQUENTIAL file (INKEYS).
FILE PERSNL INDEXED
%PERSNL
FILE INKEYS
WHO * 5 N
JOB INPUT INKEYS NAME MYPROG
READ PERSNL KEY WHO STATUS
IF FILE-STATUS EQ 16
DISPLAY 'BAD KEY=' WHO
GOTO JOB
END-IF
DISPLAY SKIP 2 HEX PERSNL
You can use either the WRITE or PUT statements to add records to an INDEXED
file. Either statement adds a single record to the file, but to use mass-sequential
insertion, use the PUT statement to add many records to the same place in the
file.
If you use the WRITE or PUT statements, you must include the CREATE or
UPDATE parameter on the FILE statement. UPDATE informs CA-Easytrieve
that all input records can potentially be updated or deleted. CREATE informs
CA-Easytrieve that the activity will use the PUT statement to load the file.
File Creation
The FILE statement and the PUT statement are used to create (load) INDEXED
files. You can reference a newly created file in subsequent activities by coding
another FILE statement with a different file name, but with JCL that points to the
same physical file. The following example illustrates reloading a INDEXED file.
The data set must be defined as reusable to use the RESET option on the FILE
statement.
FILE KSDS INDEXED CREATE RESET
%PERSNL
FILE PERSNL FB(150 1800)
COPY ESDS
JOB INPUT PERSNL NAME MYPROG
PUT KSDS FROM PERSNL STATUS
IF KSDS:FILE-STATUS NE 0
DISPLAY 'LOAD ERROR STATUS= ' ESDS:FILE-STATUS
STOP
END-IF
Deleting a Record
You can use the WRITE statement to delete individual records from an
INDEXED file. The deleted record is the file’s current input record.
FILE KSDS INDEXED UPDATE
%PERSNL
FILE KEYS
WHO 1 5 N
JOB INPUT KEYS NAME MYPROG
READ KSDS KEY WHO STATUS
IF FILE-STATUS NE 0
Updating a Record
You can modify and rewrite the current input record by using the WRITE
statement.
FILE KSDS INDEXED UPDATE
%PERSNL
FILE KEYS
WHO 1 5 N
PHONE 6 10 N
JOB INPUT KEYS NAME MYPROG
READ KSDS KEY WHO STATUS
IF FILE-STATUS NE 0
DISPLAY 'READ FAILED...KEY= ' WHO
STOP
END-IF
MOVE PHONE TO TELEPHONE
WRITE KSDS UPDATE STATUS
IF FILE-STATUS NE 0
DISPLAY 'UPDATE FAILED...KEY= ' WHO
STOP
END-IF
RELATIVE Files
CA-Easytrieve supports both sequential and random (direct file access)
processing of RELATIVE files. RELATIVE files use a four-byte binary key that
contains an integer value that specifies the relative record number. Sequential
processing retrieves records sequenced by the relative sequence number. When
also supported by the operating environment, CA-Easytrieve supports the
following relative access methods:
■ Virtual Storage Access Method Relative Record Data Set (VSAM RRDS)
■ Workstation and UNIX fixed-length relative (random-access) files.
The following example shows RELATIVE sequential input with a starting record:
FILE RRDS RELATIVE
%PERSNL
REC-NUMBER W 4 B
JOB INPUT RRDS NAME MYPROG START POINT-PROC
DISPLAY EMP# +2 NAME
POINT-PROC. PROC
REC-NUMBER = 20
POINT RRDS EQ REC-NUMBER STATUS
IF FILE-STATUS NE 0
DISPLAY 'FILE-STATUS= ', RRDS:FILE-STATUS
STOP
END-IF
END-PROC
Skip-Sequential Processing
Random Input
RELATIVE files can be read randomly (direct access mode) by the READ
statement. The example below illustrates reading a RELATIVE file, PERSNL,
using keys contained in a SEQUENTIAL file, INKEYS:
FILE PERSNL RELATIVE
%PERSNL
FILE INKEYS
WHO * 4 B
JOB INPUT INKEYS NAME MYPROG
READ PERSNL KEY WHO STATUS
IF FILE-STATUS NE 0
DISPLAY 'BAD KEY=' WHO
GOTO JOB
END-IF
DISPLAY SKIP 2 HEX PERSNL
You can use the PUT statement to add records to a RELATIVE file. If you use the
PUT statement, you must include the CREATE or UPDATE parameter on the
FILE statement. UPDATE informs CA-Easytrieve that all input records can
potentially be updated or deleted. CREATE informs CA-Easytrieve that the
activity will use the PUT statement to load the file. The following examples
illustrate record addition and file creation.
Record Addition
FILE PERSNL RELATIVE UPDATE
%PERSNL
FILE LOADER
COPY PERSNL
REC-NUMBER W 4 B VALUE 330. * STARTING SLOT NUMBER
JOB INPUT LOADER NAME MYPROG
POINT PERSNL GE REC-NUMBER STATUS
PUT PERSNL FROM LOADER STATUS
IF FILE-STATUS NE 0
DISPLAY 'ADD FAILED'
DISPLAY HEX LOADER
STOP
END-IF
REC-NUMBER = REC-NUMBER + 1
File Creation
The FILE statement and the PUT statement are used to create (load) RELATIVE
files. You can reference a newly created file in subsequent activities by coding
another FILE statement with a different file name, but with JCL that points to the
same physical file. The example below illustrates reloading a RELATIVE file.
The data set must be defined as reusable to use the RESET option on the FILE
statement:
FILE RRDS RELATIVE CREATE RESET
%PERSNL
FILE PERSNL FB(150 1800)
COPY RRDS
JOB INPUT PERSNL NAME MYPROG
PUT RRDS FROM PERSNL STATUS
IF RRDS:FILE-STATUS NE 0
DISPLAY 'LOAD ERROR STATUS= ' RRDS:FILE-STATUS
STOP
END-IF
Deleting a Record
You can use the WRITE statement to delete individual records from a RELATIVE
file. The deleted record is the file’s current input record. For example:
FILE RRDS RELATIVE UPDATE
%PERSNL
FILE KEYS
WHO 1 4 B
JOB INPUT KEYS NAME MYPROG
READ RRDS KEY WHO STATUS
IF FILE-STATUS NE 0
Updating a Record
You can modify and rewrite the current input record by using the WRITE
statement. For example:
FILE RRDS RELATIVE UPDATE
%PERSNL
FILE KEYS
WHO 1 4 B
PHONE 6 10 N
JOB INPUT KEYS NAME MYPROG
READ RRDS KEY WHO STATUS
IF FILE-STATUS NE 0
DISPLAY 'READ FAILED...KEY= ' WHO
STOP
END-IF
MOVE PHONE TO TELEPHONE
WRITE RRDS UPDATE STATUS
IF FILE-STATUS NE 0
DISPLAY 'UPDATE FAILED...KEY= ' WHO
STOP
END-IF
Sorting Files
You can use the SORT statement to sort files. CA-Easytrieve can sort any file that
can be processed sequentially. The following illustrates the position of a SORT
activity within a CA-Easytrieve program:
Environment
...
Library
...
Activities
...
... SORT ...
SORT sort procedure
... ...
...
Your installation’s sort program performs the actual sort process, except in CICS,
on the workstation, and in UNIX, where CA-Easytrieve supplies its own sort
program. CA-Easytrieve normally utilizes conventional sort interface
techniques. For example, on a mainframe CA-Easytrieve invokes the sort
program’s E15 (input) and E35 (output) exits.
You can set a site option to use versions of sort in which the sort processes all
input and output. For detailed information on the available options for sort
program utilization, refer to your installations’s sort program manual.
In the following example, the output file contains all of the records of the input
file sorted into ascending sequence by the values of fields REGION and
BRANCH:
FILE PERSNL FB(150 1800)
%PERSNL
FILE SORTWRK FB(150 1800) VIRTUAL
COPY PERSNL
SORT PERSNL TO SORTWRK USING +
(REGION, BRANCH) NAME MYSORT
JOB INPUT SORTWRK NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1
LINE REGION BRANCH EMPNAME
Sort Procedures
CA-Easytrieve normally sorts all input records and outputs them to the file you
specify. The output file usually has the same format and length as the input file.
However, sometimes you may want to sort only certain records and/or modify
the contents. To do this, you can write a sort procedure which must immediately
follow the SORT statement.
You can code any valid CA-Easytrieve statement in a sort procedure, but you
cannot code statements that generate input/output. Invalid statements are:
COMMIT DELETE
DISPLAYFETCH GET
IDMS INSERT
POINT PRINT
PUT READ
RETRIEVE (IDMS) ROLLBACK
SELECT (SQL) SELECT (IDMS)
SQL UPDATE
WRITE
Note: For debugging purposes, you can DISPLAY to the system output device
(SYSPRINT/SYSLST).
The following example illustrates how to code an output file that will contain
only a reordered subset of the input file. The output file contains only those
records for which the SELECT statement is executed:
FILE PERSNL FB(150 1800)
%PERSNL
FILE SORTWRK FB(150 1800) VIRTUAL
COPY PERSNL
SORT PERSNL TO SORTWRK USING +
(REGION, BRANCH, DEPT, +
NAME-LAST, NAME-FIRST) +
NAME MYSORT BEFORE SCREENER
*
SCREENER. PROC
IF MARITAL-STAT = 'S' AND SEX = 1
SELECT
END-IF
END-PROC
*
JOB INPUT SORTWRK NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1
LINE REGION BRANCH DEPT NAME-LAST NAME-FIRST
CA-Easytrieve has a twofold solution to help you avoid coding complex logic for
match/merge operations:
■ Automatic input that includes a universally-adaptable match/merge
algorithm.
■ Special conditional expressions that help to determine simple, yet precise file
relationships.
Example
The INPUT parameter of the JOB statement designates files and their keys for
synchronized file input. The example below illustrates a variety of synchronized
file and key combinations:
FILE FILE1 ...
KEY1A 1 5 A
KEY1B 6 4 P
...
KEY1X ...
...
FILE FILE2 ...
KEY2A 24 5 A
KEY2B 1 2 B
...
KEY2X ...
...
FILE FILEN ...
KEYNA 17 5 A
KEYNB 10 7 N
...
KEYNX ...
...
Record Availability
Records from files in CA-Easytrieve synchronized file input are made available
for processing based on the relationship of the files’ keys. Records with the
lowest keys are made available first, and the match is hierarchical based upon
the order of the files specified on the JOB statement.
Refer to the following three input files for an example of synchronized file input:
FILE1 FILE2 FILE3
1 2 1
2 3 A 3
3 A 3 B 4
3 B 4 A 5
8 A 4 B 7
8 B 6 8 A
9 7 8 B
The key is the single numeric digit and the letter indicates duplicates for
illustrative purposes. The JOB statement to process the three files for the
match/merge operation is:
JOB INPUT (FILE1 KEY(KEY1) +
FILE2 KEY(KEY2) +
FILE3 KEY(KEY3)) NAME MYPROG
Duplicate key values affect record availability differently based on which file
contains the duplicates. Remember, the matching algorithm is hierarchical so the
key is exhausted on the lowest level before another record is processed from the
next higher level file.
The following exhibit illustrates the match/merge output from the synchronized
file input process. The output shows the results of each iteration (loop) through
the JOB activity. N/A under a file indicates that a record from the file is not
available and no fields from this file can be referenced during the associated
iteration.
Refer to iterations 3 through 5 in the above output. FILE1 and FILE2 both
contain two records with a key value of 3. FILE3 contains only one record of key
3. These records are processed by CA-Easytrieve, as follows:
■ Iteration 3: The first record 3 from FILE1 and FILE2 and the only record
with key 3 from FILE3 are available.
■ Iteration 4: Since the next record on FILE3 is a key 4 record and there are
still key 3 records to process in the other files, FILE3’s record is not available.
CA-Easytrieve goes back to FILE2 and gets the next key 3 record. The
original key 3 record from FILE1 and the second key 3 record from FILE2 are
available.
■ Iteration 5: Since the next record on FILE2 is a key 4 record and there is still
a key 3 record on FILE1 to process, FILE2 is now unavailable. CA-Easytrieve
returns to FILE1 and retrieves the next record. This time the only record
available is the second key 3 record from FILE1.
Special IF Statements
MATCHED
Use the MATCHED test to determine the relationship between the current record
of one file and the current record of one or more other files.
IF [NOT] MATCHED [file-name-1 ... file-name-2 ...]
Refer to the earlier table under Match/Merge Operation Output, which depicts
automatic synchronized file input.
■ IF MATCHED is true for JOB iteration 3.
■ IF MATCHED FILE1, FILE3 is true for JOB iterations 1, 3, 11, and 12.
File Existence
To determine the presence of data from a particular file, use the following special
conditional expressions:
IF [NOT] file-name
IF [NOT] EOF file-name
When the IF file-name condition is true, a record from that file is present and
available for processing. The IF NOT file-name condition is true when the file
does not contain a record with a current key. When this condition is true, no
fields from the file can be referenced in the activity. If you reference a field in an
unavailable file, CA-Easytrieve issues a runtime error.
The following record relationship tests are based on the previous example of
automatic synchronized file input. See the table under Match/Merge Operation
Output.
■ IF DUPLICATE FILE1 is true for JOB iterations 3 through 5 and 11 through
13.
■ IF FIRST-DUP FILE2 is true for JOB iterations 3 and 6.
■ IF LAST-DUP FILE3 is true for JOB iteration 12.
Refer to the CA-Easytrieve Language Reference Guide for more detailed examples of
conditional expressions.
The next example illustrates updating a master file based upon matching
transaction file records. The program assumes:
■ A new master record is written when a match exists between the master file
and the transaction file.
■ There should be no duplicate transactions for a given master record. If this
occurs, the first duplicate is processed but subsequent duplicates are
bypassed.
■ No transaction records should exist without a matching master record. If this
occurs, the record is displayed on an error report and processing is bypassed.
FILE OLDMSTR SEQUENTIAL
O-KEY 1 2 N
O-AMT 3 3 N
FILE TRANS SEQUENTIAL
T-KEY 1 2 N
T-AMT 3 3 N
FILE NEWMSTR SEQUENTIAL
N-KEY 1 2 N
N-AMT 3 3 N
JOB INPUT (OLDMSTR KEY(O-KEY) +
TRANS KEY(T-KEY)) NAME MYPROG
* FOR MATCHED: UPDATE WITH TRAN AMT AND PUT NEWMSTR.
* IF TRAN IS A DUPLICATE BUT NOT THE FIRST, BYPASS THE RECORD.
IF MATCHED
IF DUPLICATE TRANS AND NOT FIRST-DUP TRANS
GOTO JOB
END-IF
MOVE O-KEY TO N-KEY
N-AMT = O-AMT + T-AMT
PUT NEWMSTR
GOTO JOB
END-IF
* ON OLDMSTR ONLY: PUT THE NEWMSTR WITHOUT ANY UPDATE.
IF OLDMSTR
PUT NEWMSTR FROM OLDMSTR
GOTO JOB
END-IF
* ON TRANS ONLY: PRINT ERROR REPORT.
IF TRANS
PRINT ERROR-RPT
GOTO JOB
END-IF
*
REPORT ERROR-RPT
TITLE 'REPORT OF TRANSACTION WITH INVALID KEYS'
LINE T-KEY T-AMT
Using Synchronized File Processing on a single file allows you to compare the
contents of a key field or fields from one record to the next and use IF tests to
group records according to the key fields. The file name is coded on the JOB
INPUT statement as follows:
JOB INPUT (filename KEY (keyfield...))
Using single file input allows you to determine the start of a new key value and
the end of the current key value by use of IF tests.
PRINTER Files
CA-Easytrieve enables you to create files with a device type of PRINTER to write
printed output with the REPORT and/or DISPLAY statements. See Routing
Printer Output in the “Report Processing” chapter for more information on
output creation. A PRINTER file can be directed to one of the following
destinations:
■ The user’s terminal
■ Any other terminal (only in CICS)
■ Your operating system’s spooling subsystem
■ An external data set.
The destination is determined by the FILE statement for the PRINTER file.
A PRINTER file is specified by coding PRINTER as the device type on the FILE
statement. You designate the destination of the file by specifying the data set
type. The data set type can be one of the following:
■ TERMINAL indicates that the output for the printer is routed to a terminal.
The terminal can be a display terminal or an online CICS printer terminal. In
CICS, you can specify the ID of a terminal other than the originating user’s
terminal. When you do not specify a terminal ID (regardless of operating
environment), the output is routed back to the originating terminal.
■ SPOOL indicates that the output for this printer is routed to the operating
system spooling subsystem. You can also specify the output class,
destination node, and destination userid. In CMS, spooling requires that the
user’s machine has its printer spooled to RSCS.
SYSPRINT
Workstation Files
CA-Easytrieve can access most workstation file structures in a way that allows
the program to be portable to the mainframe environment.
SYSTEM Parameter
You must use the SYSTEM parameter on the FILE statement to describe
operating environment-specific information about a file. This information may
be necessary for CA-Easytrieve to process the file on the workstation. The
SYSTEM parameter is ignored on the mainframe.
Note: CA-Easytrieve Plus versions 6.0 and below do not ignore the SYSTEM
parameter and flag it as an error. To ensure portability to these versions, code
the system information in an FCT entry.
When you code a FILE statement for a file you want to access on both the
workstation and mainframe, use the PATH subparameter instead of including
the path on the SYSNAME parameter.
File Type
The FILE statement for each file specifies the type of CA-Easytrieve access.
SEQUENTIAL is the default if not specified. Optionally, you can specify
INDEXED or RELATIVE for keyed file access.
Record Format
The record length of an EBCDIC variable-length file is the maximum data length
plus four (4) bytes. Unlike the mainframe, the PC does not support a
record-descriptor-word (RDW). For code portability, these four bytes are
maintained internally, with the first two bytes being VAREVAL.
When creating a variable-length file, assign the length of the record to the
RECORD-LENGTH field before a PUT or WRITE statement is executed. If you
do not do this, the record is padded with spaces up to the specified record length
or default record length (if not specified).
Note: Use caution when specifying variable-length EBCDIC files. There can be
cases in which the EBCDIC delimiter characters appear as part of the legitimate
data. CA-Easytrieve/Workstation interprets these as the end of record delimiter,
which does not produce the results expected.
Fixed-length records are logical in nature. The record length of the file
determines the end of one record and the beginning of the next.
If you do not specify the logical record length (LRECL) of the file,
CA-Easytrieve/Workstation assumes the record length is 256 bytes. If the file is
variable EBCDIC, this implies 252 bytes of data and four bytes for the RDW. For
variable-length files (carriage-return/line-feed terminated ASCII), 256 bytes can
be wasteful if the true record length is very small. If the true record length
exceeds 256 bytes, CA-Easytrieve/Workstation issues an error message. For
fixed format files, the length of fixed files is logical in nature. If set incorrectly,
CA-Easytrieve/Workstation will not find fields where expected. Invalid data
found in a numeric field could cause execution errors. CARD and PUNCH files
are assumed to be 80 bytes.
Use the CODE parameter of the file to specify the code system. CA-Easytrieve
programs running on the workstation can access files using either ASCII or
EBCDIC code systems. Code systems are converted as necessary. The code
system defaults to the CODE PROCESS parameter of the PARM statement or
system option. Some code systems are not supported in some access systems.
CA-Easytrieve always assumes that PRINTER and variable-length files are
ASCII.
Refer to the following table for field types normally used for files:
CA-Easytrieve always assumes that N, P, and U type numeric fields are EBCDIC
numeric format.
The following list describes the supported file structures on the workstation and
any special considerations for using them.
Sequential
Notes: The SYSTEM KEY parameter specifies the key of the record and is
required. The SYSTEM INDEX parameter names the associated index
component for the file. This allows a single data component to have alternate
indexes or keys.
See the CA-Easytrieve/Workstation User Guide for information on a utility that can
be used to build or rebuild the index component for ISAM files.
Relative (Random-access)
Notes: Random-access files are sequential files in which each record is located
using a relative record number. When used in multi-user environments (LANs)
for update the entire file remains locked while open.
BTRIEVE
Notes: The BTRIEVE record manager must be loaded when you execute
programs accessing BTRIEVE files. See the CA-Easytrieve/Workstation User Guide
for more information.
Use the SYSTEM ACCESS-PATH parameter to specify the access path used for
record retrieval. Use the SYSTEM CREATE-PATH parameter to specify the
access paths and keys to create. The keys need to be specified only during file
creation. Use the SYSTEM OWNER parameter to specify the owner
identification for the file. Use the SYSTEM CREATE-MODE parameter to set
access rights and encryption mode for the file. Use the SYSTEM PAGESIZE
parameter to set the data page size used by BTRIEVE. See your BTRIEVE
documentation for complete information.
DBASE (xBASE)
Notes: Field definitions for the CA-Easytrieve file must be compatible with the
dBASE structure. dBASE does not support N, P, B, U, I, S, or D field types. If
used during output, CA-Easytrieve converts data in these field types to character
fields. If used during input, CA-Easytrieve does not perform any conversion,
enabling the character data to be defined by these field types.
Do not include the dBASE delete indicator byte present in every dBASE file in
your record length.
When defining a file for ouput in dBASE format, the fields must be defined so
that there are no undefined bytes between fields. For the dBASE software to
correctly read the file, each field must be defined so that its first byte
immediately follows the last byte of the preceding field.
Also, the record length must be equal to the sum of all field lengths defined in
the dBASE output file. Note the following examples:
FILE DBASE-OUT F(100) +
SYSTEM(ACCESS DBASE PATH 'DBFILE.DBF')
FLD-1 1 10 A
FLD-2 11 20 A
* The record length is too long and
* should be changed to F(30).
LOTUS
Notes: CA-Easytrieve supports both WKS and WK1 file formats. The format is
determined from the extension of the file. If not extension is specified, WKS is
assumed.
When used as output, CA-Easytrieve creates cells, left-to-right, from each base
field. Cell size is set to the length of the CA-Easytrieve field. F, N, P, B, U, I, S, or
D type data is converted to a numeric cell when written to the spreadsheet.
PRINT REPT1
CA-SuperCalc
When used as output, CA-Easytrieve creates cells, left-to-right, from each base
field. Cell size is set to the length of the CA-Easytrieve field. F, N, P, B, U, I, S, or
D type data is converted to a numeric cell when written to the spreadsheet.
Comma-Delimited
Notes: When processing each record for input, CA-Easytrieve assigns each field,
left-to-right, into each base field defined in the CA-Easytrieve file. Data in the
field must conform to the field type and data is either truncated or padded to fit
the field. F type data in the file is converted to the correct format if defined as N,
P, B, U, I, S, or D. Null alphanumeric values assigned into a varying
alphanumeric field have a length of zero.
Host Mainframe
Notes: The host file is accessed using the file transfer facility of the High level
Applications Level Interface (HLLAPI). Requirements for this feature are:
– An IBM PC 3270 connection to the mainframe.
– A PC 3270 emulator program that supports HLLAPI. See the
CA-Easytrieve/Workstation User Guide for information on HLLAPI
requirements and setup options.
– HLLAPI executing resident on the workstation.
– The IND$FILE program executable in TSO or CMS.
When CA-Easytrieve opens a file for input that specifies HOST, a file transfer
request is made to download the file to a system-defined virtual file on the
workstation. When the transfer is complete, CA-Easytrieve processes the file.
CA-Easytrieve assumes the file is in EBCDIC format on the mainframe. If you
specify CODE ASCII on the FILE statement, CA-Easytrieve instructs the file
transfer to convert the code system of the file from EBCDIC to ASCII and add
carriage return and line feed characters (if variable) during the transfer.
When CA-Easytrieve opens a file for output that specifies HOST, output records
are written to a virtual file on the workstation. When the file is closed, the virtual
file is uploaded using a file transfer request to the mainframe. CA-Easytrieve
assumes the file is in EBCDIC format on the mainframe. If you specify CODE
ASCII on the FILE statement, CA-Easytrieve instructs the file transfer to convert
the code system of the file from ASCII to EBCDIC and remove carriage return
and line feed characters (if variable) during the transfer.
UNIX Files
The following guidelines apply when you code the FILE statement in UNIX.
File Type
The FILE statement for each file specifies the type of CA-Easytrieve access.
CA-Easytrieve in the UNIX environment supports SEQUENTIAL, INDEXED and
RELATIVE file types. SEQUENTIAL is the default if not specified. INDEXED
files can be processed using various access methods. See Executing Your
Program in UNIX in the User Guide.
Record Format
RELATIVE and INDEXED files permit only fixed format records. SEQUENTIAL
files can have fixed or variable format records. Variable format records are
line-feed (newline) delimited. Only text files can be variable. Binary data cannot
be stored in a sequential variable file. You should set your record length to the
length of the longest text. CA-Easytrieve reads the file for
record-length-plus-one characters or up to a newline character, whichever comes
first. If a newline character is not present, CA-Easytrieve issues an I/O error.
Fixed format records are fixed in length. The record length of the file determines
where each record in the file begins. For example, if a file has a record length of
20, bytes 0 through 19 make up the first record, bytes 20 through 39 make up the
second record, and so on. You can store binary data in fixed format files.
Because fixed format records on UNIX and the Workstation are not line-feed
delimited, you can get unpredictable results viewing or editing them.
You should specify the logical record length for each file. The defaults
CA-Easytrieve may assume in the UNIX environment most likely are wrong.
■ If you set the record length of a variable file too short, an error occurs.
■ If you set the record length of a fixed file incorrectly, any record after the first
appears to have fields shifted out of place. Often, this causes data errors.
C-ISAM
Creating C-ISAM files requires that CA-Easytrieve know what field represents
the key of the record. See the FILE statement KEY parameter for details.
CA-Easytrieve receives key information from C-ISAM after the files are created.
Currently, CA-Easytrieve supports only fixed-length, unique single-keyed
C-ISAM files and only as INDEXED files.
Not all C-ISAM data types are directly supported by CA-Easytrieve. The table
below shows the C-ISAM data types and their CA-Easytrieve equivalents.
*These C-ISAM numeric data types are not directly usable within CA-Easytrieve.
C-ISAM provides functions to convert between their machine-independent data
representation and the internal representation required by CA-Easytrieve when
it executes. You can call these routines from a FILE MODIFY exit to reformat
data into any of the various CA-Easytrieve numeric data types. A sample exit is
supplied with CA-Easytrieve as CISAMXIT.c.
C-ISAM execution requires special execution setup. See the User Guide for details
on executing your C-ISAM program.
Overview
CA-Easytrieve provides optional processing facilities for SQL databases. The
following SQL databases are supported:
■ IBM’s DB2, version 2.2 and greater
■ IBM’s DB2 for AIX, version 2.1 and greater
■ IBM’s SQL/DS, version 2.2 and greater
■ CA-Datacom/PC, version 1.0 and greater
■ CA-Datacom/DB with SQL, version 8.0 and greater
■ CA-IDMS, version 12.0 and greater
■ CA-Ingres, HP-UX and AIX, version 6.4 and greater
■ CA-OpenIngres, HP-UX, and AIX, version 1.0 and greater.
■ ORACLE, HP-UX and AIX, version 7.1 and greater.
Mainframe users:
■ Before CA-Easytrieve can process these databases, the CA-Pan/SQL
Interface product, version 2.4, must be correctly installed. See the
CA-Pan/SQL SQL Interface Installation Guide for complete information.
Workstation users:
■ CICSSERV.COM must be loaded into memory before CA-Easytrieve can
process queries to CA-Datacom/PC. If CICSSERV.COM is not loaded into
memory before compiling an SQL CA-Easytrieve program, the compile
process suspends processing on the system. See the CA-Datacom/PC
MS-DOS Database and System Administration Guide for more information
about the CICSSERV facility.
UNIX users:
■ All CA-Pan/SQL Interface functionality is installed with CA-Easytrieve. No
additional installation or documentation is required.
To use these facilities effectively, you should have a basic knowledge of SQL and
the given database management system to be processed.
Programming Methods
There are two programming methods supported for processing SQL databases:
■ Using native SQL statements to manually manage the SQL cursor
■ Allowing CA-Easytrieve to automatically manage the SQL cursor.
CA-Easytrieve supports most of the SQL statements available for a given DBMS.
The exceptions are those statements that are compiler directives and statements
that cannot be dynamically “prepared.” Using these native SQL statements, you
can code fully SQL-compliant programs in which you control the SQL cursor
operation. All native SQL statements are prefixed with the SQL keyword. See
the CA-Easytrieve Language Reference Guide for complete syntax. A list of all
supported and unsupported SQL commands is provided later in this chapter.
There are two ways that CA-Easytrieve can manage the SQL cursor for you:
■ CA-Easytrieve files
■ Automatic retrieval without a file.
CA-Easytrieve Files
Automatic retrieval does not require that you define a CA-Easytrieve file. In this
read-only method, SQL must be coded on the JOB statement in place of a file
name. A SELECT statement must be coded directly after the JOB statement to
specify the columns to be retrieved and the host variables to receive the data.
Each time the JOB activity is iterated, another row of SQL data is retrieved. This
is a simple way to retrieve SQL data into working storage or into an extract file
for subsequent output.
There are several differences in the rules to follow when coding SQL control
statements in CA-Easytrieve. The following syntax rules apply:
■ Operators must be separated by blanks.
■ Standard CA-Easytrieve continuation conventions are followed.
■ Commas are not ignored.
■ The period is used as a qualification separator, not to signify
end-of-statement.
■ The colon is used to identify host/indicator variables, not as a qualification
separator.
■ An SQL statement cannot be followed by another statement on the same
source record.
Program Environment
CA-Easytrieve processes SQL statements using the CA-Pan/SQL Interface
product on the mainframe and internal interfaces in UNIX and on the
Workstation. A specific implementation exists for each supported database:
■ For mainframe DB2, a dynamic and static interface are supported.
■ For SQL/DS, “extended dynamic” SQL is supported. SQL statements are
dynamically prepared during the compilation of your CA-Easytrieve
program and an access module or package is created. At runtime, SQL
statements are executed from the access module or package.
■ The CA-Datacom/DB SQL interface is very similar to the SQL/DS interface.
An access plan is created at compile time from which SQL statements are
executed.
■ The CA-Datacom/PC interface is similar to the CA-Datacom/DB SQL
interface on the mainframe. An access plan, from which SQL statements are
executed, is created at compile time .
See Unsupported SQL Commands later in this chapter, for a list of commands
that cannot be coded in CA-Easytrieve programs.
Units of Work
You can issue your own COMMIT and ROLLBACK statements to signal the
successful or unsuccessful end of the transaction. These COMMIT and
ROLLBACK statements are performed in addition to the ones CA-Easytrieve
does automatically.
The following PARM statement parameters set the SQL environment for the
program:
CA-Datacom/DB PLANOPTS
PREPNAME
SQLSYNTAX
CA-IDMS USERID
SQLSYNTAX
CA-Ingres SSID
USERID
SQLSYNTAX
ORACLE USERID
SQLSYNTAX
In all environments, use the SQLSYNTAX parameter to specify the level of SQL
syntax checking to be performed on the SQL statements in your program.
SQLSYNTAX FULL specifies that SQL statements will undergo detail-level
syntax checking. An SQL PREPARE statement is executed for those SQL
statements that can be dynamically prepared. Your DBMS must be available to
CA-Easytrieve. SQLSYNTAX PARTIAL indicates that your SQL statements are
checked for valid commands and secondary keywords. No connection is made
to your DBMS unless you have an SQL INCLUDE statement in your program.
Your program will not execute until it has undergone FULL syntax checking.
You can use the SQLSYNTAX NONE parameter on the PARM statement with a
static bind if you want syntax checking to be performed by the DB2 preprocessor
in a batch environment. An option of NONE causes your program to undergo
“partial” syntax checking. If no partial level compile errors are found and a
BIND option of STATIC-ONLY is specified, and no other non-SQL syntax errors
are found, your program continues to execution.
DB2
The SQLID parameter of the PARM statement results in the execution of the SQL
SET CURRENT SQLID command by the SQL Interface at compile time. The SQL
SET CURRENT SQLID command is executed at runtime for controlled or
automatic processing. Execution of the SQL SET CURRENT SQLID command is
valid for sites that have an external security package that supports group IDs.
The SSID parameter of the PARM statement can be used to specify the desired
DB2 subsystem in non-CICS environments. If the SSID parameter is not coded,
the SQL interface gets the DB2 subsystem ID from the DB2 system default
module DSNHDECP. DSNHDECP is made available through the JOBLIB or
steplib libraries. In CICS, the currently attached subsystem is used. In UNIX, the
SSID identifies the database to be connected.
To run your program statically, you must run special steps to create and link the
static command program and plan. See the “Batch Compilation” and
“Link-Editing” chapters in the CA-Easytrieve/Online User Guide for a complete
discussion.
Dynamic SQL is used to process your program when running under the
interpreter, regardless of the BIND parameter specified.
When you execute multiple static SQL programs in a given transaction or task,
you must bind all of the involved DBRMs into a single plan. Therefore, specify
the same planname for the PLAN parameter of each application program.
SQL/DS
Specify the SQL/DS userid to be used for compiling the program on the USERID
parameter of the PARM statement. At execution time, a CONNECT is executed
by CA-Easytrieve for automatic processing only. For controlled processing, you
must code the SQL CONNECT command providing the values for an sqlid and
password.
Specify the name of the SQL/DS access module for this program on the
PREPNAME parameter of the PARM statement. When an SQL program is
compiled, an access module is created or replaced. You should use unique
access module names for each application program to avoid using the default
name. In a high volume system, using the default PREPNAME can result in
catalog contention and a -911 SQLCODE resulting from a rollback.
CA-Datacom/PC
Specify the name of the CA-Datacom/PC PLAN for this program on the
PREPNAME parameter of the PARM statement. When an SQL program is
compiled, a PLAN is created or replaced. You should use unique PLAN names
for each application program to avoid using the default PLAN name from the
Site Options Table.
CA-Datacom/DB
Use the PLANOPTS parameter on the PARM statement to specify the name of a
CA-Pan/SQL PLAN options module to override the default module
(DQSMPLN@). See the CA-Pan/SQL SQL Interface Installation Guide for more
information about defining your own options module.
CA-IDMS
Use the USERID parameter to specify the name of the IDMS dictionary to be
used for explicit connect (no password is needed).
CA-Ingres
Use the SSID parameter on the PARM statement to specify the name of the
database to which this session will connect.
Use the USERID parameter on the PARM statement to specify the user identifier
under which this session will run. The password subparameter is ignored.
ORACLE
Specify the ORACLE userid to be used for compiling the program on the
USERID parameter of the PARM statement. At execution time, a CONNECT is
executed by CA-Easytrieve for automatic processing only. For controlled
processing, you must code the SQL CONNECT command providing the values
for an sqlid and password.
If you are using native SQL commands or using automatic retrieval without a
file, you usually define the fields as working storage fields. Alternatively, you
can define the fields within an active output file. This is an effective method to
select SQL data into a sequential file for extraction purposes. You must specify
which columns are to be retrieved and which host variables are to receive the
data.
When using a CA-Easytrieve file, however, fields defined within the file
correspond to the selected columns of the SQL table. The table columns are
retrieved into the file fields.
The SQL INCLUDE statement names the SQL table or view from which column
names and data types are obtained, and defines the location at which the field
definitions are generated.
The SQL INCLUDE statement must precede any other SQL or SELECT
statements and must be coded in the library section of your CA-Easytrieve
program.
Note: To use the SQL catalog INCLUDE facility on the workstation, your
database administrator must have installed the CA-Easytrieve workstation
compiler’s plan and granted you access to the system catalog tables.
Note: To use the SQL catalog INCLUDE facility for ORACLE, your database
administrator must have installed the catalog views (catalog.sql).
CA-Easytrieve supports the SQL concept of a null data value. Null is a value
that denotes the absence of a known value for a field. Specify the keyword
NULLABLE on the SQL INCLUDE statement to generate the null indicator
variables. CA-Easytrieve does the rest of the processing for you when processing
the SQL table as a file.
When a field is defined as nullable, you can use special processing statements:
■ IF NULL can be used to determine if the field contains a null value.
■ MOVE NULL can be used to set a field’s value to null.
When you use native SQL statements or automatic retrieval without a file, you
define null values differently. You define an indicator variable as a two-byte
quantitative binary field (2 B 0). This indicator variable is then used in the INTO
clause of the native or automatic SELECT statement. SQL returns a negative
value to the indicator variable when the field’s value is null. See the native SQL
examples for the use of manual indicator values.
Note: CA-Datacom/PC uses I type fields as indicator variables. You can code B
or I data types as indicator variables, however, if you code B type data,
conversion is performed whenever the database is accessed.
The following tables illustrate SQL data types and corresponding CA-Easytrieve
field definitions. SQL provides some data conversion in SQL assignments and
comparisons. Refer to your SQL manuals for more information on SQL data
conversions. See the corresponding notes after the tables for asterisked items in
the tables.
Note 3: The CA-Easytrieve data type of BINARY for a length other than 2 or 4 is
valid only for CA-Easytrieve/Workstation. When processing an SQL INCLUDE
statement on the mainframe, this data type is converted to x A.
For SQL DECIMAL data types, the scale is the same as the decimal places of a
CA-Easytrieve field. SQL precision refers to the total number of digits that can
occur in the packed field. A CA-Easytrieve length refers to the number of bytes
occupied by the packed field. A CA-Easytrieve field that is 5 P 2 is the equivalent
of an SQL DECIMAL data type of precision = 9 and scale = 2. Depending on
your SQL release, SQL may not support CA-Easytrieve packed fields with
lengths > 8.
When an SQL statement is passed to SQL for syntax checking, host variables are
converted to question marks (?) by CA-Easytrieve. It is possible that when an
SQL error is detected, the question mark is identified as the field in error. In this
case, you are responsible for looking up the error message and identifying which
host variable is in error. Because host variables are replaced with question
marks, their use in arithmetic expressions may result in compile errors. For DB2
and SQL/DS, an SQLCODE of -418 can occur.
RECORD-COUNT
RECORD-LENGTH
RECORD-LENGTH is the length of the SQL file. The length is the sum of the
maximum lengths of all fields in the file.
EOF Processing
When the end of the table(s) has been reached, either with automatic (JOB) or
controlled (FETCH) processing, the file is marked EOF (end of file). In automatic
processing, execution stops, and the FINISH procedure (if present) executes. In
controlled processing, you can code file presence tests (IF EOF file-name) to
determine whether an end of file condition exists.
All of the SQL Communication Area fields (SQLCA) are automatically created in
S (static) working storage when any of the following occurs:
■ The first SQL-managed file is encountered
■ The first SQL INCLUDE statement is encountered
■ The first native or controlled SQL statement is found
■ The first JOB INPUT SQL statement is found.
The fields generated for SQLCA for the supported SQL database management
systems are shown in the following exhibits.
SQL Communication Area Fields for DB2, SQL/DS, CA-Ingres, and ORACLE
DEFINE SQLCA S 136 A
DEFINE SQLCAID SQLCA 8 A
DEFINE SQLCABC SQLCA +8 4 B 0
DEFINE SQLCODE SQLCA +12 4 B 0
DEFINE SQLERRM SQLCA +16 72 A
DEFINE SQLERRML SQLCA +16 2 B 0
DEFINE SQLERRMC SQLCA +18 70 A
DEFINE SQLERRP SQLCA +88 8 A
Sample Database
The following two tables are used for all the examples in this chapter.
TABLE: PERSONNEL
------------------------------------------
COLUMNS: EMPNAME WORKDEPT EMPPHONE
------------------------------------------
DATA: NORIDGE DEBBIE 901 5001
OSMON SAMUEL 901 5004
MILLER JOAN 950 6034
EPERT LINDA 950 null
STRIDE ANN 901 null
ROGERS PAT 921 2231
EMPNAME - CHAR(20) (NOT NULL)
WORKDEPT - DECIMAL(3,0) (NOT NULL)
EMPPHONE - DECIMAL(5,0) (NULL)
.....................................................
TABLE: DEPARTMENTS
------------------------------
COLUMNS: DEPTNAME DEPTNUMBER
------------------------------
DATA: SHIPPING 901
HUMAN RESOURCES 921
ACCOUNTING 950
DATA PROCESSING 951
The next exhibit shows working storage field definitions for the sample tables in
the previous exhibit.
DEFINE EMPNAME W 20 A
DEFINE WORKDEPT W 2 P 0
DEFINE EMPPHONE W 3 P 0
DEFINE DEPTNAME W 22 A VARYING
DEFINE DEPTNUMBER W 2 P 0
DEFINE NULLPHONE W 2 B 0 .* NULL INDICATOR
Processing Requirements
To process data from an SQL table using this method, you must code the
following:
■ A FILE statement specifying one or more table names. If all columns defined
in the file are subject to update, specify the UPDATE keyword on the FILE
statement.
■ One or more field definitions for the columns within the table(s) that you
want to retrieve. These definitions can be coded using the DEFINE
statement or by using the SQL INCLUDE statement to automatically
generate the definitions from the SQL catalog. If you want to selectively
update only a few columns of those defined within the file, omit the
UPDATE keyword from the FILE statement and specify UPDATE only on
the field definitions (columns) you want to update. Coding UPDATE on the
SQL INCLUDE statement causes generated definitions to be subject to
update.
■ A SELECT statement that defines the result set for the cursor. If you do not
use a SELECT statement, CA-Easytrieve generates a default SELECT to
retrieve all rows for the table(s). You can override this default by specifying
your own file-based SELECT statement as the first statement following the
JOB statement.
Overriding the default SELECT allows you to use SQL techniques to
customize the result set for the cursor. For example, you can:
– Limit the result set to a subset of records (WHERE)
– Organize the data in the table by groups (GROUP BY)
– Limit the groups returned (HAVING)
– Sequence the returning records (ORDER BY).
In addition to overriding the default SELECT, you can code one or more
SELECTS anywhere in your JOB activity. This enables you to use conditional
logic to dynamically determine which SELECT is executed.
See the CA-Easytrieve Language Reference Guide for more information on SELECT
usage.
Operation
Note: UNIX DB2 and ORACLE systems are limited to a maximum of 10 cursors.
Input Processing
You can access SQL data using a CA-Easytrieve file either automatically or using
controlled processing.
Automatic Processing
CA-Easytrieve automatically accesses your SQL database if you name the SQL
file as the input file on a JOB statement. When you specify an SQL file as
automatic input, CA-Easytrieve prepares a default SELECT statement for the
cursor:
You can override the default SELECT statement by coding a SELECT statement
for the automatic input file as the first statement in the JOB, as shown in the
following exhibit:
FILE PERSNL SQL (PERSONNEL)
EMPNAME * 20 A
WORKDEPT * 2 P 0
JOB NAME RETRIEVE-PERSONNEL INPUT PERSNL
SELECT FROM PERSNL WHERE WORKDEPT = 901
DISPLAY EMPNAME +2 WORKDEPT
The above program displays only the records for employees assigned to
department 901. The SELECT statement provides the new default selection
criteria.
You can use the DEFER parameter on the SQL FILE statement to delay SELECT
processing. For example, assume you want to select only employee numbers in a
particular department and the department number is kept in a card file. The
SELECT statement contains a WHERE clause specifying the host variable in the
card file. CA-Easytrieve opens the CARD file at the initiation of the JOB activity
but the GET statement is coded in a START procedure. If the file SELECT is not
DEFERed, the SELECT is performed using an uninitialized host variable. Coding
DEFER enables the START procedure to get the card before the SELECT is
performed.
In addition, if DEFER is not specified, the default SELECT is executed before the
START procedure. Then the SELECT in the START procedure is executed. This
causes extra processing that is not needed. An example follows:
FILE PERSNL SQL (PERSONNEL) DEFER
EMPNAME * 20 A
WORKDEPT * 2 P
FILE CARDFIL CARD
CARDDEPT 1 3 N
JOB NAME RETRIEVE-PERSONNEL INPUT PERSNL START GETCARD
DISPLAY EMPNAME +2 WORKDEPT
GETCARD. PROC
GET CARDFIL
SELECT FROM PERSNL WHERE WORKDEPT = :CARDDEPT
END-PROC
The following example illustrates how to process the nullable field, EMPPHONE.
You must test for a nullable field before processing it. If EMPPHONE contains a
null value, it is set to zero before displaying it:
FILE PERSNL SQL (PERSONNEL)
SQL INCLUDE (EMPNAME, WORKDEPT, EMPPHONE) +
FROM PERSONNEL LOCATION * NULLABLE
JOB NAME RETRIEVE-PERSONNEL INPUT PERSNL
IF EMPPHONE NULL
EMPPHONE = 0
END-IF
DISPLAY EMPNAME +2 WORKDEPT +2 EMPPHONE
Multiple Tables
Both table names are specified on the FILE statement. The default SELECT is
overridden because the result set should include only those DEPARTMENT
records that match the department number of the PERSONNEL record.
Controlled Processing
You use the FETCH statement (in conjunction with SELECT and CLOSE
statements) to retrieve the records from the file with controlled processing. You
can code these statements within a PROGRAM, SCREEN, or JOB activity, with or
without automatic input. The following rules apply:
■ Controlled statements are not permitted in SORT or REPORT procedures.
■ The FETCH statement cannot reference an automatic input file within the
same JOB activity. You can FETCH from a file other than the file subject to
automatic input.
In a PROGRAM Activity
The PROGRAM activity fetches each row of the table and displays the fields.
The DO statement executes until end-of-file.
In a JOB Activity
You must execute a STOP statement when end-of-file is reached because a NULL
JOB activity automatically loops.
Random Processing
The following example illustrates a type of random processing in which the SQL
file’s cursor is built using a key contained in a sequential file.
FILE ESDS SEQUENTIAL
FILENAME 17 20 A
FILE PERSNL SQL (PERSONNEL) DEFER
EMPNAME * 20 A
WORKDEPT * 2 P 0
JOB NAME RETRIEVE-PERSONNEL INPUT ESDS
SELECT FROM PERSNL WHERE EMPNAME = :FILENAME
FETCH FROM PERSNL
IF EOF PERSNL
DISPLAY 'EMPLOYEE NOT ON FILE ' FILENAME
ELSE
DISPLAY EMPNAME +2 WORKDEPT
END-IF
CLOSE PERSNL
The sequential file is read automatically by the JOB activity. For each record, a
SELECT statement is executed to locate the employee in the PERSONNEL table.
If the FETCH statement results in end-of-file, the employee is not found.
Otherwise, the employee’s name and department are displayed.
The following example illustrates a way to match a sequential file with an SQL
file. This example uses the default SELECT and then matches the two files based
on the employee name in both files:
FILE ESDS SEQUENTIAL
FILENAME 17 20 A
FILE PERSNL SQL (PERSONNEL)
EMPNAME * 20 A
WORKDEPT * 2 P 0
JOB NAME MATCH-PERSNL INPUT (ESDS KEY (FILENAME) PERSNL KEY (EMPNAME))
IF NOT MATCHED AND ESDS
DISPLAY 'EMPLOYEE NOT IN SQL FILE' FILENAME
ELSE
IF NOT MATCHED AND PERSNL
DISPLAY 'EMPLOYEE NOT ON ESDS FILE' EMPNAME
ELSE
DISPLAY 'EMPLOYEE ON BOTH FILES' EMPNAME
END-IF
END-IF
The default SELECT could have been overridden by coding a SELECT as the first
statement after the JOB statement.
Update Processing
Controlled Processing
The following example selects a specific row from the table, updates the
department to 930, and moves a null data value to the phone number.
FILE PERSNL SQL (PERSONNEL) UPDATE
SQL INCLUDE (EMPNAME, WORKDEPT, EMPPHONE) +
FROM PERSONNEL LOCATION * NULLABLE
PROGRAM NAME RETRIEVE-PERSONNEL
SELECT FROM PERSNL WHERE EMPNAME = 'ROGERS PAT' FOR UPDATE
FETCH FROM PERSNL
IF EOF PERSNL
DISPLAY 'EMPLOYEE NOT FOUND'
ELSE
WORKDEPT = 930
MOVE NULL TO EMPPHONE
UPDATE PERSNL
END-IF
Automatic Processing
The following example changes the department number for all employees in
department 901 to 921.
FILE PERSNL SQL (PERSONNEL) UPDATE
SQL INCLUDE (WORKDEPT) +
FROM PERSONNEL LOCATION *
JOB NAME RETRIEVE-PERSONNEL INPUT PERSNL
SELECT FROM PERSNL WHERE WORKDEPT = 901 FOR UPDATE
WORKDEPT = 921
UPDATE PERSNL
The following example illustrates how to select a specific row from the table, and
then delete it.
FILE PERSNL SQL (PERSONNEL) UPDATE
SQL INCLUDE (EMPNAME, WORKDEPT, EMPPHONE) +
FROM PERSONNEL LOCATION * NULLABLE
PROGRAM NAME RETRIEVE-PERSONNEL
SELECT FROM PERSNL WHERE EMPNAME = 'ROGERS PAT' FOR UPDATE
FETCH FROM PERSNL
IF EOF PERSNL
DISPLAY 'EMPLOYEE NOT FOUND'
ELSE
DELETE FROM PERSNL
END-IF
The following example illustrates how to insert a new row into a table.
FILE PERSNL SQL (PERSONNEL) UPDATE
SQL INCLUDE (EMPNAME, WORKDEPT, EMPPHONE) +
FROM PERSONNEL LOCATION * NULLABLE
PROGRAM NAME RETRIEVE-PERSONNEL
EMPNAME = 'WIMN GLORIA'
WORKDEPT = 921
EMPPHONE = 3478
INSERT INTO PERSNL
Processing Requirements
To process data from an SQL table using this method, you must provide the
following:
■ One or more field definitions for the columns within the table(s) that you
want to retrieve. These definitions can be coded using the DEFINE
statement or by using the SQL INCLUDE statement to automatically
generate the definitions from the SQL catalog. The definitions are usually
coded in working storage, but you can define the fields in an output file for
extraction purposes.
■ A JOB statement with the INPUT SQL parameter. SQL signifies that the
automatic processing does not involve a CA-Easytrieve file.
■ A non-file-based SELECT statement that defines the result set for the cursor.
Only one non-file based SELECT statement can be coded in each JOB
activity.
This SELECT statement is very different from the file-based SELECT
statement used with a CA-Easytrieve SQL file because it more closely
approximates a true SQL SELECT clause. For example, you name the tables
which participate in the result. Also, the SELECT can perform more
advanced selections such as UNIONs.
Operation
The code in the following exhibit retrieves all columns and all rows from the
PERSONNEL table. A report is generated showing WORKDEPT, EMPNAME,
and EMPPHONE. CA-Easytrieve sorts the report by WORKDEPT. Note the use
of manual null variable indicators.
DEFINE EMPNAME W 20 A
DEFINE WORKDEPT W 2 P 0
DEFINE EMPPHONE W 3 P 0
DEFINE NULLPHONE W 2 B 0 .* NULL INDICATOR
JOB INPUT SQL NAME(SQLEX1)
SELECT * FROM PERSONNEL +
INTO :EMPNAME, :WORKDEPT, :EMPPHONE :NULLPHONE
IF NULLPHONE < 0 .* PHONE PRESENT?
EMPPHONE = 0 .* NO, SET TO 0
END-IF
PRINT PERSNL
REPORT PERSNL LINESIZE 65
SEQUENCE WORKDEPT
LINE WORKDEPT EMPNAME EMPPHONE
Selected Columns
The code in the following exhibit retrieves all rows of selected columns from the
PERSONNEL table and generates a report showing WORKDEPT and
EMPNAME. SQL orders the rows by WORKDEPT.
DEFINE EMPNAME W 20 A
DEFINE WORKDEPT W 2 P 0
JOB INPUT SQL NAME(SQLEX2)
SELECT EMPNAME, WORKDEPT +
FROM PERSONNEL +
ORDER BY WORKDEPT +
INTO :EMPNAME, :WORKDEPT
PRINT PERSNL
REPORT PERSNL LINESIZE 65
LINE WORKDEPT EMPNAME
Multiple Tables
The code in the following example retrieves an employee name and the
corresponding department name from the PERSONNEL and DEPARTMENTS
tables. This example shows parameters required for SQL/DS.
PARM USERID('SQLDBA' 'SQLDBAPW') +
PREPNAME(EASYOL 'SQLDBA')
DEFINE EMPNAME W 20 A
DEFINE WORKDEPT W 2 P 0
DEFINE EMPPHONE W 3 P 0
DEFINE DEPTNAME W 22 A VARYING
DEFINE DEPTNUMBER W 2 P 0
DEFINE NULLPHONE W 2 B 0 .* NULL INDICATOR
JOB INPUT SQL NAME(SQLEX3)
SELECT EMPNAME, DEPTNAME +
FROM PERSONNEL, DEPARTMENTS +
WHERE WORKDEPT = DEPTNUMBER +
INTO :EMPNAME, :DEPTNAME
PRINT PERSNL
REPORT PERSNL LINESIZE 65
LINE EMPNAME DEPTNAME
Processing Requirements
■ The SQL DECLARE statement must be coded in the Library Definition
section of a CA-Easytrieve program. All other SQL statements, except SQL
INCLUDE, must be coded in the Activity Definition section.
■ You should test the SQLCODE field in the SQLCA to determine whether or
not the execution of each controlled processing statement is successful.
If the SQLCODE field contains a zero (0), you should test the SQLWARN0
field to ensure that no warning conditions were issued during processing of
the SQL statement. Refer to the appropriate SQL reference manual to
determine acceptable values for SQLWARN0.
■ All SQL INCLUDE statements and SQL-managed file definitions must be
coded prior to any controlled SQL statements.
Operation
Supported Commands
DB2
All DB2 commands that can be executed using the DYNAMIC execution facilities
of DB2 are supported. See the DATABASE 2 SQL Reference (SC26-4380) manual
for more information.
SQL/DS
All SQL/DS commands that are supported through the EXTENDED DYNAMIC
facilities of SQL/DS are supported. See either the SQL/Data System Application
Programming for VSE (SH24-5018) or the SQL/Data System Application
Programming for VM/SP (SH24-5068) for more information.
CA-Datacom/PC
CA-Ingres
All CA-Ingres SQL commands that can be executed using the DYNAMIC
execution facilities are supported. See the CA-Ingres SQL Reference Guide for
information.
ORACLE
All ORACLE SQL commands that can be executed using the DYNAMIC
execution facilities are supported. See the ORACLE SQL Reference Guide for
information.
Note: Due to the ORACLE restriction against using the CURRENT OF clause
with dynamic SQL, CA-Easytrieve must mimic the CURRENT OF clause using
ROWID. This technique prohibits use of SELECT * in conjunction with DELETE
or UPDATE WHERE CURRENT OF cursor.
Note: The SELECT ... INTO ... command (single SELECT) can be simulated
using CA-Easytrieve automatic cursor management.
The following example retrieves all columns from the PERSONNEL table.
PARM USERID('SQLDBA' 'SQLDBAPW') +
PREPNAME(EASYOL 'SQLDBA')
DEFINE EMPNAME W 20 A
DEFINE WORKDEPT W 2 P 0
DEFINE EMPPHONE W 3 P 0
DEFINE DEPTNAME W 22 A VARYING
DEFINE DEPTNUMBER W 2 P 0
DEFINE NULLPHONE W 2 B 0 .* NULL INDICATOR
DEFINE USERID W 8 A VALUE ('SQLDBA')
DEFINE PASSWORD W 8 A VALUE ('SQLDBAPW')
SQL DECLARE CURSOR1 CURSOR FOR +
SELECT * +
FROM PERSONNEL
JOB INPUT NULL NAME(SQLEX4)
SQL CONNECT :USERID IDENTIFIED BY :PASSWORD
PERFORM CHECKSQL
SQL OPEN CURSOR1
PERFORM CHECKSQL
DO WHILE SQLCODE NE 100. * 1403 FOR ORACLE
SQL FETCH CURSOR1 +
INTO :EMPNAME, :WORKDEPT, :EMPPHONE :NULLPHONE
PERFORM CHECKSQL
IF NULLPHONE < 0 . * PHONE PRESENT?
EMPPHONE = 0 . * NO, SET TO 0
END-IF
IF SQLCODE NE 100 . * NOT END OF TABLE
PRINT PERSNL
END-IF
END-DO
SQL CLOSE CURSOR1
PERFORM CHECKSQL
STOP
CHECKSQL. PROC
IF SQLCODE NE 0 AND SQLCODE NE 100. * 1403 FOR ORACLE
DISPLAY 'SQLCODE = ' SQLCODE
STOP EXECUTE
END-IF
END-PROC
REPORT PERSNL LINESIZE 65
LINE EMPNAME WORKDEPT EMPPHONE
Reassign Departments
The next example reassigns all employees in department 901 to department 109
and displays the names of the employees. The PARM statement parameters are
necessary only if you want to access a DB2 or CA-Ingres database subsystem
other than the default.
PARM SSID('DB2B')
DEFINE EMPNAME W 20 A
DEFINE WORKDEPT W 2 P 0
SQL DECLARE CURSOR1 CURSOR FOR +
SELECT EMPNAME +
FROM PERSONNEL +
WHERE WORKDEPT = 901 +
FOR UPDATE OF WORKDEPT
JOB INPUT NULL NAME(SQLEX5)
SQL CONNECT :USERID IDENTIFIED BY :PASSWORD
PERFORM CHECKSQL
SQL OPEN CURSOR1
PERFORM CHECKSQL
The next example illustrates how to update a phone system. In this case all
phone numbers must be changed to 5 digits. The first character must be a 7 and
the rest of the digits remain the same. If an employee does not have a phone
number, his or her record is not updated. No update report is necessary.
JOB INPUT NULL NAME(SQLEX6)
SQL CONNECT :USERID IDENTIFIED BY :PASSWORD
PERFORM CHECKSQL
SQL UPDATE PERSONNEL +
SET EMPPHONE = 70000 + EMPPHONE +
WHERE EMPPHONE IS NOT NULL
PERFORM CHECKSQL
STOP
CHECKSQL. PROC
IF SQLCODE NE 0 AND SQLCODE NE 100. * 1403 FOR ORACLE
DISPLAY 'SQLCODE = ' SQLCODE
STOP EXECUTE
END-IF
END-PROC
Introduction
CA-Easytrieve provides optional processing facilities that interface with
CA-IDMS databases and with the CA-IDMS Integrated Data Dictionary (IDD).
CA-IDMS Interface
With automatic input (also called path processing), you can sweep an entire area
of the database or retrieve records under the control of a tickler file or integrated
indexing.
IDD Interface
The IDD interface automatically generates definitions (taken from the IDD) for
files, records, logical records, element records, and fields. This greatly reduces
the effort often associated with database processing.
CA-IDMS Functionality
Statement(s) Description
IDD statements Retrieve definitions from the Integrated Data
Dictionary
FILE Identify a CA-IDMS database
RECORD Describe database records
LOGICAL-RECORD Describe logical records
ELEMENT-RECORD Describe the database records that are part of a
logical record
RETRIEVE Describe automatic (path) processing for database
records
SELECT Describe automatic (path) processing for logical
records
IDMS statements Provide controlled retrieval and maintenance for
both database and logical records
See the CA-Easytrieve Language Reference Guide for complete syntax for these
statements.
Processing Overview
Automatic Input
-----------
| |
RETRIEVE file-name-1 ... ---------------->| |
| CA-IDMS |
| |
Controlled Processing
-----------
| |
IDMS statement ... ---------------------->| |
| CA-IDMS |
| |
(CA-IDMS controlled record processing) <--| |
... | |
-----------
The mainframe CA-IDMS data area is normally stored as EBCDIC and the
workstation data area is stored in ASCII (there are exceptions). To process data
in a CA-IDMS database, CA-Easytrieve must know the code system of the data.
The code system controls how alphanumeric and zoned-numeric data are
treated. The CODE ASCII parameter of the PARM statement is ignored on the
mainframe, therefore, you can port your programs without changing platforms.
You can either use the CODE parameter of the PARM statement (which becomes
the default for the entire program) or the FILE statement coded for the CA-IDMS
database.
For example:
PARM CODE PROCESS ASCII
Or:
FILE... CODE ASCII
Note: The PROCESS Site Option can be set to define the system-wide processing
code system. See the Execution Options Panel in Chapter 2 of the
CA-Easytrieve/Workstation User Guide for more information.
Note: If you use IDD statements to automatically generate FILE statements, the
CODE parameter is not generated. You should use the PARM statement in this
case.
ASCII files can have fields defined for all standard data types, including
alphanumeric, zoned-numeric, packed decimal, and binary. CA-Easytrieve
stores and accesses data using fields you have defined. It is your responsibility
to define the correct data types. This is critical when accessing data created by or
accessed by other software products.
Zoned-numeric data in ASCII files can have various formats for negative data.
You should use the ASCSIGN Site Option to specify the format when creating
negative data. CA-Easytrieve automatically uses any of the supported formats
for input. See the Execution Options Panel in Chapter 2 of the
CA-Easytrieve/Workstation User Guide for more information.
Computational data (USAGE COMP) can be stored either as binary (B) fields, as
on the mainframe, or as integer fields (I). CA-IDMS files normally use I fields for
computational data. You can define your own I or B fields as needed. When
fields are generated using the IDD interface, CA-Easytrieve uses the IDDCOMP
Site Option to determine which type of field to generate. When IDDCOMP is set
to B, computational fields are generated as mainframe binary (B) type fields.
When IDDCOMP is set to I, computational fields are generated as integer (I) type
fields. See the IDMS Options Panel in the CA-Easytrieve/Workstation User Guide
for more information.
CA-Easytrieve automatically converts binary data to and from integer data for
statements that require binary fields as parameters. Similarly, binary fields in the
CA-IDMS Communications Block (IDMSCOM) are automatically converted as
needed.
CA-IDMS entity names such as records, sets, or areas, that are kept in the
program source are already in ASCII on the workstation. When supplied as
dynamic parameters, CA-Easytrieve converts them to ASCII as needed.
CUSTOMER-ORDER ORDER-OREMARK
NPO MA NP MA LAST
ASC ORD-DATE-PROM
CUSTOMER-SALES DL
NPO MA
ASC SLS-PROD-NUMBER
SALES ORDER-ITEM
-------------- N MA NEXT
640|F|28|VIA
--------------
CUST-SALES
--------------
CUSTOMER-REGION
PRODUCT-SALES
NPO MA
ASC SLS-CUST-NUMBER
PRODUCT ITEM
-------------- --------------
631|F|48|CALC 621|V|3226|VIA
-------------- --------------
PROD-NUMBER|DN ORDER-ITEM
-------------- --------------
PRODUCT-REGION ORDER-REGION
PRODUCT-ITEM
NPO OA
ASC ITEM-LOG-NUMBER DF
Field Definitions
The following field definitions describe the sample database shown in the
previous exhibit. These definitions are established by the database administrator
and stored in a CA-Easytrieve macro.
FILE DBASE IDMS(DEMOSS03)
RECORD CUSTOMER 104 KEY(CUST-NO)
CUST-NO 1 10 A
CUST-NAME 11 20 A
RECORD ORDOR 40
ORD-NO 1 7 A
ORD-CPO# 8 10 A
RECORD OREMARK 72
ORD-SEQ 1 2 A
ORD-TEXT 3 70 A
RECORD SALES 28
SLS-CUST-NO 1 10 A
RECORD PRODUCT 48
PROD-NO 1 8 A
PROD-DESC 9 20 A
RECORD ITEM 3226
ITEM-PROD# 1 8 A
SELECT
MODIFY SALES.
SELECT
STORE SALES.
The CA-Easytrieve field definitions that follow describe the sample logical record
shown above. These definitions are established by the database administrator
and stored in a CA-Easytrieve macro.
*
IDD NAME DBNAME 'TSTDICT'
*
FILE DEMOSSLR IDMS (DEMOSSLR)
LOGICAL-RECORD CUST-SALES-LR
ELEMENT-RECORD CUSTOMER
CUST-NUMBER 1 10 A
CUST-NAME 11 20 A
ELEMENT-RECORD SALES
SLS-CUST-NO 1 10 A
ELEMENT-RECORD PRODUCT
PROD-NUMBER 1 8 A
PROD-DESC 9 20 A
*
JOB INPUT NULL
STOP
IDD Interface
The interface between CA-Easytrieve and the CA-IDMS Integrated Data
Dictionary (IDD) is accomplished by the use of IDD statements. To give you the
fullest control over this access, CA-Easytrieve provides the following IDD
statements:
Statement Description
IDD NAME Control which dictionary is accessed.
IDD VERSION Specify which version of the information is to
be retrieved.
IDD SUBSCHEMA Retrieve definitions of CA-IDMS files
(subschemas).
IDD FILE Retrieve definitions of non-CA-IDMS files.
IDD RECORD Retrieve definitions of records.
See the CA-Easytrieve Language Reference Guide for complete syntax for the above
statements.
Program Name
When the IDD interface creates a definition of a group item and its component
items, it is possible that an ambiguity might occur, making the definition
unusable by your CA-Easytrieve program. This ambiguity is created when a
component of the group item and another item within the same database record
have identical names. The component item name, either alone or with the record
name as a qualifier, is not sufficient to distinguish between the two items. To
resolve this ambiguity, CA-Easytrieve enables you to use the group item’s name
as a qualifier for any item it contains.
Since the group item itself might be part of a larger group item, it is possible for
an item defined with the IDD interface to use many levels of qualification. The
only limit on the number of levels is the number of levels the IDD allows you to
define for the record definition in the dictionary.
Note: On the workstation, the MAXQUAL Site Option controls the maximum
number of levels allowed in CA-Easytrieve. The minimum setting when using
CA-IDMS is 4. However, it is recommended that you set MAXQUAL to a
minimum of 8. If you define a level that exceeds the MAXQUAL setting, you
receive an error. If you set MAXQUAL too high, you use excessive memory. See
the Compiler Options Panel in the CA-Easytrieve/Workstation User Guide for more
information.
As a result, the syntax of a reference to an item defined with the IDD interface is:
[file-name :] [record-name :] [group-item-name : ...] field-name
Examples
Defining a Subschema
PARM DEBUG (DMAP)
*
IDD SUBSCHEMA DEMOSS03 SCHEMA DEMOSCHM
*
JOB INPUT NULL
STOP
IDMS Interface
When using the CA-IDMS interface, you can define subschemas using the
following statements:
Statement Description
FILE Identify the database to be processed.
RECORD Identify the database records available for
automatic or controlled processing.
LOGICAL-RECORD Identify the logical records available for
automatic or controlled processing.
ELEMENT-RECORD Identify the element records that comprise the
logical record.
See the CA-Easytrieve Language Reference Guide for complete syntax for the above
statements.
Communications Block
For those non-CA-IDMS statements that allow record names to be used, a logical
record is treated in exactly the same manner as a database record.
Automatic Input
The RETRIEVE and SELECT statements describe the particular portion of the
database to be retrieved. CA-Easytrieve performs all the calls needed to retrieve
the information described by the automatic input statements. The sequence of
processing for automatic input from a CA-IDMS database is shown in the
following exhibit.
IF first call
IDMS BIND subschema-name from INPUT file +
PROGRAM-NAME parameter from RETRIEVE/SELECT +
DBNAME parameter from RETRIEVE/SELECT +
NODE parameter from RETRIEVE/SELECT +
DICTNAME parameter from RETRIEVE/SELECT +
DICTNODE parameter from RETRIEVE/SELECT
IDMS BIND FILE file-name RECORD record-name (RETRIEVE only)
... (repeated for each record specified)
IDMS READY ALL RETRIEVAL
END-IF
retrieve next set of information
IF no more information
wrap up reports
STOP
END-IF
... (your program processes the information)
GO TO JOB
Sweep of an Area
Sweeping an entire database area for all occurrences of the root record provides
the default input. OBTAIN NEXT RECORD WITHIN AREA calls are issued at
the root level until the database area has been exhausted. If specified, the
INDEX, LIMIT, and WHILE subparameters control the sweep.
Optionally, a file of root record keys can control the extent of the database to be
processed. The keys are obtained one-at-a-time from the tickler file. OBTAIN
CALC calls are issued for each key in the tickler file. Only CALC records can be
the root when the tickler file is used. The record must have the KEY parameter
specified on the RECORD statement.
If another path is defined, denoted by a repeated record name or node, that path
is then processed until end of path. When all paths for the root have been
exhausted, the next root is obtained. Paths can be defined from a member
occurrence to its owner occurrence if owner pointers exist for the set.
Records at each level of the path below the root are retrieved using OBTAIN
NEXT RECORD WITHIN SET if the owner record type is at the higher level. If
the member record type is specified at the higher level, then OBTAIN OWNER
calls are used. The name of the set to be used must be specified with the SET
subparameter of the SELECT parameter entry for the lower level record.
The SELECT statement provides for automatic input of logical records from
CA-IDMS databases. The input is a sequential retrieval of all occurrences of a
specified logical record that satisfy a user-specified WHERE clause. OBTAIN
NEXT RECORD WHERE calls are issued for the logical record until all records
have been retrieved. A logical path is not input if LR-STATUS is LR-ERROR or
LR-NOT-FOUND.
WHERE Clause
See the Programmer’s Reference Guide - COBOL for a description of the syntax of a
Boolean expression.
Examples
This example illustrates path processing. The RETRIEVE statement returns all
data to the program for processing. Information about missing data is also
available.
CUSTOMER SALES
DISPLAY ORD-TEXT
ELSE
DISPLAY SLS-CUST-NO
END-IF
The first customer record in the area is obtained. The first sales record for the
customer is then obtained. If no sales exist, the order path is processed. If a sale
record exists for the customer, the path containing the customer and sales record
is returned to the program. This processing continues until no more sales
records exist for the customer. The order path is then processed.
The first order for the root customer is then obtained, as well as the first remark
for the order. This path is then returned to the program. Next, the second
remark for the first order is obtained and the path is returned. The customer and
order records remain unchanged. Only the remark record is affected. When all
remarks for the first order are returned, the next order for the customer is
obtained with all its remarks. This processing continues until all orders and all
remarks are obtained and returned to the program. The second customer root is
then obtained and processing continues as described above until all customer
records have been processed.
PATH-ID is used to test which path is returned to the program. When PATH-ID
= SA, the customer sales path is available. When PATH-ID = RE, the
customer/order/remark path is available. Paths for customers without sales or
without orders are not processed by this program.
Like the previous example, the program in this example also processes two
paths. The product, sales, customers, and order records are all processed. Then
the first path specifies that the item records for each order are to be returned and
then the remark records for the same order are returned. Each record also has an
ID specified.
In a typical CA-IDMS database path, each record can occur multiple times or
may not occur at all. Occasionally, you might want to determine not only which
path is available but also which records in the path are available. Based on the
previous example, the information in the following table is provided.
The program in this example illustrates path processing using a tickler file to
identify the root records to be processed.
FILE DBASE IDMS(DEMOSS03)
RECORD CUSTOMER 104 KEY(CUST-NO)
CUST-NO 1 10 A
CUST-NAME 11 20 A
FILE KEYS
KEY 1 10 N
JOB INPUT (DBASE) NAME TICKLER-FILE-CONTROL
RETRIEVE DBASE +
KEYFILE KEYS KEYVALUE(CUST-NO = KEY) +
SELECT (CUSTOMER AREA 'CUSTOMER-REGION')
IF PATH-ID EQ 'NF'
DISPLAY 'ROOT RECORD NOT FOUND FOR ' KEY
GO TO JOB
END-IF
DISPLAY CUST-NAME
The program in this example illustrates how to bypass certain paths, specifically
those paths whose lowest record is not present. This example selects only
complete paths for data processing.
FILE DBASE IDMS(DEMOSS03)
RECORD CUSTOMER 104
CUST-NO 1 10 A
CUST-NAME 11 20 A
RECORD ORDOR 40
ORD-NO 1 7 A
ORD-CPO# 8 10 A
RECORD ITEM 3226
ITEM-PROD# 1 8 A
JOB INPUT (DBASE) NAME COMPLETE-PATH-PROCESSING
RETRIEVE DBASE +
SELECT (CUSTOMER AREA 'CUSTOMER-REGION' +
ORDOR SET 'CUSTOMER-ORDER' +
ITEM ID 'IT' SET 'ORDER-ITEM')
IF PATH-ID NE 'IT'
GO TO JOB
END-IF
DISPLAY CUST-NAME ITEM-PROD#
You can use the LIMIT subparameter of the SELECT statement to limit record
occurrence retrieval. This example describes an area sweep where the number of
root records retrieved is limited to five for program testing purposes. When the
limit is reached, input processing is terminated.
FILE DBASE IDMS(DEMOSS03)
RECORD SALES 28
SLS-CUST-NO 1 10 A
JOB INPUT (DBASE) NAME RETRIEVAL-LIMIT
RETRIEVE DBASE +
You can screen any record to establish the acceptability of the record.
CA-Easytrieve bypasses record occurrences that fail the acceptance test for input
consideration. Use the WHILE condition to control record acceptance.
FILE DBASE IDMS(DEMOSS03)
RECORD CUSTOMER 104
CUST-NO 1 10 A
CUST-NAME 11 20 A
JOB INPUT (DBASE) NAME RECORD-PROCESSING
RETRIEVE DBASE +
SELECT (CUSTOMER AREA 'CUSTOMER-REGION' +
WHILE (CUST-NAME EQ 'JONES'))
DISPLAY CUST-NO
Select Statement
Controlled Processing
All valid CA-IDMS functions can be performed using the controlled processing
commands of the IDMS statement. Basically, each of these commands generates
a call to CA-IDMS in much the same manner as a COBOL program. Refer to the
appropriate CA-IDMS DML Reference Guide for details on the use of these
commands. The first parameter of the IDMS statement identifies the command
to be issued. These commands are:
ACCEPT BIND
COMMIT CONNECT
DISCONNECT ERASE
FIND or OBTAIN FINISH
GET IF
KEEP MODIFY
READY RETURN
ROLLBACK STORE
You should test the IDMSSTATUS field in the CA-IDMS Communications Block
to determine whether the execution of each controlled processing statement is
successful.
IDMS Statement
The examples that follow use the CA-IDMS test database supplied with your
CA-IDMS system.
SIGN-ON. PROC
* BIND THE RUN-UNIT
IDMS BIND 'DEMOSS03'
PERFORM STATUS-CHECK
* ASSIGN RECORD WORK AREA
IDMS BIND, FILE DBASE, RECORD CUSTOMER
PERFORM STATUS-CHECK
* READY THE AREA
IDMS READY, AREA 'CUSTOMER-REGION'
PERFORM STATUS-CHECK
END-PROC
*
STATUS-CHECK. PROC
* IF STATUS NOT OK, TERMINATE PROCESSING
IF IDMSSTATUS NE '0000'
DISPLAY NEWPAGE, 'IDMS STATUS IS ', IDMSSTATUS
IDMS FINISH
END-IF
END-PROC
*
SIGN-OFF. PROC
* SIGN-OFF THE DATA BASE
IDMS FINISH
END-PROC
*
REPORT CALC-RPT LINESIZE(72)
TITLE 'RECORD RETRIEVAL BY CALC KEY'
LINE CUST-NO CUST-NAME
*
Introduction
The IMS/DL/I interface provides complete facilities for information retrieval
and maintenance of IMS/DL/I databases. To use this interface efficiently, you
should have a basic knowledge of IMS/DL/I and of the database(s) to be
processed. Preparatory work by the database administrator significantly reduces
the effort of writing programs that process databases.
The database administrator should place the data definition statements necessary
to process each database into the CA-Easytrieve macro library. Control of these
segment and field definition statements can greatly reduce the number of simple
programming errors associated with database processing.
This chapter also discusses how automatic input uses the RETRIEVE statement
in one of three ways:
■ Sweep of a database
■ Tickler file control
■ Input definition (paths).
Test Database
The source statement samples that follow show database definition statements
(DBD) and program specification block (PSB) statements that describe the
database referenced throughout this chapter. The database is a portion of the
PARTS test database provided by IBM with the IMS system. Detailed
information about the database can be found in the IBM publication IMS/VS
Installation Guide. The test database for DLI DOS/VS is described in the IBM
publication Guide for New Users. This chapter uses only the OS/IMS test
database that is shown in the Test Database Structure diagram.
PSB Specification
In CICS, a PSB must be explicitly scheduled by your program before any DLI file
can be accessed. The DLI PCB statement must be used to schedule a PSB. See
the CA-Easytrieve Language Reference Guide for a complete description of the DLI
statement. Also see the CICS Application Programmer’s Reference Manual for
information about PSB scheduling and terminating. After a DLI PCB statement
is executed, all DLI files in the CA-Easytrieve program are accessible. The DLI
PCB statement must be executed even when automatic input (the RETRIEVE
statement) is being used to read the database. Because the PSB can only be
scheduled one time, the DLI PCB statement should be placed in a JOB START
proc, or some other one-time only code. When all DLI processing is finished, the
DLI TERM statement should be used to terminate the PSB. If this is not done, the
PSB remains scheduled until task termination. In non-CICS environments, the
DLI PCB and DLI TERM statements have no effect.
Status Information
After each DLI operation, the PCB Status Code field is placed in the
CA-Easytrieve system-defined field, FILE-STATUS. See the IBM DLI
Programmer’s Reference Manual for the definition of the status code values.
Automatic Input
Automatic input is a facility whereby CA-Easytrieve retrieves records from the
database and makes them available to the program. See Controlled vs.
Automatic Processing in the “File Processing” chapter for a description of
automatic input as it applies to conventional files. To indicate that automatic
input is to occur for the IMS/DLI database, you must do the following:
1. Code the INPUT parameter on the JOB statement for each activity that will
require automatic input from the database. The INPUT parameter must
specify the filename from the FILE statement that defines the IMS/DLI file.
This must be the only filename specified. CA-Easytrieve does not support
synchronized file processing for IMS/DLI database files.
2. Code a RETRIEVE statement following the JOB statement. Only one
RETRIEVE statement must be coded.
Sweep of Database
Sweeping the entire database provides the default input. A get next (GN) call is
issued at the root level until the database has been exhausted. LIMIT, SSA, or
WHILE parameters, if specified, control the sweep.
Optionally, a file of root segment keys can control the extent of the database to be
processed. Root segment keys are obtained one-at-a-time from the tickler file.
Get unique (GU) calls are issued for each key on the tickler file. The KEY
parameter must be specified on the RECORD statement for the root segments
retrieved by the tickler file option.
PARTROOT
(02N51P3003F0)
(AC)
STANINFO STOKSTAT
(0025906026)
(CE) (CF)
CYCCOUNT BACKORDR
(20) (30)
CYCCOUNT
(21)
CA-Easytrieve exhausts each path before proceeding to the next path. When it
exhausts the last path, it retrieves the next root and processing begins anew with
the leftmost path.
The following series of path processing examples illustrates the functions of the
various statements and parameters associated with automatic database input.
The examples are based upon the Test Database Structure depicted earlier in this
chapter. Each example also relies upon the data definition indicated below:
FILE DLIFILE DLI(DI21PART 1)
DBD-NAME 1 8 A
SEG-LEVEL 9 2 A
STATUS-CODE 11 2 A
PROC-OPTIONS 13 4 A
RESERVE-DL1 17 4 B
SEG-NAME-FB 21 8 A
LENGTH-FB-KEY 29 4 B
NUMB-SENS-SEGS 33 4 B
KEY-FB-AREA 37 43 A
*
RECORD PARTROOT 50 KEY(PARTKEY 1 17)
PARTKEY 1 17 A
PART-NUMBER 1 17 A
PART-DESC 27 24 A
*
RECORD STANINFO 85 PARTROOT KEY(STANKEY 1 2)
STANKEY 1 2 A
STAN-MAKE-DEPT 48 6 A
STAN-MAKE-TIME 62 3 A
*
RECORD STOKSTAT 160 PARTROOT KEY(STOCKEY 1 16)
STOKKEY 1 16 A
STOK-ON-ORDER 106 8 N
STOK-IN-STOCK 114 8 N
*
RECORD CYCCOUNT 25 STOKSTAT
CYCLKEY 1 2 A
*
RECORD BACKORDR 75 STOKSTAT
BACKKEY 1 2 A
BACK-Q1 11 13 A
This example illustrates path processing using a tickler file to identify the root
segments to be processed.
FILE DLIFILE DLI (DI21PART 1)
RECORD PARTROOT 50 KEY(PARTKEY 1 17)
PARTKEY 1 17 A
PART-NUMBER 1 17 A
PART-DESC 27 24 A
FILE KEYS
KEY 1 17 A
JOB INPUT (DLIFILE) NAME MYPROG
RETRIEVE DLIFILE +
KEYFILE KEYS, +
KEYVALUE KEY, +
SELECT PARTROOT
IF PATH-ID EQ 'NF'
DISPLAY 'ROOT NOT FOUND FOR ' KEY
ELSE
DISPLAY PART-NUMBER PART-DESC
END-IF
Root-only Processing
...
RETRIEVE DLIFILE ... +
SELECT (PARTROOT)
...
...
In a typical IMS/DLI database path, each segment can occur multiple times, or it
may not occur at all. It is often desirable to be able to determine not only which
path is available, but also which segments in the path are available. Based upon
the previous Two Path, One Parent Example, the following information is
provided:
Consider the following example in which we want to process data only from a
complete path. That is, when the lowest segment in the path is not present, we
want to bypass processing the path altogether.
FILE DLIFILE DLI (DI21PART 1)
RECORD PARTROOT 50 KEY(PARTKEY 1 17)
PARTKEY 1 17 A
PART-NUMBER 1 17 A
PART-DESC 27 24 A
RECORD STOKSTAT 160 PARTROOT KEY(STOKKEY 1 16)
STOKKEY 1 17 A
STOK-ON-ORDER 1 17 A
STOK-IN-STOK 27 24 A
RECORD BACKORDR 75 STOKSTAT
BACKKEY 1 2 A
BACK-Q1 11 13 A
JOB INPUT (DLIFILE) NAME MYPROG START INITPSB FINISH TERMPSB
RETRIEVE DLIFILE +
SELECT (PARTROOT +
STOKSTAT +
BACKORDR ID 'CF')
IF PATH-ID NE 'CF'
GO TO JOB
END-IF
DISPLAY PART-NUMBER PART-DESC BACK-Q1
INITPSB. PROC
DLI PCB 'EZTPPSBA'
END-PROC.
TERMPSB. PROC
DLI TERM
END-PROC
Note: The DLI PCB and DLI TERM statements are required only in CICS
environments. They are ignored in non-CICS environments.
You can use the LIMIT subparameter of SELECT to limit segment occurrence
retrieval. The following exhibit describes an area sweep where the number of
root segments retrieved is limited to five for program testing purposes. When
the limit is reached, input processing is terminated.
FILE DLIFILE DLI (DI21PART 1)
RECORD PARTROOT 50 KEY(PARTKEY 1 17)
PARTKEY 1 17 A
PART-NUMBER 1 17 A
PART-DESC 27 24 A
JOB INPUT (DLIFILE) NAME MYPROG
RETRIEVE DLIFILE +
SELECT (PARTROOT LIMIT 5)
DISPLAY PART-NUMBER PART-DESC
You can qualify root segments for retrieval by using the SSA subparameter of
SELECT. The value supplied with SSA is enclosed within parentheses and
concatenated with the segment-name to produce the root segment’s SSA. The
following example illustrates the control of input through root segment
qualification. Processing terminates when IMS/DLI returns a status-code
indicating that the qualification cannot be satisfied.
FILE DLIFILE DLI (DI21PART 1)
RECORD PARTROOT 50 KEY(PARTKEY 1 17)
PARTKEY 1 17 A
PART-NUMBER 1 17 A
PART-DESC 27 24 A
JOB INPUT (DLIFILE) NAME MYPROG
RETRIEVE DLIFILE +
SELECT (PARTROOT SSA 'PARTKEY = 02N51P3003F000 ')
DISPLAY PARTKEY PART-NUMBER PART-DESC
You can pre-screen any segment to establish the acceptability of the segment.
CA-Easytrieve bypasses segment occurrences that fail the acceptance test for
input consideration. Use the WHILE condition when the Boolean logic of
IMS/DLI is inadequate for root SSA qualification or for segment qualification
below the root level. The following example demonstrates a segment pre-screen
which is unavailable through normal IMS/DLI interfaces.
FILE DLIFILE DLI (DI21PART 1)
RECORD PARTROOT 50 KEY(PARTKEY 1 17)
PARTKEY 1 17 A
PART-NUMBER 1 17 A
PART-DESC 27 24 A
JOB INPUT (DLIFILE) NAME MYPROG
RETRIEVE DLIFILE +
SELECT (PARTROOT WHILE (PART-DESC ALPHABETIC))
DISPLAY PART-NUMBER +3 PART-DESC
Controlled Processing
You perform IMS/DLI functions using the DLI statement. This statement
generates a call to IMS/DLI which is identical to that generated by other
programming languages. It is essential that you test the status-code returned in
the PCB to determine the success of each DLI statement. These return codes are
described in the IMS/DLI Applications Programming Manual. The following
discussions illustrate typical use of DLI statements.
You must exercise caution when using the DLI statement in conjunction with
RETRIEVE. You should save and restore database positioning to ensure the
correct continuation of automatic input. Otherwise, input data can be lost or
repeated.
In all the following examples, if the execution environment is CICS, the PSB must
be scheduled using the DLI PCB statement before the database is accessed using
the DLI or RETRIEVE statement. If the execution environment is not CICS, the
DLI PCB and DLI TERM statements have no effect.
FILE DLIFILE DLI (DI21PART 1)
RECORD PARTROOT 50 KEY(PARTKEY 1 17)
PARTKEY 1 17 A
PART-NUMBER 1 17 A
PART-DESC 27 24 A
RECORD STOKSTAT 160 PARTROOT KEY(STOKKEY 1 16)
STOKKEY 1 17 A
STOK-ON-ORDER 1 17 A
STOK-IN-STOK 27 24 A
RECORD BACKORDR 75 STOKSTAT
BACKKEY 1 2 A
BACK-Q1 11 13 A
JOB INPUT (DLIFILE) NAME MYPROG START INITPSB
RETRIEVE DLIFILE +
SELECT (PARTROOT +
STOKSTAT +
BACKORDR ID 'CF')
IF PATH-ID NE 'CF'
GO TO JOB
END-IF
DISPLAY PART-NUMBER BACK-Q1
INITPSB. PROC
DLI PCB 'EZTPPSBA'
END-PROC
JOB INPUT (DLIFILE) START BEGIN NAME MYPROG2 FINISH TERMPSB
RETRIEVE DLIFILE +
SELECT (PARTROOT STOKSTAT ID 'SS')
IF PATH-ID EQ 'SS'
DISPLAY STOK-ON-ORDER
END-IF
*
BEGIN. PROC
DLI DLIFILE PARTROOT 'GU ' +
SSA 'PARTROOT(PARTKEY =>99999999999999999)'
DLI DLIFILE PARTROOT 'GN'
END-PROC
TERMPSB. PROC
DLI TERM
END-PROC.
The following example illustrates the DLI statements necessary to produce the
same input data as is produced by the automatic input of the Complete Path
Processing discussion earlier in this chapter.
SSA-PART W 37 A VALUE 'PARTROOT(PARTKEY = XXXXXXXXXXXXXXXXX)'
SSA-PART-DATA SSA-PART +19 17 A
SSA-STOK W 36 A VALUE 'STOKSTAT(STOCKEY = XXXXXXXXXXXXXXXX)'
SSA-STOK-DATA SSA-STOK +19 16 A
...
JOB INPUT (NULL)
Database Maintenance
You can perform complete database maintenance using the DLI statement. One
of the programming techniques used in association with database maintenance is
usually the dynamic construction and use of SSAs. The following exhibit
(Creation of IMS/DLI Calls) depicts some of the basic programming necessary to
dynamically create IMS/DLI calls. The next exhibit (Basic Database Maintenance
Activity) shows basic activities that do not require the sophistication of dynamic
call generation.
SSA (SSA-ROOT, +
SSA-LVL2, +
...)
END-PROC
TEST-STATUS. PROC
IF FILE-STATUS ...
...
END-IF
END-PROC.
...
...
Report Processing
7
Overview
A major function of many CA-Easytrieve programs is to produce printed reports.
The non-procedural nature of CA-Easytrieve report syntax is readily adaptable
to the production of basic and extremely complex reports, both with minimum
programming effort. Two statements generate printed output:
■ The PRINT statement initiates the basic declarative report facility.
■ The DISPLAY statement produces single print lines on print files.
PRINT is the preferred method because of its many automatic facilities. This
chapter primarily discusses report processing using the PRINT statement. Using
the DISPLAY statement to mix single print lines within a report is discussed with
report procedures.
The CA-Easytrieve report facility is basically declarative; you need only define
the format and content of the report and CA-Easytrieve creates the necessary
instructions to produce the report. The following exhibit illustrates the basic
structure of a CA-Easytrieve job with report processing. You can define one or
more reports for each activity.
Note: You can use the CA-Easytrieve/Online Report Painter to automate the
coding of a report declaration. See the CA-Easytrieve/Online User Guide for more
information.
The PRINT statement activates the report logic defined by REPORT declarations.
CA-Easytrieve extracts the data required for the requested report, formats it in
the specified manner, and sends it to the printer. The immediate result of a
PRINT statement is either of the following:
■ Data output to a print file
■ Data output to a work (or spool) file.
Note: Output to a printer can be sent to a terminal for display (except in UNIX).
See Routing Printer Output later in this chapter, for more information.
Each work file record contains all of the data required to produce the report. The
PRINT statements generate the work file when it is necessary. The order of
occurrence of work file fields is the same as the field’s reference occurrence in the
REPORT statements. In the next exhibit, the underlined fields determine work
file record contents:
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
JOB INPUT FILE1 NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 65 +
DTLCTL EVERY
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE ZIP
LINE 01 LAST-NAME STATE ZIP PAY-NET
By default, work files are written to the CA-Easytrieve system work file, xxxVFM
(where xxx is the value of WKDSNPF in the options table). The algorithm for
naming work files is xxxRnnn, where xxx is the value of the WKDSNPF option
and nnn is the sequential number of the report within the JOB activity. A typical
work file name for the first work file in a JOB is EZTR001.
You can save the work file contents for future processing by coding the FILE
parameter on the REPORT statement. The corresponding FILE statement, coded
in the library, must identify a sequential file. You must also specify that the
work file’s record length is at least as long as the dynamically created work file
record. Records should be blocked to a reasonable value to ensure efficient
processing. This technique can also be used to offload the amount of Virtual File
Manager (VFM) space required by the program to another file.
Large Reports
If you have multiple large reports in a program, you can code the WORKFILE
YES parameter on the PARM statement. This allows you to use a report work
file without coding a FILE statement and a FILE parameter on the REPORT
statement for every report in your program. You must also add a DD statement
for each report to your JCL.
The DDname must conform to the format xxxRnnn, where xxx is the WKDSNPF
option in your site option table (EZT is the default) and nnn is the report number.
For example, the first report in your program would use the DD EZTR001.
It is also recommended that a large blocksize be coded in the JCL. The default
DCB for the work file is FB with record and block lengths set to the minimum
needed for the report. You can use the PARM WORKFILE BLOCKMAX
parameter to automatically set the blocksize for you. See PARM Statement in the
CA-Easytrieve Language Reference Guide for more information.
Note: Use VFM for small reports and all reports executing in CICS.
The normal termination process of each JOB activity, illustrated in the following
exhibit, includes the processing of any print work files created during the JOB
activity. If the JOB activity abends or terminates due to a STOP EXECUTE
statement, the print work files are not processed.
Report Formats
Standard Format
Top Margin
The top margin is the space between the physical top of the form and the point to
which the printer positions when a top-of-form order is issued to the printer.
The size of the top margin is controlled by the printer carriage tape or forms
control buffer.
Title Area
The optional title area consists of 1 to 99 title lines plus a title margin between the
last title line and the first heading line.
Heading Area
The optional heading area consists of 1 to 99 heading lines plus a heading margin
between the last heading line and the report body.
Report Body
The report body consists of one or more occurrences of a line group. Each
occurrence of a line group is 1 to 99 lines plus, optionally, one or more blank
lines between occurrences.
Bottom Margin
The bottom margin is the area remaining between the bottom of the report body
and the physical bottom of the page.
Label Format
The second report format is used to print labels. The following exhibit illustrates
the basic label report page format:
A label line consists of one or more labels positioned across the label page. In the
above exhibit, labels one through four compose a label line. A single line group
composes each label. CA-Easytrieve produces a label for each PRINT statement
execution. CA-Easytrieve formats the labels on the page in the order as
numbered above. DOWN and SIZE indicate the dimensions of each label.
REPORT Statement
The REPORT statement and its parameters define the physical attributes of your
report. Code the following statements to define the content of your report:
■ SEQUENCE - optionally specifies the order of the report based on the
content of one or more fields.
■ CONTROL - identifies control fields used for a control report. A control
break occurs whenever the value of any control field changes or
end-of-report occurs.
■ SUM - specifies the quantitative fields which are totaled for a control report.
■ TITLE - defines optional report title items and their position on the title line.
■ HEADING - optionally defines an alternate heading for a field.
System-Defined Fields
CA-Easytrieve automatically provides the special data fields listed below for
your reports. These fields are stored as part of working storage and are
read-only.
LINE-COUNT
LINE-COUNT is a field that contains the number of lines printed on the page.
LINE-NUMBER
LINE-NUMBER is a field that contains the number of the line being printed
within the line group. See Standard Reports for details of line-groups.
PAGE-COUNT
PAGE-NUMBER
PAGE-NUMBER is a field that contains the number of the page being printed.
TALLY
TALLY is a field that contains the number of detail records in a control break.
See Control Reports later in this chapter for more information.
LEVEL
LEVEL indicates the control break level. See Control Reports later in this chapter
for more information.
BREAK-LEVEL
BREAK-LEVEL indicates the highest field in the break. See Control Reports later
in this chapter for more information.
Standard Reports
The report facility in CA-Easytrieve includes all of the functions necessary to
produce most reports very easily. Using CA-Easytrieve report options, you can
produce a report in almost any format. Most reports, however, are variations of
a CA-Easytrieve standard report.
Titles
The title is the first item printed on each report page. You can specify the report
title with up to 99 TITLE statements. The following exhibit illustrates the title
area of a report.
Results:
IN DEPARTMENT 903
Overriding Defaults
You can override the automatic (default) functions associated with title contents
and spacing to produce any desired report title. This may be necessary to
produce reports that use pre-printed forms as the output medium. You can use
the following parameters to produce non-standard title content and spacing:
■ NOADJUST - causes each title line to be left-justified on the page.
NOADJUST may cause line items to overlay the tags printed for SUMCTL
TAG. COL positioning is necessary for tag to appear.
■ NODATE and NOPAGE - inhibit current date and page count information
from being placed on the first title line.
■ COL - Use the COL positioning parameter to position items in specific print
columns. COL can be used with ADJUST or NODADJUST.
Note: The date overlays the left-most positions of TITLE 1 when NOADJUST is
specified. Either use NODATE or reserve an area for SYSDATE by specifying
COL 10 for SHORTDATE or COL 12 for LONGDATE before the first item on the
TITLE statement.
Examples
The following examples of title statements use title content and space adjustment
parameters. The report title that results from the statements is also illustrated.
Statements:
Results:
column column
0 2
1 0
025-30-5228
11/19/86 WIMN GLORIA
430 M ST SW 107
BOSTON , MA 02005
Headings
A report heading is normally printed for line items specified on LINE 01. Each
heading is centered over its associated line item. The following rules control the
heading; the order in which they are listed indicates the hierarchy of override:
1. The NOHEADING parameter of the REPORT statement inhibits the printing
of any headings.
2. The HEADING statement sets the item heading content.
3. The HEADING parameter of the DEFINE statement sets the item heading
content.
4. Field-name of the DEFINE statement sets the item heading content.
5. Line items which are literals do not have headings.
6. Only LINE 01 items have headings.
Results:
SOCIAL
SECURITY NET
NAME NUMBER PAY
WIMN GLORIA 025-30-5228 * NO OVERTIME * 251.65
BERG NANCY 121-16-6413 * NO OVERTIME * 547.88
Line Group
Lines compose the body of a report. The lines of a report are output in groups
for each PRINT statement issued. All of the LINE statements of the report make
up a line group, which is also called a logical report line.
LINE ... }
LINE 02 ...} line or logical report
LINE 03 ...} group line
...
1 5 10 15 1 5 10 1 4
............... ........... ....
SOCIAL
SECURITY SEX heading
EMPLOYEE NAME NUMBER CODE
Special Positioning
The next exhibit illustrates poor and good decimal alignment. The first
occurrence of FLD2 on LINE 02 is not decimal-aligned with FLD1 on LINE 01.
To align the second occurrence correctly, an additional offset of 3 spaces (+3) is
specified.
Statements:
Results:
poor good
column column
1 5 10 15 1 5 10 15
............... ...............
FLD1 FLD1
123.45 123.45 line 01
678.90 678.90 line 02
SPREAD Parameter
The SPREAD parameter of the REPORT statement offers a unique way to space
line items. When you use reports as work sheets, it is often desirable to space
line items as far apart as possible. SPREAD overrides the SPACE parameter of
the REPORT statement and creates report lines with the maximum number of
spaces between each item, as this exhibit illustrates.
Statements:
Produce:
..................................................................
11/19/86 NOSPREAD EXAMPLE PAGE 1
Label Reports
You can use the label report capability of CA-Easytrieve to print mailing labels
and other applications that require inserting variable data in a repetitious format.
A label report is different from a standard report in the following ways:
■ Label reports do not have titles and headings.
■ Multiple labels can be printed side-by-side.
■ Controlled label reports allow for control breaks, but do not automatically
total quantitative fields. Totals, however, can be specified on a SUM
statement and processed in BEFORE-BREAK and AFTER-BREAK
procedures.
You can use the label report function whenever a complete logical print page is
to be produced by each PRINT statement. Consider the W-2 form printing
example; print time could be substantially reduced by having 2-up forms. You
can then modify report declaration statements as shown in the following code. A
sample result follows the code.
REPORT LBLS LABELS (ACROSS 2 DOWN 15 SIZE 65 NEWPAGE) SPACE 1
LINE 01 COL 7 'YOUR COMPANY NAME' COL 33 '903' +
COL 39 '12-3456789'
LINE 02 COL 7 'YOUR COMPANY STREET'
LINE 03 COL 7 'YOUR COMPANY CITY STATE ZIP'
LINE 10 COL 7 SSN COL 23 YTD-FEDTAX +
COL 39 YTD-WAGES +
COL 54 YTD-FICA
LINE 12 COL 7 EMP-NAME COL 39 YTD-WAGES
LINE 14 COL 7 EMP-STREET
LINE 15 COL 7 EMP-CITY EMP-STATE EMP-ZIP
CONTROL Statement
You can use the CONTROL statement with label reports to truncate a group of
labels. Truncating makes it easy to separate labels after they are printed. The
following exhibit demonstrates how a new label page starts when the control
field changes.
Statements:
Results:
xxx
xxx
xxx
yyy yyy
...
Any labels remaining on a line are left unused. The optional NEWPAGE
parameter causes a top-of-page for the next print line.
Sequenced Reports
Report sequence is controlled either by the order in which PRINT statements
were issued or by the SEQUENCE statement. You can print both standard
reports and label reports in any sequence.
Report definitions that contain SEQUENCE statements cause the report data to
be spooled to a temporary work file upon execution of a PRINT statement. Work
file usage is transparent.
Only those data items used in the report are sorted. The sorted output is directly
printed from the sort. These attributes combine to make the SEQUENCE facility
of CA-Easytrieve extremely efficient.
CONTROL Reports
The CONTROL statement specifies that a report automatically accumulates and
prints totals of quantitative report information. The report accumulates
information according to the hierarchy indicated on the CONTROL statement.
Terminology
The following terms are used throughout the discussion on control reports:
■ A control field is any field named on a CONTROL statement to establish the
hierarchy of a control report.
■ A control break occurs whenever any field of the control hierarchy changes
value.
■ A total line is a logical line group in a report body which contains control
totals. These control totals can contain subtotal or final values. Total lines
are normally annotated with the value of control fields according to the
SUMCTL parameter of the REPORT statement. This is done by listing the
control fields first on the LINE statement.
■ A detail line is the same line data as in a standard report body line (not a
total line). Control fields on detail lines are printed according to the DTLCTL
parameter of the REPORT statement. The SUMMARY parameter of the
REPORT statement inhibits the printing of detail lines on a control report.
■ Accumulators are system-created fields which contain totals. Accumulators
are created for:
– All fields designated on the SUM statement
– All active file or W storage quantitative fields designated on the line group (LINE
nn) statements, if a SUM statement is not specified. (Quantitative fields are
numeric fields with a decimal point designation of 0 through 18.)
■ SUMFILE data are the contents of control fields and accumulators at each
minor control break.
Data Reference
In general, report statements and procedures can reference any field of an active
file or working storage. (Some report procedures have minor restrictions which
are described with the associated procedure.)
Statements and procedures can directly reference data for detail lines in
non-control reports. When control or total fields are referenced, CA-Easytrieve
automatically adjusts so that SUMFILE data is used. This assures access to the
field actually used in the report. SUMFILE data includes all control fields and
ten-byte (18 digit) packed fields for all accumulators. (See Summary File later in
this chapter.)
TALLY
TALLY is a system-defined field for control reports. TALLY contains the number
of detail records that comprise a control break. You can use TALLY on a LINE
statement or you can use it in calculations within report procedures. TALLY is
commonly used to determine averages for a control break.
TALLY is a ten-byte packed decimal field with zero decimal places. This
definition is used for calculations contained within report procedures. REPORT
TALLYSIZE defines the number of digits which are printed for TALLY. A
TALLY accumulator is created for each control break level.
LEVEL
The LEVEL values for fields on the CONTROL statement are illustrated below:
REPORT
SEQUENCE REGION BRANCH
CONTROL REGION BRANCH
LEVEL = 1
LEVEL = 2
LEVEL = 3 (FINAL)
SUMFILE data
TALLY ... 2
...
TALLY ... n
SUM SUM
FINAL TALLY field-1 ... field-n n + 1
BREAK-LEVEL
In the above example, LEVEL and BREAK-LEVEL fields are used to determine
the appropriate message to be displayed before the summary lines are printed.
Testing for LEVEL 1 tells us that CA-Easytrieve is going to print the first
summary line next (BRANCH totals). When BREAK-LEVEL is 1, only the
BRANCH field is breaking. Therefore, we want to display a message stating this.
When BREAK-LEVEL is 2, the REGION field is breaking. This causes both
BRANCH and REGION summary lines to print. When BREAK-LEVEL is 3,
CA-Easytrieve prints BRANCH, REGION, and final summary lines.
The report body contains the only difference between standard and control
report contents. Control reports print total lines in addition to detail lines
(optional). The following examples use two control fields (STATE and ZIP)
which contain data that is two and five bytes long, respectively, and one
quantitative field (PAY-NET) which contains numeric data.
The standard control report contains standard report data plus total data. The
following example illustrates the report body of such a report. Detail and total
lines are shown, with the totals illustrating the hierarchy of the report data.
Statements:
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
JOB INPUT FILE1 NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 65
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE ZIP
LINE 01 LAST-NAME STATE ZIP PAY-NET
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Results:
Line
Description Control Fields Accumulator
The same report without the detail lines is a SUMMARY report. For example:
Statements:
FILE FILE1
LAST-NAME 1 20 A
STATE 21 2 A
ZIP 23 5 N
PAY-NET 28 5 N 2
JOB INPUT FILE1 NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 65 SUMMARY +
DTLCTL NONE
SEQUENCE STATE ZIP
CONTROL STATE ZIP
LINE 01 STATE ZIP PAY-NET
Data:
BROWN IL6007612345
BROWN IL6007667890
JONES IL6007709876
JONES IL6007754321
SMITH TX7521811111
SMITH TX7521866666
Results:
Line
Description Control Fields Accumulator
This report contains only control totals because SUMMARY was specified on the
REPORT statement.
DTLCTL
The REPORT statement DTLCTL parameter establishes the method for printing
control field values on detail lines by using the subparameters EVERY, FIRST,
and NONE. The following is an example program using DTLCTL options:
Statements:
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
JOB INPUT FILE1 NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 65 +
DTLCTL option (* with option being EVERY, FIRST, or NONE *)
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE ZIP
LINE 01 LAST-NAME STATE ZIP PAY-NET
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
The next three exhibits show the results of using each of the DTLCTL options:
EVERY -- prints all control fields on every detail line.
Line
Description Control Fields Accumulator
Line
Description Control Fields Accumulator
Line
Description Control Fields Accumulator
LAST-NAME STATE ZIP PAY-NET
SUMCTL
The SUMCTL parameter of the REPORT statement establishes the method for
printing control field values on total lines of a control report by using the
subparameters ALL, HIAR, NONE, and TAG. (The DTLCOPY subparameter
controls all non-control non-total values on total lines.) The following shows an
example program using these parameters:
Statements:
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
JOB INPUT FILE1 NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 65 +
SUMCTL option
(* with option being ALL, HIAR, NONE, or TAG *)
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE ZIP
LINE 01 LAST-NAME STATE ZIP PAY-NET
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
The next three examples illustrate the results of using All, HIAR, and NONE.
Line
Description Control Fields Accumulator
Line
Description Control Fields Accumulator
TAG
Use the TAG subparameter of SUMCTL to annotate the total line with a
description of the total values being printed. The TAG subparameter of
SUMCTL creates a line area on the left side of the total line. This LINE 01 item is
governed by the following rules:
■ The length of the area is the length of the longest control-field-name plus
seven.
■ TOTAL preceded by the control field name is the annotation for control
break totals.
■ FINAL TOTAL is the annotation for the final totals line.
■ The line item area is positioned at the left margin of the report.
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
JOB INPUT FILE1 NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 65 +
SUMCTL TAG
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE ZIP
LINE 01 LAST-NAME STATE ZIP PAY-NET
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Results:
DTLCOPY
When printing control reports (particularly a summary report) you may want to
include detail information in total lines (normally, CA-Easytrieve prints only
control field values and associated totals on total lines). The DTLCOPY
subparameter of SUMCTL causes detail field contents (values just prior to the
break) to be printed on total lines for LEVEL 1 breaks. The following exhibit
illustrates the use of DTLCOPY to print the contents of the LAST-NAME detail
field on the lowest level total line (ZIP).
Statements:
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
JOB INPUT FILE1 NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 65 +
SUMMARY SUMCTL DTLCOPY
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE ZIP
LINE 01 LAST-NAME STATE ZIP PAY-NET
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Results:
LAST-NAME STATE ZIP PAY-NET
IL 1444.32
SMITH TX 75218 777.77
TX 777.77
2222.09
DTLCOPYALL
DTLCOPYALL has the same effect as DTLCOPY except that the detail fields are
printed for all control break totals. The following exhibit illustrates the use of
DTLCOPYALL to print LAST-NAME on all total lines.
Statements:
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
JOB INPUT FILE1 NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 65 +
SUMMARY SUMCTL DTLCOPYALL
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE ZIP
LINE 01 LAST-NAME STATE ZIP PAY-NET
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Results:
LAST-NAME STATE ZIP PAY-NET
BROWN IL 60076 802.35
JONES IL 60077 641.35
JONES IL 1444.32
SMITH TX 75218 777.77
SMITH TX 777.77
SMITH TX 2222.09
Occasionally, you may want to print control field values in report titles. For
example, you can use control field annotation within the title of a report to
emphasize the structure of an organization, particularly at its higher levels. This
technique uses only basic report facilities, and does not require special
parameters. The following example shows field annotation within a report title.
Statements:
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Results:
11/23/86 REPORT FOR THE STATE OF IL PAGE 1
In control reports, line items for totaled fields define an area not only for detail
lines, but also for corresponding total lines. Since totals are normally larger than
the detail, you need a means of expanding the item area. Without this expansion,
the item area might be too small to contain the totals. If your report contains this
overflow condition, CA-Easytrieve automatically depicts it by setting the
right-most character of the item area byte to an * (asterisk), as the following
example illustrates:
Statements:
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
*
JOB INPUT FILE1 NAME MYPROG
*
PRINT REPORT1
*
REPORT REPORT1 SUMSPACE 0 +
SUMCTL HIAR LINESIZE 65
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE NEWPAGE ZIP
TITLE 'REPORT FOR THE STATE OF' STATE
LINE 01 LAST-NAME STATE ZIP PAY-NET
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Results:
222.09*
Controlling Overflow
You can control overflow using two methods, as illustrated by the following
examples:
1. Line Item Expansion - Ensure that the detail field being totaled is large enough
to absorb the totals. The example below illustrates how overflow can be
prevented by effectively expanding the line item to six-digit positions.
Statements:
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
T-PAY-NET W 6 N 2 HEADING ('PAY-NET')
*
JOB INPUT FILE1 NAME MYPROG
T-PAY-NET = PAY-NET
PRINT REPORT1
*
REPORT REPORT1 SUMSPACE 0 +
SUMCTL HIAR LINESIZE 65
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE NEWPAGE ZIP
TITLE 'REPORT FOR THE STATE OF' STATE
LINE 01 LAST-NAME STATE ZIP T-PAY-NET
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Results:
2/11/87 REPORT FOR THE STATE OF IL PAGE 1
LAST-NAME STATE ZIP PAY-NET
BROWN IL 60076 678.90
BROWN 123.45
IL 60076 802.35
2,222.09
2. Item Area Expansion - Expand the item area by using the SUMSPACE
parameter of the REPORT statement. The value of SUMSPACE is added to
the length of detail fields to determine an adjusted line item length for the
total field. The resulting line item expansion is illustrated in the next
example as a print edit mask.
Statements:
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2 .* (999.99- mask without SUMSPACE specified)
*
JOB INPUT FILE1 NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1 SUMSPACE 1 +
SUMCTL HIAR LINESIZE 65
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE NEWPAGE ZIP
TITLE 'REPORT FOR THE STATE OF' STATE
LINE 01 LAST-NAME STATE ZIP PAY-NET
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Results:
2/11/87 REPORT FOR THE STATE OF IL PAGE 1
TX 777.77
Summary File
A summary file, which contains all the control and summed field values at each
minor break, can be optionally generated during processing of a control report.
JOB activities in your program can subsequently process the summary file to
provide reports not otherwise available via the standard report facilities of
CA-Easytrieve.
You can produce a summary file by defining the file in the library and then
referencing it with the REPORT SUMFILE parameter.
The FILE statement must contain the file name, record format, logical record
length, and blocksize. When you just want to retain the file for the duration of
the program, you can specify the file as an unblocked VIRTUAL file. The record
format can be any standard format. The record length must be large enough to
contain the data which is output. Blocksize should be appropriate for the
specified format and record length.
Therefore, the summary file record length is the sum of the control field area
length, plus 10 bytes for TALLY, plus 10 times the number of summed fields.
SUMFILE Example
The following example illustrates the use of SUMFILE data. The values of SFILE
are listed in order of ascending magnitude within SFILE-STATE, without
reprocessing the original data.
Statements:
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
FILE SFILE F(30)
SFILE-STATE 1 2 A
SFILE-ZIP 3 5 N
SFILE-TALLY 8 10 P 0
SFILE-PAY-NET 18 10 P 2
JOB INPUT FILE1 NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 65 +
SUMMARY SUMFILE SFILE SUMCTL DTLCOPY
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE NEWPAGE ZIP
TITLE 'REPORT FOR THE STATE OF' STATE
LINE 01 LAST-NAME STATE ZIP PAY-NET
*
JOB INPUT SFILE NAME MYPROG2
PRINT REPORT2
*
REPORT REPORT2 NOADJUST
SEQUENCE SFILE-STATE SFILE-PAY-NET
LINE 01 SFILE-STATE SFILE-ZIP +
SFILE-TALLY SFILE-PAY-NET
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Results:
IL 60077 2 641.97
IL 60076 2 802.35
TX 75218 2 777.77
Report Procedures
Although REPORT statements meet most of all report requirements, some
reports depend upon special data manipulation. Report procedures are routines
provided by CA-Easytrieve to satisfy this requirement.
Code report procedures at the end of their associated report. The report
processor invokes special-name procedures (such as BEFORE-LINE or
AFTER-BREAK) as required.
Report procedures are invoked at specific points during the report processing
activity. You can determine the specific point in time based on the name of the
procedure. The exhibit that follows illustrates the use of the procedures listed
below:
■ REPORT-INPUT - final screening of report input data. Report data can be
selected and/or modified. This procedure is invoked after the PRINT
statement is executed or as records are read back from the work file (if used).
■ BEFORE-LINE - detail line has not been created or printed. It is typically
used to modify the contents of fields or annotate the body of the report
before line printing.
■ AFTER-LINE - detail line has been printed. It is typically used to annotate
the body of the report after each line is printed.
■ BEFORE-BREAK - modification of totals before total line printing. It is
typically used to calculate averages on control reports.
■ AFTER-BREAK - total line has been printed. It is typically used to produce
special annotation following total lines on control reports.
■ ENDPAGE - at end-of-page body based on pagesize. This procedure can be
used to produce footers on each page of the report.
■ TERMINATION - at end-of-report. This procedure produces end-of-report
information such as hash or other control totals.
(BEFORE-LINE)
detail IL 60076 678.90
(AFTER-LINE)
(REPORT-INPUT - caused by the second PRINT statement)
(BEFORE-LINE)
detail IL 60076 123.45
(AFTER-LINE)
(BEFORE-LINE)
detail IL 60077 543.21
(AFTER-LINE)
(REPORT-INPUT - caused by the fourth PRINT statement)
(BEFORE-LINE)
detail IL 60077 98.76
(AFTER-LINE)
Coding Techniques
Coding report procedures is the same as coding procedures within JOB activities,
with the following exceptions:
■ You cannot use the following input/output generating statements:
DELETE FETCH
GET INSERT
POINT PRINT
PUT READ
SELECT (SQL) SQL
UPDATE WRITE
■ You cannot use the STOP, TRANSFER, or GOTO JOB statements.
■ You cannot PERFORM other procedures from within report procedures.
■ Use the DISPLAY statement to perform special report annotations. Use of
DISPLAY requires the following extra considerations:
– You cannot code the DISPLAY statement’s display-file-name parameter.
DISPLAY is only to the associated report.
Field Reference
In report procedures, you can reference any field contained in an active file or in
working storage. When control or total fields are referenced, CA-Easytrieve
automatically adjusts so that SUMFILE data is used. This assures access to the
field actually used in the report.
The following example illustrates the use of S fields versus W fields in a report
(spooled report):
Statements:
FILE FILEA
INPUT-FIELD 1 5 A
SFLD-RECORD-COUNT S 2 N
WFLD-RECORD-COUNT W 2 N
JOB INPUT FILEA
SFLD-RECORD-COUNT = RECORD-COUNT
WFLD-RECORD-COUNT = RECORD-COUNT
PRINT RPT
REPORT RPT NOADJUST
SEQUENCE INPUT-FIELD
LINE INPUT-FIELD SFLD-RECORD-COUNT WFLD-RECORD-COUNT
Data:
TESTA
TESTB
TESTC
Results:
The same program with the SEQUENCE statement removed produces quite
different results as illustrated below in the non-spooled report:
INPUT-FIELD SFLD-RECORD-COUNT WFLD-RECORD-COUNT
TESTA 01 01
TESTB 02 02
TESTC 03 03
In this example, a report work file is not needed. The format and print operation
occur upon execution of the PRINT statement and the value of
SFLD-RECORD-COUNT is captured with each execution of the PRINT
statement.
REPORT-INPUT
When the report data has been spooled (because the report was SEQUENCEd or
the printer file was in use), the REPORT-INPUT procedure is invoked as each
spooled record is read to produce this report. This implies that if the report is
sequenced, the REPORT-INPUT procedure is invoked after the sort program
returns the sorted spool record.
Although you can code the logic within the JOB activity itself, it is occasionally
desirable to place the logic in a REPORT-INPUT procedure. The next example
illustrates use of the REPORT-INPUT procedure in final report input selection.
Only the first record within each ZIP code is selected.
Statements:
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
HOLD-ZIP S 5 N VALUE 00000
JOB INPUT FILE1 NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 65 +
SUMMARY SUMCTL DTLCOPY
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE NEWPAGE ZIP
TITLE 'REPORT FOR THE STATE OF' STATE
LINE 01 LAST-NAME STATE ZIP PAY-NET
*
REPORT-INPUT. PROC
IF ZIP NE HOLD-ZIP
HOLD-ZIP = ZIP
SELECT
END-IF
END-PROC
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Results:
1888.77
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
JOB INPUT FILE1 NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 65 +
DTLCTL EVERY
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE ZIP
LINE 01 LAST-NAME STATE ZIP PAY-NET
*
AFTER-LINE. PROC
IF PAY-NET GE 500
DISPLAY '* EMPLOYEE ' LAST-NAME ' +
EXCEEDED WEEKLY SALARY GOAL *'
END-IF
END-PROC
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Results:
TX 777.77
2222.09
BEFORE-BREAK
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
*
PERCENT W 2 N 2
TOTAL-NET S 8 N 2
*
JOB INPUT FILE1 NAME MYPROG
*
TOTAL-NET = TOTAL-NET + PAY-NET
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 80 +
SUMMARY SUMCTL DTLCOPY
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE ZIP
LINE 01 LAST-NAME STATE ZIP PAY-NET PERCENT
*
BEFORE-BREAK. PROC
PERCENT = PAY-NET * 100 / TOTAL-NET + .005
END-PROC
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Results:
2222.09 100.00
AFTER-BREAK
In the next example, the total line for the control field STATE receives special
annotation:
Statements:
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
JOB INPUT FILE1 NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 65 +
SUMMARY SUMCTL DTLCOPY
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE ZIP
LINE 01 LAST-NAME STATE ZIP PAY-NET
*
AFTER-BREAK. PROC
IF LEVEL EQ 2
DISPLAY 'TOTALS FOR THE STATE OF ' STATE
END-IF
END-PROC
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Produce:
ENDPAGE
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
JOB INPUT FILE1 NAME MYPROG
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 65 +
SUMMARY SUMCTL DTLCOPY
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Produce:
...
* CONFIDENTIAL - FOR INTERNAL USE ONLY *
..................................................
...
TERMINATION
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
TOTAL-NET S 8 N 2
JOB INPUT FILE1 NAME MYPROG
TOTAL-NET = TOTAL-NET + PAY-NET
PRINT REPORT1
*
REPORT REPORT1 LINESIZE 65 +
SUMMARY SUMCTL DTLCOPY
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE NEWPAGE ZIP
TITLE 'REPORT FOR THE STATE OF' STATE
LINE 01 LAST-NAME STATE ZIP PAY-NET
*
TERMINATION. PROC
DISPLAY NOTITLE
DISPLAY SKIP 5 TOTAL-NET 'IS THE Y-T-D COMPANY NET PAY'
DISPLAY SKIP 5 'PLEASE ROUTE THIS REPORT TO CORPORATE OFFICERS'
END-PROC
Data:
BROWNIL6007612345
BROWNIL6007667890
JONESIL6007709876
JONESIL6007754321
SMITHTX7521811111
SMITHTX7521866666
Produce:
...
..................................................
2222.09 IS THE Y-T-D COMPANY NET PAY
Use the PRINTER parameter of the REPORT statement to route the printed
report. The file named by this parameter corresponds to a library defined file.
The FILE statement used to define the file must have the PRINTER parameter
specified. Unless otherwise designated, the record length of these files defaults
based upon a site option or the REPORT’s LINESIZE. See the “File Processing”
chapter for more information on defining PRINTER files.
The destination is determined on the FILE statement for the PRINTER file.
When output is sent back to the originating terminal on the mainframe or on the
workstation, the Report Display Facility is automatically invoked. See Report
Display Facility in the “Report Display Facility” chapter of the
CA-Easytrieve/Online User Guide, or Chapter 5 of the CA-Easytrieve/Workstation
User Guide.
The following example shows a program that takes advantage of print routing to
multiple logical files:
FILE PRINTR1 PRINTER F(121)
FILE PRINTR2 PRINTER F(121)
FILE FILE1
LAST-NAME 1 5 A
STATE 6 2 A
ZIP 8 5 N
PAY-NET 13 5 N 2
JOB INPUT FILE1 NAME MYPROG
IF ZIP EQ 60076, 60077
PRINT REPORT1
ELSE
PRINT REPORT2
END-IF
*
REPORT REPORT1 PRINTER PRINTR1 LINESIZE 120 +
SUMMARY SUMCTL DTLCOPY
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE NEWPAGE ZIP
TITLE 'REPORT FOR THE STATE OF' STATE
LINE 01 LAST-NAME STATE ZIP PAY-NET
*
REPORT REPORT2 PRINTER PRINTR2 LINESIZE 120 +
SUMMARY SUMCTL DTLCOPY
SEQUENCE STATE ZIP LAST-NAME
CONTROL STATE NEWPAGE ZIP
TITLE 'REPORT FOR THE STATE OF' STATE
LINE 01 LAST-NAME STATE ZIP PAY-NET
5. The order in which printed output is displayed within the Report Display
Facility is determined by the following rules:
■ Runtime errors are displayed at the point the error occurs, but after any
pending printer output.
■ The contents of PRINTER files are displayed when the PRINTER file is
closed, except for REPORT output and DISPLAY statements in JOB
activities with non-spooled reports.
■ Each PRINTER file is closed during the termination of the activity that
opened it.
■ The system-defined PRINTER file, SYSPRINT, is opened during the
initiation of the program. Therefore, it is closed during termination of
the program. All DISPLAYs to SYSPRINT are displayed last. This does
not include DISPLAY statements within report procedures or within JOB
activities with non-spooled reports.
■ Spooled report output, including any DISPLAYs within report
procedures are always displayed at the termination of the JOB activity.
■ Non-spooled report output, including any DISPLAYs within the report
procedures or the JOB activity, are displayed at the termination of the
JOB activity.
■ If an activity does not produce non-spooled reports, output from
DISPLAYs within the activity are displayed at the end of the activity that
opened the PRINTER file. This is at the end of the program for displays
to SYSPRINT.
■ When a JOB activity terminates, the file’s contents are displayed in the
following order:
– Non-spooled reports are displayed in the order in which they were
defined. These reports are displayed at the time the activity actually
terminates. DISPLAY statement output not associated with a
REPORT is displayed, along with non-spooled report output to the
same printer file.
– Spooled reports are displayed in the order in which they were
defined. These reports are displayed at the time they are despooled.
Extended Reporting
On the mainframe, CA-Easytrieve uses the CA-PSI Subsystems Reporting
Environment to produce reports on print devices so that CA-Easytrieve users do
not have to be concerned with environment and device-specific characteristics in
printing operations. The use of CA-PSI Subsystems Reporting Environment
enables printer set definitions to be shared between other Computer Associates
products (such as CA-TELON and CA-Easytrieve/IQ) that use the CA-PSI
Subsystems Reporting Environment.
The Reporting Environment provides support for Impact Dot, Ink-Jet, and
Electro-Photographic printers. This facility interacts with CA-Easytrieve
reporting processing to provide support for additional features allowing
CA-Easytrieve to:
■ Mix multiple different character sets on the same logical print line. For
example, in the same report the extended reporting option can process
EBCDIC fields and literals, and data containing DBCS (Double Byte
Character Set) format codes. Double Byte Character sets represent writing
systems that use more than 256 characters, such as Kanji (Japanese
characters).
■ Process fields and literals belonging to different fonts. For example, in the
same report you can use multiple fonts.
A font is a complete set of images of characters and symbols having common
characteristics (for example, style, height, width, weight). In a CA-Easytrieve
report, each character within a font must have the same amount of lateral
space. That is, CA-Easytrieve supports only fixed-pitch fonts.
CA-Easytrieve automatically formats a report compensating for fields and
literals that produce characters of different height and width. CA-Easytrieve
automatically calculates the size of elements on title, heading, detail, and
summary lines.
The CA-PSI Subsystems printer set definition module (PSIXRPSD) defines
the character widths that CA-Easytrieve uses. The module can define the
widths as either characters per inch (pitch) or a point size where the term
point defines the size of a character as a multiple of 1/72nd of an inch.
■ Support control codes in addition to the ANSI paper control codes.
■ Support printer files that use non-standard record formats, block sizes, and
record lengths.
Using the Reporting Environment, you can use multiple print fonts in a report.
This enables you to highlight fields of special significance. The following output
shows you an example of what the Reporting Environment can do. The
CA-Easytrieve program that produced the report is shown immediately
following the output.
END OF REGION 1
Program Example
The following CA-Easytrieve program created the previous report. Note the
fields and literals preceded by a pound sign (#) and integer.
FILE FILEA
REGION 1 1 N
BRANCH 2 2 N HEADING ( #5 'BRANCH') <
EMP# 9 5 N HEADING ('EMPLOYEE' 'NUMBER')
NAME 17 20 A HEADING ('EMPLOYEE' 'NAME')
STREET 37 20 A
CITY 57 12 A
STATE 69 2 A
ZIP 71 5 N
NET 90 4 P 2 HEADING ('NET' 'PAY')
GROSS 94 4 P 2 HEADING ('GROSS' 'PAY')
DEPT 98 3 N
DEDUCT W 4 P 2 HEADING ('DEDUCTIONS')
JOB INPUT FILEA NAME BASIC
DEDUCT = GROSS - NET
PRINT REPORT1
REPORT REPORT1 LINESIZE 130 PAGESIZE 45 SUMCTL NONE
SEQUENCE REGION BRANCH
CONTROL REGION NEWPAGE BRANCH
TITLE 01 #3 'REGION PAY SCALE SUMMARY' <
TITLE 02 #5 'REGION :' -2 #2 REGION <
LINE 01 #5 BRANCH DEPT EMP# GROSS NET DEDUCT <
AFTER-BREAK. PROC
IF LEVEL = 2
Printer Support
Each printer has its own characteristics, especially with respect to the
identification of the font, the presentation of print records, and the distinction
between character sets. To support each printer’s characteristics, CA-PSI
Subsystems uses a printer set definition module. This module defines the type of
printer that CA-PSI Subsystems supports, and the font codes that the
CA-Easytrieve program supports.
The printer set definition module provides support for special formatted files
(HTML and RTF) and for the following printers:
■ IBM 3800-I, IBM 3800-II
■ IBM 3800-III, IBM 3800-VIII
■ IBM 3820
■ IBM 3200
■ XEROX 2700, XEROX 8700, XEROX 9700
■ FACOM 6715D, FACOM 6716D
■ MELCOM 8250, MELCOM 8270, MELCOM 8290
■ HITACHI 8196
■ TORAY 8500
■ SHOWA INFORMATION SYSTEM SP7, SP8
■ MEMOREX 1500/1520
Printer Identification
The PRINTER command in the printer set definition module identifies the type
of printer(s) that the CA-Easytrieve system uses. A unique extended printer
name (ebstring-1) identifies each printer in the module. This name not only
identifies the characteristics of the printer but also enables you to define up to
256 different font codes for use in CA-Easytrieve programs. The font codes cause
fields and literals to be correctly formatted into output lines so that the printer
can print them using the correct font sets.
Font Identification
The next exhibit illustrates the definition of two extended reporting printer
names in the printer set definition module. Both definitions are for an IBM 3800
printer, but a different set of fonts is associated with each printer.
The fonts used in the previous exhibit are defined for the extended reporting
printer called IBM38002. This definition is illustrated in the following exhibit.
As a result, FIELD1 is output at 10 characters per inch (the default as no override
was coded) and FIELD2 is output using a font of 15 characters per inch. If a field
or literal is to use a different font, then you must precede the field with the
character ‘#’ followed by an integer. This integer defines the number of the font
in the font table of the extended reporting printer that you are using. The entry
must exist for the data type of the field or literal, that is EBCDIC, DBCS, or
MIXED. The DBCS data type defines data associated with a Double Byte
Character Set (DBCS). Use this data type to output characters for languages such
as Japanese, Chinese, Korean, and so on.
Printer Set Definition Module - PSIXRPSD
The record and block sizes on the CA-Easytrieve FILE statement should be as
large as possible to get the most advantage of a page mode printer (3800-3 or
3820). Coding a value of U(32760) would be a good value.
To make a USER3806 printer definition, using relative coordinates for a set of 10,
12, 15 and 10 bold pitch fonts with 8 LPI, code the printer definition as follows.
The default font is 10 pitch:
Set;
Printer Name('USER3806') Use(System);
Page Startpos ( 0, 0);
Dataset ASA(No) Record(V , 4096) Concatenate(Yes);
Defaults Size( 1, 1) Form( 3168, 2400) Fonts( 1 );
SetVerPos Value( X'2BD304C600002BD304D40000') RelPos ( 21, 4,B);
SetHorPos Value( X'2BD304C80000') RelPos ( 9, 4,B);
StartPage Value( X'F10040');
FormatPage Value( X'5A');
FormatPage Value( X'0000D3EE9B000000') RecLength( 1, 4,B)
RecNumber( 13, 4,B);
Font Number( 1) Width( 24.00) Height( 30.00) Format(EBCDIC);
FctHeader Value(X'2BD303F000');
Font Number( 2) Width( 20.00) Height( 30.00) Format(EBCDIC);
FctHeader Value(X'2BD303F001');
Font Number( 3) Width( 16.00) Height( 30.00) Format(EBCDIC);
FctHeader Value(X'2BD303F002');
Font Number( 4) Width( 24.00) Height( 30.00) Format(EBCDIC);
FctHeader Value(X'2BD303F003');
EndPrinter;
EndSet;
SAVE OBJECT('PSIXRPSD');
or if you have a FORMDEF that has CHARS (and any other pertinent
information) you could code:
//OUT1 OUTPUT CLASS=A,FORMDEF=formdef
//SYSPRINT DD OUTPUT=OUT1
VSE printer information can be given using the CHARS and TRC parameters on
the SETPRT statement, or the information can be specified in a Printer-Parameter
Member.
To make a LINE3801 printer definition, using line compatibility for a set of 10, 12,
and 15 pitch fonts, code the printer definition as follows. The default font is 10
pitch:
Set;
Printer Name('LINE3801') Use(System);
Line OverPrint(Merge, 4) Control(Ansi);
Dataset ASA(Yes) Record(F , 206) Device(Printer) MaxLrecl( 206)
MaxData ( 204);
Defaults Size( 1 ) Fonts( 1 );
Font Number( 1) Width( 7.20) Format(EBCDIC);
OpCode Value(X'F0');
Font Number( 2) Width( 6.00) Format(EBCDIC);
OpCode Value(X'F0');
Font Number( 3) Width( 4.80) Format(EBCDIC);
OpCode Value(X'F0');
Font Number( 4) Width( 7.20) Format(EBCDIC);
OpCode Value(X'F1');
EndPrinter;
EndSet;
SAVE OBJECT('PSIXRPSD');
XEROX Printers
Assume that you define a PDE, we will call it PDE200, using the following fonts:
font width approx type
name (dots) point size face
L0112A 22 9 1200
L02BOA 20 9 BOLD
L03BOA 22 7 BOLD
L0412A 20 7 1200
L0512A 30 12 1200
L05SCA 30 12 SCRIPT
To actually use this definition, you would code the following CA-Easytrieve
program:
Screen Processing
8
Overview
CA-Easytrieve provides all the facilities necessary to display and receive
information from an online terminal. As with other features, the non-procedural
nature of CA-Easytrieve provides relief from having to deal with many of the
complexities of transaction programming.
Basic Structure
You use a SCREEN activity to describe and process a screen display. The
CA-Easytrieve screen processing facility is basically declarative; you only need
to define the format and content of the screen and CA-Easytrieve creates the
necessary instructions to send and receive the screen. There are two sections in a
SCREEN activity.
1. The screen declaration statements that define the contents of the screen.
2. The optional screen procedures that permit you to code procedural logic to
perform file I/O or complex editing of fields displayed on the screen.
CA-Easytrieve Program
FILE
(library section)
Screen Format
The CA-Easytrieve screen format is illustrated below. The size of the screen
defaults to the values specified in your site options. These values can be
overridden by the LINESIZE and ROWCOUNT parameters of the SCREEN
statement.
LINESIZE
Title Area
R
O
W
Work Area C
O
U
N
T
Message Area
Function Key Area
Title Area
The title area is an optional area that consists of screen rows designated as titles
by TITLE statements in the screen declaration. Titles normally identify the
screen to the user and are automatically centered at the top of the screen. The
title area cannot be updated by the terminal user.
Work Area
The work area contains the items to be displayed to or received from the
terminal user. The items are specified by ROW statements in the screen
declaration. Repeating groups of rows can be specified with the REPEAT and
END-REPEAT statements.
Message Area
The optional function key area is used to tell the terminal user which function
keys are active and the action they perform. This area, if used, is always located
on the last line(s) at the bottom of the screen. You use the KEY statement in the
screen declaration to define the function key area.
Screen Borders
Screen Example
The following exhibit illustrates the type of screen that can be created with
CA-Easytrieve.
Please type V, E, D, or X
F1=Help F3=Exit F12=Cancel
Following is the screen declaration used to create the example screen above:
SCREEN NAME MAIN-MENU
TITLE 'Employee File Main Menu'
ROW 6 COL 10 'Type an option, then press Enter.'
ROW 8 COL 10 'Option ===>' WS-REPLY VALUE ('V' 'E' 'D' 'X') +
ERROR 'Please type V, E, D, or X'
ROW 10 COL 22 'V View employee'
ROW COL 22 'E Edit employee'
ROW COL 22 'D Delete employee'
ROW COL 22 'X Exit'
KEY F1 NAME 'Help' IMMEDIATE
KEY F3 NAME 'Exit' EXIT
KEY F12 NAME 'Cancel' EXIT IMMEDIATE
KEY ENTER
SCREEN Statement
See the CA-Easytrieve Language Reference Guide for complete syntax of these
statements.
Screen Items
Screen items include the fields and literals that you want to display to or receive
from the terminal user. Basic rules regarding items on a screen include the
following:
■ Unless directed otherwise, CA-Easytrieve automatically places items for the
same screen row one space apart. You can optionally add to this space or
locate an item at a specific column number.
■ The space preceding each item contains system information describing the
screen attributes for the item. The attributes contain information that
controls the display of screen items such as color and brightness.
CA-Easytrieve always uses the space preceding each screen item for
attributes.
Note: The space preceding an item located in the first column of any screen
row is actually located in the last column of the previous screen row. The
space preceding an item located in the first column of the first screen row is
located in the last column of the last screen row.
■ You can override the automatic placement of items by using the COL
parameter. You use COL to specify an explicit screen column number where
the item is placed. The COL parameter specifies the column number where
the data contained in the item is placed.
Use an offset (+n) to add to the minimum single space used between items
(+1 is the default). The offset applies to the data to be displayed. To add
additional space, use an offset greater than +1. There must always be at least
one space between each item on the screen. Items cannot overlap each other.
■ You can specify screen attributes for each item on the screen. If you do not
specify attributes for each item, default attributes apply. The following
hierarchy is used to determine screen attributes:
– If attributes are not specified for an item, (ATTR parameter on the ROW
or TITLE statement), CA-Easytrieve uses default attributes specified on
the DEFAULT statement at the beginning of the SCREEN declaration.
– If a DEFAULT statement is not coded in the SCREEN activity,
CA-Easytrieve uses attributes set in the site options.
Attributes can be specified either as one or more keywords or by using a
declared screen attribute. Use of declared attributes provides the ability to
define and name a set of attribute keywords. See Declaring Screen Item
Attributes in “Coding a CA-Easytrieve Program” chapter in this guide, and
DECLARE Statement in the CA-Easytrieve Language Reference Guide for more
information. In addition, screen attributes can be changed dynamically
during program execution using the SET statement. See SET Statement in
the CA-Easytrieve Language Reference Guide.
■ You must ensure that fields used on a screen are in available storage. This
requires that you code WORKAREA on FILE statements for fields used on
the screen where you do not execute an input statement to fill the fields with
data prior to displaying the screen.
Note: You must know the record length to reserve a WORKAREA.
CA-Easytrieve does not initialize WORKAREAs. Results are unpredictable
if an uninitialized WORKAREA is displayed.
System-Defined Fields
CA-Easytrieve automatically provides the special data fields listed below for
your screens. These fields are stored as part of working storage and are
read-only.
KEY-PRESSED
TERM-COLUMNS
TERM-ROWS
TERM-NAME
SYSUSERID
Title Rules
Title Examples
Following are title statement examples and their resulting screen titles.
This example illustrates two title rows that are automatically centered on the
screen. The titles are displayed with default screen attributes.
SCREEN NAME SCREEN1
TITLE 1 'Personnel View Utility'
TITLE 2 'Acme, Inc.'
This example shows titles that contain items that are explicitly located on the title
row using column specification (COL). The company name in the second title
row is displayed bright yellow because the ATTR parameter for the literal is
coded to override the default set of attributes for title items.
SCREEN NAME SCREEN1
TITLE 1 COL 1 'ViewUtil' 'Personnel View Utility' COL 73 SYSDATE
TITLE 2 'Acme, Inc.' ATTR (INTENSE YELLOW) COL 73 SYSTIME
Item Location
The following rules apply to the location of items in the screen work area:
■ You can specify the screen row number in the ROW statement. If you do not
specify a row number, the next screen row number is assigned. The next row
number is one higher than the row number for the previous ROW or TITLE
statement. If no TITLE or ROW statement is previously coded, the row is
assigned to the first line at the top of the screen.
■ All title rows must precede rows associated with the screen work area. This
does not mean that you must code all TITLEs before ROWs. Instead, a row
number explicitly or implicitly defined for a title cannot be greater than any
row number defined for a work area row.
■ You need not code ROW statements for empty rows between rows with
data. You can code ROW statements as placeholders for other ROWs
defined without row-numbers. An empty row is coded with a ROW
statement without any items.
■ Multiple items on a row are automatically separated from each other by one
space. This space contains the screen attributes for the second of the two
items. You can optionally add to this space or locate an item at a specific
column number.
■ You can override the automatic placement of items using the COL
parameter. You use the COL parameter to specify an explicit screen column
number where the item is placed. The COL parameter specifies the column
number where the data contained in the item is placed.
Use an offset (+n) to add to the minimum single space used between items
(+1 is the default). The offset applies to the data to be displayed. To add
additional space, use an offset greater than +1. There must always be at least
one space between each item on the screen. Items cannot overlap each other.
■ You can repeat a ROW statement or group of ROW statements within the
REPEAT and END-REPEAT statements to display an array on a screen.
■ You can specify the screen attributes for each item on a work area row. If
you do not specify attributes for each item, default attributes apply as
follows:
– If attributes are not specified for a field (ATTR parameter on the ROW
statement), CA-Easytrieve uses default attributes specified on the
DEFAULT FIELD statement, if coded at the beginning of the SCREEN
declaration.
– If attributes are not specified for a literal (ATTR parameter),
CA-Easytrieve uses default attributes specified on the DEFAULT
LITERAL statement, if coded.
– If DEFAULT statements are not coded in the SCREEN activity,
CA-Easytrieve uses attributes set in site options.
Because literals and read-only fields are not updatable, the following
attributes are flagged as warnings when compiled and ignored when used:
CURSOR NUMERIC
INVISIBLE MUSTFILL
MUSTENTER TRIGGER
ALARM
■ Field attributes can be changed during program execution with the SET
statement. See SET Statement in the CA-Easytrieve Language Reference Guide
for more information.
Location Examples
The following example illustrates various ROW statements and their resulting
screen displays.
SCREEN NAME SCREEN1
TITLE 1 'Personnel View Utility'
ROW 3 'Type the following information, then press Enter.'
ROW 6 COL 10 'Name . . . .' EMPNAME
ROW 8 COL 10 'Gross Pay . .' GROSS-PAY
ROW 10 COL 10 'Dept . . . .' DEPT-NO
Name . . . . BERG
Gross Pay . . 759.20
Dept . . . . 943
Attribute Examples
The following example illustrates various ROW statements coded with specific
attributes. The default attribute for fields is changed to protect the data. The
screen attribute for GROSS-PAY is then specified to unprotect data entry in the
field. CA-Easytrieve automatically places the cursor in the first unprotected field
on the screen.
SCREEN NAME SCREEN1
DEFAULT FIELD ATTR (PROTECT TURQUOISE)
TITLE 1 'Personnel View Utility'
ROW 3 'Type the new gross pay, then press Enter.' ATTR WHITE
ROW 6 COL 10 'Name . . . .' EMPNAME
ROW 8 COL 10 'Gross Pay . .' GROSS-PAY ATTR (INTENSE TURQUOISE)
ROW 10 COL 10 'Dept . . . .' DEPT-NO
Name . . . . BERG
Gross Pay . . _ 759.20
Dept . . . . 943
Note: When you override the default attribute setting, you must supply all of
the attributes for the item. Attributes are not merged. For example, if the default
attribute is BLUE PROTECT and you specify ATTR TURQ, the field is left
unprotected because you did not also specify PROTECT in the override.
Use the FILL parameter to translate all trailing blanks in a field or literal to a
specific character or nulls. If the field is also an input field, CA-Easytrieve
automatically translates all fill characters to spaces before placing the data back
into the field data area.
Varying length fields with FILL NULL specified do not have trailing nulls
translated to spaces. The first trailing null terminates the varying length field
and sets its length.
The following example illustrates filling a data entry field with underscores to
show the terminal user how much data can be entered. CA-Easytrieve removes
any remaining underscores when the screen is received.
SCREEN NAME SCREEN1
TITLE 1 'Personnel View Utility'
ROW 3 'Change the employee''s name, then press Enter.'
ROW 6 COL 10 'Name . . . .' EMPNAME FILL '_'
Name . . . . BERG________________
The following example illustrates filling a data entry field with nulls in order to
allow the user to insert characters into the field. The 3270 Display Station
requires trailing nulls in a field in order for insertion to work.
SCREEN NAME SCREEN1
TITLE 1 'Personnel View Utility'
ROW 3 'Change the employee''s name, then press Enter.'
ROW 6 COL 10 'Name . . . .' EMPNAME FILL NULL
The user can then insert characters into the field to change it to the correct name,
BERG.
The JUSTIFY RIGHT parameter shifts the data in the display field to the right.
Trailing spaces and nulls are deleted and leading spaces are inserted. The
JUSTIFY LEFT parameter shifts the data in the display field to the left. Leading
spaces and nulls are deleted and trailing spaces are inserted. The following
example illustrates these two parameters.
SCREEN NAME SCREEN1
TITLE 1 'Personnel View Utility'
ROW 3 COL 10 'Name . . . .' EMPNAME
ROW 4 COL 10 'Name . . . .' EMPNAME JUSTIFY RIGHT
ROW 6 COL 10 'Gross Pay . .' GROSS-PAY
ROW 7 COL 10 'Gross Pay . .' GROSS-PAY JUSTIFY LEFT
Name . . . . BERG
Name . . . . BERG
Gross Pay . . 759.20
Gross Pay . . 759.20
When CA-Easytrieve displays a numeric field, it uses the mask associated with
the field (either the default or its override on the DEFINE statement). If you
want to use a mask other than the default or override mask for display upon the
screen, use the MASK parameter on the ROW statement. The mask on the ROW
specifies the mask to be used for this specific occurrence of the field on the
screen. If the field is used more than once on the screen, the mask must be
specified for each occurrence.
You can use a mask identifier to identify a mask for future use. This shortens
coding time when you want to use a particular mask for several fields of the
same size on the screen.
If you have defined a mask for a field on a DEFINE statement and you want to
use the system-defined default mask, code NOMASK on the ROW statement for
the field.
Mask Example
Mask Examples
Using Default Mask 1,234.56
Using Defined Mask $1,234.56
Applying a Mask *1,234.56
Reverting a Mask 1,234.56
BWZ Mask
Mask Examples
Name . . . . C2C5D9C740404040404040404040404040404040
Gross Pay . . 0075920C
See Setting Errors later in this chapter for information on how you can use the
SET statement to edit input data.
UPPERCASE
You can specify UPPERCASE for fields coded on a ROW statement. When
UPPERCASE is coded, CA-Easytrieve converts data entered on the screen to
uppercase characters as it is received from the terminal. To convert all fields on
the screen to uppercase, code UPPERCASE on the SCREEN statement.
MASK
Decimal alignment is performed only for input. When you display data with
a mask, there is no implied relationship between the mask and the number
of decimal digits in the field.
■ Allow and discard characters that appear in the mask that are displayed
along with the data. For example, commas appearing in a quantitative field
or parentheses and a hyphen appearing in a telephone number are discarded
from the input before the data is stored in the actual field.
Display characters in the data must occur in the same order they appear in
the mask. The characters, however, are not required to appear in the data.
For example, applying the mask, 99,999.99, against the data, 12345.67 does
not cause an error condition. However, applying the mask, ‘(999) 999-9999’,
against the data, ‘(617 322-2762)’ is in error because the display characters
are out of order.
Any other characters not appearing in the mask cause an error message to be
displayed to the terminal user. Blanks imbedded in the middle of data that
are not part of the mask also cause an error condition.
■ Allow only numeric data for numeric fields. A blank entry is allowed only
when the mask specifies blank when zero. A field is blank when zero when
the mask is BWZ or contains only Z’s for digits.
■ Fields that use a hexadecimal mask (MASK HEX) have the input data
automatically validated for correct double-digit hexadecimal characters (0
through F). You can display numeric or alphanumeric (except VARYING)
fields with the hexadecimal mask. If MASK HEX is applied to a numeric
field, CA-Easytrieve only edits data for a valid hexadecimal format, not that
data is numerically valid.
PATTERN
You typically use a PATTERN to edit a field that contains a mixture of alphabetic
and numeric characters in a specific sequence.
This pattern tells CA-Easytrieve to accept entries such as A123C and reject
entries such as 1A23C.
The valid pattern characters and their meanings are listed in the following table.
Character Meaning
A Represents an uppercase or a lowercase letter.
B Represents a single blank.
D Represents a digit.
E Represents an empty string.
L Represents a lowercase letter.
N Represents an uppercase letter or a national character.
U Represents an uppercase letter.
X Represents any character.
“x” Double quotes surrounding a character or a sequence of
characters literally represent the character or the sequence
of characters contained within. The x represents any
character. To literally represent single or double quotes, use
two sets of quotes within the surrounding set of double
quotes (‘““““‘ or ‘“x””x”‘, ‘“‘‘“‘ or ‘“x’’x”‘).
blank Blanks (unless contained in double quotes) serve as
delimiters but are otherwise ignored. They can be inserted
into the pattern to increase readability.
() Represents grouping to control the precedence of operators.
or | or , Represents a choice between alternatives.
(m) or (m..n) Represents the repetition of the preceding pattern
expression. The m and n represent numbers and m must be
or (m..*)
less than n. A single number within the parentheses
or (*) indicates the exact number of repetitions. (m..n) represents
a range of repetitions, minimum to maximum. An asterisk
or *
in a range, (m..*), represents an infinite maximum. An
asterisk by itself, (*) or *, represents a range from 0 to
infinity.
# or /-/ Represents the remove (or toss) operation. This operation
applies only to a single character set at a time and must
immediately follow the character set in the pattern. This
operation removes from the data the character that matched
the character set.
+ Represents character set addition to form another character
set.
Character Meaning
- Represents character set difference to form another
character set.
concatenation Concatenation is implied by proximity. For example,
DDDU means 3 digits followed by an uppercase letter.
The edit pattern is evaluated from left to right (that is, the data from the screen is
processed from left to right). Patterns examine only one character at a time.
They do not look ahead and they do not back track.
Building Patterns
Step 2: Determine the order in which you expect users to key characters. Use
concatenation to describe the order.
Step 3: Determine how to describe which characters you want to allow in each
position in the order.
Step 4: If there is more than one order, use the choice operator to separate the
orders.
If you have a field which requires that 5 and only 5 digits be keyed into a field,
such as a zip code:
Step 3: The best pattern character for each position is D, since D represents the
character set of digits. The pattern becomes: DDDDD.
Step 4: Because there is only 1 order expected for this field, Step 4 does not
apply.
Step 5: Because D repeats 5 times, the pattern can be D(5). In this case, the
application of this step is not required. CA-Easytrieve internally generates the
same for DDDDD and D(5). You can use either pattern.
Step 2: There are 3 possible orders for how the characters for this field can be
keyed:
■ The first order is all blanks (requirement 1).
■ The second order is an uppercase character followed by one or more
lowercase characters followed by 0 or more blanks (requirements 2, 3, and 4).
■ The third order is an uppercase character followed by a period followed by
blanks (requirements 5 and 6).
Steps 3, 4, and 5: The part of the pattern which corresponds to the first order is a
repetition of B, since B represents blanks.
If the field is 10 characters long, one way to specify this order is B(10) or
BBBBBBBBBB. A better way to specify this order is B*. B* means that an infinite
number of blanks can be accepted. Since the field is only 10 bytes long, there can
be at most 10 blanks to accept. The B* generates a much smaller internal
representation, and also adapts better to changes in the size of the field.
The part of the pattern which corresponds to the second order is:
■ A U for the uppercase character
■ A repetition of L’s for the lowercase characters
■ A repetition of B’s for the trailing blanks.
If the field is 10 characters long, there can be 1 through 9 lowercase letters. One
way to specify the repetition is L(1..9), but a better way is to use L(1..*) since the
length of the field enforces a practical limit. For the repetition of blanks, use B*
instead of B(0..8). The part of the pattern for the second order is UL(1..*) B*.
(Blanks imbedded in patterns are ignored.)
The part of the pattern which corresponds to the third order is:
■ A U for the uppercase character
■ A “.” for the period
■ A repetition of B’s for the blanks.
Although there is always the same number of blanks, use B* to describe the
trailing blanks in the order. B(*) produces a much smaller internal
representation and is also more flexible. The part of the pattern for the third
order is U “.” B*.
Character Sets
A pattern represents the order of character sets in which you accept the data
from the screen for a particular field. The letters A, B, E, D, L, N, U, and X
represent predefined character sets. A single letter enclosed in double quotes
represents a character set consisting of one character. (A sequence of letters
enclosed in double quotes represents a series of character sets.)
A character set indicates which characters are acceptable. For example, the letter
U (when not enclosed in double quotes) indicates that any uppercase letter is
acceptable.
Occasionally, you prefer to identify characters which do not fit into one of the
predefined character sets. In these cases, you can build a character set that
identifies exactly the characters you require. The + and the - operators enable
you to add sets together or to obtain the set difference. The ( ) enable you to
control the precedence of the operations.
A frequent use for set difference is constructing a set of all characters except a
specific set of characters. For example, a pattern to specify all characters excepts
blanks is X-B.
Both U+B and U|B recognize the same data. The internal form of U+B is
marginally better than U|B because U+B describes a character set; U|B does not.
As a character set, the action operator # can be appended to the set. The set can
be combined with another set using - or + to form a different set.
Note: If you need to specify a pattern for predefined character sets in another
language, contact Computer Associates Technical Support.
You can use a PATTERN to provide advanced editing of numeric data. For
example, you can use a MASK to provide basic display and edit criteria for a
nine-digit ZIP code:
ROW 13 'ZIP Code . . .' ZIP-CODE MASK '99999-9999'
The mask, when used alone, allows the user to simply type zero. To require the
user to enter all nine digits with or without the hyphen, add the following
PATTERN:
ROW 13 'ZIP Code . . .' ZIP-CODE MASK '99999-9999' +
PATTERN 'D(5)"-"(0..1)D(4)B(*)'
The pattern specifies that there should be exactly five digits entered, followed by
0 to 1 hyphens followed by exactly four digits.
The PATTERN specifies that there should be exactly three digits entered,
followed by 0 to 1 hyphens, followed by exactly two digits, followed by 0 to 1
hyphens, followed by exactly four digits, followed by any number of spaces.
You can use a PATTERN to ensure the terminal operator enters valid data in a
name field:
ROW 13 'Name . .' EMPNAME PATTERN 'U(1..*) B(*)'
The PATTERN specifies that only a single name of at least one uppercase-only
character, followed by any number of spaces is valid.
To enable one or more names in uppercase with separation by only one space:
ROW 13 'Name . .' EMPNAME PATTERN 'U(1..*) (B U(1..*))(*) B(*)'
This pattern strips leading blanks while not permitting an all blank field:
ROW 13 'Description . .' DESCRIPTION PATTERN 'B#(*) (X-B) X(*)'
X-B signifies that all characters except blanks are allowed. To permit an all blank
field:
ROW 13 'Description . .' DESCRIPTION +
PATTERN 'B(*) ((X-B)(1..*), B(*))(*)'
This topic discusses some advanced material relating to the internal operation of
patterns. This information is not required to build most patterns. However, if
you have difficulty building a pattern with the # and (m..n) operators, this
information is helpful.
Patterns are implemented as state tables. A state table examines each character
in a string to determine if the string is acceptable or not. Each character
examined causes a transition from one state to the next. Most compilers use state
tables for recognizing tokens (for example, labels or identifiers).
In CA-Easytrieve, there are two extensions in the pattern language which are not
always converted to a state table: the # and the (m..n) operators. These
operations are implemented as actions which are associated with transitions.
This pattern allows data that consists of a single string of non-blank characters
with or without leading and trailing blanks, or an all blank field. The following
exhibit illustrates the state table and graphical representation of the table.
The body of the table indicates what CA-Easytrieve does when in a given state
with given input. If the entry indicates a state, CA-Easytrieve goes to that state.
If the entry indicates accept, the data is valid. If the entry is error, the data is
rejected.
If you change the pattern to remove any leading blanks, the pattern becomes:
'B#* (X-B)* B*'
In the process of converting the pattern to the state table, all of the possible paths
through the pattern are considered. If the first entry is a blank, CA-Easytrieve
does not know whether to remove the character or not (does it match the B#* or
the B*?). This pattern generates an error message when compiled.
This pattern removes leading and trailing blanks. When the first character is a
blank, it does not matter if it is a leading or a trailing blank since both get
removed. The loss of trailing blanks is not damaging. After the data has been
accepted, CA-Easytrieve moves the data into the corresponding field in the
library section. If the field is alphanumeric, it is padded with blanks. If it is a
VARYING alphanumeric field, the length of the field reflects the data, less the
trailing blanks. If the field is numeric, the conversion to the correct data format
ignores the blanks.
The second extension is the range repetition with a fixed upper bound, (m..n).
This type of repetition is called a limited repetition. The restrictions on its use
are:
1. Limited repetitions cannot be nested within other repetitions (except (m)).
2. When a character from the input data is examined, there can be no
ambiguity as to which is the next state and how to count the character.
Rule 1 is the result of the nature of state tables. All actions are done at the
transition from one state to the next. The counting and the checking required by
a limited repetition is done at a transition. It is impossible, in all cases, to assign
an action to one or more transitions that reset the counters.
If the first character in the input data is a digit, does it match the first D(0..2) or
the second? If CA-Easytrieve could look ahead to see the rest of the input it
could decide which one it was. But, as stated earlier, patterns examine only one
character at a time. Therefore, this pattern generates an error message when
compiled.
Note: The pattern ‘D(0..2) (“.”|E) D(0..2)’ does not appear to have any practical
application.
Additional Considerations
If the first character to be examined by the pattern is a blank, does the blank
match the B* or the X? If it matches the B* there can be more data. If it matches
the X, there can be no more input. Therefore, this pattern generates an error
message when compiled.
When CA-Easytrieve gets data back from the screen, the data is almost always
padded with trailing blanks unless you filled the entire field with data. The EOF
key on the 3270 terminal may set the rest of the field on the screen to nulls, but
by the time the pattern sees the data, the nulls have been converted to blanks.
You may want to allow for trailing blanks in your patterns.
VALUE
CA-Easytrieve automatically edits the input data against the value(s) specified in
the VALUE parameter for the field on the ROW statement. You can
automatically edit the data against a single value, a range of values, or a series of
values. The VALUE parameter works similar to a CA-Easytrieve IF statement.
■ All input fields are edited each time a user presses a programmable key (for
example, PA keys, function keys, Enter) unless the key pressed is an
IMMEDIATE key. IMMEDIATE keys cause the screen to be received but the
data is not edited and moved into program fields. See Screen Key
Processing, later in this chapter for details.
Note: If you are executing in the workstation environment, CA-Easytrieve
performs much of the automatic editing as the data is entered in the field. It
does not wait for a programmable key to be pressed before editing the data.
■ Each field found in error receives the FIELD ERROR attribute. You can
specify this attribute on a DEFAULT FIELD ERROR statement at the
beginning of the screen declaration. If you do not use the DEFAULT FIELD
ERROR statement, this attribute is taken from the site options. You can set
individual error attributes for a field using the ERROR ATTR parameter for
the field on the ROW statement.
■ CA-Easytrieve automatically displays a message describing the error for the
first field in error on the screen. This message typically tells the user that the
field did not match one of the values permitted for the field or that the
format of the data was incorrect. You can override the system-issued
message with your own message using the ERROR parameter for the field
on the ROW statement.
Messages issued for editing errors, whether system-issued or from the
ERROR parameter, are always an ACTION message level. See Screen
Message Area, later in this chapter for more information.
Cursor Placement
You can specify the placement of the cursor on the screen in the following ways:
■ Use the CURSOR attribute in the ATTR parameter for the field on the ROW
statement. You can also specify the CURSOR attribute for a field flagged in
error using the ERROR ATTR parameter for the field on the ROW statement.
■ Execute a CURSOR statement in a screen procedure to specify the field on
the screen that receives the cursor upon the next display of the screen.
When more than one way is used to place the cursor in a specific location,
CA-Easytrieve uses the following hierarchy to determine how the cursor is
placed. The priority is from highest to lowest.
1. If the screen is re-displayed using a RESHOW action (see Screen Procedures
later in this chapter), the cursor is placed in the same position as when the
screen was received, regardless of any other method used.
CA-Easytrieve supports the display of arrays on the screen with the REPEAT
and END-REPEAT statements. You use the REPEAT and END-REPEAT
statements to surround one or more ROW statements in the screen declaration,
and specify the number of times that the enclosed group of ROW statements is
repeated on the screen.
Policies
32894671
65274902
76642915
Two-dimensional Arrays
As illustrated in the previous example, you can code a subscript on each element
of an array within a REPEAT group. If these fields are elements of a
two-dimensional array, you can also add a second subscript. CA-Easytrieve
does not automatically increment a second subscript for you. The second
subscript must be specified as a literal or as a static field. The following example
illustrates this:
...
WS-EMPLOYEE W 33 A OCCURS 3 . * 2-dimensional table of
WS-NAME WS-EMPLOYEE 30 A . * 3 employees containing:
WS-STATUSES WS-EMPLOYEE +30 3 A . * employee name and
WS-STAT WS-STATUSES 1 A OCCURS 3. * 3 statuses
...
SCREEN NAME EMPLOYEE-LIST
TITLE 'List of Employees'
ROW 3 'Name' COL 30 'Statuses'
REPEAT 3 TIMES VARYING USER-SUB
ROW WS-NAME (USER-SUB) +
WS-STAT (USER-SUB, 1) WS-STAT (USER-SUB, 2) +
WS-STAT (USER-SUB, 3)
END-REPEAT
List of Employees
Name Statuses
WIMN, GLORIA F G O
BERG, NANCY C
CORNING, GEORGE I T
The default message area location is at the bottom of the screen, just above the
function key display area. You can move the message area by specifying its row
number on a DEFAULT MESSAGE statement at the beginning of the screen
declaration. By default, all three levels of messages are sent to the same screen
row number. Use the DEFAULT statement to designate from one to three rows
to display different levels of messages on the screen.
Message Attributes
You can specify attributes for the three levels of messages on DEFAULT
MESSAGE statements. If you do not use a DEFAULT MESSAGE statement,
screen attributes for each message level are taken from the site options.
Message Text
The screen message area is used both for system-issued and programmer-issued
messages. System-issued messages result from the edit process that
CA-Easytrieve automatically performs on input data. You can override the
message resulting from the edit process with the ERROR parameter of the ROW
statement. See Automatic Editing of Input earlier in this chapter. You can also
issue messages from the screen procedures that you code following the screen
declaration by executing the MESSAGE or SET statement prior to the display of
the screen.
Location
The function key area is always located at the bottom of the screen. The display
is determined by the KEY statements you code in the screen declaration. You
can specify descriptive text on each KEY statement to be displayed with the
name of the key. Depending on the number of keys and the length of the
descriptive text, more than one row of the screen may be required to display the
active function keys.
Note: If you specify that one or more message areas use the same screen row as
the function key area, messages may overlap the function key area. The default
location for messages is just above the function key area.
Attributes
You can specify attributes for the function key area on a DEFAULT KEY
statement. If you do not use a DEFAULT KEY statement, screen attributes for
the function key area are taken from the site options.
Keys can also be assigned to perform specific actions when the key is pressed.
As described earlier in Screen Function Key Area, you also control the display of
information about the keys to the terminal user on KEY statements.
Action Effect
REFRESH Restore the initial condition of the screen
EXIT Terminate the SCREEN activity
When the terminal user presses CLEAR, PA1, PA2, or PA3, the 3270 Display
Station returns only the name of the key pressed. Data on the screen is not
received and the cursor position cannot be determined.
Screen Procedures
The execution of a SCREEN activity is actually a collection of procedures that
CA-Easytrieve performs in a certain sequence. There are four points in a
SCREEN activity in which CA-Easytrieve invokes special-named procedures.
You can code these special-named procedures to perform customized actions
specific to your application. The special-named screen procedures are:
■ INITIATION
■ BEFORE-SCREEN
■ AFTER-SCREEN
■ TERMINATION
You are not required to code these procedures. If not coded, CA-Easytrieve
simply proceeds to the next step in the activity.
The following exhibit illustrates the SCREEN activity process that CA-Easytrieve
performs and when the special-named procedures, if coded, are executed.
Step 3: Build the screen using program fields, pending messages, and pending
cursor placement. Clear the internal pending message buffer.
Step 4: Send the screen to the terminal. Terminate and resume the program (if
pseudo-conversational). Receive the screen from the terminal
Step 9: Go to Step 2.
Step 10: When EXIT is requested, reset working storage, then perform
TERMINATION procedure, processing any branch actions.
INITIATION
The INITIATION procedure is performed one time during the initiation of the
activity. Use INITIATION to perform actions that can only be executed once, for
example, setting a field to an initial value or positioning a file at a specific
starting location. Work fields with the RESET parameter specified are
automatically initialized before the INITIATION procedure is invoked.
BEFORE-SCREEN
AFTER-SCREEN
All branch actions are valid in the AFTER-SCREEN procedure. See Branch
Actions later in this chapter, for details.
TERMINATION
Programmer-Defined Procedures
You can code your own procedures in a SCREEN activity and perform them
from the special-named screen procedures. Procedures you code are local to the
screen activity and cannot be performed from other activities.
Branch Actions
There are four actions that cause the program execution to branch to specific
steps in the SCREEN activity process:
GOTO SCREEN
You can use the GOTO SCREEN statement to repeat the activity process. The
default action of a SCREEN activity is to repeat the process until an EXIT action
is executed. If the bottom of the process (the end of the AFTER-SCREEN
procedure) is reached, the activity simply repeats, starting with the
BEFORE-SCREEN procedure. (The INITIATION procedure is a one-time-only
procedure).
You can code the GOTO SCREEN statement to cause an immediate branch to the
top of the activity. This is similar to the way in which GOTO JOB branches to the
top of a JOB activity.
REFRESH
When the user presses F5, data currently on the screen is ignored and the screen
is rebuilt from the original field contents. When the user presses F6, the data
entered is edited as specified on the ROW statements. Pressing F10 also edits the
data but then performs an AFTER-SCREEN procedure that updates the file.
You can also use REFRESH to update the screen contents with the current data
available. For example, a user enters a quantity and a price and wants to see the
extended price (price times quantity). You can use a REFRESH coded in an
AFTER-SCREEN procedure to compute the extended price as shown in the next
example.
SCREEN NAME MYSCREEN
TITLE 'Inventory Control'
KEY F2 NAME 'Reset to zero'
KEY F6 NAME 'Refresh' IMMEDIATE REFRESH
KEY F9 NAME 'Show Extended Price'
KEY F10 NAME 'Update'
ROW 3 'Quantity . .' QUANTITY
ROW 5 'Price . . . .' PRICE
ROW 7 'Ext Price . .' EXT-PRICE ATTR (TURQ ASKIP)
...
BEFORE-SCREEN. PROC
MOVE ZEROS TO QUANTITY, PRICE, EXT-PRICE
END-PROC
AFTER-SCREEN. PROC
IF KEY-PRESSED = F9
EXT-PRICE = PRICE * QUANTITY
REFRESH
END-IF
...
END-PROC
When the user types the quantity and price and presses F9, the quantity and
price are received, and the extended price is computed. The REFRESH then
re-displays the screen using the current value of the program fields, and the
newly-computed extended price is displayed.
RESHOW
When associated indirectly with an IMMEDIATE key, you can ignore any data
entered on the screen, display a second screen, then RESHOW the first screen
intact. For example, you can permit the user to view a help screen, then return to
the screen on which the user requested help. See Providing Help Screens later in
this chapter, for an example of program code.
When associated indirectly with a non-IMMEDIATE key, you can permit the
user to display a selection list, accept and process the user’s selection(s), then
re-display the original screen.
EXIT
EXIT terminates the SCREEN activity and returns control to the activity from
which it was EXECUTEd. If the current SCREEN activity was not EXECUTEd
from another activity, EXIT terminates the program. Associating EXIT with an
IMMEDIATE key is equivalent to a cancel function. Any data on the screen is
ignored and the activity terminates. Associating EXIT with a non-IMMEDIATE
key saves the data into the program fields after editing it.
The SCREEN activity process illustrated in the ten steps under Screen
Procedures earlier in this chapter shows how CA-Easytrieve handles
pseudo-conversational programs. In Step 4, CA-Easytrieve sends the screen to
the terminal. If your SCREEN activity is executing in a pseudo-conversational
mode (COMMIT NOTERMINAL is not specified for a CICS program),
CA-Easytrieve then terminates the task and returns to CICS. When the terminal
user presses a programmable terminal key, CICS executes the program again,
and CA-Easytrieve resumes the task and receives the screen. See Commit
Processing later in this chapter, for more information.
Also see Units of Work/Commit Processing and Coding Programs That Run
Under CICS in “Coding a CA-Easytrieve Program” chapter for additional
information.
Sending Messages
CA-Easytrieve maintains an internal message area for each message area defined
on your screen. The MESSAGE statement can be executed anywhere in your
program to update the pending message area. When the next screen is
displayed, the screen message area is built from the pending message. The
pending message area is then cleared.
You can use these pending messages across activities to prepare messages in one
activity for display on a screen in another activity. The following example shows
how to code messages in a SCREEN activity, and show the resulting screen.
FILE PERSNL INDEXED WORKAREA 150
%PERSNL
SCREEN NAME VIEW-UTILITY
KEY ENTER
KEY F3 NAME 'Exit' EXIT
TITLE 1 'Employee View Utility'
ROW 3 'Employee Number . .' EMP#
ROW 5 'Employee Name . . .' EMPNAME
INITIATION. PROC
Employee Number . . _
Employee Name . . .
...
Enter an employee number.
F3=Exit
You can determine the position of the cursor when the screen is received by
using the special IF CURSOR statement in a screen procedure. You use the IF
CURSOR statement to test whether the cursor is present within a specified field.
The following example illustrates the IF CURSOR statement testing for cursor
placement on any of four subscripted array elements on the screen.
DEFINE OPTION W 1 A OCCURS 4
SCREEN NAME MENU
KEY F2 NAME 'Select'
KEY F3 NAME 'Exit' EXIT
TITLE 1 'Employee System Main Menu'
ROW 3 'Position the cursor by your selection, press F2 to select.'
ROW 5 COL 10 OPTION (1) 'View employee'
ROW COL 10 OPTION (2) 'Edit employee'
ROW COL 10 OPTION (3) 'Delete employee'
ROW COL 10 OPTION (4) 'Add employee'
AFTER-SCREEN. PROC
IF OPTION (1) CURSOR
EXECUTE VIEW-EMPLOYEE
ELSE-IF OPTION (2) CURSOR
EXECUTE EDIT-EMPLOYEE
ELSE-IF OPTION (3) CURSOR
EXECUTE DELETE-EMPLOYEE
ELSE-IF OPTION (4) CURSOR
EXECUTE ADD-EMPLOYEE
ELSE
MESSAGE 'Position cursor by a menu selection.'
END-IF
END-PROC
...
You can use the IF MODIFIED statement to test whether a field was modified by
the terminal user. Following are the rules for using the IF MODIFIED statement:
■ The test for modification determines whether the value of the field actually
changed. If the user types the same value in the field as was originally
displayed, the modification test is false.
■ The results of the IF MODIFIED test are set at the time the screen is received.
If the value of the input data is not equal to the value of the program field,
the field was modified. If the input data is equal to the program field, the
field is considered not modified.
■ The IF MODIFIED comparison is performed logically for both alphanumeric
fields and numeric fields.
Using the IF MODIFIED test can help you write more efficient programs. For
example, you may not want to perform complex editing on a field unless it was
changed by the user. The following is an example of the IF MODIFIED test.
SCREEN NAME EDIT-EMPLOYEE
KEY ENTER
KEY F3 NAME 'Exit' EXIT
TITLE 1 'Employee Edit Utility'
ROW 3 'Enter the employee number and new job category.'
ROW 5 'Employee number . .' EMP#
ROW 7 'Job Category . . . .' JOB-CATEGORY
AFTER-SCREEN. PROC
IF JOB-CATEGORY MODIFIED
PERFORM SEARCH-JOB-CATEGORY-TABLE
IF NOT JOBTABLE
MESSAGE 'Job category is invalid. Please reenter.'
ELSE
PERFORM UPDATE-EMPLOYEE
MESSAGE 'Job category updated.' LEVEL INFORMATION
MOVE ZERO TO EMP# JOB-CATEGORY
END-IF
ELSE
MESSAGE 'Job category not modified.' LEVEL WARNING
JOB-CATEGORY = 0
END-IF
END-PROC
...
Setting Errors
When you can determine the validity of user input with a simple IF statement,
such as IF DEPT = 901 THRU 999, the VALUE parameter on the ROW statement
provides easy automatic error handling. Often, however, you must provide
more complex logic to determine the validity of a value. For example, you may
need to perform cross-field editing where the value of one field on the screen
determines acceptable values for another field on the screen, or you may have to
perform a table look-up or other advanced processing to determine validity.
You can use the SET statement to extend automatic error handling in screen
procedures. When you execute a SET statement for a field, CA-Easytrieve uses
the SET information the next time the screen is displayed. You can simply
change the field’s screen attributes; however, if you code the ERROR parameter,
the screen process treats the field as if automatic editing detected the error. The
field’s error attributes and error message are used by default but you can even
override these with a SET statement. See Sample Screen Applications later in
this chapter, and the SET Statement in the CA-Easytrieve Language Reference Guide
for more information.
Commit Processing
You can use CA-Easytrieve commit processing in screen activities to provide file
integrity during update operations.
See the following topics in this guide for additional information on how
CA-Easytrieve performs commit processing:
■ Controlling Program Flow: Units of Work/Commit Processing in the
“Coding a CA-Easytrieve Program” chapter for information on instructing
CA-Easytrieve to use either automatic or controlled commit processing
during program execution.
■ Overview: Hold/Release Processing in the “File Processing” chapter for
how CA-Easytrieve processes requests to update records during file
processing.
The COMMIT parameter of the SCREEN statement controls the way CA-Easytrieve
automatically issues commit points during screen processing. The
TERMINAL|NOTERMINAL subparameter controls whether records are held
during terminal I/O operations. In multi-user environments such as CICS or
workstation networks, it is important to fully understand the use of
TERMINAL|NOTERMINAL.
The next example shows the same program using COMMIT TERMINAL to tell
CA-Easytrieve to issue a commit point during terminal I/O. COMMIT TERMINAL
is the default if not specified. The commit point issued between the time the user
sees the record and finally updates it allows other users to access the record. It also
frees valuable system resources each time a terminal operation is performed.
The program must read the record again following the user’s request to update it
(F6). Any hold issued during the read for the find request (F5) is lost when the
employee record is displayed on the terminal. The program specifically states
NOHOLD on the READ statement for finding the record and HOLD on the READ
statement for updating the record. If NOHOLD had not been specified, a hold
would have been issued but released when the screen was displayed.
Re-reading the record presents an additional complexity. If the actual record is used
as the screen data area (as in this example), the second READ statement causes the
data entered by the terminal user to be lost. To handle this condition, simply define
a work area to hold the record contents during the read operation. Restore the
contents before the update takes place.
FILE KPERSNL INDEXED UPDATE
%PERSNL
WORK-EMP# W 5 N
WORK-AREA W 150 A
SCREEN NAME UPDATE-KPERSNL COMMIT TERMINAL
KEY F3 NAME 'Exit' EXIT
KEY F5 NAME 'Find employee'
KEY F6 NAME 'Update employee'
TITLE 'Update Social Security Number'
ROW 5 'Employee Number. . . . . .' WORK-EMP#
ROW 7 'Social Security Number . .' SSN
INITIATION. PROC
SSN = 0
MESSAGE 'ENTER EMPLOYEE NUMBER. PRESS F5 TO FIND.' +
LEVEL INFORMATION
END-PROC
AFTER-SCREEN. PROC
CASE KEY-PRESSED
WHEN F5
READ KPERSNL KEY WORK-EMP# NOHOLD STATUS
IF NOT KPERSNL
MESSAGE 'EMPLOYEE NOT FOUND. ENTER NEXT EMPLOYEE.'
MOVE ZERO TO SSN
ELSE
MESSAGE 'ENTER NEW SSN. PRESS F6.' LEVEL INFORMATION
CURSOR AT SSN
END-IF
WHEN F6
MOVE KPERSNL TO WORK-AREA
READ KPERSNL KEY WORK-EMP# HOLD
MOVE WORK-AREA TO KPERSNL
WRITE KPERSNL UPDATE STATUS
IF FILE-STATUS NE 0
MESSAGE 'EMPLOYEE NOT UPDATED. REASON=' FILE-STATUS
ELSE
MESSAGE 'SSN UPDATED. ENTER NEXT EMPLOYEE. PRESS F5.' +
LEVEL INFORMATION
END-IF
END-CASE
END-PROC
Concurrent Updates
There are several coding conventions to handle these conditions. Two of the more
common are:
■ Set a flag in the record that is under consideration for update. All programs
accessing the file must test the flag before allowing any update access.
■ Save a copy of the data that is displayed to the user. Before updating it,
compare the current data to the saved copy. If any changes are detected,
display the current data and warn the user that there was an intermittent
change to the record.
The next example contains the previous program in which code has been added to
handle intermittent updates. A copy of the social security number displayed to the
user is saved in the working storage field, SAVE-SSN. Code has been added to
detect when the record is deleted by another user. When the read is successful, the
social security number in the record is compared to that originally displayed to the
user. If it is not the same, the user is warned that another user already changed the
number, and he is asked to process the change again.
FILE KPERSNL INDEXED UPDATE
%PERSNL
WORK-EMP# W 5 N
WORK-AREA W 150 A
SAVE-SSN W SSN
SCREEN NAME UPDATE-KPERSNL COMMIT TERMINAL
KEY F3 NAME 'Exit' EXIT
KEY F5 NAME 'Find Employee'
KEY F6 NAME 'Update employee'
TITLE 'Update Social Security Number'
ROW 5 'Employee Number. . . . . .' WORK-EMP#
ROW 7 'Social Security Number . .' SSN
INITIATION. PROC
SSN = 0
MESSAGE 'ENTER EMPLOYEE NUMBER. PRESS F5 TO FIND.' +
LEVEL INFORMATION
END-PROC
AFTER-SCREEN. PROC
CASE KEY-PRESSED
WHEN F5
READ KPERSNL KEY WORK-EMP# NOHOLD STATUS
IF NOT KPERSNL
MESSAGE 'EMPLOYEE NOT FOUND. ENTER NEXT EMPLOYEE.'
MOVE ZERO TO SSN
ELSE
SAVE-SSN = SSN
MESSAGE 'ENTER NEW SSN. PRESS F6.' LEVEL INFORMATION
CURSOR AT SSN
END-IF
WHEN F6
MOVE KPERSNL TO WORK-AREA
READ KPERSNL KEY WORK-EMP# HOLD STATUS
IF NOT KPERSNL
MESSAGE 'EMPLOYEE ' WORK-EMP# ' NO LONGER ON FILE. +
ENTER NEW EMPLOYEE. PRESS F5.'
MOVE ZERO TO SSN
GOTO SCREEN
ELSE-IF SSN NE SAVE-SSN
MESSAGE 'INTERMITTENT CHANGE DETECTED! RETYPE NEW VALUE +
AND PRESS F6 TO UPDATE.' LEVEL WARNING
SAVE-SSN = SSN
GOTO SCREEN
END-IF
MOVE WORK-AREA TO KPERSNL
WRITE KPERSNL UPDATE STATUS
IF FILE-STATUS NE 0
MESSAGE 'EMPLOYEE NOT UPDATED. REASON=' FILE-STATUS
ELSE
MESSAGE 'SSN UPDATED. ENTER NEXT EMPLOYEE. PRESS F5.' +
LEVEL INFORMATION
END-IF
END-CASE
END-PROC
The programs in the previous examples process an indexed file. This next example
illustrates how the previous program (Concurrent Updates) looks when an SQL
table is processed instead.
FILE KPERSNL SQL( SSRPRS0.PERSNL) UPDATE
SQL INCLUDE ( EMP#, SSN) FROM SSRPRS0.PERSNL LOCATION *
MASK-SSN SSN SSN MASK('999-99-9999')
WORK-EMP# W EMP# MASK('99999')
WORK-AREA W 8 A
SAVE-SSN W SSN
SCREEN NAME UPDATE-PERSNL COMMIT TERMINAL
KEY F3 NAME 'Exit' EXIT
KEY F5 NAME 'Find Employee'
KEY F6 NAME 'Update employee'
TITLE 'Update Social Security Number'
ROW 5 'Employee Number. . . . . .' WORK-EMP#
ROW 7 'Social Security Number . .' MASK-SSN
INITIATION. PROC
MASK-SSN = 0
MESSAGE 'ENTER EMPLOYEE NUMBER. PRESS F5 TO FIND.' +
LEVEL INFORMATION
END-PROC
AFTER-SCREEN. PROC
CASE KEY-PRESSED
WHEN F5
SELECT FROM KPERSNL +
WHERE EMP# = :WORK-EMP#
FETCH FROM KPERSNL
IF NOT KPERSNL
MESSAGE 'EMPLOYEE NOT FOUND. ENTER NEXT EMPLOYEE.'
MOVE ZERO TO MASK-SSN
ELSE
SAVE-SSN = SSN
MESSAGE 'ENTER NEW SSN. PRESS F6.' LEVEL INFORMATION
CURSOR AT MASK-SSN
END-IF
WHEN F6
MOVE KPERSNL TO WORK-AREA
SELECT FROM KPERSNL +
WHERE EMP# = :WORK-EMP# +
FOR UPDATE
FETCH FROM KPERSNL
IF NOT KPERSNL
MESSAGE 'EMPLOYEE ' WORK-EMP# ' NO LONGER ON FILE. +
ENTER NEW EMPLOYEE. PRESS F5.'
MOVE ZERO TO MASK-SSN
GOTO SCREEN
ELSE-IF SSN NE SAVE-SSN
MESSAGE 'INTERMITTENT CHANGE DETECTED! RETYPE NEW +
VALUE AND PRESS F6 TO UPDATE.' LEVEL WARNING
SAVE-SSN=SNN
GOTO SCREEN
END-IF
MOVE WORK-AREA TO KPERSNL
UPDATE KPERSNL
IF FILE-STATUS NE 0
MESSAGE 'EMPLOYEE NOT UPDATED. REASON=' FILE-STATUS
ELSE
MESSAGE 'SSN UPDATED. ENTER NEXT EMPLOYEE. PRESS F5.' +
LEVEL INFORMATION
END-IF
END-CASE
END-PROC
The following example illustrates a screen activity that uses dynamic screen
attributes. DECLAREd attributes are used for the job category prompt text and
JOB-CATEGORY field. These DECLAREd attributes are initialized when created
with the DECLARE statement. When an error occurs, the attributes of both the
prompt text and field are changed to highlight the condition. When an error
condition does not exist, the normal attributes are used.
DECLARE TEXT-ATTR ATTR (GREEN ASKIP)
DECLARE FIELD-ATTR ATTR (TURQ)
DECLARE NORMAL-TEXT-ATTR ATTR (GREEN ASKIP)
DECLARE ERROR-TEXT-ATTR ATTR (YELLOW INTENSE REVERSE ASKIP ALARM)
DECLARE NORMAL-FIELD-ATTR ATTR (TURQ)
DECLARE ERROR-FIELD-ATTR ATTR (YELLOW INTENSE REVERSE ALARM)
SCREEN NAME EDIT-EMPLOYEE
KEY ENTER
Using a Menu
CA-Easytrieve allows you to provide help screens for your terminal users. The
example in this topic illustrates how you can display a help screen from the main
menu used in the previous example.
F3=Exit
Field-specific Help
You can easily implement field-specific help screens using code similar to the
previous example combined with the IF CURSOR test:
■ The terminal user could press a function key while the cursor is in the field
for which he wants help.
■ Test each field on your screen to determine the position of the cursor in an
AFTER-SCREEN procedure.
■ EXECUTE a specific SCREEN activity that displays help for the specific field.
Windowed Screens
CA-Easytrieve allows you to code pop-up windows or dialog boxes in your screen
declarations. Windows are easily coded by executing one screen activity from
another in which the second screen is smaller than the first. The following example
illustrates a pop-up window in which the terminal user is asked to confirm an
update request before the update is actually performed.
...
SCREEN NAME EMPLOYEE-UPDATE LINESIZE 80 ROWCOUNT 24
KEY F3 NAME 'Exit' EXIT
KEY F6 NAME 'Update'
TITLE 1 'EMPLOYEE RECORD'
ROW 3 'EMPLOYEE NUMBER' COL 24 EMP#
ROW 6 'SOCIAL SECURITY NUMBER' SSN
ROW 8 'LAST NAME' COL 24 NAME-LAST
ROW 10 'FIRST NAME' COL 24 NAME-FIRST
...
AFTER-SCREEN. PROC
EXECUTE CONFIRM-WINDOW
END-PROC
SCREEN NAME CONFIRM-WINDOW LINESIZE 40 ROWCOUNT 10 ROW 12 COL 20 +
BORDER (SINGLE)
KEY F6 NAME 'Update'
KEY F12 NAME 'Cancel' EXIT IMMEDIATE
TITLE 1 'Confirm Update'
ROW 3 'Are you sure?'
ROW 5 'Press F6 to update record'
ROW 6 'Press F12 to cancel update'
AFTER-SCREEN. PROC
MOVE PERSNL TO WORK-AREA
READ PERSNL KEY EMP#
MOVE WORK-AREA TO PERSNL
WRITE PERSNL UPDATE
MESSAGE 'Record updated.' LEVEL INFORMATION
EXIT
END-PROC
The first screen is defined as 24 rows by 80 columns. When the user presses F6 to
update the record, a second SCREEN activity, CONFIRM-WINDOW, is executed.
CONFIRM-ACTIVITY is defined as 10 rows by 40 columns and the upper-left
corner is located in row 12 column 20. This second screen overlays the first and
waits for the user to confirm the request before updating the record. The screen
looks like this:
EMPLOYEE RECORD
EMPLOYEE NUMBER 00370
Confirm Update
F3=Exit F6=Update
You can use an action bar with a pull-down menu in your application by invoking
overlay screens. The following screen has an action bar at the top of the screen:
EMPLOYEE RECORD
Options
+---------------+
...
When the user presses F10, the following pull-down menu is displayed:
EMPLOYEE RECORD
Options
+---------------+
| Find>> |
| Print | 00370
| | BER 256-52-8737
| |
| F3=Exit | NAGLE
+---------------+
Graph Processing
9
Overview
CA-Easytrieve provides a facility for producing bit-mapped presentation graphs
with a non-procedural technique similar to reporting. The styles of graphs
available include pie charts, bar charts, line graphs, and scatter diagrams. The
graph facility controls graph format making assumptions based on best-fit.
Basic Structure
The CA-Easytrieve graph facility is fully declarative; you need only define the
style and content of the graph, and CA-Easytrieve creates the necessary
instructions to produce it. The following exhibit illustrates the basic structure of
a CA-Easytrieve JOB with graph processing. You can define one or more graphs
for each JOB activity.
CA-Easytrieve Program
FILE
(library)
INPUT
DATA JOB
(job activity)
DRAW GRAPH1
DRAW GRAPH2
GRAPH GRAPH1
GRAPH GRAPH2
The DRAW statement activates the graph logic defined by GRAPH declarations.
CA-Easytrieve extracts the data required for the requested graph, formats it in
the specified manner, and sends it to the terminal for display and, optionally,
printing.
Graph Format
Title Area
Work Area
Title Area
The optional title area consists of a single line designated as the title by a TITLE
statement in the graph declaration.
Work Area
The work area contains the display of data points specified on the VALUE
statement. The y-value data points are optionally summarized and categorized
by x-value. The work area also displays a legend identifying the data.
CA-Easytrieve fields are identified by their headings. The following rules
control the heading; the order in which they are listed indicates the hierarchy of
override:
The function key area shows the system-defined function key assignments for
the graph view facility. Using these keys you can receive help, exit the view, or
print the graph to the default print device.
GRAPH Statement
■ SEQUENCE - optionally specifies the order of the graph values. You would
normally sequence the values by the x-value.
■ TITLE - defines optional title items and their position on the title line.
■ HEADING - optionally defines an alternative heading or label for a field.
■ VALUE - defines the content of the graph. The x-value is used as the
horizontal axis of the graph. One or more numeric y-values are used on the
vertical axis of the graph.
Processing a Graph
CA-Easytrieve performs the following steps to produce graphs:
Step 1: For each DRAW statement executed, a spool file record is written to a
temporary work file. The spool file record contains the contents of all the fields
coded in the GRAPH subactivity.
Step 2: At normal termination of the JOB activity, each graph spool file is closed,
optionally sequenced, and re-opened.
Step 3: A temporary graph metafile is created. This file becomes the input to the
Graph Display Facility. The Graph Display Facility actually displays the graph.
Step 4: Each record from the spool is read and the sequence and title fields are
discarded. The x-value and y-value fields are written to the metafile.
Step 7: The Graph Display Facility is invoked to display the graph via an
MS-DOS shell. This facility reads the metafile and performs the summation of
the y-values for duplicate x-values if SUMMARY is specified on the GRAPH
statement.
Step 9: If you press F6, the graph is printed to the default printer device.
Step 10: When you press F3, the Graph Display Facility terminates and deletes
the metafile.
Pie Chart
The following program produces a pie chart showing the summary of gross pay
categorized by region. If you do not specify a STYLE on the GRAPH statement,
CA-Easytrieve defaults to a pie chart.
FILE PERSNL
%PERSNL
JOB INPUT PERSNL NAME DISPLAY-GRAPH
DRAW PAY-BY-REGION
GRAPH PAY-BY-REGION SUMMARY
SEQUENCE REGION
TITLE ‘Gross Pay By Region’
VALUE REGION PAY-GROSS
The following program produces a vertical bar chart showing the summary of
gross pay categorized by region.
FILE PERSNL
%PERSNL
JOB INPUT PERSNL NAME DISPLAY-GRAPH
DRAW PAY-BY-REGION
GRAPH PAY-BY-REGION SUMMARY STYLE ‘VBAR’
TITLE ‘Gross Pay By Region’
VALUE REGION PAY-GROSS
The following program produces a horizontal bar chart showing the count of
employees by department. The numeric literal 1 is used to count the employees.
FILE PERSNL
%PERSNL
JOB INPUT PERSNL NAME DISPLAY-GRAPH
DRAW EMPLOYEES-BY-DEPARTMENT
GRAPH EMPLOYEES-BY-DEPARTMENT SUMMARY STYLE ‘HBAR’
TITLE ‘Employees By Department’
VALUE DEPT 1
Line Chart
The following program produces a line chart showing the summary of gross pay
categorized by region.
FILE PERSNL
%PERSNL
JOB INPUT PERSNL NAME DISPLAY-GRAPH
DRAW PAY-BY-REGION
GRAPH PAY-BY-REGION SUMMARY STYLE ‘LINE’
TITLE ‘Gross Pay By Region’
VALUE REGION PAY-GROSS
Scatter Diagram
System Services
10
This chapter first discusses how macros are invoked using the macro invocation
statement. Second, it discusses the two parts of a macro:
■ The macro prototype statement
■ The macro body.
Syntax
%macro-name [positional-parameters]...[keyword-parameters]
macro-name Supply the name of a previously stored macro that you want to
invoke.
Invoking Macros
To invoke a macro, you code a macro invocation statement anyplace within the
CA-Easytrieve source program. Macro invocation statements cause a series of
statements to be retrieved from the macro library and included as source
statements in the CA-Easytrieve program. The series of statements can be
modified by parameters supplied on the macro invocation statement.
Source Input Macro Library
macro-1
...
macro-1 invocation series of
... macro-1
macro-2 invocation statements
...
...
macro-2
series of
macro-2
statements
...
Produces
CA-Easytrieve input
...
macro-1
expanded
statements
...
macro-2
expanded
statements
...
Macro Library
Mainframe macro statements are stored and maintained in a macro library. Each
macro library is connected by your system administrator. You can enable or
disable the libraries as required. See the CA-Easytrieve/ESP User Guide for more
information.
Macro Files
UNIX and Workstation macro statements are stored as files. Each macro is
stored in a file named xxxxxxxx.mac where xxxxxxxx is the macro’s name. See
the CA-Easytrieve/Workstation User Guide or the CA-Easytrieve for UNIX User
Guide for more information.
CA-Easytrieve allows you to protect your macro statements with the use of an
ACCESS record. For both CA-Panvalet and VSAM macro storage access
methods, the ACCESS record can appear anywhere in the CA-Easytrieve
program prior to the retrieval of the macro, and remains in effect until the next
ACCESS record is encountered. The ACCESS record must be on a record by
itself. CA-Easytrieve does not print the ACCESS record. Refer to the
CA-Easytrieve/Online Administrator Guide for detailed information about creating
and maintaining macro libraries.
CA-Panvalet
VSAM
VSAM provides the capability of protecting the macro library through the use of
VSAM password protection. Before CA-Easytrieve can retrieve a macro from a
secured library, you must supply the library password on an ACCESS record
prior to the first macro call. The syntax is:
ACCESS 'eight-byte password'
Macro Definition
A macro’s name is the same as the member name in the macro storage library.
The following illustrates the parts of a macro:
PROTOTYPE
STATEMENT MACRO 2 NUMBER RESULT
**********************************************************
* *
* NAME: MACRO EXAMPLE *
* CALCULATE THE CUBE OF A NUMBER *
* *
BODY * FUNCTION: THIS MACRO CALCULATES THE CUBE OF A NUMBER.*
* *
**********************************************************
DEFINE CUBE_NUMBER_ S 6 N VALUE 000000
CUBE_NUMBER_ = &NUMBER * &NUMBER * &NUMBER
&RESULT = CUBE_NUMBER_
Optional
Termination MEND
Command
Positional Parameters
Use positional parameters when a value is always required for the parameter
each time the macro is invoked. Frequently used parameters are often
positional, since you need to code only the value of the parameter.
Keyword Parameters
Prototype Examples
Following are examples of macro prototype statements. The first example shows
a macro with no substitution parameters:
MACRO
...
...
This example shows a macro with only positional parameters. The number of
positional parameters is not indicated. You could have coded the optional
parameter as a 2.
This example shows a macro with only keyword parameters. Here you code the
number of positional parameters as zero. This is a required parameter when you
use keyword parameters.
MACRO 0 KEY1 VALUE1 KEY2 VALUE2
...
...
This example shows a macro with positional and keyword parameters. Here
you code the number of positional parameters as a 1.
MACRO 1 POS1 KEY1 VALUE1
...
...
Macro Body
The optional macro termination command is used at the end of a macro. Its
syntax is:
MEND
Macro Processing
Parameter Substitution
The rules for substituting macro parameters are the basic rules-of-syntax and the
following:
■ You must specify positional parameter values on the macro invocation
statement in the same order that they appear on the prototype statement.
Examples
The next example illustrates keyword parameter substitution. The default value
of a space for the second keyword entry (TYPE) is an efficient way to code
parameters that are used infrequently.
Macro invocation Macro member = FILE
This example illustrates the use of the ampersand within a macro body statement
and concatenated substitution words. The extra ampersand and the periods used
for concatenation are not part of the resulting statements.
Macro invocation Macro member = FILE
Produces
...
FILE TESTIN
NEW-SSN 1 9 N
NEW-MAIL 10 75 A, +
HEADING 'NAME & ADDRESS'
...
Instream Macros
Instream macros are placed at the beginning of the source input prior to any
other statements. Each instream macro is bounded by an MSTART and MEND
statement. The format of these statements is:
MSTART macro-name
MACRO 2 NUMBER RESULT
****************************************************************
* *
* NAME: MACRO EXAMPLE *
* CALCULATE THE CUBE OF A NUMBER *
* *
* FUNCTION: THIS MACRO CALCULATES THE CUBE OF A NUMBER. *
* *
****************************************************************
DEFINE CUBE_NUMBER_ S 6 N VALUE 00000
CUBE_NUMBER_ = &NUMBER * &NUMBER * &NUMBER
&RESULT = CUBE_NUMBER_
MEND
Macro-name is the name of the macro. It can be from one to eight characters long.
The first character must be alphabetic.
Example
MSTART EXMACRO
MACRO 2 NUMBER RESULT
PUSH
SKIP 1
SKIP 1
LIST OFF
*****************************************************************
* *
* NAME: MACRO EXAMPLE *
* CALCULATE THE CUBE OF A NUMBER *
* *
* FUNCTION: THIS MACRO CALCULATES THE CUBE OF A NUMBER. *
* *
*****************************************************************
POP
SKIP 1
DEFINE CUBE_NUMBER_ S 6 N VALUE 000000
SKIP 1
CUBE_NUMBER_ = &NUMBER * &NUMBER * &NUMBER
&RESULT = CUBE_NUMBER_
SKIP 1
MEND
*
DEFINE CUBED_RESULT W 6 N VALUE 000000 MASK (J 'ZZZZZ9')
JOB INPUT NULL NAME MACROI
%EXMACRO 3 CUBED_RESULT
DISPLAY CUBED_RESULT
STOP
Produce:
27
Glossary–1
external table JOB activity
Table data that is located in a file external to the An activity in a CA-Easytrieve program that
program. An external table is established just reads information from files, examines and
before use. manipulates data, writes information to files,
and initiates reports and graphs.
graph definition statements
A set of CA-Easytrieve statements that defines a label report format
graph style, format, sequence, and data content. An alternate CA-Easytrieve report format that is
used to prints labels.
graph format
The display format of a CA-Easytrieve graph, library section
consisting of a title area, work area, and An optional section of a CA-Easytrieve program
function key area. that describes the data to be processed by the
program. A library section is optional only if a
GRAPH subactivity program is not doing any input or output of
An area in a JOB activity where graphs are files.
described.
macro
hexadecimal literal One or more often-repeated CA-Easytrieve
A word used to code a value that contains source statements that you can save to use in
characters not available on standard data entry more than one program or multiple times within
keyboards. A hexadecimal literal must be a program.
prefixed with X’, and terminated with a single
quote, and can contain digits 0 through 9, and mask
letters A through F. A user-supplied sequence of characters against
which CA-Easytrieve edits data input into a
indexing numeric field.
A data reference that results from
CA-Easytrieve deriving a displacement value to MIXED format literal
correspond to a particular occurrence in a field A word that contains both DBCS and SBCS
name defined with OCCURS. See Array characters.
Processing for more information.
native SQL statements
input edit pattern CA-Easytrieve SQL statements, prefixed by the
A sequence of characters that describes the SQL keyword, that are equivalent to many of
format of the data in the field. those available in COBOL.
Glossary–3
state tables system default masks
Examine each character in a string to determine Edit masks supplied by CA-Easytrieve.
if the string is acceptable or not. Each character
examined causes a transition from one state to system-defined fields
the next. Most compilers use state tables for Special read-only data fields provided by
recognizing tokens, such as labels or identifiers. CA-Easytrieve that are stored as part of working
storage.
subscript
An integer (or a field containing an integer) that table
represents the occurrence number of the element A collection of uniform data records. The
within the array to be referenced. argument uniquely identifies a table entry; the
description is the remainder of the table entry.
Synchronized File Processing (SFP)
A facility in CA-Easytrieve that performs unsigned (non-quantitative) field
match/merge operations on multiple files, or A numeric field with no decimal positions.
compares the contents of a key field or fields
from one record to the next in a single file. Virtual File Manager (VFM)
A CA-Easytrieve sequential access method that
SYSPRINT processes work files needed by a program.
The default CA-Easytrieve system output
printer, whose actual destination is set in the W (work) working storage field
Site Options Table. A field that is copied onto the report work files
at the time a PRINT statement is executed.
evaluating 2-33
Arithmetic operators 2-32
%
Array processing 2-44
bounds checking 2-45
% (percent sign) 10-5 multiple dimension arrays 2-46
single dimension arrays 2-45
%macro-name 10-1 subscripting 2-49, 2-50
subscripts 2-78
Arrays
& displaying on a screen 8-27
two-dimensional 8-28
& (ampersand) 10-6, 10-7 ASCII
alpha (A) data format 2-17
alphanumeric literals 2-14
/ data formats 2-15
hexadecimal literals 2-14
Assembler calling convention 2-60
/C (compiler) compiler switch 2-73, 2-76
Assembler subprogram linkage 2-57
/FR (Far Reference) compiler switch 2-73, 2-76, 2-77
Assignment statement 2-7, 2-31, 2-35
mainframe EBCDIC to DBCS conversion 2-36
rules 2-36
A
Assignments and moves 2-31
Index–1
BASIC calling convention 2-60 CLOSE statement 4-18
BEFORE procedure 3-22 COBOL subprogram linkage 2-58
BEFORE-BREAK report procedure 7-39 Code system 2-15, 2-16
DBCS 2-18, 2-19, 2-20
BEFORE-LINE report procedure 7-38
Comma-delimited files 3-10, 3-35
BEFORE-SCREEN screen procedure 8-31, 8-33
Commit processing 2-25, 8-40
Binary fields 2-78
automatic 2-26
Binary numbers 2-7, 2-8 commit points 2-25
Index–3
Expressions, arithmetic 2-32 on the workstation 3-29
PRINTER device type 3-28
Extended reporting 7-46
SYSTEM parameter 3-2, 3-29
WORKAREA parameter 3-4, 3-6
Files
F BTRIEVE 3-33
CA-SuperCalc 3-35
FABS ISAM files 3-14 C-ISAM 3-38
on the workstation 3-32 closing 3-7
comma-delimited 3-35
FAR PASCAL calling convention 2-60 DBASE 3-33
FETCH statement 4-20 host mainframe 3-36
LOTUS 3-34, 3-36
Field definitions 2-5 opening 3-7
IDD interface 5-8 UNIX 3-37
Fields FILE-STATUS field 3-5, 3-6
assigning and moving 2-11
binary 2-78 FILL parameter 8-12
comparing 2-12 Fonts
copying 2-32 defined 7-46
defining 2-5 font codes 7-49
file fields 2-6 identification 7-49
integer 2-78
packed decimal 2-78 Footers
quantitative 2-7 page 7-41
unsigned (non-quantitative) 2-8 report 7-42
varying length 2-10, 2-11, 2-40 Format relationship rules
working storage 2-6 mainframe 2-20
File access modes 3-8 workstation 2-15
FILE statement 2-5, 3-2, 3-13, 3-15, 3-28, 7-32 Graph definition statements 9-3
CODE parameter 3-31 Graph Display Facility 9-4
EXIT parameter 2-54, 2-59, 2-62
MODIFY subparameter 2-63 Graph format
GRAPH subactivity 2-4, 2-23, 9-1, 9-4 IF CURSOR statement 8-38, 8-50
Index–5
Input mode 3-7 LINE-COUNT field 7-8
Input/output exits 2-62 LINE-NUMBER field 7-8
Instream macros 10-7 LINK statement 2-55
HOST parameter 2-74
Instream tables 2-42, 2-43
implementation 2-73
Integer fields 2-78 vs. CALL statement 2-71
workstation 2-73
Integer numbers 2-8
Linkage conventions
Interprogram linkage 2-54 mainframe 2-57
Invoking programs 2-71 workstation 2-60, 2-66
other CA-Easytrieve programs 2-54 Linking subprograms 2-13
subprograms in other languages 2-55
Literals
alphanumeric 2-14
DBCS format 2-22
J hexadecimal 2-14
MIXED format 2-22
JOB activity 2-4 types of 2-13
graph subactivity 9-2 Local Area Networks (LANs) 3-10
print file processing 7-4
Logical record definitions, IDD interface 5-8
Job flow 2-24
Logical records 5-11
JOB INPUT SQL statement 4-13, 4-23 use of 5-10, 5-15
JOB INPUT statement 3-27 Logical unit of work 2-26
JOB statement 3-23, 3-24, 4-18 LOTUS 3-10, 3-34, 3-36
synchronized file processing 3-24
JUSTIFY parameter 8-13
M
Index–7
POINT statement 3-23 R
Portability between mainframe and workstation 3-2
PRINT statement 2-7, 7-1, 7-2 READ statement 3-15
Printed output 3-28 Record address 3-5
Printer files 3-28 Record definitions, IDD interface 5-8
PRINTER parameter 7-43 Record format 3-4
on the workstation 3-30
Procedure
AFTER-BREAK 7-34 Record key 3-14, 3-17, 3-27
AFTER-LINE 7-34
RECORD-COUNT field 3-6, 4-13
AFTER-SCREEN 8-31
BEFORE 3-22 RECORD-LENGTH field 3-5, 4-13
BEFORE-BREAK 7-34
BEFORE-LINE 7-34 REFRESH action 8-30, 8-33, 8-34
BEFORE-SCREEN 8-31 Registers 2-57
ENDPAGE 7-34
INITIATION 8-31 Relative files 3-17
programmer-defined 8-33 adding records to 3-19
REPORT-INPUT 7-34 creating 3-19
sort 3-21 deleting a record 3-19
START 3-23 random input 3-18
TERMINATION 7-34 skip-sequential processing 3-18
TERMINATION 8-31 updating a record 3-20
Index–9
providing help screens 8-48 Sort flow 2-25
pull-down menus 8-52
Sort procedures 3-21
re-displaying 8-35
repeating data rows 8-27 SORT statement 3-20
restoring screen 8-34
rows 8-9 Sorting files 3-20
sample applications 8-45 Spooling subsystem 3-28
screen format 8-2
setting errors procedure 8-39 SQL data types 4-9
state tables 8-22 SQL databases
subscripts 8-27 accessing data 4-18
system-defined fields 8-6 automatic cursor management 4-2
terminal keys 8-6, 8-30 automatic processing 4-18
title area 8-7 automatic retrieval without file 4-3
title attributes 8-8 CA-Easytrieve SQL files 4-17
two-dimensional arrays 8-28 catalog INCLUDE facility 4-8
underscore entry field 8-12 COMMMIT command 2-28, 2-29
uppercase convert 8-15 communications area fields (SQLCA) 4-13, 4-25
using a menu 8-47 controlled processing 4-20
value checking 8-25 deleting from SQL file 4-23
work area 8-9 inserting SQL row 4-23
SCREEN statement 8-2, 8-4 joining tables 4-20
LINESIZE parameter 8-7 library section definition 4-7
native processing 4-25
SEARCH statement 2-43, 2-44 NULLable field processing 4-19
Security access code for macros 10-3 NULLable fields 4-8
overriding default SELECT statement 4-19
Segmented data 5-9 PARM statement parameters 4-4
programming methods 4-2
SELECT statement 3-22, 4-17, 4-18, 4-24
random processing 4-21
SEQUENCE statement 7-7, 7-17, 7-37, 9-3 retrieval without a file 4-23
ROLLBACK command 2-28, 2-29
Sequential access mode 3-8
syntax checking 4-12
Sequential files system-defined fields 4-13
automatic processing 3-11 updating CA-Easytrieve SQL files 4-22
CARD input 3-11
SQL DECLARE statement 4-25
controlled processing 3-11
fixed length 3-12 SQL INCLUDE statement 4-8, 4-17, 4-23, 4-26
variable-length 3-12, 3-13
SQL SET CURRENT SQLID statement 4-5
SEQUENTIAL files 3-10
SQL statement rules 4-3
SET statement 8-2, 8-10, 8-15, 8-27, 8-29, 8-39
SQLCODE field 4-18, 4-24, 4-26
example 8-46
SQLSYNTAX, in PARM statement 1-9
Shift codes 2-22
Stack usage 2-61
Signed (quantitative) fields 2-7
START procedure 3-23
Single dimension arrays 2-45
Statement order 2-5
Single file keyed processing 3-22, 3-27
STATUS parameter 3-5
Skip-sequential processing, relative files 3-18
STOP EXECUTE statement 7-4
SORT activity 2-4
Storage management
T
V
Table processing 2-42, 2-78
argument 2-42 VALUE parameter 8-25
defining tables 2-42
VALUE statement 9-2, 9-4
external tables 2-42
instream tables 2-42, 2-43 Varying length fields 2-10
search arguments 2-43 assigning and moving 2-11
SEARCH statement 2-43, 2-44 comparing 2-12
Index–11
rules 2-40 executing on 2-78
exit parameter list 2-62
Vertical axis on graph 9-4
FABS ISAM files 3-14
Vertical bar chart example 9-6 file code system 3-31
file exits 2-54, 2-59
Virtual File Manager (VFM) 2-79, 3-13, 7-4, 7-44 FILE statement 3-29
VSAM ESDS files 3-10 file types 3-30
files 3-29
VSAM files 3-4 fixed length relative files 3-17
creation 3-12 format and conversion rules 2-14
KSDS files 3-14 format relationship rules 2-15
VSAM password protection 10-3 HLLAPI 2-74
host interface 2-74
VSAM RRDS 3-17 invoking subprograms in other languages 2-62
VSE printer 7-54 LINK statement 2-73
linkage conventions 2-60, 2-66
Local Area Networks (LANs) 3-10
logical record length 3-31
W MODIFY exits 2-63
program linking 2-60, 2-65
PROGRAM statement 2-76
W (work) working storage fields 2-6
record format 3-30
WARNING message level 8-28 Relative files 3-17
SEQUENTIAL files 3-10
WORKAREA parameter 3-3 sort program 3-21
WORKFILE parameter, PARM statement 2-79 standard return code convention 2-61
storage management 2-60, 2-66
Working storage fields 2-6, 2-7 supported file types 3-32
Workstation synchronized file processing 3-22
allowed field types 3-31 TRANSFER statement 2-76
bounds checking 2-45, 2-79 WRITE statement 3-15, 3-16, 3-17, 5-15
CALL statement 2-60
CARD files 3-11
compiler switches 2-76
compiler switches 2-73 Z
data types supported (SQL) 4-30
error condition handling 2-65, 2-70
Zoned decimal numbers 2-7, 2-8
error conditions 8-26