Change

PURPOSE:  The CHANGE command creates an interactive environment in which to modify field values in records, delete records, or enter new records.  Records can be selected by a conditional clause, or by matching against values in key fields.  The command can also specify whether all or certain fields are available for change.  A variety of options allows control of search order, display of old records, the choice of editing or replacement of old field values, duplication, automatic changes to all qualified records, entry of new records, and deletion of records. 

The CHANGE command has two modes of operation, and each mode works with either sequential or indexed processing, creating four possible environments.

MODE 1:  Key Field Names in Command

In the command, specify only the name(s) of the field(s) that will be tested to see which records are changed.  ACCENT R then prompts for key field values that will identify the records to be changed.  The specific records are not identified in the command, but in response to later prompts.  ACCENT R prompts for new search field values to start the interaction, and after each change is completed.  This mode also allows entry of new records and deletion of records.  For sequential processing, this mode is accessed by the ON \\fields\\ clause.  For example:

*CHANGE ON PUB_CODE
PUB_CODE:: 1203
(change dialogue)
PUB_CODE:: 8713
.
.
.

For indexed processing, this mode is accessed by the change by \\fields\\ clause.

EXAMPLE

*CHANGE BY STORE_CODE
STORE_CODE:: 7549
(change dialogue)
STORE_CODE:: 8439
.
.
.

MODE 2:  Key Field Values in Command

The records to be changed are identified in a command clause.  ACCENT R then proceeds to move through the Data Set, either sequentially or in Data Index (DI) order, selecting the specified records and conversationally effecting the change.  For sequential processing, this mode is specified with an IF; UNLESS clause.  For example:

*CHANGE IF TITLE_CODE BEGINS WITH "C"

For indexed processing, this mode can be specified with the WHEN clause.  For example:

*CHANGE WHEN STATE = "CA"

The two modes are treated separately in the following descriptions.

SYNTAX

MODE 1:  Key Field Names in Command

CHANGE {/MATCH/ BY \fields\; /MATCH ON\ fields\} [SEARCH; PROCEED; NO ORDER]
[/USE/ DOMAIN name]
[{IF; UNLESS} clause]
FIELDS THRU NAME; FIELDS \names\
[WITH [&]PROMPTS]
[SHOWING clause]
[SET clause]
[{STOP; END} clause]
[DUP/LICATE/]
[/CHECK/; NO CHECK]
[VIA pm_name [ONLY]]
[EDIT [MODE] [TYPE DATA]]
[[ENTER [FIELDS THRU NAME; FIELDS \names\] ENTER WITH[&]PROMPTS]]

/MATCH/ BY \\fields\\

is used for indexed retrieval.  The key fields specified must be a left subset of the fields in the domain being used.  ACCENT R prompts for the key field entry values before each change dialogue.  This option also allows for the entry or deletion of records.

/MATCH/ BY \\fields\\ can be used with all other CHANGE clauses except /MATCH/ ON \\fields\\.

/MATCH/ ON \\fields\\

is used for sequential retrieval.  If none of the three options is specified, ACCENT R assumes that the Data Set (DS) is sorted on the ON fields and that the user will enter key values in order.  This is the most efficient choice if many changes are being made to a non-indexed DS, as it causes only one sequential pass through the DS.  ACCENT R prompts for the key field entry values before each change dialogue.  This option also allows for the entry or deletion of records.

/MATCH/ ON \\fields\\ can be used with all other CHANGE clauses except USE DOMAIN and /MATCH/ BY \\fields\\.

Supplying Key Field Values: Changing, Entering or Deleting

When key field names are given in the CHANGE command in either a MATCH ON \\fields\\ or a MATCH BY \\fields\\ clause, ACCENT R prompts for the values by displaying the key field names.  One of three responses is allowed to the prompt for key field values.

[C;]\\field_values\\ gives the new values in the order of the key fields specified in the command.  After supplying the values, ACCENT R searches for the first record that has matching key field values and also satisfies any conditional clause.  ACCENT R then prompts for the changes to that record.  [C;] is the default for change.

[D;]\\field_values\\.  The D; preceding the field value indicates to delete the specified record.  If a SHOWING clause is included in the command, the record is shown prior to deletion.

[E;]<CR> indicates the entry of a new record.  When a record is entered during the CHANGE command, ACCENT R prompts for and receives data as it does in the ENTER command.  The ENTER clause of the CHANGE command shows which options are available.  New records are added to the end of the current DS.

