Setup STATEMENTS

PURPOSE:  The SETUP statement sets a flag that causes the specified action to occur after the current iteration of a PM section is completed.  It controls four separate functions: inclusion or omission of a given record in a DS or output set, the order of matching, simulation of the end-of-file condition, and updating of date and time system fields.  There is a form for each function.

SYNTAX

FORM 1: (SETUP)  Inclusion or Omission or Record

SETUP [NOT] /TO/ {OMIT /MASTER/; OMIT TRANSACTION; REWRITE

/TRASACTION/; INCLUDE /TRANSACTION/; IGNORE /CHANGED/} [HUSH]

[IF; UNLESS clause] [iterate clause]

NOT

reverses the action set previously in the same section by a previous SETUP TO statement.

OMIT MASTER

deletes the present master record.  If the master DS is related for UPDATE, the record is deleted from the master DS.  If the master is related for INPUT, the record is deleted from an output DS if one was specified.

OMIT TRANSACTION

causes the present transaction record to be deleted.  The transaction DS must be related for UPDATE.

REWRITE TRANSACTION

causes the present transaction record to be written back to its DS after processing is completed.  If this option is used, the transaction DS must be related with the option UPDATE in the RELATE statement.

INCLUDE TRANSACTION

appends the present transaction record to the master DS or an output DS if one is specified in the command.  The transaction SD must be the same as that of the master DS.  This statement can be used in the BEFORE:T, MATCHED, AFTER:T, or UNMATCHED:T section.  If the master is related for UPDATE, the statement appends the record to the master DS.

IGNORE CHANGED

is used in a PM called by the CHANGE command to prevent incorporation of entered changes and leave the record in its original state.  It should be used when a record fails a validation check.

Example

SETUP TO OMIT MASTER IF QTY:T = 0

NOTES:  The command that invokes a PM determines whether the master, transaction, or the output DS is affected.

The SETUP statement can be used anywhere within a section.  However, it causes the specified effect only when processing of the current record is completed.  It is generally used to override default conditions.  By default, ACCENT R sets up a condition at the beginning of record processing so that after the master record is processed by the section, it is rewritten to the master DS.  The SETUP TO OMIT MASTER RECORD sets a flag to override this default and delete the record instead.  On the other hand, transaction records, by default, are not rewritten to the transaction set, since default processing does not expect a transaction record to be updated.  Therefore, if a transaction record is to be updated, a flag must be set (SETUP TO REWRITE TRANSACTION) to write the record to the transaction set after processing of the record is completed.  Records are deleted “in place”.

Example

USE DS BOOKS
UPDATE WITH SALES ON BOOK.NO TO NBOOKS VIA PROBOOKS

In this example master records will be copied in their updated form to NBOOKS and the DS books not changed.  Therefore the statements:

SEE ALSO:  “Flow of Control in Record Processing sections

Setup Statement (FORM 2)

SYNTAX

FORM 2:  (SETUP) Order of Matching

SETUP [NOT] /FOR/ NEXT /MATCHING/ {MASTER; TRANSACTION} [HUSH]

[IF; UNLESS clause] [iterate clause]

NOT

reverses the action set previously in the same section by a previous SETUP TO statement.

MASTER

causes the first matching transaction record to be processed against all matching master records.  When a DI is declared, this statement applies every matching transaction to every matching master. 

TRANSACTION

causes the first matching master record to be processed against all matching transaction records. 

Example

This example will cause ACCENT R to hold the current transaction record to see if it matches the next master record, thus processing each transaction against all matching master records.

SETUP NOT FOR NEXT MATCHING TRANSACTION

NOTES:  A SETUP FOR NEXT MATCHING statement in a PM overrides any ADVANCE clause in the command that calls the PM.  If no SETUP FOR NEXT MATCHING statement occurs and there is no ADVANCE clause in the command, SETUP FOR NEXT MATCHING TRANSACTION is the default.

The one-for-one matching called for by ADVANCE BOTH in the command invoking the PM can be achieved in a PM by including two statements.  The order is not important.

00605   SETUP FOR NEXT MATCHING MASTER
00600   SETUP FOR NEXT MATCHING TRANSACTION

SEE ALSO:  Common Clauses

Setup Statement (FORM 3)

SYNTAX

FORM 3:  (SETUP) End-of-File Condition

SETUP [NOT] /FOR/ FINAL [HUSH] [IF; UNLESS clause] [iterate clause]

NOT

reverses the action set previously in the same section by a previous SETUP TO statement.

FINAL

set end-of-file condition on both the master and transaction data sets.  The FINAL section would typically be executed next, or the TOTALS, FOOTINGS, and FINAL for a PM that generates one or more reports.

Example

SETUP FOR FINAL IF ROYALTY:D = 0

Setup Statement (FORM 4)

SYNTAX

FORM 4:  (SETUP) Advancing Data and Time

SETUP CALENDAR

CALENDAR

sets current information to all Date and Time system fields.  By default, values are set to these fields at the beginning of command execution, and remain until control returns to command level.  Therefore, any of the fields accessed repeatedly during execution of a PM yield identical values at each access.  The SETUP CALENDAR statement within a PM section causes those fields to be advanced to current values immediately.