![]() |
IR Insert Records from a Second file
Merging of two sequential files.
In the output file, record 1 of file 1 should be followed by record 2 of file 2, and so on.
ONXCONV' '='.ISAM',FCBTYPE=ISAM,IK (IK: Insert Keys)
The sequential files 1 and 2 are first converted into ISAM files using the ONXCONV Variable Action.
Enter M as an Action Code for the first ISAM file (File-1). Set DUPKEY mode on with the DUPK command.
IR 9999,file-2,K
Records from the second ISAM file will be inserted into the first file according to the respective key positions.
ONXCONV'.ISAM'='.SAM',FCBTYPE=SAM,EK
Terminate the display of file 1 with K1 and convert it back to a sequential file. The ISAM keys will be deleted (EK).
A string 'ABC' in the keys should be replaced by 'XYZ' in an ISAM file with KEYPOS=10 and KEYLEN=20. The resulting records will be sequenced according to their new keys. This can be achieved as described below.
S9999,:6-13:'ABC'=W CFS.DAT3
S9999,:6-13:'ABC'=D
ONXCONV' '='.SAM',FCBTYP=SAM
S9999,:6-13:'ABC'='XYZ'
ONXCONV'.SAM'='',FCBTYP=ISAM,KEYPOS=10,KEYLEN=20
IR9999,CFS.DAT3,K
All records from a Display file containing the string 'ABC' will be transfered to the file CFS.DAT3. These records must them be deleted from the Display file, since they will be re-inserted into the file as a last step, but with different keys, and at different positions.
The file CFS.DAT3 can be processed separately. Keys may not be amended using Search and Replace in CFS Editor, since it is an ISAM file. This is only possible if the ISAM file is converted to a temporary sequential file, CFS.DAT3.SAM, and the ISAM key is then amended as normal data with Search and Replace. The sequential file is then converted back to an ISAM file with its original format. Bringing the file CFS.DAT3 into the original Display file is achieved with the command IR 9999,CFS.DAT3,K.