SEARCH

does a binary search rather than a sequential read of the DS.  The DS must be sorted in the order specified in the ON \\fields\\ clause.  This is the most efficient way to make a few changes to a very large DS that is not indexed.  SEARCH is not valid for multiple record type data sets.

PROCEED

allows search field values to be entered out of order.  If entering a search field value lower than the current record’s value, ACCENT R restarts its record search at the beginning.  Without PROCEED, ACCENT R requires confirmation before it begins a new sequential read of the DS.  See discussion of "Searching Out of Order".

NO ORDER

indicates that the records are not necessarily in the order specified in the ON field clause.  Each time new values are entered for the ON fields, ACCENT R begins a new sequential search of the DS.  This option involves high overhead costs, particularly if the search is restarted several times.

/USE/ DOMAIN name

specifies the domain of a declared DS.  If USE DOMAIN name is not specified, the first domain of the DI is used by default.

{IF; UNLESS} clause

can be used with either the ON or BY clause.  It further qualifies records that have already matched the key field values.  Described in detail in Chapter 7.

CHANGE FIELDS THRU NAME

makes all fields (except the record key field) available for change, allowing different fields to be changed in each record, but requires that both the field name and value be supplied for each change.  ACCENT R prompts with double colons (::) at the beginning of each new line.  The field name, a space, and the field value is entered.  All field names and values can be entered on one line, separated by the character in @DELIM (comma by default), or the information for each field can be input on a separate line.  The current value of @END_RECORD (** by default) must be used to terminate entry for a record.  If a field has multiple occurrences, the field name must be identified by a subscript number in parentheses.  The forms are:

CHANGE FIELDS THRU NAME

::fieldname (1) value

::fieldname (2) value

::fieldname value

::**

::fieldname value

… 

::**

or

::fieldname value, fieldname value,. . .,**

FIELDS THRU NAME can be used with all other clauses of the CHANGE command except FIELDS \\names\ and WITH [&]PROMPTS.

FIELDS \\names\\

limits changes to the named fields.  (The "M"  response to the confirmation check can override this clause).

If values are not given for all specified fields before the carriage return is typed, ACCENT R prompts with the name of the next field that requires a value.

If too many values are entered ACCENT R displays an error message: "!! TOO MUCH DATA FOR THE CURRENT RECORD."  All the field values can then be re-entered or the SLIM editor can be invoked to edit the line just entered by entering <CRTL> V twice.

FIELDS \\names\\ can be used with all other clauses of the CHANGE command except FIELDS THRU NAME and VIA pm_name ONLY.

If neither FIELDS THRU NAME or FIELDS \\names\\ option is included, ACCENT R expects changes to all fields of the record.

WITH[&]PROMPTS

causes ACCENT R to prompt for each field value at the beginning of a new line.  This clause has the same effect as the ENABLE PROMPTS command.  If PROMPTS is used, ACCENT R prompts with the field name.  If &PROMPTS is used, ACCENT R prompts with the field title if the field has a title; otherwise, the field name is used.

If WITH[&]PROMPTS is not used, ACCENT R prompts with double colons (::).  Values are entered on one line, separated by the character in @DELIM (comma by default).

WITH [&]PROMPTS can be used with all other CHANGE clauses except FIELDS THRU NAME and VIA pm_name ONLY.

SHOWING clause

displays (or saves) the specified information after the SET clause is applied but before accepting data changes.  Described in detail in Chapter 7.

SHOWING can be used with all other clauses of the CHANGE command.

SET clause

automatically makes the specified changes to each qualifying record before interactive changes are made.  Changes occur before the SHOWING clause is executed and before the DETAILS section of a specified Process Module (PM). Described in detail in Chapter 7. SET can be used with all other CHANGE clauses except VIA pm_name ONLY.

{STOP; END} clause

terminates the CHANGE command when the condition is satisfied. Described in detail in Chapter 7.

STOP; END can be used with all other clauses of the CHANGE command.

DUPLICATE

enables the value of a given field to be copied from the last record affected by CHANGE.  Instead of entering the value again, type the character currently in @DUPLICATE (= by default), and ACCENT R enters the field value from the last record.  This clause has the same effect as the ENABLE DUPLICATE command.

DUPLICATE can be used with all other CHANGE clauses except FIELDS THRU NAME and VIA pm_name ONLY.

/CHECK/; NO CHECK

