DYNA-MatCH
Introduction
FAQ
Free Trial
Accolades
Pricing
Examples
enve

Contact Allumina Software

Examples

Examples

    These examples demonstrate how DYNA-MatCH is used to solve a variety of basic data processing problems. All problems are presented as if a customer were requesting a special process. The files used in the examples are the PERSONNEL and PAYROLL datasets described below. Both files are sorted by Employee Number.

Personnel Dataset Description

Field Name

Length

Position

Data Format

Employee Number

6

1

NUMERIC

Last Name

20

8

CHAR

First Name

10

28

CHAR

Address-Street

20

40

CHAR

Address-City

20

60

CHAR

Address-State

2

80

CHAR

Address-Zip

6

82

NUMERIC

Date of Birth

6

88

YYMMDD

Marital-Status

1

96

M/S

Sex-Code

1

97

M/F

Telephone

12

98

NUMERIC

Payroll Dataset Description

Field Name

Length

Position

Data Format

Employee Number

6

1

NUMERIC

Pay-Hour

4

7

NUMERIC

Department

6

11

CHAR

SSN

9

17

NUMERIC

Hire Date

6

26

YYMMDD

Vacation Hours

3

32

NUMERIC

Simple Dataset Extraction

Problem: I need a dataset containing employees who are eligible for retirement in the next three years. I need their Employee Number, Name and Telephone Number.

//EXAMPLE EXEC PGM=DYNAMCH
//SYSUT1A  DD DSN=personnel.ds,DISP=SHR
//SYSUT1B  DD DUMMY
//SYSUT2   DD DSN=NEW.FILE,DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,SPACE=(TRK,(15,15))
//SYSOUT   DD SYSOUT=*
//SYSIN    DD *
OUTPUT ALL
USEA  006 088 LT '651231'
FIELD 037   A 001      
FIELD 012   A 098  

OUTPUT ALL indicates all records from SYSUT1A are to be used - matched or unmatched. Because SYSUT1B is dummied, and there is no MATCH control statement, all records are considered matched. The USEA control statement selects records from SYSUT1A when 006 bytes in column 088 is Less Than '651231'. The output will be 037 bytes from column 001 of SYSUT1A. The next 012 bytes will be from column 098 of SYSUT1A. The 49-byte output will contain employee number, last name, first name, and telephone number.  

 

Simple Match

Problem: I need a dataset containing employee names, telephone numbers, and the number of vacation hours. 

//EXAMPLE EXEC PGM=DYNAMCH
//SYSUT1A  DD DSN=personnel.ds,DISP=SHR
//SYSUT1B  DD DSN=payroll.ds,DISP=SHR
//SYSUT2   DD DSN=new.file,DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,SPACE=(TRK,(15,15))
//SYSOUT   DD SYSOUT=*
//SYSIN    DD *
OUTPUT MATCHED
MATCH 006 001 001             
FIELD 031   A 007     
FIELD 012   A 098    
FIELD 003   B 032
 

The two input files are matched by employee number (the files must be sorted by employee number). The match fields are described in the MATCH control statement. Both input files have a 006 byte key starting in column 001. The output is the last name, the first name, and the telephone number from SYSUT1A, and the number of vacation hours from SYSUT1B.  

 

Simple Unmatched

Problem: I have a list of employee numbers that I want deleted from the Personnel Master file. 

//EXAMPLE EXEC PGM=DYNAMCH
//SYSUT1A  DD DSN= personnel.ds(0),DISP=SHR
//SYSUT1B  DD  *
024954
038957
038977
049123
049321
055667
055889
067123
099111
//SYSUT2   DD DSN=personnel.ds(+1),DISP=NEW,CATLG,DELETE),
//            UNIT=SYSDA,SPACE=(TRK,(15,15))
//SYSOUT   DD SYSOUT=*
//SYSIN    DD *
OUTPUT UNMATCHED     
MATCH 006 001 001             
FIELD 110   A 001   

  The Personnel Master file (SYSUT1A) is matched against the list of employee numbers (SYSUT1B). Records from SYSUT1A that donšt match are written to SYSUT2. The OUTPUT UNMATCHED control statement selects those records from SYSUT1A whose keys do not match a key in SYSUT1B. The MATCH control statement defines the keys as 006 bytes, starting in column 001 of SYSUT1A and column 001 of SYSUT1B. The FIELD control statement defines the output as 110 bytes from column001 of SYSUT1A. 

