MERGE control statement use in SORT - Tech Agilist (2024)

MERGE control statement use in SORT - Tech Agilist (1)

The MERGE control statement must be used when a merge operation is to be performed; this statement describes the control fields in the input records on which the input data sets have previously been sorted. Use the MERGE control statement:

  • To perform a merge application, where it describes the control fields for the previously sorted input records.
  • To perform a copy application.
  • To merge or copy up to 100 datasets with Blockset merge or up to 16 data sets with Conventional merge.

MERGE SYNTAX

 V | >>-MERGE--FIELDS=--+-(----p,m,f,s-+--)----------------------+---> | .-,---------------. | | V | | +-(----p,m,--+----+--s-+--)--,--FORMAT=f-+ | '-f,-' | '-COPY-----------------------------------' >--+--------------------------+-------------------------------->< | .-,------------------. | | V | | '-,---+-+-EQUALS---+---+-+-' | '-NOEQUALS-' | +-FILES=n--------+ +-+-FILSZ=x-+----+ | '-SIZE=y--' | +-SKIPREC=z------+ +-STOPAFT=n------+ '-Y2PAST=--+-s-+-' '-f-' 

MERGE FIELD EXPLANATION

OperandDescription
FIELDSSpecify as p, m, f, or s.
FIELDS=COPY or FIELDS=(COPY)Copies one or more input files to an output file. When FIELDS=COPY:Ignores all other MERGE operands, except SKIPREC and STOPAFT.CSI-SORT terminates when specified with SUM or INREC control statement.Default—None; optional.
FORMATUse only when all control fields in the entire FIELDSexpression have the same format.Default—None; must specify if not includedin FIELDS operand.
EQUALS NOEQUALSOverride options available at installation, such as DIAG, and
Supply optional information, such as ADDROUT and LABEL.
FILES/FILSZSpecifies number of input files to be merged or copied.
Specify as FILES=n, where n is any number from 1 through 9.
Default—None; must specify for merge applications; 1 for copy applications.FILSZ – Total number of records in input dataset.
SKIPRECSpecify as SKIPREC=n.
STOPAFTSpecify as STOPAFT=n.
Y2PASTTemporarily overrides the Y2PAST installation option, which specifies the sliding (s) or fixed (f) century window. The century window is used with DFSORT’s Y2 formats to correctly interpret two-digit year data values as four-digit year data values.Note: CENTURY=value and CENTWIN=value can be used instead of Y2PAST=value.

Additional information to know about the MERGE control statement is:

  • In the control fields, +0, 0, and –0 are treated as the same number and compare equal.
  • Input files must be either all SAM or all VSAM.
  • Specify the number of volumes using the VOLUME operand of the INPFIL control statement if any of the input files are multivolume and unlabeled or nonstandard labeled.

MERGE EXAMPLES

Example 1

MERGE FIELDS=COPY

FIELDS:Indicates copy the input file to the output file without merging. This is treatedlike a SORT of no fields.

Example 2

MERGE FIELDS=(2,5,CH,A),FILES=3

The FIELDS control field:

  • Begins on byte 2 of each record in the input files
  • Is five bytes long
  • Contains character, EBCDIC, data that will be sorted in ascending order.

FILES shows merge three input files

Example 3

MERGE FIELDS=(2,5,CH,A),FILSZ=29483

The FIELDS control field:

  • Begins on byte 2 of each record in the input files
  • Is five bytes long
  • Contains character, EBCDIC, data that will be sorted in ascending order.

FILSZ input data sets contain exactly 29483 records.

Example 4

MERGE FIELDS=(25,4,A,48,8,A),FORMAT=ZD,FILES=9
MERGE FIELDS=(25,4,ZD,A,48,8,ZD,A),FILES=9

FIELDS major control field:

  • Begins on byte 25 of each record
  • Is four bytes long
  • Contains zoned decimal data that will be sorted in ascending order

FIELDS second control field:

  • begins on byte 48
  • Is eight bytes long
  • Contains the same data format as the major field
  • Will be sorted in ascending order when the major control field is the same in two records

FORMAT operand is used because both control fields have the same data format—zoned decimal.

FILES indicates merging nine files.

Example 5

MERGE FIELDS=(3,8,ZD,E,40,6,CH,D)

The FIELDS control field:

  • Begins on byte 3 of each record, is 8 bytes long, and contains zoned decimaldata that is modified by your routine before the merge examines it.
  • The second control field begins on byte 40, is 6 bytes long, and containscharacter data in descending order.

Example 6

MERGE FIELDS=(25,4,A,48,8,A),FORMAT=ZD

The FIELDS control field:

  • The major control field begins on byte 25 of each record, is 4 bytes long, and contains zoned decimal data that has been placed in ascending sequence.
  • The second control field begins on byte 48, is 8 bytes long, is also in zoned decimal format, and is also in ascending sequence. The FORMAT parameter isused to indicate that both fields have ZD format.

MERGE with EQUALS

MERGE FIELDS=(1,8,CH,A,20,4,PD,A) OPTION EQUALS 

MERGE statement– FIELDS specifies an ascending 8-byte character control field starting at position 1 and an ascending 4-byte packed-decimal field starting at position 20. The records in each input data set must already be in the order specified.

OPTION statement– EQUALS specifies that the order of output records with equal control fields is to be based on the file number of the input data sets and the original order of the records within each input data set.

ICETOOL Utilities – MERGE Examples

IBM Reference: Click Here INCLUDE and OMIT Condition: Click Here

MERGE control statement use in SORT - Tech Agilist (2024)

References

Top Articles
Latest Posts
Article information

Author: Gov. Deandrea McKenzie

Last Updated:

Views: 6507

Rating: 4.6 / 5 (46 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Gov. Deandrea McKenzie

Birthday: 2001-01-17

Address: Suite 769 2454 Marsha Coves, Debbieton, MS 95002

Phone: +813077629322

Job: Real-Estate Executive

Hobby: Archery, Metal detecting, Kitesurfing, Genealogy, Kitesurfing, Calligraphy, Roller skating

Introduction: My name is Gov. Deandrea McKenzie, I am a spotless, clean, glamorous, sparkling, adventurous, nice, brainy person who loves writing and wants to share my knowledge and understanding with you.