Specifying Field-to-Constant Standard Comparisons - mfx - 3.1

Syncsort™ MFX Programmers Guide

Product type
Software
Portfolio
Integrate
Product family
Syncsort™ Software
Product
Syncsort™ MFX > MFX
Version
3.1
Language
English
Content type
Programmer’s Guide
Product name
Syncsort™ MFX
Title
Syncsort™ MFX Programmers Guide
Topic type
How Do I
Copyright
2024
First publish date
2010
Last edition
2024-08-27
Last publish date
2024-08-27T08:14:56.318001
The format of a data field determines the type of constant to which it can be compared. The figure below illustrates which field-to-constant comparisons are permitted.
Table 1. Permissible Field-to-Constant Comparisons
Format Decimal Hexadecimal Character

Binary

(bit pattern)

Year Constant

AC   X X    
AQ   X X    
ASL X        
AST X        
BI X* X X X  
CH   X X    
CLO/OL X        
CSF/FS X        
CSL/LS X        
CST/TS X        
CTO/OT X        
FI X**        
PD X        
PD0   X      
SS   X X    
Y2B X       X
Y2C/Y2Z X       X
Y2D X       X
Y2P X       X
Y2S X       X
Y2T*** X       X
Y2U*** X       X
Y2V*** X       X
Y2W*** X       X
Y2X*** X       X
Y2Y*** X       X
SFF X        
UFF X        
ZD X        
Note:

* The decimal constant cannot be higher than 18446744073709551615 or lower than 0.

** The decimal constant cannot be higher than 9223372036854775807 or lower than -9223372036854775808.

*** Full-Date formats

A constant will be padded or truncated to the length of the field with which it is compared. Decimal constants are padded or truncated on the left; hexadecimal, binary, and character constants are padded on the right. The padding characters are:
Binary string B'00000000'
Character string X'40'
Hexadecimal string X'00'
Decimal fields

Zeros of proper format. Decimal constants for 2-digit year formats are padded or truncated to two decimal digits representing a year. The year constant will then have CENTWIN processing applied to it for comparison to a Y2 field. These are only for the two digit year fields, not for full date constants.

The constants for PD0 comparison should not include the first digit and trailing sign of the PD0 data that will be ignored. Thus, a PD0 field of n bytes will be compared to a constant of n-1 bytes.

Current Date Constant Specification

You can compare fields to the date of an MFX run or the date of the run with an offset in addition to decimal fields and binary, character, and hexadecimal strings. Thus, records can more easily be included or omitted based on whether their dates are equal to, less than, or greater than the run date or the run date with an offset.

The format of a current date constant is illustrated below.
Figure 1. Current Date Constant Format

Where:
current date constant

Specifies a form of one of the &DATEx, &DATEx(c), &DATExP, or Y'DATEx' parameters where x is 1, 2, 3, 4 or 5 and depends on date comparison compatibility.

+ Specifies a date after the current date.
Specifies a date before the current date.
nnnn

Specifies the number of offset days or offset months depending upon x in the following cases: when the x in &DATEx, &DATEx(c), &DATExP, or Y'DATEx' is 1, 3, 4 or 5, ‘nnnn’ represents offset days and can be from 0-9999; when the x in &DATEx, &DATEx(c), &DATExP, or Y'DATEx' is 2, ‘nnnn’ represents offset months and can be from 0-999.

For an example of an INCLUDE control statement that uses a date range based on a date constant, see figure Sample INCLUDE Control Statement Using Current Date Constant and Current Date With an Offset Comparison.

The forms of current date constants available for standard comparisons are:
  • &DATEx and &DATEx(c) represent the current date as a character string (C'string') to which a field can be compared.

  • &DATExP represents the current date as a decimal number (+n) to which a field can be compared.

  • Y'DATEx' represents the current date with a Y constant (Y'string') to which a field can be compared.

The following table shows the current date constants and the format produced by each. The c character in &DATEx(c) represents a non-blank separator character, except open and close parentheses.
Table 2. Current Date Constant Formats

Current Date Constant

Generated Constant

&DATE1 [{±}nnnn]

C'yyyymmdd'

&DATE1(c) [{±}nnnn]

C'yyyycmmcdd'

&DATE1P [{±}nnnn]

+yyyymmdd

&DATE2 [{±}nnn]

C'yyyymm'

&DATE2(c) [{±}nnn]

   C'yyyycmm'

&DATE2P [{±}nnn]

+yyyymm

&DATE3 [{±}nnnn]

   C'yyyyddd'

&DATE3(c) [{±}nnnn]

C'yyyycddd'

&DATE3P    [{±}nnnn]

+yyyyddd

&DATE4 [{±}nnnn]

C'yyyy-mm-dd-hh.mm.ss'

&DATE5[{±}nnnn]

C'yyyy-mm-dd-hh.mm.ss.nnnnnn'

Y'DATE1'

   Y'yymmdd'

Y'DATE2'

Y'yymm'

Y'DATE3'

Y'yyddd'

Full-Date Format Constant Specifications

Constants used for full-date comparisons should have the same number of digits in the constant as in the full-date field that has been specified. Leading zeros must be specified when needed. The constant is constructed from two items; the first is a 2-digit year and the second is a value representing the months or days that comprise the remainder of the full date format. For example, if a 5-byte Y2W field were to be compared for a value greater than the 20th day of 1996, 96020 should be the code for the constant.

Constants can be coded to represent special values, such as those found in header or trailer records. All zeros or nines may be used with Y2T, Y2U, Y2V, Y2W, Y2X, and Y2Y. The same number of digits must be present as in the field that is being compared. The constant string Y'LOW' (representing binary zeros), Y'HIGH' (representing binary ones), or Y'BLANKS' (representing blanks) may be coded with the fields Y2T, Y2W, and Y2S. Y'DATEx' (representing the current date) may be coded with certain full-date formats specifically (see Full-Date Comparisons).

