JCL

MERGE control statement use in SORT

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

Operand Description
FIELDS Specify 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.
FORMAT Use only when all control fields in the entire FIELDS  expression have the same format. Default—None; must specify if not included in FIELDS operand.
EQUALS NOEQUALS Override options available at installation, such as DIAG, and
Supply optional information, such as ADDROUT and LABEL.
FILES/FILSZ Specifies 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.
SKIPREC Specify as SKIPREC=n.
STOPAFT Specify as STOPAFT=n.
Y2PAST Temporarily 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 treated like 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 decimal data that is modified by your routine before the merge examines it.
  • The second control field begins on byte 40, is 6 bytes long, and contains character 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 is used 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

Admin

Share
Published by
Admin

Recent Posts

Optimize Outer Join Queries in the COBOL DB2 Program

Optimize Outer Join queries is a powerful tool for retrieving data from multiple tables. However,…

3 months ago

OUTER JOIN Queries: Common Errors and Resolutions

OUTER JOIN Queries are a valuable tool in SQL, allowing you to retrieve data from…

3 months ago

Impediments: Examples and Strategies for Scrum Masters

Mastering impediments is crucial to the Scrum Master's role in fostering a high-performing Scrum Team.…

3 months ago

Sprint Goal in Scrum with Examples

A Sprint Goal is a short, clear, and motivating target the Scrum Team aims to…

4 months ago

Context Switching – Measure and Avoid

Context switching refers to changing focus or shifting attention from one task or activity to…

5 months ago

Motivate People to Use Scrum – Strategies and Examples

Embracing change is never easy, especially when it involves a shift in work methodology. Motivate…

6 months ago