INREC Control Statement - mfx - 3.1

Syncsort™ MFX Programmers Guide

Product type
Software
Portfolio
Integrate
Product family
Syncsort™ Software
Product
Syncsort™ MFX > MFX
Version
3.1
Language
English
Content type
Programmer’s Guide
Product name
Syncsort™ MFX
Title
Syncsort™ MFX Programmers Guide
Copyright
2024
First publish date
2010
Last updated
2024-08-27
Published on
2024-08-27T08:14:56.318001

The INREC control statement reformats the input records. Use the INREC control statement to add, delete, or reformat fields before the records are sorted or merged. Use the OUTREC control statement or the OUTREC parameter of the OUTFIL control statement to delete or reformat fields after the records are sorted or merged. Note that INREC is performed after E15 exit processing and INCLUDE/OMIT control statement processing.

Using the INREC control statement to delete data fields improves sort performance by reducing the number of bytes MFX must process. The same result may be achieved in some cases by changing the data format of certain fields. For example, if you need to change the format of a ZD field to PD, which reduces the number of bytes for the field, it is more efficient to use INREC rather than OUTREC for the conversion. Additionally, for SORT/MERGE processing PD fields are processed more efficiently than ZD fields.

Except for CONVERT, all the functions performed by the OUTREC control statement, such as inserting character strings or changing the data format of a numeric field, can also be performed by the INREC control statement. (See OUTREC Control Statement for an explanation of these functions.) For example, you can use the INREC control statement to insert zeros of the proper format to expand a numeric field before SUM or DUPKEYS processing to prevent arithmetic overflow. However, you will usually want to use the OUTREC control statement rather than the INREC control statement to expand the record because OUTREC processing takes place after records are sorted or merged.

There is one function available with INREC    that is not available with the OUTREC control statement or the OUTREC parameter of the OUTFIL control statement: the &MULTIINDD subparameter.

If you use the INREC control statement to reformat the input record, remember to use the post-INREC field positions when you specify the SORT, MERGE, SUM, DUPKEYS, OUTREC, and/or OUTFIL control statements.

If the SEQNUM function is used in a SORT application to insert a sequence number field in the record, this field will reflect the order of the records prior to sorting. In a MERGE application, the field will reflect the order of the records as they were read from each input in the merge.

INREC Control Statement Format

The format of the INREC control statement is illustrated below:
Figure 1. INREC Control Statement Format

See OUTREC Control Statement for a complete description of all of the INREC statement parameters, except for &MULTIINDD.

&MULTIINDD Subparameter (Optional)

The &MULTIINDD subparameter of the INREC FIELDS parameter is used together with the MULTIIN PARM, which directs MFX to read multiple input files from separate DD statements. &MULTIINDD is defined as the two-byte C’nn’ of the SORTMInn ddname (or the two-byte C’n ’ for SORTMIn) from which a record was read.

&MULTIINDD inserts the two-byte character string identifying the input record’s origin into the record produced by the INREC statement.

If the MULTIIN PARM option is not in effect, then &MULTIINDD is defined as two blanks (C’  ‘). If an E15 or E32 exit inserts a record, &MULTIINDD will be C’EX’ for that record. There will be no change to the &MULTIINDD definition when an E15 exit accepts or changes a record.

&MULTIINDD can only be specified on the INREC statement, including within the IFTHEN WHEN subparameter on INREC, and not on the OUTREC control statement or the OUTREC parameter of the OUTFIL control statement.

Sample INREC Control Statements

Figure 2. Sample INREC Control Statement

This INREC control statement specifies three data fields from an 80-byte record:

  • The first field begins in byte 1 of the input record and is 20 bytes long.

  • The second field begins in byte 40 of the input record and is a 15-byte ZD field. The data format is to be converted to PD. Since the input field contains 15 decimal digits, the converted PD output field created by MFX will be 8 bytes long.

  • The third field begins in byte 60 of the input record and is 5 bytes long.

These three fields have been positioned to begin in bytes 1, 21, and 29, as indicated by their column prefixes.

The reformatted input record is now just 33 bytes long.
Figure 3. Sample INREC Control Statement with &MULTIINDD

This INREC control statement can be used when multiple input files are for different time periods, but do not contain time-distinguishing data.

In this example, a report will be formatted with the year as the primary key when each of three input files is for a different year.

For comprehensive examples that illustrate the INREC control statement see How to Use the MFX Data Utility Features.