Note: This simple example could be done by any of the popular SORT utilities, but as the list of employees grows it becomes more awkward to code all the employee numbers in the control statements. DYNA-MatCH requires no control statement changes when the employees to be deleted changes. In addition, DYNA-MatCH only checks the key against one value for each record, due to the matching process. This makes DYNA-MatCH more efficient.

 

Match With Data Replacement

Problem: I have a list of employee numbers whose Sex code is wrong. Fix it. 

//EXAMPLE EXEC PGM=DYNAMCH
//SYSUT1A  DD DSN=personnel.ds(0),DISP=SHR
//SYSUT1B  DD *
024954   M
038957   F
038977   F
049123   M
049321   M
055667   M
055889   M
067123   F
099111   F
//SYSUT2   DD DSN= personnel.ds(+1)DISP=NEW,CATLG,DELETE),
//            UNIT=SYSDA,SPACE=(TRK,(15,15)),DCB=MODEL
//SYSOUT   DD SYSOUT=*
//SYSIN    DD *
OUTPUT ALL                 
MATCH 006 001 001             
FIELD 096   A 001       
FIELD 001   B 010 A 097
FIELD 013   A 098        

All records from SYSUT1A will be written to SYSUT2 without any changes, except those records with the employee codes listed under SYSUT1B. SYSUT1A records that are matched to SYSUT1B records will have column 97 changed to the code in column 10 of SYSUT1B. The second FIELD control statement uses an alternate field, that will be used whenever an unmatched condition occurs. 

Complex Single File Process

Problem: I need a list of employees who live at the same address and are single. Therešs a possibility that we can save on our health insurance by getting a married rate. 

//SORT     EXEC SORT
 SORT FIELDS=(40,20,CH,A)
//*
//EXAMPLE EXEC PGM=DYNAMCH
//SYSUT1A DD DSN=personnel.ds(0),DISP=SHR
//SYSUT1B DD DUMMY
//SYSUT2  DD DSN=temp.address,DISP=NEW,CATLG,DELETE),
//           UNIT=SYSDA,SPACE=(TRK,(15,15))
//SYSOUT  DD SYSOUT=*
//SYSIN   DD  *
OUTPUT ALL           <--SELECT ALL RECORDS
FIELD 110   A 001    <--ALL 110 BYTES OF THE FILE  
DELETE               <--NO DEFAULT OUTPUT 
WHEN  020 240 EQ 040 <--PREV ADDRESS=CURR ADDRESS
AND   001 096 EQ 'S' <--AND CURRENT MARRIAGE CODE--SINGLE
AND   001 296 EQ 'S' <--AND PREVIOUS MARRIAGE CODE--SINGLE
ALTER 039 401    001 <--MVE EMPLOYEE # AND NAMES--CURRENT
ALTER 039 440    201 <--MVE EMPLOYEE # AND NAMES--PREVIOUS
OUT= SYSUT2    401    <--WRITE SYSUT2 FROM COL 301
*
WHEN  001 001 EQ 001 <--UNCONDITIONAL
ALTER 110 201    001 <--MOVE RECORD TO COL 201

The Personnel dataset must be sorted by the address. The last control statement moves the 110 byte personnel record to column 201 for use by subsequent records. The DELETE control statement is coded so only the records explicitly written by the OUT= control statement will be output. The street address of the current record is compared to the street address of the previous work area in column 201. When they are equal, and both the current and previous marriage codes are 'S', then the first 39 bytes of both records are moved to columns 401 and 440 and written to SYSUT2 from column 401. The last WHEN statement makes the ALTER on the next line unconditional. 

