SORT Commands

This chapter describes how to use SORT commands and their operands.

1. Overview

The following table contains a list of SORT commands (operators) provided by OpenFrame. For usage and operand of each command, refer to the respective section.

Command Description

ALTSEQ

Alters certain characters in a specified order when performing SORT, MERGE, or COPY through the ALTSEQ conversion table.

DUPKEYS

Calculates the values of given fields for the same key value records and displays as one record, when executing SORT/MERGE.

END

Specifies the end of a SORT statement.

INCLUDE/OMIT

INCLUDE statement performs SORT/MERGE only with a record satisfying given conditions. OMIT statement performs SORT/MERGE only with the other records than those satisfying the given conditions.

INREC

Reformats input records according to a given format before performing SORT, MERGE or COPY.

JOINKEYS, JOIN, REFORMAT

Joins input data sets, specified in SORTJNF1 and SORTJNF2, into an output data set.

MERGE

Merges nn(the number of data sets specified in SORTINnn) input data sets into an output data set.

MODS

Registers user exit functions through scripts using a MODS control statement.

OPTION

Specifies options.

OUTFIL

Stores SORTOUT in the data set described in multiple OUTFIL DDs.

OUTREC

Reformats the output record before printing the result to the data set, specified in OUTFIL, after performing SORT, MERGE or COPY.

RECORD

Specifies the format and length of a record.

SORT

Sorts the input data set records by the given key in ascending or descending order, and prints them to the output data set.

SUM

Sums up all the values of the given field for the records with the same key value when performing SORT or MERGE, and prints the sum to one of the records.

2. ALTSEQ

Alters certain characters in a specified order when performing SORT, MERGE or COPY, through the ALTSEQ conversion table. You can change the order of keys or modify filtering conditions. OpenFrame follows the ASCII order.

Modification of the order applies only when executing SORT or MERGE, and does not change the output contents of the records.

Usage

The following example uses an ALTSEQ statement.

ALTSEQ CODE=(xxyy,xxyy,...,xxyy)
Operands

The following describes each operand.

  • CODE

    • Specifies an existing character to alter, and a new character for it to be altered to. For the new character, the order is modified according to xxyy.

    • The following describes each item.

      Field Description

      xx

      Specifies a two-digit hexadecimal number indicating the character whose order is to be altered.

      yy

      Specifies a new order.

    • The following example alters the order of 1 (ASCII number: 31) to a (ASCII number: 61) when performing SORT, and sorts the records in ascending order.

      SORT FILEDS=(1,8,AQ,A)
      ALTSEQ CODE=(3161)

3. DUPKEYS

Calculates the values of given fields for the same key value records and displays as one record, when executing SORT/MERGE. Except for the displayed record, all the other records are deleted. You can also delete all the other remaining records except for one record without performing operation on fields of records having the same key value.

Usage

The following example uses a DUPKEYS statement.

DUPKEYS function[,function]...[,FORMAT=f]|
 FIELDS=NONE|ALLDUPS|FIRSTDUP[,NODUPS]|LASTDUP[,NODUPS]|NODUPS|[,XDUP]
 where function is
 AVG|MAX|MIN|SUM=(p1,l1,[,f1][,p2,l2[,f2]]...)
Operands

The following describes each operand.

  • FORMAT=f

    • When field types used in operations are all the same, you can specify them all at once by using FORMAT=f after the COND statement without specifying the type in the field one by one.

    • The following example sums up FI type records of 10 to 2 bytes, 12 to 4 bytes, and 16 to 8 bytes.

      DUPKEYS SUM=(10,2,12,4,16,8),FORMAT=FI

      In OpenFrame, only when all of the control field types are the same, specifying FORMAT options is available.

  • FIELDS=NONE

    • Deletes all but one record with the same key value without operating records.

    • The following example deletes all records having the same key value except only one.

      DUPKEYS FIELDS=NONE
  • ALLDUPS

    • Deletes all records but those with the same key value without operating records.

    • The following example deletes all records except those having the same key value.

      DUPKEYS ALLDUPS
  • FIRSTDUP[,NODUPS]

    • Deletes all records with the same key value except for the first one without operating records. If you add NODUPS operand, the operand leaves records that do not have the same key value.

    • The following example deletes all records having the same key value except for the first one and those with different key values.

      DUPKEYS FIRSTDUP,NODUPS
  • LASTDUP[,NODUPS]

    • Deletes all but the last one of records with the same key value without operating records. If you add NODUPS operand, the operand leaves records that do not have the same key value.

    • The following example deletes all records having the same key value except for the last one.

      DUPKEYS LASTDUP
  • NODUPS

    • Deletes all records having the same key value without operating records, and leaves only those that do not have the same key value.

    • The following example deletes all records with the same key values and leaves only those with different key values.

      DUPKEYS NODUPS
  • XDUP

    • Stores the records deleted by the DUPKEYS command in the data set with the DD name SORTXDUP.

    • The following example stores records having the same key value to the data set with the DD name SORTXDUP.

      DUPKEYS NODUPS,XDUP
  • AVG|MAX|MIN|SUM

    • Specifies the key fields in order to calculate the input records. ()

      Item Description

      AVG

      Average operation

      MAX

      Maximum value

      MIN

      Minimum value

      SUM

      Total value

    • Determines the start position, length, and type of key fields.

    • The following describes each item.

      Item Description

      p

      Describes the starting position of the field to calculate. For more information, refer to p item of FIELDS in SORT.

      m

      Specifies the field length in bytes.

      f

      Specifies field type.

      s

      Sets a sorting standard for the control field.

      • A: Ascending order

      • D: Descending order

      • E: Custom order for user. (Not supported in OpenFrame)

    • The following example calculates ZD type records by summing up as 10 bytes from the starting point 10, and then by averaging as 4 bytes from the starting point 5.

      DUPKEYS SUM=(10,10,ZD),AVG=(5,4,ZD)
Note

Note the following when writing a DUPKEYS statement.

  • When NOEQUALS is specified in SORT/MERGE, which records are calculated or deleted is determined randomly.

    • For SORT, when EQUALS is specified, the remaining records are operated first in the input record.

    • For MERGE, when EQUALS is specified, the number is added to the smallest record in SORTINnn, and if SORTINnn is the same, it is added to the first record input.

  • When DUPKEYS is performed, only the contents of the specified record field are operated and the contents of other fields are not.

  • If an overflow occurs while DUPKEYS is performed, the operation is not performed and the records that do not perform the operation are also not deleted.

4. END

Specifies the end of the SORT statement. Commands following an END statement are not processed, and an END statement does not have additional operands.

The END statement can be omitted if "/*" or another JOB control statement comes immediately after the END statement.

Usage

The following example uses an END statement.

END

5. INCLUDE/OMIT

Sets a condition for an input record before performing SORT or MERGE.

An INCLUDE statement performs SORT or MERGE only with records that satisfy the given condition, while an OMIT statement performs SORT or MERGE with records that do not satisfy the condition. You can reduce the size of the input relational_condition record in order to enhance efficiency.

INCLUDE and OMIT cannot be used together.

Usage

The following example uses INCLUDE/OMIT statements.

{INCLUDE | OMIT} COND=(logical_expression) [,FORMAT=f]
logical_expression=relational_condition1,[AND | OR],[,relational_condition2[,....]]
relational_condition=([(p1,m1,f1)],[EQ|NE|GT|GE|LT|LE],[(p2,m2,f2)|NUM|constant])
Operands