allows the choice whether or not to check entered changes, entries, or deletions.  ACCENT R automatically performs a confirmation check for each record unless NO CHECK is expressed.  This allows for proofreading of the values that were just entered, or to abort altering the record.  If CHECK is in effect, ACCENT R prompts with the question:  OKAY?; OKAY TO DELETE?; OKAY TO ENTER?   depending on the operation being performed.

CHECK can be used with all other clauses of the CHANGE command.

VIA pm_name

declares a PM for manipulating records or validating changes.  With this form of the VIA clause, normal prompting occurs, and all other CHANGE clauses are allowed.

VIA pm_name ONLY

suspends normal field prompting, and does not allow WITH [&] PROMPTS, FIELDS THRU NAME, or FIELDS \\names\\.  Changes to the data within fields can be made through Screen Management Facility (SMF) screens and PM ACCEPT or RECEIVE statements.  However, this option can be combined with the record retrieval options, the SHOWING clause, and the CHECK clause, so that these built-in features can be used for record selection, display, and confirmation.

When either VIA pm_name or VIA pm_name ONLY is used with the ON \\fields\\ or BY \\fields\\ clause, the system field @OPER contains a key to the operation currently being performed (change, delete, or enter).

EDIT [MODE]

allows the use of the Single Line Image Editor (SLIM) on an existing field value, instead of typing in a replacement value.  If EDIT is specified without MODE, the edit mode is accessed by typing the <CTRL> V twice.  If <CTRL> V is not used, the replacement value is entered directly.  When MODE is included, the edit mode is automatically accessed.  All changes must then be accomplished by editing; direct entry is not allowed.

Since the EDIT option makes the old field value available for editing, the image of the previously entered value is not available for editing.

EDIT [MODE] can be used with FIELDS THRU NAME or WITH [&]PROMPTS.  It is also available when the "M" response is given during confirmation check.

When EDIT [MODE] is used with FIELDS THRU NAME, the field name can be followed by a carriage return.  Then, if MODE is in effect or <CTRL> V is typed twice, the old field value is available for editing.

When WITH [&]PROMPTS is used, DUPLICATE is allowed with EDIT, but not with EDIT MODE or EDIT  <CTRL> V <CTRL> V.

TYPE DATA

causes each old field value to be displayed before editing/entry of the field value.  If  FIELDS THRU NAME is in effect, the field name can be followed by a carriage return.  ACCENT R displays the field name and its value. The field name is displayed again as a prompt.  At this point, the new value can be entered, or the old value can be edited.  The edit clause is required with this option.

ENTER

specifies the option for entry of new records.  ACCENT R supplies blanks or zeros for any field not entered.  If an ENTER clause is not specified, any new records are entered without field prompts, on one or more lines; field values are separated by the character in @DELIM.  Data is expected for all fields, in the order they are described in the SD.

MODE 2:  Key Field Values in Command (no MATCH ON or MATCH BY clause)

CHANGE [/USE/DOMAIN name]
[WHEN clause]
[{IF; UNLESS} clause]
FIELDS THRU NAME; FIELDS \names\
[WITH [&]PROMPTS]
[SHOWING clause]
[SET clause]
[{STOP; END} clause]
[DUP/LICATE/]
[/CHECK/; NO CHECK]
[VIA pm_name [ONLY]]
[EDIT [MODE] [TYPE DATA]]

/USE/ DOMAIN name

is as described for Mode 1.

WHEN clause (and) IF; UNLESS clause

are the options used to specify the qualification criteria.  If neither of these options is specified, ACCENT R assumes that all records are to be changed in Data Set (DS) or domain sequence.  ACCENT R prompts for changes to each record until the last record has been changed, or until the @END_INPUT character (*** by default) has been entered.

WHEN clause

is used only for indexed retrieval.  It does a keyed retrieval of those records having the specified key field values.

The WHEN clause can be used with all other CHANGE clauses when a Data Index (DI) is declared.

{IF; UNLESS} clause

limits action to specified records of the DS.  For non-indexed DS’s, the IF; UNLESS clause causes ACCENT R to make one sequential pass through the DS, and the order of the DS is not important.

The IF; UNLESS clause can be used with all other clauses of the CHANGE command.  If it is used with the WHEN clause for indexed DS’s, it further screens records after they have been selected by the WHEN clause.  If an IF; UNLESS clause is used without the WHEN clause for an indexed DS, all records are examined in first domain order.  Described in detail in Chapter 7.