Table 3. Full-Date Comparisons

Y Constant

Date Form

Length and Data Format Allowed

Y'DATE1'

yyxxxx and xxxxyy

6,Y2T

6,Y2W

4,Y2V

4,Y2Y

Y'DATE2'

yyxx and xxyy

4,Y2T

4,Y2W

3,Y2V

3,Y2Y

Y'DATE3'

yyxxx and xxxyy

5,Y2T

5,Y2W

3,Y2U

3,Y2X

Substring Comparisons

Substring comparison (SS format) can be based on any of the following searches:
  • Match occurrence of a constant within a record field

  • Match occurrence of a record field within a constant

  • Match occurrence of a pattern (wildcard) constant within a record field

In the first form, the length of the constant is less than the length of a specified field. Records will be searched for the occurrence of the constant anywhere within the field. The condition will be true if an EQ operator is specified and the constant is found or if a NE operator was specified and the constant is not found. For example, consider the constant “ANYTOWN” and a 60-byte field that contains an address. Records will be searched for the occurrence of the literal “ANYTOWN” anywhere within the 60-byte address field. If a match is found and the logical operator is EQ, then the logical result is “true.” The logical result is also “true” if the literal does not appear within the 60 bytes and the logical operator is NE.

In the second form, the length of a constant is greater than or equal to the length of a specified field. Records will be searched for an occurrence of the field within the constant. For example, the constant 'A02,A05,A06,A09' can be compared against the contents of a 3-byte field within the record. This constant is composed of four 3-byte substrings in a format that is known to match the data in the record field, separated by commas, a character known not to be in the record field. This means that ‘A02’, ‘A05’, ‘A06’, and ‘A09’ are the only possible 3-byte strings that could possibly match the data in the record field. If the 3-byte field matches any 3-byte character string in the constant, the logical result is “true” if the logical operator is EQ. If the 3-byte field does not match all 3-byte character strings in the constant, the logical result is “true” if the logical operator is NE.

The character used to separate elements of the constant should be a character that does not appear in the field being compared. The comparison is then equivalent to a standard comparison with ORed conditions when the logical operator is EQ. That is, the condition is true if 'A02' OR 'A05' OR 'A06' OR 'A09' is found in the field being compared. The substring comparison is a much more compact expression than multiple OR conditions in a standard comparison. When the logical operator is NE, the comparison is equivalent to a standard comparison with ANDed conditions.

In the third form, a pattern constant is used to describe a string that is the object of the search rather than the exact characters to be found. The pattern constant can consist of one or more character or hexadecimal constants and wildcard characters. A wildcard can be either a percent sign ‘%’ which matches any single character or an asterisk ‘*’ which can match zero or more characters in a string.

In this form of searching, only an occurrence of a pattern constant within a record field can be performed. An occurrence of a record field cannot be searched for in a pattern constant.

Typically this form of substring search is used when the beginning and ending characters of a field contain the major values of the search. The middle characters represent a range of values within this major category that are desired for selection.

For all forms of substring comparison, fields in the record can be from 1 to 32752 bytes in length. Constants can be in either character or hexadecimal format and can be from 1 to 256 bytes in length. (See the description of constants just after Permissible Field-to-Constant Comparisons.)

See examples starting with the figure Sample INCLUDE Control Statement Using Substring Comparison for some samples of how to use the substring comparison.

NUM Subparameter

Use NUM to identify a field as numeric or non-numeric in CSF/FS, FD, PD or ZD format. Specify NUM with the field (p,l), format (CSF/FS, FD, PD or ZD) and comparison operators (EQ or NE), described as follows:
p,l

Specify field subparameters p as the starting position of the field in the record; and l as the length in bytes (1 to 256) of the field.

CSF/FS/FD/PD/ZD

Specify CSF or FS format to evaluate the field for character numerics. A field is character numeric if every byte contains only characters from 0 to 9. In hexadecimal format, for X'hhhh...hh', every 'hh' represents hex values in the range F0 to F9. Otherwise, the field is non-numeric. For example, 2468 and X'F3F2F1' are character numeric; 24A68 and X'F3F2C1' are character non-numeric.

Specify PD format to evaluate the field for packed decimal numerics. A field is packed decimal numeric if every non-sign byte contains values from the range of 0 to 9 and the sign byte is C, D, or F. In hexadecimal format, for X'ppp...ps', every p represents values in the range 0 to 9; s represents C, D, or F. Otherwise, the field is non-numeric. For example, X'2468C' and X'1359D' are packed decimal numeric; X'24A68' and X'F3F2B1' are packed decimal non-numeric.

Specify ZD format to evaluate the field for zoned decimal numerics. A field is zoned decimal numeric if every non-sign byte contains only characters from 0 to 9 and the sign byte contains hex values in the ranges of C0 to C9, D0 to D9, or F0 to F9. In hexadecimal format, for X'zzzz...sz', every zz represents hex values in the range of F0-F9; sz represents hex values in the ranges of C0 to C9, D0 to D9, or F0 to F9. Otherwise, the field is non-numeric. For example, 2468 and X'F3F2F1D5' are zoned decimal numeric; 24A68 and X'F3F2B1' are zoned decimal non-numeric.

Specify FD format to evaluate the field for decimal floating point numerics. A field is numeric if it is a finite number. Positive, negative infinity and signaling and quiet NaNs (Not-a-Number) are considered non-numeric.

EQ/NE

Specify EQ to evaluate the field for numerics; specify NE to evaluate the field for non-numerics.

See figure Sample OMIT Control Statement Using NUM for an example of how to use the NUM subparameter.