The record processing sections are all optional sections used for specifying detailed processing and reporting on subsets of records. The sections correspond to the conditional clauses, MATCH BY clause, and MATCH ON clause in the command that calls the PM.
The discussion "Flow of Control in Record Processing" later in this chapter shows the effect of each record processing section on subsets of records. The effect depends on the command that calls the PM.
Four record processing sections are allowed with the commands ALTER, CHANGE, ENTER, DELETE, EXTRACT, LOAD, REPORT and Sort. The BEFORE, UNQUALIFIED and AFTER sections are only valid if a Master Data Set is related.
BEFORE/:M/ section is executed once for each qualified master record. A record is "qualified" if it passes the selection criteria in the command. It is executed before the DETAILS section, a SET clause, a SHOWING clause, and prompting in the CHANGE command. This section allows you to operate on the record before it is affected by any other clauses or statements.
DETAIL section is executed for each record that passes the selection criteria in the command. This section is where primary processing and detailed reporting occur. If a SET clause is specified in the command invoking the PM, it is executed before the DETAIL section is executed.
AFTER/:M/ section is executed after the DETAIL section is executed for each qualified record. If records are being updated, this section executes just before the master record is rewritten to the master data set.
UNQUALIFIED/:M/ section is executed for each record that failed the selection criteria in the command. If a WHEN clause is used for indexed retrieval, records are looked up through the index. Records that fail the WHEN clause are not read. If a WHEN clause is combined with an IF; UNLESS clause in a command, the IF; UNLESS clause is applied after the WHEN clause. Thus records that pass the WHEN clause but fail the IF; UNLESS clause are available in this section.
The following sections can be used with the commands MERGE, PURGE, SELECT & UPDATE.
The BEFORE/:M/ section is executed once for each qualified master record. Each master record is "qualified" if it passes the master selection criteria in the command. It is executed before the MATCHED or UNMATCHED:M section.
The MATCHED section is executed for each qualified master record that has a matching transaction record. A matched record may be processed by the MATCHED section several times. Multiple processing of a record depends on the ADVANCE option in the command and if a SETUP statement with a matching option is in effect.
The UNMATCHED/:M/ section is used with the MATCH ON clause for sequential processing. It is executed once for each master record that qualifies but does not have a matching transaction record. If the MATCH BY clause is used for indexed retrieval, only master records that match on the MATCH BY field are read. This section is therefore not executed, since unmatched records are not processed.
The AFTER/:M/ section is executed once after the MATCHED:M or UNMATCHED:M section for each qualified master record.
The UNQUALIFIED/:M/ section is executed once for each master record that failed the master selection criteria or the after conditional clause in the command invoking the PM.
The BEFORE:T section is executed once, before the MATCHED or UNMATCHED:T section, for each transaction record that passes the transaction selection criteria.
The UNMATCHED:T section is executed once for each transaction record that passes the transaction selection criteria but does not have a matching master record.
The AFTER:T section is executed once, after the MATCHED or UNMATCHED:T section, for each qualified transaction record.
The UNQUALIFIED:T section is executed once for each transaction record that fails the transaction selection criteria or the AFTER conditional clause in the command invoking the PM.
Process Modules (PM) invoked by the USE command differ very little from Data Manipulation PM’s in structure and design. They are used for calculations that do not involve the processing of a Master Data Set (DS). However, they may include operations on auxiliary DS’s. Data Sets processed in a PM invoked by the USE command must be read with the “GET” statement.
The PM sections available in a stand-alone PM
are as follows:CONTROL
DECLARE
DETAIL
EXCEPTIONS
FINAL
FOOTINGS
HEADINGS
INITIAL
PROCESS
TITLES
The DETAILS section executes only once. The automatic paging of TITLES, HEADINGS, and FOOTINGS operates the same as in a data manipulation PM.
The list below shows which records are available in which Process Module (PM) sections.
Data Set Fields are available for input in all the sections listed in the column below labeled “Available In". Whether they are available for update depends on the RELATE statement and the command that calls the PM.
Data Set |
Available In |
Not Available In |
|
Master |
PROCESS HEADINGS SUBHEADINGS FOOTINGS DETAIL BEFORE:M |
UNMATCHED:M AFTER:M UNQUALIFIED:M TOTALS MATCHED |
INITIAL TITLES* BEFORE:T UNMATCHED:T AFTER:T UNQUALIFIED:T FINAL |
Transaction |
PROCESS HEADINGS SUBHEADINGS FOOTINGS DETAIL MATCHED |
UNMATCHED:T AFTER:T UNQUALIFIED:T TOTALS BEFORE:T |
INITIAL TITLES BEFORE:M UNMATCHED:M AFTER:M UNQUALIFIED:M FINAL |
Auxiliary |
All sections |
— |
|
*First master record available |
The following table summarizes the availability of different types of fields and functions in each of the sections.
Master Data Set fields |
Not available in: Before:T, UNMATCHED:T, AFTER:T and UNQUALIFIED:T. |
Transaction Data Set fields |
Not available in: Before:M, UNMATCHED:M, AFTER:M and UNQUALIFIED:M. |
Declared Fields |
Available in all PM sections. |
Global Storage Fields |
Available in all PM sections. |
System Fields other than Record Information Fields |
Available in all PM sections. |
System Functions |
Available in all sections for input. |
Inter-record Functions |
Available only in TOTALS and FINAL sections. |
Any Data Set (DS) can be an auxiliary DS. The term auxiliary simply denotes the way in which a Process Module (PM) accesses and manipulates the particular DS. ACCENT R accesses all gateway Structured Query Language (SQL) data servers as auxiliary DS’s. An important feature of auxiliary DS’s is that they can be related more than once by simply assigning another designation.
An important distinction between auxiliary DS’s and master and transaction DS records is a manner of access. Master and transaction DS records are implicitly available for processing when the PM is run. The executable sections contain implied loops, which process each record in order from master and transaction sets.
In contrast, process statements entirely control access to auxiliary DS’s, and must explicitly state the order of access and the accessing mode. In executable sections of the PM, three record input-output statements are available for manipulating auxiliary DS’s. Records are accessed in auxiliary DS’s with a GET statement. The records can then be modified and written back to the same auxiliary DS with the PUT statement, or they can be removed from the DS with DELETE statements.
Two other record input-output statements, READY and CREATE, operate on auxiliary, master, and transaction DS’s. These statements can be used (in combination) to take information from one DS and use it as the basis for creating new records for another DS.
Within a PM, auxiliary DS’s are referenced by a designator assigned by you while ACCENT R assigns :M as the master designator and :T as the transaction designator. Assign the designator in a RELATE statement in the CONTROL section of the PM. The RELATE statement also specifies how each DS will be used in the PM. You must refer to the auxiliary DS by its designator unless it is the only DS related.
Up to one hundred auxiliary DS’s can be declared in one PM. One input-output channel is used by each DS and System File (SF) declared in a PM. Each Data Index (DI) requires two input-output channels: one for the DS, and one for the DI. Up to 10 reports can be related and assigned to system files.