FIELDS THRU NAME; FIELDS \\names\\

are as described for Mode 1.

WITH [&]PROMPTS

is as described for Mode 1.

SHOWING clause

is as described for Mode 1.

SET clause

is as described for Mode 1.

{STOP; END} clause

is as described for Mode 1.

DUPLICATE

is as described for Mode 1.

/CHECK/; NO CHECK

is as described for Mode 1, with a couple of exceptions.  Since records cannot be added or deleted in Mode 2, the prompts and responses that apply to record entry and deletion are not valid.  The only other difference is that the "Y" and "I" responses cause ACCENT R to go on to the next qualifying record, rather than to prompt for the next key value.

VIA pm_name [ONLY]

is as described for Mode 1.

EDIT [MODE] [TYPE DATA]

is as described for Mode 1.

EXAMPLE

MODE 1:

The first example shows the use of several responses to the "Okay?" prompt.  It uses a MATCH ON \\fields\\ clause (ORD_DATE) so that ACCENT R will prompt for the values to be used to qualify the records.  Only the field ORD_NUM is to be changed.

The first response to the "Okay?" prompt, "F", tells ACCENT R to accept the change and get the next record having the same date.  The response "M" allows the user to change additional fields not specified in the FIELDS clause of the command.  The user changes the field STORE_CODE and signifies the end of the changes to that record with the @END_RECORD value "**'.  The response "C" signals that ACCENT R should prompt for a new ORD_DATE value.  The user wants to enter a new record, and therefore types "E;".  Since there is no ENTER clause in the command, ACCENT R expects data to be entered as it would for the ENTER command with no options.  As with ENTER, CHANGE prompts for any fields not entered before the carriage return.  After the last field is entered, CHANGE prompts with "Okay to Enter?" The response "Y"  causes the new record to be added to the DS, and then prompts for a new key field value.  The final response "T" tells ACCENT R to accept the change and terminate the command.

*USE DS SALES_DBM2

*SORT ON ORD_DATE, ORD_NUM

*CHANGE MATCH ON ORD_DATE FIELDS ORD_NUM SHOWING ORD_NUM,1B, STORE_CODE, 1B, QT
ORD_DATE

:: 01/01/1990
D4482 6360 10
:: D4428
Okay? F
P2121 6360 40
:: P2122
Okay? M
:: STORE_CODE 6418
:: **
Okay?
ORD_DATE:: E;
:: 6001,AX111,5/19/91
QTY: 30
PAY_TERMS: NET 30
TITLE_CODE: CP1707
Okay to Enter? Y
ORD_DATE:: 5/26/91
A143 5742 15
:: A1434
Okay? T

The next example uses a Data Index (DI).  Since no domain is specified, the first domain is used by default.  The MATCH BY \\fields\\ clause (BY TITLE_CODE) specifies that key field values are to be entered interactively.  The clause FIELDS THRU NAME allows the user to change any or all fields in each qualifying record by entering the field name with each value.  For the first qualifying record (TITLE_CODE CP2264) the user changes only the publication date.  For the second record chosen, the fields PUB_CODE, PRICE and ROYALTY are changed.  All changes are entered on one line.  For the third change, the user enters each field name and new value on a separate line.  The @END_INPUT value “***” terminates the command.  Since the option NO CHECK is in effect, ACCENT R prompts for a new search field value each time a change is completed.

*USE DS BOOKS_DBM2 DI BOOKS_DBM2

*CHANGE MATCH BY TITLE_CODE FIELDS THRU NAME NO CHECK

TITLE_CODE:: CP2264

:: PUB_DATE 05/10/1991,**

CUSTNO:: TR1717

:: PUB_CODE 1030,PRICE 3.15,ROYALTY 8,**

CUSTNO:: FL94776

:: PUB_CODE 1030

:: NOTES close-out special

:: ***

MODE 2:  EXAMPLES

This example uses a conditional clause to limit changes to sales records (PAY_TERMS= "NET 30") for order number A2976 (ORD_NUM = A2976).  The clause FIELDS AMOUNT limits changes to one field, and the WITH PROMPTS option causes ACCENT R to prompt with the field name.  When the user enters a wrong value for the first qualifying record, he answers "N" to the prompt "Okay?" so that the user will be prompted again and can enter the correct value.  ACCENT R continues to prompt for replacement values until the last qualifying record has been corrected, then returns control to command level.

*USE DS SALES_DBM2