The following describes each operand.

  • COND

    • Specifies a condition for records to perform SORT/MERGE.

    • Specifies a condition for input records to perform SORT, MERGE or COPY. If the logical operation value for each relational_condition of logical_expression is TRUE, the condition is satisfied. AND or OR is used as logical operators, and two or more relational conditions can be combined by using the logical operator. AND and OR can be replaced by ‘&’ and ‘|’ respectively.

    • The following example uses a logical_expression. If an eight-byte CH record starting from 5 is larger than that of one starting from 13, or a four-byte BI record starting from 105 is equal to or smaller than 1000, the record is included in SORT or MERGE operation.

      INCLUDE COND=(5,8,CH,GT,13,8,CH,OR,105,4,BI,LE,1000)
  • FORMAT=f

    • If all fields of relational_condition have the same format, you can use FORMAT=f after the COND statement to specify the format at once without specifying individual format for each field.

    • The following example uses FORMAT=f when all fields of the COND condition have the same format.

      • Condition 1: A one-byte CH record starting from 5 is equal to that of one starting from 8.

      • Condition 2: A one-byte CH record starting from 10 is A or B; or the one starting from 30 is neither C nor B.

      Records that satisfy both conditions 1 and 2 are excluded.

      OMIT COND=((5,1,EQ,8,1),&,((10,1,EQ,C’A’,|,10,1,EQ,C’B’),|,(30,1,NE,C’C’,&,30,1,NE,C’D’))),FORMAT=CH

      In OpenFrame, FORMAT=f can be specified only after a COND operand, and it can only be set when the control field formats are all the same.

  • relational_condition

    Specifies a relational condition for an input record. p1, m1, and f1 are information about field 1, and p2, m2, and f2 are information about field 2.

    • p

      Sets a starting position for field 1 and field 2. For more information, refer to 'p' in the FIELDS section from SORT.

    • m1, m2

      Sets a relative length from the starting position of field 1 and field 2, in bytes.

    • f1, f2

      Sets the format of field 1 and field 2. The following formats and lengths can be specified.

      Format Description Length Sign

      CH

      Character (ASCII)

      1 to 32,760 Byte(s)

      X

      AC

      Character (ASCII)

      1 to 32,760 Byte(s)

      X

      ZD (Zoned Decimal)

      Zoned decimal number

      1 to 18 Byte(s)

      O

      PD (Packed Decimal)

      Packed decimal number

      1 to 9 Byte(s)

      O

      FI (Fixed-point)

      Fixed-point binary number

      1 to 8 Byte(s)

      O

      BI (Binary Integer)

      Binary number

      1 to 8 Byte(s)

      X

      CSF or FS

      Signed number with optional leading floating sign

      1 to 17 Byte(s)

      O

      UFF (Unsigned Free Format)

      Unsigned free form number

      1 to 17 Byte(s)

      X

      SFF (Signed Free Format)

      Signed free form number

      1 to 17 Byte(s)

      O

      ASL

      Signed number, ASCII, leading separate sign

      1 to 18 Byte(s)

      O

      AST

      Signed number, ASCII, trailing separate sign

      1 to 18 Byte(s)

      O

      AQ

      Character (in the order defined in ALTSEQ)

      1 to 32760 Byte(s)

      X

    • EQ|NE|GT|GE|LT|LE

      Comparison fields are concatenated with a relational operator, and if the condition specified by the operator is satisfied, the result becomes TRUE. The following relational operators can be used.

      Relational Operator Description

      EQ

      Field 1 = Field 2

      NE

      Field 1 ≠ Field 2

      GT

      Field 1 > Field 2

      GE

      Field 1 >= Field 2

      LT

      Field 1 < Field 2

      LE

      Field 1 <= Field 2

    • NUM

      Relational expression used to determine whether a field is a number.

      x1y1...xmym

      If the result of expressing a field as a hexadecimal number is the same as the previous expression, the result of a relational expression with the EQ operator is as follows:

      • When f1 is CSF (or FS) or FORMAT=CSF (or FS) is described

        If x1=...=xm=3 and 0≤y1,...,ym≤9, the relational expression is true. Otherwise, it is false.

      • When f is ZD or FORMAT=ZD is described

        If x1=...=xm-1=3, xm∈{3,4,5,7}, and 0≤y1,.\..,ym≤9, the relational expression is true. Otherwise, it is false.

      • When f is PD or FORMAT=PD is described

        If 0≤x1,...,xm≤9, 0≤y1,...,ym-1≤9, and ym∈{C,D,F}, the relational expression is true. Otherwise, it is false.

        The result of a relational expression with the NE operator is contrary to that of a relational expression with EQ.

    • Constant

      Can be specified with decimal numbers (n, +n, -n), strings (C’xx...x’), and hexadecimal strings (X’yy...y’). The current date (DATE1) and a future date (DATE1+n) can also be used as strings.

      In a constant, a sign must be located before a number. A string must be enclosed by apostrophes ('), and to include apostrophes in a string, two apostrophes must be used consecutively.

6. INREC

Reformats input records according to a given format before performing SORT, MERGE or COPY.

Usage

The following example uses an INREC statement.

INREC PARSE=(parse_item[,parse_item[,...]]) |
      FIELDS=(reformat_command[,reformat_command[,...]]) |
      BUILD=(reformat_command[,reformat_command[,...]])
      OVERLAY=(reformat_command[,reformat_command[,...]])
      FINDREP={IN=incon,OUT=outcon | IN=(incon1,incon2[,...]),OUT=outcon |
               INOUT=(incon1,outcon1[,incon2,outcon2[,...]])}
              [,STARTPOS=p |ENDPOS=q]
      IFTHEN=WHEN=INIT,{BUILD | OVERLAY | FINDREP} |
                  WHEN=GROUP,BEGIN=(logexp),END=(logexp),RECORDS=n,PUSH=(items) |
                  WHEN=(logexp),{BUILD | OVERLAY | FINDREP} |
                  WHEN=NONE,{BUILD | OVERLAY | FINDREP}

[parse_item]

parse_item=%nn= { FIXLEN=m | ABSPOS=p | ADDPOS=x | SUBPOS=y |
               STARTAFT=string | STARTAFT=BLANKS |
               STARTAT=string | STARTAT=BLANKS | STARTAT=NONBLANK |
               ENDBEFR=string | ENDBEFR=BLANKS |
               ENDAT=string | ENDAT=BLANKS |
               PAIR=APOST | PAIR=QUOTE }

[reformat_command]

reformat_command=[c:] | s | %nn | p,m | p,m,TRAN=LTOU|UTOL | p,m,TRAN=ALTSEQ |
               p,m,Y2x | p,m,f,edit | p,m,f,to | arexp,edit | p,m,CHANGE | p,m,a |
               DATEn | DATE | &DATE | DATE=(abcd) | &DATE=(abcd) | TIME | &TIME |
               p,m,f,dateop | p,m,Yxx,todate | TIME=(abc) | &TIME=(abc) | seqnum | p,m,justify | %nn,justify | p,m,squeeze | %nn,squeeze
Operands

The following describes each operand.

  • PARSE

    • Extracts a fixed-length parsed field from a variable-length input record. You can use the parsed field where you can use (p,m) in BUILD or OVERLAY.

    • The following describes each item.

      Item Description

      %nn

      Converts variable-length input records to fixed-length output records. Use the parsed field anywhere you can use (p,m) in BUILD or OVERLAY.

      FIXLEN=m

      Specifies the length of the parsed field. This attribute must be present in all parse fields.

      ABSPOS=p

      Specifies the parse starting position p in the input record.

      ADDPOS=x

      Increases the parse starting position by x in the input record.

      SUBPOS=y

      Decreases the parse starting position by y in the input record.

      STARTAFT

      • STARTAFT=string: Starts the parsed field record after the first string of the input record.

      • STARTAFT=BLANKS: Starts the parsed field record after the first blank of the input record.

      STARTAT

      • STARTAT=string: Starts the parsed field record including the first string of the input record.

      • STARTAT=BLANKS: Starts the parsed field record after the first blank of the input record.

      • STARTAT=NONBLANK: Starts the parsed field record after the nonblank.

      ENDBEFR

      • ENDBEFR=string: Ends the parsed field record before the first string of the input record.

      • ENDBEFR=BLANKS: Ends the parsed field record before the first blank of the input record.

      ENDAT

      • ENDAT=string : Ends the parsed field record including the first string of the input record.

      • ENDBEFR=BLANKS : Ends the parsed field record including the first blank of the input record.

      PAIR

      • PAIR=APOST: Does not consider the areas enclosed by apostrophe (') as blanks or strings.

      • PAIR=QUOTE: Does not consider the areas enclosed by quote (") as blanks or strings.

  • FIELDS | BUILD

    • Specifies a key field to be selected by the input record. It sets a starting position for the key field and its length. When multiple fields are specified, the subsequent field follows the previous field, and is reformatted to the output record. If the record has a variable length (VB), and the record length is modified after reformatting, the contents of the record descriptor word (RDW) are also varied.

    • BUILD can be used instead of FIELDS.

    • The following describes each item.

      Item Description

      c:

      Specifies a starting position in the reformatted input record of the field, just after the c: option. The head of the record for FB and that of RDW for VB are each considered as 1.

      The position specified by c: cannot be the same as that of a previously selected field or the inserted blank. Any part that is not defined because of the c: option is filled with blanks.

      s

      Separation field for setting a string or blank.

      • nX: Inserts blank characters as many as n.

      • nC’xx...x': Inserts a character string. n means the number of times the string is repeated.

      • nX’yy...yy': Inserts a hexadecimal string. n means the number of times the string is repeated.

      DATEn

      Outputs the current date. OpenFrame only supports DATE1 which is displayed as C’yyyymmdd'.

      TIMEn

      Outputs the current time.

      n can be 1, 2, or 3, and each value has the following meaning.

      • 1: C’hhmmss'

      • 2: C’hhmm'

      • 3: C’hh'

      DATE=(abcd) or &DATE=(abcd)

      Outputs the current date in the format of C’adbdc'. d is a delimiter. a,b,c∈{M,D,Y,4}, and each value has the following meaning.

      • M: Displays two-digit month (01~12).

      • D: Displays two-digit days (01~31).

      • Y: Displays two-digit years.

      • 4: Displays four-digit years.

      DATE or &DATE

      Outputs the current date in the format of C’mm/dd/yy'.

      • mm: month (01-12)

      • dd: day (01-31)

      • yy: last two digits of a year

      DATENS=(abc) or &DATENS=(abc)

      Outputs the current date in the format of C’abc'.

      a,b,c∈{M,D,Y,4}, and each value has the following meaning.

      • M: Displays two-digit month (01~12).

      • D: Displays two-digit days (01~31).

      • Y: Displays two-digit years.

      • 4: Displays four-digit years.

      TIME or &TIME

      Outputs the current time in the format of C’hh:mm:ss'.

      • hh: hour (00-23)

      • mm: minutes (00-59)

      • ss: seconds (00-59)

      TIME=(abc) or &TIME=(abc)

      Specifies how to output an hour value. (24-hour type or 12-hour type)

      • ab: Specifies either 24 or 12 that means a 24-hour type and a 12-hour type respectively.

      • c: Delimiter that is inserted as C’hhcmmcss'.

      p,m

      Outputs a specified input record field to the output field.

      • p: Sets a starting position of the specified field. For more information, refer to 'p' of OUTREC in OUTFIL.

      • m: Sets the length of the output field in bytes.

      %nn

      Outputs the parsed record field of %nn label to the output field.

      p,m,TRAN=LTOU|UTOL

      • p, m: See the previous descriptions of p and m.

      • TRAN=LTOU: Changes small letters (lowercase) in the field to capital letters (uppercase).

      • TRAN=UTOL: Changes capital letters to small letters.

      p,m,TRAN=ALTSEQ

      • p, m: Same as the previous descriptions of p and m.

      • TRAN=ALTSEQ: Alters records in the field according to the ALTSEQ conversion table.

      p,m,Y2x

      • p: Same as the previous description of p.

      • m: Specifies the length of the output field displaying the year value.

      • Y2x: OpenFrame only supports Y2C displayed as C’yyyy'.

      p,m,f,edit

      Converts the specified field to a defined format, and outputs it to the OUTFIL record. For more information, refer to the OUTREC command in OUTFIL.

      p,m,f,to

      Converts the format of the input field. For more information, refer to the OUTREC command in OUTFIL.

      arexp,edit

      Converts an arithmetic expression to an edit format to reformat the input record. For more information, refer to the OUTREC command in OUTFIL.

      p,m,CHANGE

      Replaces the specified string of the input field with another string. For more information, refer to the OUTREC command in OUTFIL.

      p,m,a

      Outputs a specified input field to an output field. If the alignment is not correct, fields are left-padded with null characters (0x0).

      a can be H, F, or D, and each value has the following meaning.

      • H: halfword (2 bytes)

      • F: fullword (4 bytes)

      • D: doubleword (8 bytes)

      p,m,f,dateop

      Performs the date operation for the specified input field.

      Date operations are performed as follows:

      • ADDDAYS: Adds the number of days specified in the input field.

      • ADDMONS: Adds the number of months specified in the input field.

      • ADDYEARS: Adds the number of years specified in the input field.

      • SUBDAYS: Subtracts the number of days specified in the input field.

      • SUBMONS: Subtracts the number of months specified in the input field.

      • SUBYEARS: Subtracts the number of years in the input field.

      p,m,Yxx,todate

      Converts the specified input field into the format option specified with todate.

      The following values are supported for todate.

      • DT=(abcd):

        • a, b, c: Specify year (2-digit: Y, 4-digit: 4), month (M), day (D) in the desired order.

        • d: Specify the delimiter character between year, month, and day.

      • TOJUL=[Yaa | Yaa(s)]: Prints the input field in Julian date.

        • Yaa: Specify the Julian date format.

          • Y2T: C’yysddd' | C’yyddd'

          • Y2W: C’dddsyy' | C’dddyy'

          • Y2U: X’yydddf'

          • Y2X: X’dddyyf'

          • Y4T: C’ccyysddd' | C’ccyyddd'

          • Y4W: C’dddsccyy' | C’dddccyy'

          • Y4U: X’ccyydddf'

          • Y4X: X’dddccyyf'

        • s: Specify the delimiter character.

      • TOGREG=[Yaa | Yaa(s)]: Prints the input field in Gregorian date.

        • Yaa: Specify the Gregorian date format.

          • Y2T: C’yysmmsdd' | C’yymmdd'

          • Y2W: C’mmsddsyy' | C’mmddyy'

          • Y2V: X'0yymmddf'

          • Y2Y: X'0mmddyyf'

          • Y4T: C’ccyysmmsdd' | C’ccyymmdd'

          • Y4W: C’mmsddsccyy' | C’mmddccyy'

          • Y4V: X'0ccyymmddf'

          • Y4Y: X'0mmddccyyf'

        • s: Specify the delimiter character.

      seqnum

      Outputs a sequence number of the output record. The sequence number is added after the input record.

      OpenFrame supports the following formats.

      SEQNUM,n,fs[,START=j][,INCR=i][,RESTART=(p,m)]
      • SEQNUM: Specifies a command to output the sequence number.

      • n: Required option. Specifies the number of digits in the sequence number.

      • fs: Required option. Specifies the string format for the sequence number.

      • START=j: Can be omitted (if omitted, it is considered to be START=1). Set the starting value of the sequence number to j.

      • INCR=i: Can be omitted (if omitted, it is considered to be INCR=1). Set the increment value of the sequence number to i.

      • RESTART=(p,m): Can be omitted. If the specified field does not match the field of the previous record, SEQNUM is initialized to j.

      p,m,justify

      Converts the specified field to the defined format and outputs it. For more information, refer to the OUTREC command in OUTFIL.

      %nn,justify

      Converts the parsed record field of %nn label to the defined format and outputs it. For more information, refer to the OUTREC command in OUTFIL.

      p,m,squeeze

      Converts the specified field to the defined format. For more information, refer to the OUTREC command in OUTFIL.

      %nn,squeeze

      Converts the parsed record field of the %nn label to the defined format. For more information, refer to the OUTREC command in OUTFIL.

  • OVERLAY

    • Specifies an item with which to overwrite the output record. Columns that are not overwritten are output as they are.

  • FINDREP

    • Searches a specified variable in the input record, and replaces it with another variable.

    • For more information about variable replacement, refer to the FINDREP command in OUTFIL.

  • IFTHEN

    • Reformats different records in each different method according to given conditions.

    • For more information about specifying conditions, refer to the IFTHEN command in OUTFIL.

7. JOIN

Sets options to output which records. If not specified, records that satisfy the join condition from left data set (SORTJNF1) and right data set (SORTJNF2) are outputted. This is similar to inner join in database management system (DBMS).

Usage

A JOIN statement can be used as follows:

JOIN UNPAIRED,[F1|F2|ONLY][,[F1|F2|ONLY][,...]]
Operands

The following are available combinations of operands.

  • UNPAIRED,F1,F2 or UNPAIRED

    • Outputs records that satisfy the join condition from left and right data sets and the other records from both data sets. Similar to full outer join in DBMS.

  • UNPAIRED,F1

    • Outputs records that satisfy the join condition from left and right data sets and the other records from the left data set. Similar to left outer join in DBMS.

  • UNPAIRED,F2

    • Outputs records that satisfy the join condition from left and right data sets and the other records from the right data set. Similar to right outer join in DBMS.

  • UNPAIRED,F1,F2,ONLY or UNPAIRED,ONLY

    • Does not output records that satisfy the join condition and outputs the other records from the left and right data sets.

  • UNPAIRED,F1,ONLY

    • Does not output records that satisfy the join condition and outputs the other records from the left data set.

  • UNPAIRED,F2,ONLY

    • Does not output records that satisfy the join condition and outputs the other records from the right data set.

The following does not output records that satisfy the join condition and outputs the other records from the left data set.

JOINKEYS FILE=F1,FIELDS=(1,8,A)
JOINKEYS FILE=F2,FIELDS=(1,8,A)
JOIN UNPAIRED,F1,ONLY
REFORMAT FIELDS=(F1:1,80)

8. JOINKEYS

Specifies data sets to join, a join field, and other information used when performing join.

If the record format for the input data set is the V type, RDW must be considered for processing the record.

Usage

A JOINKEYS statement can be used as follows:

JOINKEYS {{FILE|FILES}={F1|F2}|F1=ddname|F2=ddname},FIELDS=(p,m,s[,p,m,s[,...]]) [,SORTED|INCLUDE=(logical_expression)|OMIT=(logical_expression)]+
Operands

The following describes each operand.

  • FILES (Alias: FILE)

    • When performing join, specifying FILES=F1 uses SORTJNF1 as the left data set and specifying FILES=F2 uses SORTJNF2 as the right data set.

    • The following joins SORTJNF1 and SORTJNF2.

      JOINKEYS FILE=F1,FIELDS=(1,7,A)
      JOINKEYS FILE=F2,FIELDS=(1,7,A)
  • F1

    • Uses the data set named ddname as the left data set.

    • The following joins DD1 and SORTJNF2.

      JOINKEYS F1=DD1,FIELDS=(1,7,A)
      JOINKEYS FILE=F2,FIELDS=(1,7,A)
  • F2

    • Uses the data set named ddname as the right data set.

    • The following joins SORTJNF1 and DD2.

      JOINKEYS FILE=F1,FIELDS=(1,7,A)
      JOINKEYS F2=DD2,FIELDS=(1,7,A)
  • FIELDS

    • Specifies a join field used to join input records.

    • The following describes each item.

      Item Description

      p

      Starting position of the control field. A starting position of a control field varies as follows:

      • When the input record is a fixed-length NVSM record (FB), the first byte of the record is 1.

      • When the input record is a variable-length NVSM record (VB), a four-byte RDW is added before the record, and the RDW begins from 1 while the actual record begins from 5.

      • When the input record is a VSAM data set, and it is processed as a variable-length record by OpenFrame SORT, an RDW beginning with 1 is added before the record, and therefore the actual data begins from 5.

      m

      Control field length.

      s

      Control field sorting order.

      • A: ascending order

      • D: descending order

    • The following performs join based on the first 7 bytes of SORTJNF1 and the first 7 bytes of SORTJNF2.

      JOINKEYS FILE=F1,FIELDS=(1,7,A)
      JOINKEYS FILE=F2,FIELDS=(1,7,A)
  • SORTED

    • If the input data set is TSAM, specify the record processing mode for the data set.

    • If the data set is the F type, do not include RDW in the record. If the data set is the V type, include RDW in the record. The default type is F.

    • The following example joins SORTJNF1 and SORTJNF2. SORTJNF1 is a TSAM data set, and the record processing type is V.

      JOINKEYS FILE=F1,FIELDS=(5,7,A),TYPE=V
      JOINKEYS FILE=F2,FIELDS=(1,7,A)
  • TYPE

    • It is recommended to specify this operand if input data sets are already sorted based on a join field.

    • The following joins SORTJNF1 and SORTJNF2. SORTJNF1 is already sorted based on the first 7 bytes.

      JOINKEYS FILE=F1,FIELDS=(1,7,A),SORTED
      JOINKEYS FILE=F2,FIELDS=(1,7,A)
  • INCLUDE

    • Joins records that satisfy the condition. For information about logical_expression, refer to INCLUDE.

    • The following joins records whose 9th byte is 'A' in SORTJNF1 and all records in SORTJNF2.

      JOINKEYS FILE=F1,FIELDS=(1,7,A),INCLUDE=(9,1,CH,EQ,C'A')
      JOINKEYS FILE=F2,FIELDS=(1,7,A)
  • OMIT

    • Joins records that do not satisfy the condition. For information about logical_expression, refer to OMIT.

    • The following joins records whose 9th byte is not 'A' in SORTJNF1 and all records in SORTJNF2.

      JOINKEYS FILE=F1,FIELDS=(1,7,A),OMIT=(9,1,CH,EQ,C'A')
      JOINKEYS FILE=F2,FIELDS=(1,7,A)

9. MERGE

Combines multiple input data sets defined in SORTINnn (where nn is a two-digit number and the first n can be 0) into an output data set. A number up to 99 can be specified for SORTINnn. Records in input data sets must be sorted based on a key field specified in the FIELDS option for MERGE statements.

When not using the FTOV or VTOF option for OUTFIL, both input and output data sets must use the same record format.

Usage

A MERGE statement can be used as follows:

MERGE FIELDS=(p,m,f,s[,p,m,f,s[,...]]) | (p,m,s[,p,m,s[,...]]),FORMAT=f | COPY
      [SKIPREC | STOPAFT | CKPT | EQUALS | NOEQUALS | FILES=n | FILSZ=[E|U]n |
       SIZE=[E|U]n | Y2PAST | CENTWIN]
Operands

The following describes each operand.

  • FIELDS

    • Specifies a key field to merge input records.

    • Specifies a starting position and the length of the key field, its format, and standards for merge operation.

    • The following describes each item.

      Item Description

      p

      Sets a starting position for the control field. For details, refer to 'p' in the FIELDS section of SORT.

      m

      Sets the length of the control field.

      f

      Sets a format for the control field. The list of available formats and lengths is the same as that for SORT.

      s

      Sets a sort standard for the control field.

      • A: ascending order

      • D: descending order

    • The following example merges a fixed-length character record from the first byte to the 7th byte in ascending order.

      MERGE FIELDS=(1,7,CH,A)

      The following example merges a three-byte variable-length character record starting from 5 in descending order. The RDW specified from 1 to 4 is excluded.

      MERGE FIELDS=(5,3,CH,D)

      In a variable-length record, the head of the actual record without RDW is 5. If a starting position for MERGE has been specified to a value between 1 and 4, an error will not occur, but MERGE will not successfully be operated as RDW is included.

  • FORMAT=f

    • If all the formats of control fields are the same as each other, the format can be set simultaneously by using the FORMAT=f command, rather than specifying the field in each control field.

    • The following example of FORMAT sets two CH-format fixed-length control fields. The ten-byte record from the first byte is sorted in ascending order, and the ten-byte record from the 11th byte is merged in descending order.

      MERGE FIELDS=(1,10,A,11,10,D),FORMAT=CH

      In OpenFrame, the FORMAT=f operand can only be used when the control field formats are all the same. For instance, when the format of a field is different to that of other fields, an error occurs if the format of the field is internally set, and the format of the other fields are set with FORMAT=f.

  • COPY

    • Copies an input data set record to the output data set without specifying the control field.

    • The following is an example of COPY.

      MERGE FIELDS=COPY

      When COPY is specified for MERGE, it is impossible to use multiple SORTINs. It outputs the input record as performing COPY for SORT, and so the merge function is not performed.

  • SKIPREC=x

    • Sets how many input records from the first record will be discarded without being sorted.

    • x means the number of records.

    • SKIPREC can be used only when the COPY command is used.

    • The following example of SKIPREC copies the input records, excluding the first to fifth records, to the output data set.

      MERGE FIELDS=COPY,SKIPREC=5
  • STOPAFT=x

    • Sets how many input records from the first record will be merged. The following records after the specified number are discarded.

    • x means the number of records.

    • STOPAFT can only be used when the COPY command is used.

    • The following example of STOPAFT copies the first to fifth input records, and discards the other records.

      MERGE FIELDS=COPY,STOPAFT=5
  • CKPT

    • Sets a check point.

    • In OpenFrame, it is supported only for preventing a syntax error.

  • EQUALS | NOEQUALS

    • Sets a sequence for output records whose control field contents are the same.

    • The following describes each item.

      Item Description

      EQUALS

      Records are output in the same order in which they are input. (stable sort)

      NOEQUALS

      It is not guaranteed that records are output in the same order in which they are input. (unstable sort, default value)

    • The following example of EQUALS sorts records using the contents of the control fields, but outputs records, whose control field contents are the same, in the same order in which they were input.

      MERGE FIELDS=(1,7,CH,A),EQUALS
  • FILES=n

    • Specifies the number of input files to MERGE with a decimal number.

    • In OpenFrame, it is supported only for preventing a syntax error.

  • FILSZ=[E|U]n

    • Specifies the number of records used for a sort.

    • In OpenFrame, it is supported only for preventing a syntax error.

  • SIZE=[E|U]n

    • Specifies the number of input records.

    • For more information, refer to OPTION.

  • Y2PAST | CENTWIN

    • For more information, refer to OPTION.

10. MODS

Registers user exit functions through scripts using a MODS control statement. A user exit function reformats a record passed from the previous level, and transfers it to the next. In a SORT or COPY operation, the user exit function E15 can be used to reformat input records. The user exit function E35 is used to reformat OUTREC result records. A MERGE operation uses E32, but it is not supported in OpenFrame.

Usage

A MODS statement can be used as follows:

MODS exit=(n1,m1[,s1][,L1]),…,exit=(nn,mn[,sn][,Ln])
Operands

The following describes each operand.

  • exit

    • Sets the name of the user exit function to be registered.

    • OpenFrame only supports E15 and E35.

      Function Description

      E15

      Processes input records. It retrieves records from the specified input data set, and passes them to a user defined position.

      E35

      Processes output records. It controls records before they are passed to the output data set after SORT or MERGE.

    • The following describes each item.

      Item Description

      n

      Sets a member name used in the library of user exit functions.

      m

      Sets the size of storage used by user exit functions in bytes. Not supported in OpenFrame.

      s

      Sets a DD name for the library where user exit functions exist.

      If this operand is omitted, STEPLIB is searched for the user function. If STEPLIB is not defined in JCL, the directory specified in the EXITLIB key of the sort subject from the PATH section under OpenFrame Configuration. For more information about OpenFrame Configuration, refer to OpenFrame Configuration Guide.

      L

      Sets whether or not a linkage editor is needed for user exit functions. Not supported in OpenFrame.

Examples

The following example of a user exit function passes all records.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int
EXIT(int  *record_flags,
     char *new_rec,
     char *return_rec,
     char *unused1,
     int  *unused2,
     int  *new_rec_len,
     int  *return_rec_len,
     int  *unused3,
     int  *exitarea_len,
     char *exitarea)
{
    if (*record_flags == 8)
        return 8; /* do not return */

    return 0; /* no action */
}

The next example copies and inserts all the records. Records a, b, c passed from the previous level are transferred to the next level as a, a, b, b, c, c.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int
INSERT(int  *record_flags,
       char *leaving_rec,
       char *return_rec,
       char *output_rec,
       int  *unused1,
       int  *leaving_rec_len,
       int  *return_rec_len,
       int  *output_rec_len,
       int  *exitarea_len,
       char *exitarea)
{
    static int inserted = 0;
    /* Inserted records are not modified */
    if (inserted) {
        inserted = 0;
        return 0; /* no action */
    }

    if (*record_flags == 8)
        return 8; /* do not return */

    memcpy (return_rec, leaving_rec, *leaving_rec_len);
    *return_rec_len = *leaving_rec_len;
    inserted = 1;

    return 12; /* insert record */
}

The following example registers a member name 'EXIT' to E15, and 'INSERT' to E35. The library file to be dynamically linked resides in the SYS1.JCLLIB directory, and this directory is specified with the DD name 'MYLIB.'

MYLIB DD DSN=SYS1.JCLLIB,DISP=OLD
….
MODS E15=(EXIT,3990,MYLIB),
      E35=(INSERT,3990,MYLIB)

11. OPTION

Specifies options.

Usage

An OPTION statement can be used as follows:

OPTION COPY | MSGPRT | PRINT | SIZE=[E|U]n | FILSZ=[E|U]n | CKPT |
       DYNALLOC[=([d][,n])] | OVFLO=(RC0|RC4|RC16) | SOLRF | NOSOLRF |
       SORTDD=cccc | SORTIN=ddname | SORTOUT=ddname | ZDPRINT | NZDPRINT |
       Y2PAST=(s|f) | CENTWIN=value | NULLOUT=(RC0|RC4|RC16) |
       VLSHRT | NOVLSHRT | VLTESTI=(0|1|2) |
       USE_ALTERNATIVE_TP_TYPE=(Y|N)
Operands

The following describes each operand.

  • COPY

    • Outputs SORTIN data sets as they are.

    • Functions in the same was as SORT FIELDS=COPY.

    • Overrides the SORT statement.

      In OpenFrame, OPTION COPY cannot be used with either a SORT statement or a MERGE statement.

  • MSGPRT

    • Specifies a message to print. In OpenFrame, it is supported only for preventing a syntax error.

  • PRINT

    • Functions in the same way as MSGPRT. In OpenFrame, it is supported only for preventing a syntax error.

  • SIZE=[E|U]n

    • Specifies the number of input records and raises an error if the specified number is different from the actual number of input records.

    • In OpenFrame Configuration, if the VALUE item of the FSZEST key in the OPTION section from the sort subject is set to YES, or E or U is specified before n, this option is ignored. For more information, refer to OpenFrame Configuration Guide.

  • FILSZ=[E|U]n

    • Specifies the number of records used for a sort.

    • In OpenFrame, it is supported only for preventing a syntax error.

  • CKPT

    • Sets a check point for using COPY.

    • In OpenFrame, it is supported only for preventing a syntax error.

  • DYNALLOC [=([d][,n])]

    • Dynamically allocates work data sets.

    • The following describes each item.

      Item Description

      d

      Sets the device type or group name for dynamic allocation.

      n

      Sets the number of work data sets for dynamic allocation.

    • In OpenFrame, it is supported only for preventing a syntax error.

  • OVFLO=[RC0 | RC4 | RC16]

    • Specifies how to process an overflow that occurred in the sum field.

    • The following describes each item.

      Item Description

      RC0

      Outputs a warning message once and returns 0 as a return value, when an overflow occurs.

      RC4

      Outputs a warning message once and returns 4 as a return value, when an overflow occurs.

      RC16

      Outputs an error and returns 16 as a return value, when an overflow occurs.

  • SOLRF| NOSOLRF

    • Specifies which length to be used when a SORTOUT record length is not specified.

    • The following describes each item.

      Item Description

      SOLRF

      Uses the length of the reformatted record. For the priority order of record lengths, refer to Data Set Definition.

      NOSOLRF

      Does not use the length of the reformatted record. The priority order of record lengths is as follows:

      1. Value specified in L3 of the RECORD statement

      2. Value specified through E15 in L2 of the RECORD statement

      3. The maximum length specified in SORTIN

      4. Value specified in L1 of the RECORD statement

  • SORTDD=cccc

    • Specifies 4 characters to replace 'SORT' of DD names used for data sets such as SORTIN, SORTnn, SORTOUT, and SORTWKnn.

  • SORTIN=ddname

    • Specifies a DD name used for a SORTIN data set. The length of the name can be up to 8 characters.

  • SORTOUT=ddname

    • Specifies a DD name used for a SORTOUT data set. The length of the name can be up to 8 characters.

  • ZDPRINT | NZDPRINT

    • Related to EBCDIC expressions for ZD fields. Since ZD fields are output in the ASCII format in OpenFrame, this option is not required.

    • In OpenFrame, it is supported only for preventing a syntax error.

  • Y2PAST=[s | f]

    • Temporarily overwrites the Y2PAST option with sliding(s) or fixed(f) century window.

      With the Y2 format, the century window is used to interpret a two-digit year value to a four-digit year value.

    • The following describes each item.

      Value Description

      s

      A starting value of the sliding century window is the value obtained by subtracting the s value from the current year (four digits). For example, when Y2PAST is set to 11 and the year is 2011, the century window becomes 2000 to 2099.

      f

      Sets a starting value of the fixed century window. For instance, when Y2PAST is 2011, the century window becomes 2011 to 2110.

  • CENTWIN=value

    • Functions in the same way as Y2PAST=value.

  • NULLOUT=[RC0 | RC4 | RC16]

    • Specifies the operation when the number of records to write in the SORTOUT dataset is zero.

    • The following describes each item.

      Value Description

      RC0

      Returns 0.

      RC4

      Returns 4.

      RC16

      Returns 16.

  • VLSHRT|NOVLSHRT

    • Specifies the operation when the specified field does not exist in the input record or only part of the field exists in the SORT, MERGE, INCLUDE, OMIT, or SUM operation.

    • The following describes each item.

      Value Description

      VLSHRT

      For SORT or MERGE operation, if the specified field does not exist in the input record or only part of the field exists, it is padded with null characters.

      • INCLUDE or OMIT operation: If the specified field does not exist in the input record or only part of the field exists, the relational expression is considered to be 'false'.

      • SUM operation: If the specified field does not exist in the input record or or only part of the field exists, the corresponding record is excluded for operation.

      NOVLSHRT

      If the specified field does not exist in the input record or only part of the field exists, an error occurs.

  • VLTESTI=(0|1|2)

    • Specifies the operation when the specified field does not exist in the input record or only part of it exists in an INCLUDE or OMIToperation.

    • The following describes each item.

      Value Description

      0

      The entire range of all fields in the INCLUDE or OMIT operation must exist in the input record. Otherwise, an error occurs. If the VLTESTI option is not specified, it operates as if VLTESTI=0 was specified.

      1

      For the INCLUDE operation, if the specified field does not exist in the input record or only part of the field exists, the record is not displayed. For the OMIT operation, if the specified field does not exist in the input record or if only part of the field exists, the record is displayed.

      2

      For the INCLUD or OMIT operation, if the specified field does not exist in the input record or only part of the field exists, the relational expression is considered to be 'false'.

12. OUTFIL

Stores SORTOUT in the data set described in multiple OUTFIL DDs. It is also used to filter and reformat records. It is possible to output the same records to each output data set, and to output different records by reformatting them in different ways. (Alias: OUTFILE)

Usage

An OUTFIL statement can be used as follows:

OUTFIL param[,param[,...]]
param = <FNAMES=ddname[,ddname[,...]> |
      <FILES=suffix[,suffix[,...]> | STARTREC | ENDREC | INCLUDE | OMIT |
      SAVE | OUTREC | PARSE | BUILD | OVERLAY | FINDREP | IFTHEN | SPLIT |
      SPLITBY | SPLIT1R | VTOF | CONVERT | VLFILL=c | FTOV | VLTRIM=c |
      NULLOFL | LINES | HEADER | TRAILER | SECTIONS | NODETAIL | REMOVECC |
      IFTRAIL
Operands

The following describes each operand.

  • FNAMES=ddname|(ddname,ddname,…​)

    • Sets an identifier of the DD name to store results of OUTFIL.

    • The identifier cannot be the same as an identifier of another OUTFIL statement. If the operand is omitted, ddname of the output data set is specified to SORTOUT.

    • When outputting the same records by equally processing multiple data sets, for instance, outputting the same contents to SORTOF01, SORTOF02, and SORTOF03, it is possible to specify the operand like the following.

      FNAMES=(SORTOF01,SORTOF02,SORTOF03)
  • FILES=suffix

    • Sets an identifier for the DD name to store results of OUTFIL.

    • When multiple records are output, 'SORTOF' is specified as a prefix by default, and a one- or two-character identifier is attached by using the FILES operand. The identifier must not be the same as that of other OUTFIL statements, and if the operand is omitted, the ddname of the output data set is set to SORTOUT.

    • When outputting the same records by equally processing multiple data sets, for instance, outputting the same contents to SORTOF01, SORTOF02, and SORTOF03, it is possible to specify the operand as in the following.

      FILES=(01,02,03)
  • STARTREC=n

    • Sets a starting position of OUTFIL in the input record.

  • ENDREC=n

    • Sets an end position of OUTFIL in the input record.

  • INCLUDE | OMIT

    • Outputs (INCLUDE) or excludes (OMIT) only records that meet the condition, from OUTFIL processing.

    • In a normal INCLUDE or OMIT statement, it is specified as "INCLUDE/OMIT COND=". In an OUTFIL statement, it is specified as "INCLUDE/OMIT=".

    • The only difference from a normal INCLUDE or OMIT statement is that it is impossible to set a format with the FORMAT=f operand in an OUTFIL statement.

  • SAVE

    • Outputs records that do not correspond to the previous filters after executing INCLUDE or OMIT.

  • PARSE

    • Extracts a fixed-length parsed field from a variable-length input record. You can use the parsed field where (p,m) can be used in BUILD or OVERLAY.

    • The following describes each option.

      Item Description

      %nn

      Converts variable-length input records to fixed-length output records. You can use the parsed field where (p,m) can be used in BUILD or OVERLAY.

      FIXLEN=m

      Specifies the length of the parsed field. This attribute must be present in all parse fields.

      ABSPOS=p

      Specifies the parse starting position p in the input record.

      ADDPOS=x

      Increases the parse starting position by x in the input record.

      SUBPOS=y

      Decreases the parse starting position by y in the input record.

      STARTAFT

      • STARTAFT=string: Starts the parsed field record after the first string of the input record.

      • STARTAFT=BLANKS: Starts the parsed field record after the first blank of the input record.

      STARTAT

      • STARTAT=string: Starts the parsed field record including the first string of the input record.

      • STARTAT=BLANKS: Starts the parsed field record after the first blank of the input record.

      • STARTAT=NONBLANK: Starts the parsed field record after the nonblank.

      ENDBEFR

      • ENDBEFR=string: Ends the parsed field record before the first string of the input record.

      • ENDBEFR=BLANKS: Ends the parsed field record before the first blank of the input record.

      ENDAT

      • ENDAT=string : Ends the parsed field record including the first string of the input record.

      • ENDBEFR=BLANKS : Ends the parsed field record including the first blank of the input record.

      PAIR

      • PAIR=APOST: Does not consider the areas enclosed by apostrophe (') as blanks or strings.

      • PAIR=QUOTE: Does not consider the areas enclosed by quote (") as blanks or strings.

  • OUTREC | BUILD

    • Reformats records that have passed through the record filter (INCLUDE or OMIT), before recording them in the OUTFIL DD. The only difference from a normal OUTREC statement is that in an OUTFIL statement, it is set to "OUTREC=" rather than "OUTREC COND=".

    • BUILD can be used instead of OUTREC.

    • The following describes each option.

      Option Description

      c:

      Specifies the starting position of an output record.

      s

      Inserts a separation field into the reformatted output record.

      • nX: Inserts n blank characters.

      • nC’xx…​x': Insert a character string. n is the number of times for repeating the string.

      • nX’yy…​yy': Inserts a hexadecimal string. n is the number of times of repeating the string.

      DATEn

      Outputs the current date. OpenFrame supports DATE1 only, displayed as C’yyyymmdd'.

      DATEn+r

      Outputs a future date. OpenFrame supports DATE1+r only, that is a date comprised of 'the current date + r days.'

      TIMEn

      Outputs the current time. n can be 1, 2, or 3, and each value has the following meaning.

      • 1: C’hhmmss'

      • 2: C’hhmm'

      • 3: C’hh'

      DATE=(abcd) or &DATE=(abcd)

      Outputs the current date in the format of C’adbdc'. d is a delimiter. a,b,c∈{M,D,Y,4}, and each value has the following meaning.

      • M: 2-digit month (01-12)

      • D: 2-digit day (01-31)

      • Y: last two digits of a year

      • 4: four-digit year

      DATE or &DATE

      Outputs the current date in the format of C’mm/dd/yy'.

      • mm: month (01-12)

      • dd: day (01-31)

      • yy: last two digits of a year

      DATENS=(abc) or &DATENS=(abc)

      Outputs the current date in the format of C’abc'. a,b,c∈{M,D,Y,4}, and each value has the following meaning.

      • M: 2-digit month (01-12)

      • D: 2-digit day (01-31)

      • Y: last two digits of a year

      • 4: four-digit year

      /…​/ or n/

      Inserts new lines as many as the number of '/' or n. In OpenFrame, up to five consecutive '/'s can be specified for /…​/, and for n/, there is no limitation.

      p

      Outputs a specified input record field to the output field. It sets a starting position for the key field. A starting position of an input record varies depending on circumstances.

      • When the input record is a fixed-length NVSM record (FB), the first byte of the record is 1.

      • When the input record is a variable-length NVSM record (VB), a four-byte RDW is added before the record, and the RDW begins from 1 while the actual record begins from 5.

      • When the input record is a VSAM data set, and it is processed as a variable-length record by OpenFrame SORT, an RDW beginning with 1 is added before the record, and therefore the actual data begins from 5.

      To execute OpenFrame SORT, it is required to set whether to determine a VSAM data set as a fixed-sized record or a variable-sized record. When one of the following three cases is satisfied, the data set is determined as a variable-sized record.

      1. When RECORD TYPE=V is set

      2. When SORTOUT is set to RECFM=VB

      3. When both SORTIN and SORTOUT are VSAM

      For a VB record, p in the first key field must be set to 1 at all times, and the key field must include a RDW. It is possible to set the field from 1 to 4, and then set the next field. It is also possible to set the first field from 1 to 4 or more. For the latter case, note that the actual record begins from 5.

      m

      Outputs a specified input record field to the output field. It specifies the length of the selected field in bytes.

      %nn

      Outputs the parsed record field of %nn label to the output field.

      p,m,TRAN=LTOU|UTOL

      • p, m: See the previous description.

      • TRAN=LTOU: Replaces small letters (lowercase) in the field with capital letters (uppercase).

      • TRAN=UTOL: Replaces capital letters in the field to small letters.

      p,m,TRAN=ALTSEQ

      • p, m: See the previous description.

      • TRAN=ALTSEQ: Modifies records of the field according to the ALTSEQ conversion table.

      p,m,Y2x

      • p: See the previous description.

      • m: Sets the length of an output field to display a year value.

      • Y2x: OpenFrame supports Y2C only, displayed as C’yyyy'.

      p,m,DTx

      • p: See the previous description.

      • m: Outputs a specified input record field to the output field. It specifies the length of the selected field in bytes. The format of the input record field is X'0cyydddF'. (c is 0 for 20 century or 1 for 21 century. yy is a two-digit year, and ddd is a three-digit day of the year.)

      • DT1: Outputs the input record field in the format of C’yyyymmdd'. yyyy is a four-digit year, mm is a two-digit month, and dd is a two-digit day.

      • DT2: Outputs the input record field in the format of C’yyyymm'. yyyy is a four-digit year, mm is a two-digit month.

      • DT3: Outputs the input record field in the format of C’yyyyddd'. yyyy is a four-digit year, and ddd is a three-digit day of the year.

      p,m,TMx

      • p: See the previous description.

      • m: Outputs a specified input record field to the output field. It specifies the length of the selected field in bytes. The format of the input record field is X’nnnnnnnF'. (nnnnnnn is the number of centiseconds since midnight.)

      • TM1: Outputs the input record field in the format of C’hhmmss'. hh is hour, mm is minute, and ss is second.

      • TM2: Outputs the input record field in the format of C’hhmm'. hh is hour, and mm is minute.

      • TM3: Outputs the input record field in the format of C’hh'. hh is hour.

      • TM4: Outputs the input record field in the format of C’hhmmssxx'. hh is hour, mm is minute, ss is second, and xx is centisecond.

      p,m,f,edit

      Converts a specified field to a defined format, and outputs it to the OUTFIL record.

      • p, m: See the previous description.

      • f: Sets a format of the field.

      • edit: Defines a format to convert the field into. For more information about the EDIT command, refer to EDIT Command.

      p,m,f,to

      Modifies the format of the input field.

      • p, m, f: See the previous description.

      • to: Specifies a format of the output record to convert the pattern 'f' of the input field to.

        When the format f of the input field is ZDF, the operation is the same as if f is ZD.

        The to command is set as follows:

        of|TO=[of|(of)][,LENGTH=[n|(n)]]
        • TO=[of | (of)]: Defines a format to convert to. 'TO=' can be omitted.

        • LENGTH=[n | (n)]: Defines the length of the output field to convert to.

      arexp,edit

      Converts an arithmetic expression to an editing pattern, and outputs it to an OUTFIL record.

      Means an arithmetic expression, with the following pattern.

      p,m,f,operator,n[,operator,n,...]
      • p, m, f: See the previous description.

      • n: A decimal number. Both positive and negative number can be set.

      A number of the form f from p to m is computed with n by using the operator. The following operators can be used:

      • MIN (minimum)

      • MAX (maximum)

      • MUL (multiplication)

      • DIV (division)

      • MOD (modulus)

      • ADD (addition)

      • SUB (sbutraction)

      The priority order of operators is as follows:

      1. MIN, MAX

      2. MUL, DIV, MOD

      3. ADD, SUB

      p,m,CHANGE

      Replaces a specified string of the input field with another string.

      • p: See the previous description.

      • m: Sets the length of the input field to compare with the string in find.

      • CHANGE: Replaces the compared string with the one that meets the condition. The syntax of CHANGE is as follows:

        CHANGE=(v,find,set[,find,set,...]),NOMATCH=(set)
        • v: Sets the length of the field to be output.

        • find: Sets a string to find from the input field.

        • set: Sets a string to output to the output field.

        • NOMATCH: If there is not a corresponding string in find, the NOMATCH option is specified. It is set to specify a string to output, when there is not a corresponding string to find.

      seqnum

      Outputs a sequence number of the output record. The sequence number is added after the output record. OpenFrame supports the following:

      SEQNUM,n,fs[,START=j][,INCR=i][,RESTART=(p,m)]
      • SEQNUM: Indicates a command to output a sequence number.

      • n: Specifies the number of digits for the sequence number. Required option.

      • fs: Specifies a string format for the sequence number. Required option.

      • START=j: Can be omitted (if omitted, it is considered to be START=1). Set the starting value of the sequence number to j.

      • INCR=i : Can be omitted (if omitted, it is considered to be INCR=1). Set the increment value of the sequence number to i.

      • RESTART=(p,m): Can be omitted. If the specified field does not match the field of the previous record, SEQNUM is initialized to j.

      p,m,justify

      Converts the specified field to the defined format and outputs it as OUTFIL record. OpenFrame supports the following:

      JFY=(SHIFT=(LEFT | RIGHT),[LENGTH=n],[PREBLANK=list],[LEAD=string],[TRAIL=string])
      • SHIFT: Specifies whether to align the left after removing the left blanks or align the right after removing the right blanks.

      • LENGTH=n: Specifies the length of the output field of FY. If not specified, it is the same as the length of the input field.

      • PREBLANK=list: Converts one or more strings to blanks.

      • LEAD=string: Specifies a string before the first nonblank field.

      • TRAIL=string: Specifies a string after the last nonblank field.

      %nn,justify

      Converts the parsed record field of %nn label to the defined format and outputs it.

      p,m,squeeze

      Converts the specified field to the defined format and outputs it as OUTFIL record. OpenFrame supports the following:

      SQZ=(SHIFT=(LEFT | RIGHT),[LENGTH=n],[PREBLANK=list],[LEAD=string],[MID=string],[TRAIL=string],[PAIR=(APOST | QUOTE)])
      • SHIFT: Specifies whether to align left or right after removing all blanks.

      • LENGTH=n: Specifies the length of the output field of SQZ. If not specified, it is the same as the length of the input field.

      • PREBLANK=list: Converts one or more strings to blank.

      • LEAD=string: Specifies a string before the first nonblank field.

      • MID=string: Specifies a string in the area where blanks are removed between the first and last nonblank fields.

      • TRAIL=string: Specifies a string after the last nonblank field.

      • PAIR=(APOST | QUOTE): Cannot remove blanks for the record values between single quotation marks ('') or double quotation marks (" "), or convert the record values to blanks with PREBLANK.

      %nn,squeeze

      Converts the parsed record field of the %nn label to the defined format and outputs it.

  • OVERLAY

    • Sets what to overlay the output record with. Non-overlaid rows are output as they are.

      Parameters used in OUTREC or BUILD can be used for OVERLAY, with the exception of the '/' syntax.

  • FINDREP

    • Searches for a specified variable from the input record, and replaces it with another.

    • Searches for a string corresponding to incon from the input record, and replaces it with another string specified in outcon.

      IN=incon,OUT=outcon
    • Specifies multiple strings in the input record, and replaces them with outcon.

      IN=(incon1,incon2[,...]),OUT=outcon
    • Searches for a string corresponding to inconi from the input record, and replaces it with another string specified in outconi. (i ≥ 1)

      INOUT=(incon1,outcon1[,incon2,outcon2[,...]])
    • Sets a position in the input record where the search starts. If not specified, 1 is set by default.

      STARTPOS=p
    • Sets a position in the input record where the search ends. If not specified, the search is performed to the last row of the record.

      ENDPOS=q
  • IFTHEN

    • Reformats different records in each different method, according to given conditions.

    • The following expression can be used once or more to apply the BUILD, OVERLAY, or FINDREP reformatting function. WHEN=GROUP has the highest priority among other items of IFTHEN=INIT.

      WHEN=GROUP,BEGIN=(logexp),END=(logexp),RECORDS=n,PUSH=(items)
      Option Description

      BEGIN=(logexp)

      Starts a new group when the logexp condition is met.

      END=(logexp)

      Ends the current group when the logexp condition is met.

      RECORDS=n

      Ends a group when the number of records belonging to the group reaches n.

      PUSH=(items)

      • c:p,m: Overlays the values for p,m in the first record of the group to position c.

      • c:ID=n: Represents a group ID of length n. Overlays the current group ID to position c.

      • c:SEQ=n: Represents a record sequence in a group of length n. Overlays the record sequence in the current GROUP to position c.

    • The following expression can be used once or more to apply the BUILD, OVERLAY, or FINDREP reformatting function. WHEN=INIT has the highest priority among other items of IFTHEN=GROUP.

      WHEN=INIT,BUILD/OVERLAY/FINDREP
    • If the input record satisfies the logical expression specified in logexp, the following expression can be used once or more to apply the BUILD, OVERLAY, or FINDREP reformatting function.

      WHEN=(logexp),BUILD/OVERLAY/FINDREP
    • If the input record does not satisfy all the logical expressions specified in logexp, the following expression can be used once to apply the OVERLAY and FINDREP reformatting function.

      WHEN=NONE,BUILD/OVERLAY/FINDREP
  • SPLIT | SPLITBY | SPLIT1R

    • Outputs reformatted records to multiple OUTFIL data sets in order.

      Option Description

      SPLIT

      Sequentially outputs records to multiple output data sets one by one.

      SPLITBY=n

      Sequentially outputs to multiple output data sets n records each time. SPLIT is equivalent to SPLITBY=1.

      SPLIT1R=n

      Sequentially outputs to multiple output data sets n records each time, and then outputs all the remaining records to the last data set.

  • VTOF | CONVERT

    • Converts a variable-length record to a fixed-length record.

  • VLFILL=c

    • Fills the right side of an input record with the character c if the record does not have field(s).

  • FTOV

    • Converts a fixed-length record to a variable-length record.

  • VLTRIM=c

    • Removes the c character(s) in the right side of a result record if the characters exist.

  • NULLOFL= [ RC0 | RC4 | RC16 ]

    • Specifies an action to take when there is zero result record.

      Option Description

      RC0

      Sets the return value to 0, and proceeds to the subsequent operation.

      RC4

      Sets the return value to 4, and proceeds to the subsequent operation.

      RC16

      Stops the operation and returns 16.

  • LINES=n

    • Sets the number of lines for the report page. (Default value: 60)

  • HEADER1

    • Sets the header of a report. HEADER1 is output only to the first page of the report.

    • The following describes each option.

      Option Description

      c:

      Specifies a first position to output the contents of a related report.

      r

      Inserts a blank or a string into an output report.

      • nX: Inserts n blank characters.

      • n’xx…​x': Inserts n strings.

      • nX’yy…​yy': Inserts n hexadecimal strings.

      • /…​/ or n/: Inserts new lines as many as the number of '/' or n. In OpenFrame, up to five consecutive '/'s can be specified for /…​/, and for n/, there is no limitation.

      p,m

      Outputs an input record field of OUTFIL to a report.

      • p: Relative position to the first byte of the input record.

      • m: The length of the input field.

      DATE or &DATE

      Outputs the current date in the format of C’mm/dd/yy'.

      • mm: month (01-12)

      • dd: day (01-31)

      • yy: last two digits of a year

      DATE=(abcd) or &DATE=(abcd)

      • abc: For a, b and c, M, D and Y can be used. They mean month, day and year respectively. The order of M, D and Y determines what to be displayed first. Y can be replaced by 4. An year value is displayed in four digits.

      • d: Delimiter. If DATE=(MDY-) is specified, data is displayed in the format C’mm-dd-yy'.

      TIME or &TIME

      Outputs the current time in the format of C’hh:mm:ss'.

      • hh: hour (00-23)

      • mm: minutes (00-59)

      • ss: seconds (00-59)

      TIME=(abc) or &TIME=(abc)

      Specifies how to output an hour value. (24-hour type or 12-hour type)

      • ab: Specifies either 24 or 12 that means a 24-hour type and a 12-hour type respectively.

      • c: Delimiter that is inserted as C’hhcmmcss'.

      PAGE or &PAGE

      Outputs an eight-digit page number for the report, to the header once.

  • TRAILER1

    • Writes a trailer for the report. TRAILER1 is output only to the last page of the report.

    • The following describes each option.

      Option Description

      c:

      Refer to the description of HEADER1.

      r

      Refer to the description of HEADER1.

      p,m

      Refer to the description of HEADER1.

      DATE

      Refer to the description of HEADER1.

      & DATE

      Refer to the description of HEADER1.

      TIME

      Refer to the description of HEADER1.

      &TIME

      Refer to the description of HEADER1.

      PAGE or &PAGE

      Outputs the current page number to the trailer only once.

      COUNT

      Outputs the number of output records with an eight-digit number.

      COUNT15

      Outputs the number of output records with a 15-digit number.

      SUBCOUNT

      Outputs the number of input records accumulated so far. TRAILER1 functions in the same way as COUNT.

      SUBCOUNT15

      Outputs the number of input records accumulated so far.

      TRAILER1 functions in the same way as COUNT15.

      TOTAL=(p,m,f)

      Outputs the sum of values in the specified number input field. Can also be used as TOT. The description for p,m,f is the same as previous.

      MIN=(p,m,f)

      Outputs the smallest value in the specified number input field. The description for p,m,f is the same as previous.

      MAX=(p,m,f)

      Outputs the largest value in the specified number input field. The description for p,m,f is the same as previous.

      AVG=(p,m,f)

      Outputs the average value of the values in the specified number input field. The description for p,m,f is the same as previous.

      SUBTOTAL=(p,m,f)

      Outputs a subtotal value accumulated so far. In TRAILER1, the same result as TOTAL is displayed. Can also be used as SUBTOT or SUB.

      SUBMIN=(p,m,f)

      Outputs the minimum value accumulated so far. In TRAILER1, the same result as MIN is displayed.

      SUBMAX=(p,m,f)

      Outputs the maximum value accumulated so far. In TRAILER1, the same result as MAX is displayed.

      SUBAVG=(p,m,f)

      Outputs the average value accumulated so far. In TRAILER1, the same result as AVG is displayed.

  • HEADER2

    • Writes the header of the report. HEADER2 is output to each page of the report.

    • The following describes each option.

      Option Description

      c:

      Refer to the description of HEADER1.

      r

      Refer to the description of HEADER1.

      p,m

      Refer to the description of HEADER1.

      DATE

      Refer to the description of HEADER1.

      &DATE

      Refer to the description of HEADER1.

      TIME

      Refer to the description of HEADER1.

      &TIME

      Refer to the description of HEADER1.

      PAGE or &PAGE

      Outputs each page number to each corresponding page with an eight-digit number.

  • TRAILER2

    • Writes a trailer for the report. TRAILER2 is output to each page of the report.

    • The following describes each option.

      Option Description

      c:

      Refer to the description of HEADER1.

      r

      Refer to the description of HEADER1.

      p,m

      Refer to the description of HEADER1.

      DATE

      Refer to the description of HEADER1.

      &DATE

      Refer to the description of HEADER1.

      TIME

      Refer to the description of HEADER1.

      &TIME

      Refer to the description of HEADER1.

      PAGE

      Refer to the description of HEADER2.

      &PAGE

      Refer to the description of HEADER2.

      COUNT

      Refer to the description of TRAILER1.

      COUNT15

      Refer to the description of TRAILER1.

      SUBCOUNT

      Refer to the description of TRAILER1.

      SUBCOUNT15

      Refer to the description of TRAILER1.

      TOTAL

      Refer to the description of TRAILER1.

      MIN

      Refer to the description of TRAILER1.

      MAX

      Refer to the description of TRAILER1.

      AVG

      Refer to the description of TRAILER1.

      SUBTOTAL

      Refer to the description of TRAILER1.

      SUBMIN

      Refer to the description of TRAILER1.

      SUBMAX

      Refer to the description of TRAILER1.

      SUBAVG

      Refer to the description of TRAILER1.

  • SECTIONS

    • Sets sections of a report created by OUTFIL. The report is divided into sections according to the binary value of the specified field.

    • p,m

      • Sets a standard field for sectionalization. For more information, refer to the description of HEADER1.

    • SKIP=P | L | nL

      • Specifies how to sectionalize the record.

      • The following describes each option.

        Option Description

        P

        Outputs each section to a new page. OpenFrame only supports parsing.

        L

        Outputs sections to the same page with a single blank line between sections. L is the same as 1L.

        nL

        Outputs sections to the same page with n blank lines between sections.

    • HEADER3

      • Writes the header of the section.

      • The following describes each option.

        Option Description

        c:

        Refer to the description of HEADER1.

        r

        Refer to the description of HEADER1.

        p,m

        Refer to the description of HEADER1.

        DATE

        Refer to the description of HEADER1.

        &DATE

        Refer to the description of HEADER1.

        TIME

        Refer to the description of HEADER1.

        &TIME

        Refer to the description of HEADER1.

        PAGE or &PAGE

        Outputs the page number of each section with an eight-digit number.

    • PAGEHEAD

      • Outputs the section header to the first part of each page of the report.

      • If PAGEHEAD is not specified, the section header is output only to the first part of each section. If a section is continued to the next page, the header of the next section may be output in the middle of the page. This option is used to output the header to the top of the page.

      • PAGEHEAD is available only when HEADER3 is specified.

      • OpenFrame only supports parsing.

    • TRAILER3

      • Writes a trailer for the section.

      • The following describes each option.

        Option Description

        c:

        Refer to the description of HEADER1.

        r

        Refer to the description of HEADER1.

        p,m

        Refer to the description of HEADER1.

        DATE

        Refer to the description of HEADER1.

        &DATE

        Refer to the description of HEADER1.

        TIME

        Refer to the description of HEADER1.

        &TIME

        Refer to the description of HEADER1.

        PAGE

        Refer to the description of HEADER2.

        &PAGE

        Refer to the description of HEADER2.

        COUNT

        Refer to the description of TRAILER1.

        COUNT15

        Refer to the description of TRAILER1.

        SUBCOUNT

        Refer to the description of TRAILER1.

        SUBCOUNT15

        Refer to the description of TRAILER1.

        TOTAL

        Refer to the description of TRAILER1.

        MIN

        Refer to the description of TRAILER1.

        MAX

        Refer to the description of TRAILER1.

        AVG

        Refer to the description of TRAILER1.

        SUBTOTAL

        Refer to the description of TRAILER1.

        SUBMIN

        Refer to the description of TRAILER1.

        SUBMAX

        Refer to the description of TRAILER1.

        SUBAVG

        Refer to the description of TRAILER1.

  • NODETAIL

    • Does not output data records in a report output by OUTFIL. It means that only the contents of the report are stored in the output data set.

  • REMOVECC

    • Removes ANSI control characters from the OUTFIL output record.

  • IFTRAIL

    • Updates COUNT or TOTAL values in TRAILER1 when its records are identified in the input data set.

    • If TRAILER 1 records are identified, all succeeding records are ignored, and the preceding records are used to update the COUNT and TOTAL values. As the result, those succeeding TRAILER 1 records are not shown even in the output data set specified in the OUTFIL statement.

    • If both INCLUDE and OMIT are found in one OUTFIL statement containing IFTRAIL, the records treated as HEADER and TRAILER1 are not filtered.

    • The following describes each option.

      Option Description

      HD=YES

      Treats the first record in the input dataset as HEADER. If not specified, the first record is treated as a regular record by default.

      TRLID=(logexp)

      Identifies the TRAILER1 record by referring to the specified logexp. If no TRAILER1 is identified because there is no record matching with the specified logexp, no update occurs.

      TRLUPD=(c:item,…​)

      Keeps calculating the sum of all specified fields even when no TRAILER1 record matching the TRLID logexp is identified, if TOTAL (TOT) among the following items is specified. An exception may occur if specified fields are not numeric.

      • c: Specifies the starting position for the output record.

      • Items

        • COUNT=(edit) or (to)

        • COUNT+n=(edit) or (to)

        • COUNT-n=(edit) or (to)

        • TOTAL=(p,m,f,edit) or (p,m,f,to)

      COUNT outputs the count of input records that have been read so far, and n is the value to be added to or subtracted from the count. TOTAL outputs the sum of all specified numeric fields, and you can use TOT as an abbreviation for TOTAL. Refer to the following table entries for descriptions of each item.

      p,m,f,edit

      Converts the specified field to the defined format and outputs it as an OUTFIL record.

      • p, m: See the previous description.

      • f: Describes the format of the specified field.

      • edit: Describes the format into which the specified field is to be converted. For more information about the EDIT command, refer to EDIT command.

      p,m,f,to

      Changes the input field format and outputs it.

      • p,m,f: See the previous description.

      • to: Specifies the output record format into which the input field (the original format f) is to be converted. If f is either ZDF or ZD, the behavior is the same. The syntax of the to command is as follows:

        of|TO=[of|(of)][,LENGTH=[n|(n)]]
        • TO=[of | (of)]: Specifies the format into which the field is to be converted. 'TO=' can be omitted.

        • LENGTH=[n | (n)]: Specifies the length of the output field.

    • The following example shows how to use IFTRAIL.

      IFTRAIL=([HD=YES,]TRLID=(logexp),TRLUPD=(c:item,...))
      
      IFTRAIL=(HD=YES,TRLID=(1,3,CH,EQ,C'TRL'),TRLUPD=(11:COUNT=(M11,LENGTH=4),21:TOT=(M11,LENGTH=6)))
EDIT Command

Defines a format to convert the field into. The EDIT command is set as follows:

  • Usage

    Mn|EDIT=(pattern)[,SIGNS=(lp,ln,tp,tn)][,LENGTH=[n|(n)]
    Option Description

    pattern

    Defines an editing pattern to convert I, T, S, CR and a number field given with printable characters.

    For the number of digits of a value in a number field (ZD, PD, BI, FI and etc.), and editing pattern I and T, data is converted one by one from the end of the field. If I or T is larger than the length of the absolute value of the number field, the pattern from which the exceeded part has been removed is internally used. The parts indicating signs are kept.

    • I: Unimportant digit. When the digit corresponding to I is a meaningless leading 0, it is replaced by a blank.

    • T: Important digit. Although the digit corresponding to T is a leading 0, it is displayed as 0.

    • S: Indicates a sign. If it appears at the very first of the pattern, it is considered as a leading sign, and is replaced by lp or ln of the SIGNS option. If it appears at the very end of the pattern, it is considered as a trailing sign, and is replaced by tp or tn of the SIGNS option. If no SIGNS option is given, it is ignored.

    • CR: When a value of the number field is negative, CR is displayed at the right side, and if positive, two blanks are displayed at the right side.

    Mn

    Predefined editing pattern. (0 <= n <= 26) In Mn, there is a SIGNS that is applied by default.

    SIGNS

    Defines a character that indicates a sign.

    • lp: Defines a sign character at the very first of the EDIT result, when the value is positive.

    • tp: Defines a sign character at the very first of the EDIT result, when the value is negative.

    • ln: Defines a sign character at the very last of the EDIT result, when the value is positive.

    • tn: Defines a sign character at the very last of the EDIT result, when the value is negative.

    LENGTH

    Specifies the length of the output field.

    • n: Specifies the length of the output field. It can also be used as (n).

Pre-defined EDIT statements are as follows:

Mask Pattern Displayed as Example (Value) Example (Result)

M0

IIIIIIIIIIIIIIIIIIIIIIIIIIIIIITS

(None,None,Blank,-)

+01234

□1234□

-00001

□□□□1-

M1

TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTS

(None,None,Blank,-)

-00123

00123-

+00123

00123□

M2

II,III,III,III,III,III,III,III,III,IIT.TTS

(None,None,Blank,-)

+123450

1,234.50□

-000020

□□□□0.20-

M3

II,III,III,III,III,III,III,III,III,IIT.TTCR

(None,None,None,None)

-001234

□□□12.34CR

+123456

1,234.56□□

M4

SII,III,III,III,III,III,III,III,III,IIT.TT

(+,-,None,None)

+0123456

□+1,234.56

-1234567

-12,345.67

M5

SII,III,III,III,III,III,III,III,III,IIT.TTS

(Blank,Left Parenthesis,Blank,Right Parenthesis)

-001234

□□□(12.34)

+123450

□1,234.50□

M6

III-TTT-TTTT

(None,None,None,None)

00123456

□□□□012-3456

12345678

□□1-234-5678

M7

TTT-TT-TTTT

(None,None,None,None)

00123456

000-12-3456

12345678

012-34-5678

M8

IT:TT:TT

(None,None,None,None)

030553

□3:05:53

121736

12:17:36

M9

IT/TT/TT

(None,None,None,None)

123004

12/30/04

083104

□8/31/04

M10

IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIT

(None,None,None,None)

01234

□1234

00000

□□□□0

M11

TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT

(None,None,None,None)

00010

00010

01234

01234

M12

SI,III,III,III,III,III,III,III,III,III,IIT

(Blank,-,None,None)

+1234567

□1,234,567

-0012345

□□□-12,345

M13

SI.III.III.III.III.III.III.III.III.III.IIT

(Blank,-,None,None)

+1234567

□1.234.567

-0012345

□□□-12.345

M14

SI III III III III III III III III III IITS

(Blank,Left Parenthesis,Blank,Right Parenthesis)

+1234567

□1 234 567□

-0012345

□□□(12 345)

M15

I III III III III III III III III III IITS

(None,None,Blank,-)

+1234567

1 234 567□

-0012345

□□□12 345-

M16

SI III III III III III III III III III IIT

(Blank,-,None,None)

+1234567

□1 234 567

-0012345

□□□-12 345

M17

SI’III’III’III’III’III’III’III’III’III’IIT

(Blank,-,None,None)

+1234567

□1'234'567

-0012345

□□□-12'345

M18

SII,III,III,III,III,III,III,III,III,IIT.TT

(Blank,-,None,None)

+0123456

□□1,234.56

-1234567

-12,345.67

M19

SII.III.III.III.III.III.III.III.III.IIT,TT

(Blank,-,None,None)

+0123456

□□1.234,56

-1234567

-12.345,67

M20

SI III III III III III III III III IIT,TTS

(Blank,Left Parenthesis,Blank,Right Parenthesis)

+0123456

□□1 234,56□

-1234567

(12 345,67)

M21

II III III III III III III III III IIT,TTS

(None,None,Blank,-)

+0123456

□1 234,56□

-1234567

12 345,67-

M22

SI III III III III IIII III III III IIT,TT

(Blank,-,None,None)

+0123456

□□1 234,56

-1234567

-12 345,67

M23

SII’III’III’III’III’III’III’III’III’IIT.TT

(Blank,-,None,None)

+0123456

□□1'234.56

-1234567

-12'345.67

M24

SII’III’III’III’III’III’III’III’III’IIT,TT

(Blank,-,None,None)

+0123456

□□1'234,56

-1234567

-12'345,67

M25

SIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIT

(Blank,-,None,None)

+01234

□□1234

-00001

□□□□-1

M26

STTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT

(+,-,None,None)

1234

+1234

-1

-1

13. OUTREC

Reformats output records before outputting the result to the data set specified by SORTOUT or OUTFIL, after executing SORT, MERGE or COPY. While INREC reformats records before being processed by SORT, OUTREC reformats those records after SORT processing.

Usage

An OUTREC statement can be used as follows:

OUTREC PARSE=(parse_item[,parse_item[,...]]) |
       FIELDS=(reformat_command[,reformat_command[,...]]) |
       BUILD=(reformat_command[,reformat_command[,...]])
       OVERLAY=(reformat_command[,reformat_command[,...]]) |
       FINDREP={IN=incon,OUT=outcon | IN=(incon1,incon2[,...]),OUT=outcon |
                INOUT=(incon1,outcon1[,incon2,outcon2[,...]])}
               [,STARTPOS=p | ENDPOS=q]
       IFTHEN=WHEN=INIT,{BUILD | OVERLAY | FINDREP} |
                   WHEN=GROUP,BEGIN=(logexp),END=(logexp),RECORDS=n,PUSH=(items) |
                   WHEN=(logexp),{BUILD | OVERLAY | FINDREP} |
                   WHEN=NONE,{BUILD | OVERLAY | FINDREP} |
       CONVERT

[parse_item]

parse_item=%nn= { FIXLEN=m | ABSPOS=p | ADDPOS=x | SUBPOS=y |
               STARTAFT=string | STARTAFT=BLANKS |
               STARTAT=string | STARTAT=BLANKS | STARTAT=NONBLANK |
               ENDBEFR=string | ENDBEFR=BLANKS |
               ENDAT=string | ENDAT=BLANKS |
               PAIR=APOST | PAIR=QUOTE }

[reformat_command]

reformat_command=[c:] | s | %nn | p,m | p,m,TRAN=LTOU|UTOL | p,m,TRAN=ALTSEQ |
               p,m,Y2x | p,m,f,edit | p,m,f,to | arexp,edit | p,m,CHANGE | p,m,a |
               DATEn | DATE | &DATE | DATE=(abcd) | &DATE=(abcd) | TIME | &TIME |
               p,m,f,dateop | p,m,Yxx,todate | TIME=(abc) | &TIME=(abc) | seqnum | p,m,justify | %nn,justify | p,m,squeeze | %nn,squeeze
Operands

The following describes each operand.

  • PARSE

    • Extracts a fixed-length parsed field from a variable-length input record. Use the parsed field where you can use (p,m) in BUILD or OVERLAY.

    • The following describes each item.

      Item Description

      %nn

      Converts variable-length input records to fixed-length output records. Use the parsed field where you can use (p,m) in BUILD or OVERLAY.

      FIXLEN=m

      Specifies the length of the parsed field. This attribute must be present in all parse fields.

      ABSPOS=p

      Specifies the parse starting position p in the input record.

      ADDPOS=x

      Increases the parse starting position by x in the input record.

      SUBPOS=y

      Decreases the parse starting position by y in the input record.

      STARTAFT

      • STARTAFT=string: Starts the parsed field record after the first string of the input record.

      • STARTAFT=BLANKS: Starts the parsed field record after the first blank of the input record.

      STARTAT

      • STARTAT=string: Starts the parsed field record including the first string of the input record.

      • STARTAT=BLANKS: Starts the parsed field record after the first blank of the input record.

      • STARTAT=NONBLANK: Starts the parsed field record after the nonblank.

      ENDBEFR

      • ENDBEFR=string: Ends the parsed field record before the first string of the input record.

      • ENDBEFR=BLANKS: Ends the parsed field record before the first blank of the input record.

      ENDAT

      • ENDAT=string : Ends the parsed field record including the first string of the input record.

      • ENDBEFR=BLANKS : Ends the parsed field record including the first blank of the input record.

      PAIR

      • PAIR=APOST: Does not consider the areas enclosed by apostrophe (') as blanks or strings.

      • PAIR=QUOTE: Does not consider the areas enclosed by quote (") as blanks or strings.

  • FIELDS | BUILD

    • Sets a key field to be selected in the input record. A starting position and the length of the key field can be specified.

      When multiple fields are specified, a field is reformatted as an output record, after the previous field. If the length of a variable-length record is changed, the contents of its record descriptor word (RDW) is also changed.

    • BUILD can be used instead of FIELDS.

    • The following describes each item.

      Item Description

      c:

      Specifies a starting position in the reformatted input record of the field, just after the c: option. The head of the record for FB and that of RDW for VB are each considered as 1.

      The position specified by c: cannot be the same as that of a previously selected field or the inserted blank. The part that is not defined due to the c: option is filled with blanks.

      s

      Separation field for setting a string or blank.

      • nX: Inserts blank characters as many as n.

      • nC’xx…​x': Inserts a character string. n means the number of times the string is repeated.

      • nX’yy…​yy': Inserts a hexadecimal string. n means the number of times the string is repeated.

      DATEn

      Outputs the current date. OpenFrame only supports DATE1 displayed as C’yyyymmdd'.

      TIMEn

      Outputs the current time. n can be 1, 2, or 3, and each value has the following meaning.

      • 1: C’hhmmss'

      • 2: C’hhmm'

      • 3: C’hh'

      DATE=(abcd) or &DATE=(abcd)

      Outputs the current date in the format of C’adbdc'. d is a delimiter. a,b,c∈{M,D,Y,4}, and each value has the following meaning.

      • M: 2-digit month (01-12)

      • D: 2-digit day (01-31)

      • Y: last two digits of a year

      • 4: four-digit year

      DATE or &DATE

      Outputs the current date in the format of 'C’mm/dd/yy'.

      • mm: month (01-12)

      • dd: day (01-31)

      • yy: last two digits of a year

      DATENS=(abc) or &DATENS=(abc)

      Outputs the current date in the format of C’abc'. a,b,c∈{M,D,Y,4}, and each value has the following meaning.

      • M: 2-digit month (01-12)

      • D: 2-digit day (01-31)

      • Y: last two digits of a year

      • 4: four-digit year

      TIME or &TIME

      Outputs the current time in the format of C’hh:mm:ss'.

      • hh: hour (00-23)

      • mm: minutes (00-59)

      • ss: seconds (00-59)

      TIME=(abc) or &TIME=(abc)

      Specifies how to output an hour value. (24-hour type or 12-hour type)

      • ab: Specifies either 24 or 12 that means a 24-hour type and a 12-hour type respectively.

      • c: Delimiter that is inserted as C’hhcmmcss'.

      p,m

      Outputs a specified input record field to the output field.

      • p: Sets a starting position of the control field. For more information, refer to 'p' of OUTREC in OUTFIL.

      • m: Sets the length of the selected field in bytes.

      %nn

      Outputs the parsed record field of %nn label to the output field.

      p,m,YDDDNS=(ab)

      Outputs a specified input record field in the YDDDNS=(ab) format.

      • p,m: See the previous descriptions of p and m.

      • YDDDNS=(ab): a can be either 4 or Y; b cannot be D. See the previous description for DATE=(abcd) for description of 4 and Y, and D is the day of the year (a number between 1 and 366).

      p,m,TRAN=LTOU|UTOL

      • p, m: See the previous descriptions of p and m.

      • TRAN=LTOU: Changes small letters (lowercase) in the field to capital letters (uppercase).

      • TRAN=UTOL: Changes capital letters to small letters.

      p,m,TRAN=ALTSEQ

      • p, m: Same as the previous descriptions of p and m.

      • TRAN=ALTSEQ: Alters records in the field according to the ALTSEQ conversion table.

      p,m,Y2x

      • p: Same as the previous description of p.

      • m: Specifies the length of the output field displaying the year value.

      • Y2x: OpenFrame only supports Y2C displayed as C’yyyy'.

      p,m,Y2x,DT=(abcd)

      Outputs a record field that has been converted to the Y2x format as the DT=(abcd) format.

      • p,m,Y2x: Same as the previous description of p,m,Y2x.

      • DT=(abcd): Outputs a Y2x date in C’adbdc' format. d is the delimiter. See the previous description for DATE=(abcd) for description of a,b,c.

      p,m,f,edit

      Converts the specified field to a defined format, and outputs it to the OUTFIL record. For more information, refer to the OUTREC command in OUTFIL.

      p,m,f,to

      Converts the format of the input field. For more information, refer to the OUTREC command in OUTFIL.

      arexp,edit

      Converts an arithmetic expression to an edit format to reformat the input record. For more information, refer to the OUTREC command in OUTFIL.

      p,m,CHANGE

      Replaces the specified string of the input field with another string. For more information, refer to the OUTREC command in OUTFIL.

      p,m,a

      Outputs a specified input field to an output field. If the alignment is not correct, fields are left-padded with null characters (0x0). a can be H, F, or D, and each value has the following meaning.

      • H: halfword (2 bytes)

      • F: fullword (4 bytes)

      • D: doubleword (8 bytes)

      p,m,f,dateop

      Performs the date operation for the specified input field.

      Date operations are performed as follows:

      • ADDDAYS: Adds the number of days specified in the input field.

      • ADDMONS: Adds the number of months specified in the input field.

      • ADDYEARS: Adds the number of years specified in the input field.

      • SUBDAYS: Subtracts the number of days specified in the input field.

      • SUBMONS: Subtracts the number of months specified in the input field.

      • SUBYEARS: Subtracts the number of years in the input field.

      p,m,Yxx,todate

      Converts the specified input field into the format option specified with todate.

      The following values are supported for todate.

      • DT=(abcd):

        • a, b, c: Specify year (2-digit: Y, 4-digit: 4), month (M), day (D) in the desired order.

        • d: Specify the delimiter character between year, month, and day.

      • TOJUL=[Yaa | Yaa(s)]: Prints the input field in Julian date.

        • Yaa: Specify the Julian date format.

          • Y2T: C’yysddd' | C’yyddd'

          • Y2W: C’dddsyy' | C’dddyy'

          • Y2U: X’yydddf'

          • Y2X: X’dddyyf'

          • Y4T: C’ccyysddd' | C’ccyyddd'

          • Y4W: C’dddsccyy' | C’dddccyy'

          • Y4U: X’ccyydddf'

          • Y4X: X’dddccyyf'

        • s: Specify the delimiter character.

      • TOGREG=[Yaa | Yaa(s)]: Prints the input field in Gregorian date.

        • Yaa: Specify the Gregorian date format.

          • Y2T: C’yysmmsdd' | C’yymmdd'

          • Y2W: C’mmsddsyy' | C’mmddyy'

          • Y2V: X'0yymmddf'

          • Y2Y: X'0mmddyyf'

          • Y4T: C’ccyysmmsdd' | C’ccyymmdd'

          • Y4W: C’mmsddsccyy' | C’mmddccyy'

          • Y4V: X'0ccyymmddf'

          • Y4Y: X'0mmddccyyf'

        • s: Specify the delimiter character.

      seqnum

      Outputs a sequence number of the output record. The sequence number is added after the input record.

      OpenFrame supports the following formats.

      SEQNUM,n,fs[,START=j][,INCR=i][,RESTART=(p,m)]
      • SEQNUM: Specifies a command to output the sequence number.

      • n: Required option. Specifies the number of digits in the sequence number.

      • fs: Required option. Specifies the string format for the sequence number.

      • START=j: This option can be omitted (if omitted, it is considered to be START=1). Set the starting value of the sequence number to j.

      • INCR=i: This option can be omitted (if omitted, it is considered to be INCR=1). Set the increment value of the sequence number to i.

      • RESTART=(p,m): This option can be omitted. If the specified field does not match the field of the previous record, SEQNUM is initialized to j.

      p,m,justify

      Converts the specified field to the defined format and outputs it. For more information, refer to the OUTREC command in OUTFIL.

      %nn,justify

      Converts the parsed record field of %nn label to the defined format and outputs it. For more information, refer to the OUTREC command in OUTFIL.

      p,m,squeeze

      Converts the specified field to the defined format and outputs it. For more information, refer to the OUTREC command in OUTFIL.

      %nn,squeeze

      Converts the parsed record field of the %nn label to the defined format and outputs it. For more information, refer to the OUTREC command in OUTFIL.

  • OVERLAY

    • Specifies a item with which to overwrite the output record. Columns that are not overwritten are output as they are.

  • FINDREP

    • Searches a specified variable in the input record, and replaces it with another variable.

    • For more information about variable replacement, refer to the FINDREP command in OUTFIL.

  • IFTHEN

    • Reformats each different record in each different method, according to given conditions.

    • For more information about specifying conditions, refer to the section on the IFTHEN command in OUTFIL.

  • CONVERT

    • Converts a variable-length record to a fixed-length record.

14. RECORD

Specifies the format and length of a record.

Usage

A RECORD statement can be used as follows:

RECORD [TYPE=[F|V|D] [,LENGTH=[(L1)|(L1,L2,L3,L4,L5)]]
Operands

The following describes each operand.

  • TYPE

    • Sets a record format.

    • The following describes each item.

      Item Description

      F

      Fixed-sized record. Can also be described as FB.

      V

      Variable-sized record. Can also be described as VB.

      D

      Variable-sized ASCII record. Can also be described as DB. OpenFrame only supports parsing.

    • TYPE can be used to process a VSAM input data set as FB or VB. If F is specified, the input record is processed as it is, and if V is specified, RDW is added before the input record. When the input data set is NVSM, its RECFM information determines its format, and TYPE is ignored.

  • LENGTH

    • Sets the length of the record.

    • For a fixed-length record, L1 to L3 can be specified, and for a variable-length record, L1 to L5 can be set. All with the exception of L1 can be omitted.

    • The following describes each item.

      Item Description

      L1

      Specifies the length of the input record. This is a mandatory input item.

      The length of the input record for FB and the maximum length of the input record for VB must be specified. This item can also be used when lrecl (logical record length) of SORTIN has not been given. If there is no record control statement, a value defined in the DCB parameter is used.

      L2

      Specifies the length of the SORT-processing record for FB and the maximum length of the SORT-processing record for VB. If omitted, the value specified in L1 is used. In OpenFrame, L2 processing is performed only up to parsing and other functions are not supported.

      L3

      Specifies the length of the output record for FB and the maximum length of the output record for VB. If either INREC or OUTREC is specified, L3 means the length of the processed record, and if neither INREC nor OUTREC is specified, the L1 value is set.

      L4

      Specifies the minimum length of the input record. In OpenFrame, L4 processing is performed only up to parsing, and other functions are not supported.

      L5

      Specifies the average length of the input record. If omitted, the average value of L1 and L4 is set. However, in MERGE processing, another value is not set even though L5 is omitted. In OpenFrame, L5 processing is performed only up to parsing, and other functions are not supported.

Examples

The following example specifies a fixed-length record whose length is 200 bytes:

RECORD TYPE=F,LENGTH=(200)

The next example specifies a variable-length record whose maximum length is 100 bytes and minimum length is 50 bytes.

RECORD TYPE=V,LENGTH=(100,,,50)

15. REFORMAT

Outputs specified parts in records when performing join.

It is recommended to specify REFORMAT when performing join in OpenFrame. If not specified, a REFORMAT statement is specified with the max length set in a dataset specified in F1 or F2 depending on the JOIN statement.

Usage

A REFORMAT statement can be used as follows:

REFORMAT FIELDS=({F1|F2}:p,m[,p,m[,...]][,{F1|F2}:p,m[,p,m[,...]][,...]])
Operands

The following describes each operand.

  • FIELDS

    • Specifies a key field to select from an input record.

      Value Description

      F1

      If F1 is specified, a key field is selected from the left data set (SORTJNF1).

      F2

      If F2 is specified, a key field is selected from the right data set (SORTJNF2).

      When multiple fields are specified, a field is reformatted as an output record, after the previous field.

      If any one of the two input data sets uses the V type record format, RWD must be included in the field.

    • The following are options.

      Option Description

      p,m

      Outputs a specified input record field to the output field.

      • p: start position of a key field. For more information, refer to 'p' in the OUTREC section in OUTFIL.

      • m: field length. (Unit: bytes)

    • The following joins SORTJNF1 and SORTJNF2. The first 17 bytes of SORTJNF1 records and the first 10 bytes of SORTJNF2 records are outputted.

      JOINKEYS FILE=F1,FIELDS=(11,7,A)
      JOINKEYS FILE=F2,FIELDS=(11,7,A)
      REFORMAT FIELDS=(F1:1,17,F2:1,10)
    • The following is the example of join when a REFORMAT statement is not specified. The max length of SORTJNF1 and SORTJNF2 is 7. The following REFORMAT statement is added in OpenFrame.

      JOINKEYS FILE=F1,FIELDS=(1,7,A)
      JOINKEYS FILE=F2,FIELDS=(1,7,A)
      JOIN UNPAIRED,ONLY,F1,F2
      REFORMAT FIELDS=(F1:1,7,F2:1,7)

16. SORT

Sorts records in the input data set in ascending or descending order, and outputs them to the output data set.

When ot using the FTOV or VTOP option for OUTFIL, both the input and output data sets must use the same record format.

Usage

A SORT statement can be used as follows:

SORT FIELDS=(p,m,f,s[,p,m,f,s[,...]]) | (p,m,s[,p,m,s[,...]]),FORMAT=f | COPY
     [SKIPREC | STOPAFT | CKPT | DYNALLOC | EQUALS | NOEQUALS | FILSZ=[E|U]n |
      SIZE=[E|U]n | Y2PAST | CENTWIN]
Operands

The following describes each operand.

  • FIELDS

    • Sets a key field to sort input records and a starting position, length, format, and sorting standard for the key field. (Alias: KEYS)

    • The following describes each item.

      Item Description

      p

      Sets a starting position for the control field. A starting position for a control field varies depending on circumstances.

      • When the input record is a fixed-length NVSM record (FB), the first byte of the record is 1.

      • When the input record is a variable-length NVSM record (VB), a four-byte RDW is added before the record, the RDW begins from 1 while the actual record begins from 5.

      • When the input record is a VSAM data set, and it is processed as a variable-length record by OpenFrame SORT, an RDW beginning with 1 is added before the record, and therefore the actual data begins from 5.

      To execute OpenFrame SORT, it is required to set whether to determine a VSAM data set as a fixed-sized record or a variable-sized record. When one of the following three cases is satisfied, the data set is determined as a variable-sized record.

      1. When RECORD TYPE=V is set

      2. When SORTOUT is set to RECFM=VB

      3. When both SORTIN and SORTOUT are VSAM

      m

      Sets the length of the control field.

      f

      Sets the length of the control field. The following table contains available formats and lengths for a control field.

      s

      Sets a sorting standard for the control field.

      • A: Ascending order

      • D: Descending order

      • E: Custom order for user. (Not supported by OpenFrame)

      The following are available formats and lengths for a control field.

      Format Description Length Sign

      CH

      Character (ASCII)

      1 to 32760 Bytes

      X

      AC

      Character (ASCII)

      1 to 32760 Bytes

      X

      ZD (Zoned Decimal)

      Zoned decimal number

      1 to 32760 Bytes

      O

      PD (Packed Decimal)

      Packed decimal number

      1 to 32760 Bytes

      O

      PDF

      Packed decimal number with a sign bit of F for a positive number

      1 to 32760Bytes

      O

      PD0

      Packed decimal with first and last nibbles ignored

      1 to 32760Bytes

      X

      FI (Fixed-point)

      Fixed-point binary number

      1 to 32760 Bytes

      O

      FL (Floating-point)

      Floating-point decimal number

      1 to 32760 Bytes

      O

      BI (Binary Integer)

      Binary number

      1 to 32760 Bytes

      X

      CSF or FS

      Number with an additional prefixed floating sign

      1 to 32760 Bytes

      O

      UFF

      Unsigned free form numeric

      1 to 32760 Bytes

      X

      SFF

      Signed free form numeric

      1 to 32760 Bytes

      O

      CSL

      Number with a prefixed separation sign

      1 to 32760 Bytes

      O

      CST

      Number with a postfixed separation sign

      1 to 32760 Bytes

      O

      CLO

      Number with a prefixed overpunch sign

      1to 32760 Bytes

      O

      CTO

      Number with a postfixed overpunch sign

      1to 32760 Bytes

      O

      ASL

      Number with a prefixed separation sign, ASCII

      1to 32760 Bytes

      O

      AST

      Number with a postfixed separation sign, ASCII

      1to 32760 Bytes

      O

      AQ

      Character (in the order defined in ALTSEQ)

      1 to 32760 Bytes

      X

      Y2C or Y2Z

      Two-digit string or ZD year data

      2 Bytes

      X

      Y2P

      Two-digit PD year data

      2 Bytes

      X

      Y2D

      Two-digit decimal year data

      1 Byte

      X

      Y2S

      Two-digit string or ZD year data

      2 Bytes

      X

      Y2B

      Two-digit binary year data

      1 Byte

      X

    • The following example sorts a fixed-length character record in ascending order from the first byte to the seventh.

      SORT FIELDS=(1,7,CH,A)

      The following sorts a three-byte character record in descending order from the fifth byte without the RDW from the first to the fourth.

      SORT FIELDS=(5,3,CH,D)

      The actual record data of a variable-length record without RDW begins from 5. If a starting position of SORT is specified between 1 and 4, no error will occur, but SORT will fail as the RDW is included.

  • FORMAT=f

    • If the formats of control fields are all the same, the FORMAT=f command can be used to specify the format at once, rather than specifying it in each control field.

    • The following example specifies two fixed-sized CH control fields. The first ten bytes from the first byte are sorted in ascending order, and the following ten bytes from the 11th byte are sorted in descending order.

      SORT FIELDS=(1,10,A,11,10,D),FORMAT=CH

      In OpenFrame, the FORMAT=f operand can be used only when the formats of the control fields are all the same. For example, if the format of a control field is different from that of other control fields, the FORMAT=f operand cannot be used. If specifying the format of the field separately, and FORMAT=f is used for that of other fields, an error will occur. Note that an error will also occur when FORMAT=f is used before FIELDS, rather than after.

  • COPY

    • Copies the contents of the input data set record to the output data set without specifying the control field.

    • The following is an example of COPY.

      SORT FIELDS=COPY
  • FILSZ=[E|U]n

    • Specifies the number of records used for sort.

    • In OpenFrame, it is supported only to prevent a syntax error.

  • SIZE=[E|U]n

    • Specifies the number of input records.

    • For more information, refer to OPTION.

  • SKIPREC=x

    • Sets the number of input records starting from the first record to be discarded without being sorted.

    • x means the number of records.

    • The following example sorts records except the first record to the fifth in the input data set.

      SORT FIELDS=(1,7,CH,A),SKIPREC=5
  • STOPAFT=x

    • Sets the number of input records starting from the first record to be sorted. Records after the specified number are discarded.

    • x means the number of records.

    • The following example sorts records except the first record to the fifth in the input data set, and discards the following records.

      SORT FIELDS=(1,7,CH,A),STOPAFT=5
  • CKPT

    • Sets a check point for SORT or COPY.

    • In OpenFrame, it is supported only to prevent a syntax error.

  • DYNALLOC [=([d][,n])]

    • Dynamically allocates work data sets.

    • The following describes each item.

      Item Description

      d

      Sets a device type or a group name to dynamically allocate data sets.

      n

      Sets the number of work data sets for dynamic allocation.

    • In OpenFrame, it is supported only to prevent a syntax error.

  • EQUALS | NOEQUALS

    • Sets the order for outputting records from the control field when they are all the same.

    • The following describes each item.

      Item Description

      EQUALS

      Records are output in the order that they have been input (stable order).

      NOEQUALS

      It is not guaranteed that records are output in the order that they have been input (unstable order). (Default value)

  • Y2PAST | CENTWIN

    • For more information, refer to OPTION.

17. SUM

Sums up all the values of the given field for the records with the same key value when performing SORT or MERGE, and outputs the sum to one of the records. After, other records are deleted. It is also possible to keep a record out of records with the same key value without summing up the field, and remove the other records.

Usage

A SUM statement can be used as follows:

SUM FIELDS=(p,m,f,[p,m,f[,...]])|(p,m[,p,m[,...]),FORMAT=f|NONE[,XSUM]
Operands

The following describes each operand.

  • FIELDS

    • Specifies a key field to sum up its input records.

    • Sets the starting position, length, and format of the key field.

    • The following describes each item.

      Item Description

      p

      Sets the starting position of the field. For more details, refer to 'p' in the FIELDS section of SORT.

      m

      Sets the length of the field in bytes.

      f

      Sets the format of the summed-up field.

      s

      Sets the sorting standard for the control field.

      • A: Ascending order.

      • D: Descending order.

      • E: Custom order for user. (Not supported by OpenFrame)

    • The following example sums up ten-byte ZD records from the 10th byte.

      SUM FIELDS=(10,10,ZD)
  • FORMAT=f

    • When the format of the summed-up fields are all the same, FORMAT=f can be used after the COND statement in order to specify the format overall, rather than specifying the format in each field.

    • The following example sums up FI records which begins from 10, 12, and 16, and whose length is 2 bytes, 4 bytes, and 8 bytes respectively.

      SUM FIELDS=(10,2,12,4,16,8),FORMAT=FI

      In OpenFrame, the FORMAT option can be used only when the formats of the control fields are all equal.

  • NONE

    • Keeps a record of the records with the same key value without summing up them, and removes the other records.

    • The following example keeps one of the records with the same key, and removes the other records.

      SUM FIELDS=NONE
  • XSUM

    • Stores records with the same key value to be deleted in the dataset with a DD name of SORTXSUM.

    • The following example stores the deleted records with the same key in the dataset with a DD name of SORTXSUM.

      SUM FIELDS=NONE,XSUM
Note

When writing a SUM statement, note the following:

  • When NOEQUALS is specified for SORT or MERGE, there are no specific rules to determine which record from among the records are summed up, and which records will be deleted.

    • In case of SORT: When EQUALS is specified, records are summed up to the record that was first input.

    • In case of MERGE: When EQUALS is specified, records are summed up to the record whose number in SORTINnn is the smallest. If the SORTINnn are the same, they are summed up to the one that was first input.

  • When performing SUM, records in the specified record field are summed up, and those in other fields are not.

  • When performing SUM, records are not summed up in the event of overflow. The records that have not been summed up are not deleted.