Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Updating fields in an existing output record

&pagelevel(3)&pagelevel

The ISAM file PERSONNEL already exists and is available as output file; it has the following attributes:

RECORD-FORMAT = FIXED RECORD-SIZE = 60
KEY-POSITION  = 1     KEY-LENGTH = 4

Contents of the file PERSONNEL prior to the PERCON run:

Column 
1-4        5-17       18-29     30-34  35-39    41-60 
Pers.no.   Last name  1st name  Dpt.   Salary   Town 
0005       MILLER     HOWARD    A      06500    MANCHESTER 
0008       BROWN      KAREN     B1     04800    FULBOURN 
0012       INGRAM     OLIVER    A23    03450    UTTOXETER 
0015       ALBURY     IRENE     B12    02880    MANCHESTER 
0023       BERGER     ALBERT    A1     04250    NORWICH 
0036       BOTHA      BARBARA   K2     04300    WORTHING 

The file is to be updated, incorporating modifications in the salary and town columns. The update data is to be taken from the PERS.UPDATE file. A 3-character identifier is to be used to indicate the field to be updated. The personnel number (key field) is used to link input and output records:

Structure of the update records (variable record format):

Column 
5-7    8-11       12 - max. 31 
Id.    Pers.no.   Update data (depending on identifier) 
TWN    0015       READING             Change of town 
SAL    0008       05300               Change of salary 
TWN    0011       SHEFFIELD           Change of town, but pers.no. 
                                      not found 

PERCON statements:

/ADD-FILE-LINK LINK-NAME=PCOUT1 ,FILE-NAME=PERSONAL ,OPEN-MODE=*INOUT &* (1)
/ADD-FILE-LINK LINK-NAME=PCOUT2 ,FILE-NAME=PERSONAL ,OPEN-MODE=*INOUT
/START-PERCON &* ——————————————————————————————————————————————————————  (2)
//ASSIGN-INPUT-FILE FILE=*DISK-FILE(NAME=PERS.UPDATE) &* ——————————————  (3)
//ASSIGN-OUTPUT-FILE LINK-NAME=PCOUT1 &* ——————————————————————————————  (4)
//ASSIGN-OUTPUT-FILE LINK-NAME=PCOUT2 
//SELECT-INPUT-RECORDS - &* ———————————————————————————————————————————  (5)
//   CONDITION=((5,3)='SAL') ,OUTPUT-LINK-NAME=PCOUT1 
//SELECT-INPUT-RECORDS - &* ———————————————————————————————————————————  (6)
//   CONDITION=((5,3)='TWN') ,OUTPUT-LINK-NAME=PCOUT2 
//SET-RECORD-MAPPING - &* —————————————————————————————————————————————  (7)
//   OUTPUT-LINK-NAME=PCOUT1,-
//   FILLER=*OUTPUT(-
//      KEY-NAME=*PRIMARY,- 
//      KEY-VALUE=*BY-INPUT-RECORD(KEY-POSITION=8)),- 
//   OUTPUT-FIELDS=*FIELD(-
//      INPUT-POSITION=12,-
//      INPUT-LENGTH=5,- 
//      INPUT-FORMAT=*ZONED-DECIMAL,- 
//      OUTPUT-POSITION=35) 
//SET-RECORD-MAPPING - &* —————————————————————————————————————————————  (8)
//   OUTPUT-LINK-NAME=PCOUT2,-
//   FILLER=*OUTPUT(-
//      KEY-NAME=*PRIMARY,- 
//      KEY-VALUE=*BY-INPUT-RECORD(KEY-POSITION=8)),- 
//   OUTPUT-FIELDS=*FIELD(-
//      INPUT-POSITION=12,- 
//      INPUT-LENGTH=*RECORD-LENGTH(REDUCTION=7),- 
//      OUTPUT-POSITION=41,-
//      OUTPUT-LENGTH=20) 
//END &* ——————————————————————————————————————————————————————————————  (9)
%  PER0054 WARNING: KEY '0011' MISSING IN FILE ':2OS6:$WKST.PERSONAL', LINK='PCOUT2'
%  PER0030 NUMBER OF PROCESSED RECORDS FOR LINK='PCIN' (FILE=:2OS6:$WKST.PERS.UPDATE):                   3
%  PER0030 NUMBER OF PROCESSED RECORDS FOR LINK='PCOUT1' (FILE=:2OS6:$WKST.PERSONAL):                   1
%  PER0030 NUMBER OF PROCESSED RECORDS FOR LINK='PCOUT2' (FILE=:2OS6:$WKST.PERSONAL):                   1
%  PER0031 PERCON TERMINATED NORMALLY

(1)

If ISAM files are used, several ADD-FILE-LINK commands with OPEN-MODE=*INOUT and different link names can be issued for one and the same output file. These link names serve to establish links with the various PERCON statements.

Note

Specifying FILLER=*OUTPUT in the SET-RECORD-MAPPING statement ensures that the output files concerned are always opened with OPEN-MODE=*INOUT; the corresponding specification in /ADD-FILE-LINK is therefore optional.

(2)

PERCON is started.

(3)

The input file PERS.UPDATE, which contains the update data, is assigned.

(4)

The output file is assigned several times using different link names.

(5)

This statement selects those records from the input file which are to be used to update the “Salary” field via the identifier SAL. The link name PCOUT1 establishes the link with the SET-RECORD-MAPPING statement which modifies the field “Salary”.

(6)

This statement selects those records from the input file which are to be used to update the “Town” field via the identifier TWN. The link name PCOUT2 establishes the link with the SET-RECORD-MAPPING statement which modifies the field “Town”.

(7)

This statement causes a record from the output file to be used to pre-fill the output area. The record is selected using the field “Pers.no.” contained in the update record. The update data itself is to be transferred to the “Salary” field in the output record.

(8)

This statement causes a record from the output file to be used to pre-fill the output area. The record is selected using the field “Pers.no.” contained in the update record. The update data itself is to be transferred to the “Town” field in the output record.

(9)

The END statement starts the transfer operation and terminates PERCON.

Contents of the file PERSONNEL after a PERCON run using the above statements:

Two records have been updated, the ones with personnel numbers 0008 and 0015.

Column 
1-4        5-17       18-29     30-34  35-39    41-60 
Pers.no.   Last name  1st name  Dpt.   Salary   Town 
0005       MILLER     HOWARD    A      06500    MANCHESTER 
0008       BROWN      KAREN     B1     05300    FULBOURN —————————————— (10) 
0012       INGRAM     OLIVER    A23    03450    UTTOXETER 
0015       ALBURY     IRENE     B12    02880    READING ——————————————— (11) 
0023       BERGER     ALBERT    A1     04250    NORWICH 
0036       BOTHA      BARBARA   K2     04300    WORTHING 

(10)

In this record, the “Salary” field has been updated.

(11)

In this record, the “Town” field has been updated.

The file PERSONNEL does not contain any record with personnel number 0011. When the relevant update record is processed, message PER0054 is output.