Section Description

Each of the sections are discussed in more detail on the next few pages.

CONTROL Section

The CONTROL section is the first section of the Process Module (PM).  It defines the scope of the processing environment by declaring the Data Sets (DS), Data Indexes (DI), Schema Definitions (SD), Global Storage (GS) areas, and System Files (SF) that are to be used.  All DS’s and SF’s used in any section of the PM must be specified in the CONTROL section.

The only statements allowed in the CONTROL section are RELATE statements.

Example

CONTROL section
RELATE DI PARTS AS MASTER FOR UPDATE
RELATE DS NEW PART AS TRANSACTION FOR INPUT
RELATE GS PARTS.UPDATE
RELATE SF UPDATE_PARTS.REP AS REPORT 1

DECLARE Section

The DECLARE section defines local variables and picture formats to be used during execution of the Process Module (PM).

The DECLARE section can contain PICTURE statements, Declared Field statements, and SCREEN LAYOUT statements from the Screen Management Facility (SMF).

Example

DECLARE SECTION
PART_ARRAY, C, 10, OCCURS 300
LOP_COUNT, I, MAX
PART_COUNT, I MAX

PROCESS Section

The PROCESS section contains ROUTINEs that can be called in later sections of the Process Module (PM).  Each group of statements that make up a ROUTINE is preceded by a ROUTINE name.  The kind of statements that can be included in the PROCESS section depend on what statements are allowed in the section(s) from which the ROUTINE will be called.  The limit on the number of ROUTINES that could be defined in a PM is 8191.

Example

PROCESS SECTION
ROUTINE FIND_PART
1 TO LOP_COUNT
START
LEAVE IF PART:M = PART_ARRAY (LOP_COUNT:D) OR LOP_COUNT>
PART_COUNT
INCR LOP_COUNT
REPEAT
IF LOP_COUNT\> PART_COUNT
PART:M TO PART_ARRAY(LOP_COUNT)
INCR PART_COUNT
CONTINUE

INITIAL Section

The INITIAL section is used to display instructions and assign or accept data to control the execution of other sections.  It can also be used to assign initial values to the declared fields and system fields.  This section is executed only once, before any master or transaction Data Set (DS) records are processed.  However, auxiliary DS records are available in this section.

Example

INITIAL SECTION
TYPE ‘Please enter process month: 'NOCR
ACCEPT PROCESS_MONTH

FINAL Section

The FINAL section is executed only once after all master Data Set (DS) records have been processed, and can contain the five inter-record functions, SUM, MIN, MAX, AVG, and STD_DEV (discussed later in this chapter).

The FINAL section can be used to specify final calculations, to store results in a report file, or to display final messages on the terminal screen.  No master or transaction records are available in this section.  However auxiliary DS records are available

Example

FINAL SECTION
TYPE “Total PARTS records:\”, @RECORDS:M
TYPE “Total NEWPART records:\”, @RECORDS:T

EXCEPTIONS Section

The EXCEPTIONS section is designed to handle unusual circumstances that may occur while executing a PM.  EXCEPTIONS must be the last section in the PM.

EXCEPTIONS can have two subsections - INTERRUPT and TERMINATION.  When an exception condition occurs, program control will be transferred to the proper EXCEPTION subsection.  This assumes that a condition has not been disabled.  For example, if interrupts were disabled, Control-C would be ignored and the exception condition would not occur.  Unless an EXIT PROCESS statement is executed in the sub-sections, control is returned to the section that called the EXCEPTIONS section.  The PM will then resume execution at the point of the exception condition.

INTERRUPT handles keyboard generated Control-C interrupts.  OpenVMS indicates the interrupt by displaying a reverse video "Cancel" message.  This message could disrupt the screen display.

TERMINATION handles abnormal termination of a PM.

Example

DECLARE SECTION
I.COUNT, I, MAX, PP = ""
DETAIL SECTION
TYPE "Enter something:  ", NOCR
ACCEPT @string
TYPE "The string you entered was:  ", @STRING@""
TYPE "There were  ", I.COUNT, " interrupts detected."
EXCEPTIONS SECTION
INTERRUPT
INCR I.COUNT