*CHANGE IF ORD_NUM = A2976 AND PAY_TERMS = "NET 30" FIELDS AMOUNT &

SHOWING ORD_DATE, 1B, QTY WITH PROMPTS

09/01/90 50

AMOUNT: 25

Okay? N

AMOUNT: 35

Okay? Y

01/01/91 40

AMOUNT: 30

Okay? Y

.

.

.

*

NOTES:  When changing records, old data can be retained by typing only a carriage return or, if using SLIM in the EDIT clause, by returning a completely deleted line.  Zero or blank as data can be entered by typing a space before a carriage return.  Leading blanks and tabs are trimmed from entered data.

The character in @END_OCCURS (* by default) can be used to terminate entry to a subscript occurrence of a field before all elements are entered.  The value in @END_RECORD- (** by default) terminates changes to the current record.  The value in @END_INPUT (*** by default), typed at the beginning of a line, terminates the CHANGE command.

It is possible to change these and other controlling characters for CHANGE.

ACCENT R accepts system field and Global Storage (GS) field names wherever it expects data field values, and transfers the content as data entered.  If the name of a system field or GS field is itself to be entered as a data value, it must be preceded by the character in @LIT.

Searching Order and Efficiency:  With the MATCH ON \\fields\\ clause, ACCENT R assumes that the DS is ordered on the key fields given in the ON list, unless NO ORDER is specified.  Records are read in order until a record is found with matching key values.  ACCENT R ends the search when it encounters the end of the DS or a record that has a higher value in the key field than the specified value.  If a record is encountered that has a lower key field value than the preceding record, ACCENT R prompts with:

SEARCH KEYS OUT OF SEQUENCE (R, E, P, or ?)?

The responses allowed are as follows:

R

Causes ACCENT R to go back to the first record in the data set and restart a new sequential search.

E

Causes prompting for entry of new MATCH ON \\fields\\ values.

P

Suppresses this check for the rest of the command and automatically restarts the search anytime lower key field values are entered.  This response has the same effect as including PROCEED in the command itself.

?

Causes a brief explanation of the possible responses to be displayed at the terminal.

Processing is most efficient if all DS’s of key field values are given in the sorted order.  In addition, if only existing records are searched, the entire CHANGE session makes only one pass through the DS.  New records are added to the end of the DS.  The new records are not accessible to the current CHANGE command if the records are assumed to be in order; however, they are accessible if NO ORDER is specified.

For indexed retrieval with MATCH BY \\fields\\, the order of key field values is unimportant, since each data set (DS) entry of key field values causes a new indexed search.  New records are recorded in all domains of the Data Index (DI) as they are entered and are available for immediate subsequent processing.

Responses to Confirmation Checks:  When the CHECK option of the CHANGE command is specified or is in effect by default, ACCENT R performs a confirmation check on each record.  ACCENT R prompts with:

OKAY?, OKAY TO DELETE?, or OKAY TO ENTER?

Depending on whether the operation involves changes, entries, or deletions.  Respond in one of the following ways:

?

causes a brief explanation of the possible responses to be displayed at the terminal.

Y or <CR>

causes ACCENT R to accept the changes, new record, or deletion.  This response assumes that the user wants to change only the first qualifying record, and therefore prompts immediately for new key field values; compare with "F" below.  (In mode 2 this response causes ACCENT R to go on to the next qualifying record).

T, S or E

(terminate, stop, or end) causes the changes, entry, or deletions to be accepted, and terminates the command.

I

(ignore) cancels changes, entry, or deletion and prompts for new key values.  (In mode 2 this response causes ACCENT R to go on to the next qualifying record).

N

(no) cancels changes or entry, but retains the record and allows changes or entry again.

M

(more) holds current entry or changes, and allows more changing on the record.  The further changes must be in the format of the FIELDS THRU NAME option, and must be terminated with the @END_RECORD value (** by default).  ACCENT R again prompts for confirmation.  This response overrides the FIELDS \\names\\ option and makes all fields available for change.

C

(change) causes the changes, entry, or deletion to be accepted, and prompts for new key field values.

F

(following) causes changes or deletions to be accepted, and then enters a mode in which it continues to access the next record that matches on the current key field values and satisfies any conditional clause.  A "Y" or <CR> response then stays in this mode.  A "C" or "T" response cancels this mode.  If a new record is being entered, "F" confirms the record and causes ACCENT R to prompt for another new record.  (In mode 2 this response causes ACCENT R to go on to the next qualifying record).