Notice that any columns not used for control statement information can be used for comments.  

Arithmetic Processing

Problem: Personnel needs a dataset that will contain a list of all employees hired as teenagers. 

//EXAMPLE EXEC PGM=DYNAMCH
//SYSUT1A DD DSN=personnel.ds(0),DISP=SHR       
//SYSUT1B DD DSN=payroll.ds(0),DISP=SHR
//SYSUT2  DD DSN=temp.dept,DISP=NEW,CATLG,DELETE),
//           UNIT=SYSDA,SPACE=(TRK,(15,15))
//SYSOUT  DD SYSOUT=*
//SYSIN   DD *
OUTPUT MATCHED
MATCH 006 001 001
FIELD 036   A 001
FIELD 006   A 088
FIELD 006   B 026   
DELETE
+     002 043 DISPLAY
-     002 037 DISPLAY
=     002 050 DISPLAY
WHEN  002 050 LT '020'
OR
WHEN  002 050 EQ '020'
AND   002 043 LT 037
OR
WHEN  002 050 EQ '020'
AND   002 043 EQ 037
AND   002 045 LT 039
OUT=SYSUT2

The files are matched on employee number. The FIELD control statements extract the employee number, first and last names, date of birth, and hire date. The DELETE control statement suppresses the default output so that only records meeting the specified criteria will be written. 

The "+" control statement adds the year hired into the accumulator. The "-" control statement subtracts the year born from the accumulator. The "=" control statement places the result into column 050 as a 002 byte display numeric. The WHEN, AND, and OR control statements are used to set a condition if the employee was hired when LessThan '020' years of age. The employee is a teen hire WHEN: 1) the difference of years is Less Than '020', OR 2) WHEN the difference is EQual to '020' AND the month hired is Less Than the month born, or 3) WHEN the difference is equal to '020' AND the month born is EQual to the month hired AND the day hired is Less Than the day born.

File Splitting

Problem: Management wants both the Personnel and Payroll files separated into two, based upon the department number. Department numbers 500000 and above are moving to a new division.

//EXAMPLE EXEC PGM=DYNAMCH
//SYSUT1A DD DSN=personnel.ds(0),DISP=SHR
//SYSUT1B DD DSN=payroll.ds(0),DISP=SHR
//LOWPER  DD DSN=personnel.low,DISP=NEW,CATLG,DELETE),
//           DCB=RECFM=FB,LRECL=110,BLKSIZE=11440),
//           UNIT=SYSDA,SPACE=(TRK,(15,15))
//LOWPAY  DD DSN=payroll.low,DISP=NEW,CATLG,DELETE),
//           DCB=(RECFM=FB,LRECL=34,BLKSIZE=11458),
//           UNIT=SYSDA,SPACE=(TRK,(15,15))
//HIGHPER DD DSN=personnel.high,DISP=NEW,CATLG,DELETE),
//           DCB=(RECFM=FB,LRECL=110,BLKSIZE=11440),
//           UNIT=SYSDA,SPACE=(TRK,(15,15))
//HIGHPAY DD DSN=payrol.high,DISP=NEW,CATLG,DELETE),
//           DCB=(RECFM=FB,LRECL=34,BLKSIZE=11458),
//           UNIT=SYSDA,SPACE=(TRK,(15,15))
//SYSIN   DD *
OUTPUT MATCHED
MATCH 006 001 001
FIELD 110   A 001
FIELD 034   B 001
DELETE
WHEN  001 121 LT '5'
OUT=LOWPER    001
OUT=LOWPAY    111
WHEN  001 121 GE '5'
OUT=HIGHPER   001
OUT=HIGHPAY   111
 

The Personnel and Payroll masterfiles must be sorted by employee number. These input files are matched by employee number. Both files are moved to the work area. Column 11 of SYSUT1B, which has been moved to column 121 of the work area, is compared to a '5'. If it is Less Than '5', LOWPER and LOWPAY are written, otherwise, HIPER and HIPAY are written. The payroll files are written from column 111 of the work area