View previous topic :: View next topic
|
Author |
Message |
chillmo
New User
Joined: 31 Aug 2017 Posts: 54 Location: USA
|
|
|
|
I have a requirement to change a few records based on the input file but wanted to dynamically create them via sort. The sort card would be used in the next aka 2nd step.
Input:
Code: |
D09301 09301
D05401 05401
A19001 19001
|
Sort card:
Code: |
OUTFIL REMOVECC,
HEADER1=(C' INREC IFTHEN=(WHEN=(26,3,CH,EQ,',
C'''020'',AND,60,6,CH,EQ,C''',1,6,C'''),',/,16X,
C'OVERLAY=(60:C''',8,5,C''')),'),
BUILD=(8X,C'IFTHEN=(WHEN=(26,3,CH,EQ,',
C'''020'',AND,60,6,CH,EQ,C''',1,6,C'''),',/,16X,
C'OVERLAY=(60:C''',8,5,C''')),')
|
Desired output is:
Code: |
INREC IFTHEN=(WHEN=(26,3,CH,EQ,'020',AND,60,6,CH,EQ,C'D09301'),
OVERLAY=(60:C'09301')),
IFTHEN=(WHEN=(26,3,CH,EQ,'020',AND,60,6,CH,EQ,C'D05401'),
OVERLAY=(60:C'05401')),
IFTHEN=(WHEN=(26,3,CH,EQ,'020',AND,60,6,CH,EQ,C'A19001'),
OVERLAY=(60:C'19001')) |
But I get the following:
Code: |
INREC IFTHEN=(WHEN=(26,3,CH,EQ,'020',AND,60,6,CH,EQ,C'D09301'),
OVERLAY=(60:C'09301')),
IFTHEN=(WHEN=(26,3,CH,EQ,'020',AND,60,6,CH,EQ,C'D09301'),
OVERLAY=(60:C'09301')),
IFTHEN=(WHEN=(26,3,CH,EQ,'020',AND,60,6,CH,EQ,C'D05401'),
OVERLAY=(60:C'05401')),
IFTHEN=(WHEN=(26,3,CH,EQ,'020',AND,60,6,CH,EQ,C'A19001'),
OVERLAY=(60:C'19001')),
|
Second step:
Code: |
//STEP2 PERFORMS THE ACTUAL COPY
//SORTIN DD DSN=ORIGINAL.INPUT.FILE
//SORTOUT DD DSN=NEW.DATA.SET
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(50,10),RLSE)
//SYSOUT DD SYSOUT=*
//SYSIN DD DSN=TEMP.CONTROL.STATEMENTS (THIS IS SORTOUT FROM STEP 1)
// DISP=(OLD,DELETE,DELETE),UNIT=SYSDA
|
Any assistance would be greatly appreciated!
Also, if I read the manual correctly, since for each record only one of the conditions would be true, no HIT=NEXT is required......is this true? |
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1390 Location: Bamberg, Germany
|
|
|
|
The following takes care of the ending comma. F1 and F2 have to be the same.
Code: |
//WHATEVER EXEC PGM=SORT
//F1 DD *
D09301 09301
D05401 05401
A19001 19001
/*
//F2 DD *
D09301 09301
D05401 05401
A19001 19001
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(81,1,A)
JOINKEYS F2=F2,FIELDS=(81,1,A)
REFORMAT FIELDS=(F1:1,80,F2:82,2)
INREC OVERLAY=(83:SEQNUM,2,BI)
OUTFIL FNAMES=(SORTOUT),
REMOVECC,
IFTHEN=(WHEN=(83,2,BI,EQ,+1),OVERLAY=(85:C'INREC '),HIT=NEXT),
IFTHEN=(WHEN=(81,2,BI,NE,83,2,BI),
BUILD=(2X,85,6,C'IFTHEN=(WHEN=(26,3,CH,EQ,C''020''',
C',AND,60,6,CH,EQ,C''',1,6,C'''),',/,16X,
C'OVERLAY=(60:C''',8,5,C''')),')),
IFTHEN=(WHEN=(81,2,BI,EQ,83,2,BI),
BUILD=(2X,85,6,C'IFTHEN=(WHEN=(26,3,CH,EQ,C''020''',
C',AND,60,6,CH,EQ,C''',1,6,C'''),',/,16X,
C'OVERLAY=(60:C''',8,5,C'''))'))
END
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:Z))
END
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:Z,+1,BI,LENGTH=2))
SUM FIELDS=(82,2,BI)
END
/* |
Code: |
****** **************************** Datenanfang ***************************
000001 INREC IFTHEN=(WHEN=(26,3,CH,EQ,C'020',AND,60,6,CH,EQ,C'D09301'),
000002 OVERLAY=(60:C'09301')),
000003 IFTHEN=(WHEN=(26,3,CH,EQ,C'020',AND,60,6,CH,EQ,C'D05401'),
000004 OVERLAY=(60:C'05401')),
000005 IFTHEN=(WHEN=(26,3,CH,EQ,C'020',AND,60,6,CH,EQ,C'A19001'),
000006 OVERLAY=(60:C'19001'))
****** **************************** Datenende ***************************** |
|
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1390 Location: Bamberg, Germany
|
|
|
|
Forgot, also add
Code: |
HEADER1=(2X,C'OPTION COPY') |
and some code that makes your output F[B]80. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2218 Location: USA
|
|
|
|
Code: |
SORT FIELDS=COPY
OUTFIL REMOVECC,
HEADER1=(C' SORT FIELDS=COPY',
/,C' INREC IFTHEN=(WHEN=INIT,OVERLAY=(1:1,1)),'),
BUILD=(8X,C'IFTHEN=(WHEN=(26,3,CH,EQ,',
C'''020'',AND,60,6,CH,EQ,C''',1,6,C'''),',/,16X,
C'OVERLAY=(60:C''',8,5,C''')),'),
TRAILER1=(C' IFTHEN=(WHEN=NONE,OVERLAY=(1:1,1))',
/,C' END ')
END |
Code: |
********************************* TOP OF DATA **
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(1:1,1)),
IFTHEN=(WHEN=(26,3,CH,EQ,'020',AND,60,6,CH,EQ,C'D09301'),
OVERLAY=(60:C'09301')),
IFTHEN=(WHEN=(26,3,CH,EQ,'020',AND,60,6,CH,EQ,C'D05401'),
OVERLAY=(60:C'05401')),
IFTHEN=(WHEN=(26,3,CH,EQ,'020',AND,60,6,CH,EQ,C'A19001'),
OVERLAY=(60:C'19001')),
IFTHEN=(WHEN=NONE,OVERLAY=(1:1,1))
END
******************************** BOTTOM OF DATA ** |
|
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2218 Location: USA
|
|
|
|
In the real life, a task like this one usually requires replacement of thousands to millions of different values to some replacing values. Such as, let's say, "substitution by a dictionary".
In this situation it becomes impossible to dynamically generate SORT statements with thousands or millions of parameters. Generation of the statements is possible, but the generated statements cannot be executed.
For such situation JOIN option of SORT utility is used, which matches possible values in the "master file" with corresponding values from the "dictionary file", and replaces found values as defined. This is "training number 2" to code a different solution for the initial task. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2218 Location: USA
|
|
|
|
My suggestion is: to change the initial approach.
Code: |
//*====================================================================
//SORTSELJ EXEC PGM=SORT
//*
//SYSOUT DD SYSOUT=*
//DICT DD *
D09301 09301
D05401 05401
A19001 19001
//*-+----1----+----2----+----3----+----4----+----5----+----6----+----7
//MASTER DD *
020 D09301
021 D09301
020 D09302
021 D09302
020 D05401
021 D05401
020 D05402
021 D05402
020 A19001
021 A19001
020 A19002
021 A19002
//*-+----1----+----2----+----3----+----4----+----5----+----6----+----7
//*
//SORTOUT DD SYSOUT=*
//*....................................................................
//SYSIN DD *
JOINKEYS F1=MASTER,
FIELDS=(60,6,A) field to look for
JOINKEYS F2=DICT,
FIELDS=(01,6,A) values to be replaced
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,80, full master record
?, match indicator
F2:8,5) value to replace
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(81,1,CH,EQ,C'B', match found?
AND,26,3,CH,EQ,C'020'), especially marked?
OVERLAY=(60:82,5)) substitute replacement value
OUTFIL BUILD=(1,80) truncate temporary fields
END
//*....................................................................
//*==================================================================== |
Code: |
********************************* TOP OF DATA ******************************
020 190011
021 A19001
020 A19002
021 A19002
020 054011
021 D05401
020 D05402
021 D05402
020 093011
021 D09301
020 D09302
021 D09302
******************************** BOTTOM OF DATA **************************** |
|
|
Back to top |
|
 |
chillmo
New User
Joined: 31 Aug 2017 Posts: 54 Location: USA
|
|
|
|
Joerg.Findeisen, as usual your suggestion worked perfectly.
Thanks again!
Sergeyken, I truly appreciate the alternate option. I thought about this but since the sort card would be less than 500, I didn't worry about maxing out the sort statements. Furthermore, I modified your solution for my purposes as I was going from a 6-bytes to 5-bytes (see below) and the remaining 1-byte made the field incorrect:
Code: |
F2:8,5) value to replace |
to
Code: |
F2:8,6) value to replace |
Thanks again! |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2218 Location: USA
|
|
|
|
Joerg.Findeisen wrote: |
The following takes care of the ending comma. F1 and F2 have to be the same.
Code: |
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(81,1,A)
JOINKEYS F2=F2,FIELDS=(81,1,A)
REFORMAT FIELDS=(F1:1,80,F2:82,2)
INREC OVERLAY=(83:SEQNUM,2,BI)
OUTFIL FNAMES=(SORTOUT),
REMOVECC,
IFTHEN=(WHEN=(83,2,BI,EQ,+1),OVERLAY=(85:C'INREC '),HIT=NEXT),
IFTHEN=(WHEN=(81,2,BI,NE,83,2,BI),
BUILD=(2X,85,6,C'IFTHEN=(WHEN=(26,3,CH,EQ,C''020''',
C',AND,60,6,CH,EQ,C''',1,6,C'''),',/,16X,
C'OVERLAY=(60:C''',8,5,C''')),')),
IFTHEN=(WHEN=(81,2,BI,EQ,83,2,BI),
BUILD=(2X,85,6,C'IFTHEN=(WHEN=(26,3,CH,EQ,C''020''',
C',AND,60,6,CH,EQ,C''',1,6,C'''),',/,16X,
C'OVERLAY=(60:C''',8,5,C'''))'))
END
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:Z))
END
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:Z,+1,BI,LENGTH=2))
SUM FIELDS=(82,2,BI)
END
/* |
|
A really working solution, but with some disadvantages:
1) overcomplicated logic (see my first example above),
2) duplicated input of the same input data is required,
3) physically limited maximum number of allowed substitutions,
4) two-step processing is required, which is not necessary for this task (see my second example above).
Simple tasks need to be done by simple methods. This is my opinion. |
|
Back to top |
|
 |
chillmo
New User
Joined: 31 Aug 2017 Posts: 54 Location: USA
|
|
|
|
The business added another requirement, no surprise here.......lol!
Furthermore, is it possible to do this in one pass?
Code: |
WHEN=(26,3,CH,EQ,C'010',AND,91,5,CH,EQ,C'12345'), OVERLAY=(86:C'99999'))
|
Input
Code: |
D09301 09301 12345 99999
D05401 05401 67890 88888
A19001 19001 13579 77777 |
I felt it's best to put the new requirement in different columns to further differentiate this. Again, I can do this in two passes but wanted to know if one pass is possible. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2218 Location: USA
|
|
|
|
chillmo wrote: |
The business added another requirement, no surprise here.......lol!
Furthermore, is it possible to do this in one pass?
Code: |
WHEN=(26,3,CH,EQ,C'010',AND,91,5,CH,EQ,C'12345'), OVERLAY=(86:C'99999'))
|
Input
Code: |
D09301 09301 12345 99999
D05401 05401 67890 88888
A19001 19001 13579 77777 |
I felt it's best to put the new requirement in different columns to further differentiate this. Again, I can do this in two passes but wanted to know if one pass is possible. |
You can easily modify my example with JOIN master and dictionary files, to achieve this "changed requirement".
But now I'll not give you a ready-to-copy-and-paste answer. Only use it as a hint. |
|
Back to top |
|
 |
chillmo
New User
Joined: 31 Aug 2017 Posts: 54 Location: USA
|
|
|
|
Yes, it's below. NOT sure why I created my input file as such, but once i changed it, plus your hint, it worked.
Thx!
Code: |
//*====================================================================
//SORTSELJ EXEC PGM=SORT
//*
//SYSOUT DD SYSOUT=*
//DICT DD *
D09301 09301
D05401 05401
A19001 19001
12345 99999
67890 88888
13579 77777
//*-+----1----+----2----+----3----+----4----+----5----+----6----+----7
//MASTER DD *
020 D09301
021 D09301
020 D09302
021 D09302
020 D05401
021 D05401
020 D05402
021 D05402
020 A19001
021 A19001
020 A19002
021 A19002
010 12345
010 67890
011 67890
010 13579
//*-+----1----+----2----+----3----+----4----+----5----+----6----+----7
//*
//SORTOUT DD DSN=I.LUV.THIS.GROUP,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(5,5),RLSE)
//*....................................................................
//SYSIN DD *
JOINKEYS F1=MASTER,
FIELDS=(60,6,A,40,5,A) FIELD TO LOOK FOR
JOINKEYS F2=DICT,
FIELDS=(01,6,A,15,5,A) VALUES TO BE REPLACED
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,80, FULL MASTER RECORD
?, MATCH INDICATOR
F2:8,6,F2:21,5) VALUE TO REPLACE
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(81,1,CH,EQ,C'B', MATCH FOUND?
AND,26,3,CH,EQ,C'020'), ESPECIALLY MARKED?
OVERLAY=(60:82,6)), SUBSTITUTE REPLACEMENT VALUE
IFTHEN=(WHEN=(81,1,CH,EQ,C'B', MATCH FOUND?
AND,26,3,CH,EQ,C'010'), ESPECIALLY MARKED?
OVERLAY=(40:88,5)) SUBSTITUTE REPLACEMENT VALUE
OUTFIL BUILD=(1,80) TRUNCATE TEMPORARY FIELDS
END
//*....................................................................
//*====================================================================
|
|
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2218 Location: USA
|
|
|
|
Wrong solution.
Did you try to test it?
All fields listed in FIELDS= parameter must match simultaneously, in a single record. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2218 Location: USA
|
|
|
|
A non-obvious problem with "new requirement" is, different size and position of the field to be matched (5 or 6 chars).
One way to resolve it - use master file preprocessing (as //JNF1CNTL DD) to create intermediate field of max size 6 chars, to be matched in following JOIN operation. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2218 Location: USA
|
|
|
|
sergeyken wrote: |
Wrong solution.
Did you try to test it?
All fields listed in FIELDS= parameter must match simultaneously, in a single record. |
Frankly, this way also would work, but only for specific test data - when all unused matching fields in all records are filled with blanks. AFAIU, in the real life this does not happen... |
|
Back to top |
|
 |
chillmo
New User
Joined: 31 Aug 2017 Posts: 54 Location: USA
|
|
|
|
sergeyken wrote:
Wrong solution.
Did you try to test it?
All fields listed in FIELDS= parameter must match simultaneously, in a single record.
Yes, I tested this and it worked for my test data but I'll test it next w/real live data.
I'll keep you posted. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2218 Location: USA
|
|
|
|
chillmo wrote: |
sergeyken wrote:
Wrong solution.
Did you try to test it?
All fields listed in FIELDS= parameter must match simultaneously, in a single record.
Yes, I tested this and it worked for my test data but I'll test it next w/real live data.
I'll keep you posted. |
but only for specific test data - when all unused matching fields in all records are filled with blanks. AFAIU, in the real life this does not happen... |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2218 Location: USA
|
|
|
|
One possible solution is as follows.
Code: |
//*====================================================================
//SORTSELJ EXEC PGM=SORT
//*
//SYSOUT DD SYSOUT=*
//*
//SYMNAMES DD *
Dict_Match0,15,3,CH dictionary match field 1
Dict_MatchX,1,6,CH dictionary match field 2/3
Dict_Repl5,8,5,CH 5-chars replacement
Dict_Repl6,=,6,CH 6-chars replacement
*
Mast_Match0,26,3,CH master match field 1
Mast_Match6,60,6,CH master match field 2
Mast_Match5,40,5,CH master match field 3
*
Mast_Record,1,80,CH
Join_Ind,*,1,CH joining indicator: 'B', '1', '2'
Join_Repl5,*,5,CH replacement for 5-chars field
Join_Repl6,=,6,CH replacement for 6-cahrs field
Join_Match6,*,6,CH full 6-chars matching field
Join_Match5,=,5,CH 5-chars matching field
Join_Ext6,*,1,CH extention of 5-chars to 6-chars
//*
//DICT DD *
D09301 09301 020
D05401 05401 020
A19001 19001 020
12345 99999 010
67890 88888 010
13579 77777 010
//*-+----1----+----2----+----3----+----4----+----5----+----6----+----7
//MASTER DD *
020 XXXXX D09301
021 XXXXX D09301
020 XXXXX D09302
021 XXXXX D09302
020 XXXXX D05401
021 XXXXX D05401
020 XXXXX D05402
021 XXXXX D05402
020 XXXXX A19001
021 XXXXX A19001
020 XXXXX A19002
021 XXXXX A19002
010 12345 XXXXXX
010 67890 XXXXXX
011 67890 XXXXXX
010 13579 XXXXXX
//*-+----1----+----2----+----3----+----4----+----5----+----6----+----7
//*
//SORTOUT DD SYSOUT=*
//*....................................................................
//JNF1CNTL DD *
* prepare common match field for both 5 and 6 characters
INREC IFTHEN=(WHEN=(Mast_Match0,EQ,C'020'),
OVERLAY=(Join_Match6:Mast_Match6)),
IFTHEN=(WHEN=(Mast_Match0,EQ,C'010'),
OVERLAY=(Join_Match5:Mast_Match5,
Join_Ext6:X)),
IFTHEN=(WHEN=NONE,
OVERLAY=(Join_Match6:6X))
//*....................................................................
//SYSIN DD *
JOINKEYS F1=MASTER,
FIELDS=(Mast_Match0,A, fields to look for
Join_Match6,A) extended 6-char match
JOINKEYS F2=DICT,
FIELDS=(Dict_Match0,A, values to be replaced
Dict_MatchX,A) extended 6-char match
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:Mast_Record, full master record
?, match indicator
F2:Dict_Repl6) value to replace, 5 or 6 chars
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(Join_Ind,EQ,C'B', match found?
AND,Mast_Match0,EQ,C'020'), especially marked?
OVERLAY=(Mast_Match6:Join_Repl6)), replace 6-char field
IFTHEN=(WHEN=(Join_Ind,EQ,C'B', match found?
AND,Mast_Match0,EQ,C'010'), especially marked?
OVERLAY=(Mast_Match5:Join_Repl5)) replace 5-char field
OUTFIL BUILD=(Mast_Record) truncate temporary fields
END
//*....................................................................
//*==================================================================== |
Code: |
********************************* TOP OF DATA **********************************
010 99999 XXXXXX
010 77777 XXXXXX
010 88888 XXXXXX
011 67890 XXXXXX
020 XXXXX 19001
020 XXXXX A19002
020 XXXXX 05401
020 XXXXX D05402
020 XXXXX 09301
020 XXXXX D09302
021 XXXXX D09301
021 XXXXX D09302
021 XXXXX D05401
021 XXXXX D05402
021 XXXXX A19001
021 XXXXX A19002
******************************** BOTTOM OF DATA ******************************** |
P.S.
By default, during JOIN the utility usually re-orders input records to improve join operation by using sorted data.
If that is not desired, the SORT code can be slightly modified, to restore the original order of records. |
|
Back to top |
|
 |
chillmo
New User
Joined: 31 Aug 2017 Posts: 54 Location: USA
|
|
|
|
Sergeyken,
Yes, this worked perfectly....thanks!
And yes, the data is already sorted, so I added the parms SORTED and NOSEQCK to the job, to aid in performance.
Thanks again!
FYI - I haven't used SYMNAMES in ages....brought back memories. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2218 Location: USA
|
|
|
|
chillmo wrote: |
And yes, the data is already sorted, so I added the parms SORTED and NOSEQCK to the job, to aid in performance. |
In general case, the fields to be replaced are rarely pre-sorted on input. That's why the order of output records may be often changed by SORT.
If the order of output data needs to be retained by business requirement, the more common solution can be like this:
Code: |
//*====================================================================
//SORTSELJ EXEC PGM=SORT
//*
//SYSOUT DD SYSOUT=*
//*....................................................................
//SYMNAMES DD *
Dict_Match0,15,3,CH dictionary match field 1
Dict_MatchX,1,6,CH dictionary match field 2/3
Dict_Repl5,8,5,CH 5-chars replacement
Dict_Repl6,=,6,CH 6-chars replacement
*
Mast_Match0,26,3,CH master match field 1
Use5,C'010' marker to replace 5 chars
Use6,C'020' marker to replace 6 chars
Mast_Match6,60,6,CH master match field 2
Mast_Match5,40,5,CH master match field 3
*
Mast_Record,1,80,CH
Join_Ind,*,1,CH joining indicator: 'B', '1', '2'
Join_Repl5,*,5,CH replacement for 5-char field
Join_Repl6,=,6,CH replacement for 6-char field
Join_Seq,*,8,ZD initial record sequence number
Join_Match6,*,6,CH full 6-char matching field
Join_Match5,=,5,CH 5-char matching field
Join_Ext6,*,1,CH extention of 5-char to 6-char
//*....................................................................
//DICT DD *
D09301 09301 020
D05401 05401 020
A19001 19001 020
12345 99999 010
67890 88888 010
13579 77777 010
//*-+----1----+----2----+----3----+----4----+----5----+----6----+----7
//MASTER DD *
020 XXXXX D09301
021 XXXXX D09301
020 XXXXX D09302
021 XXXXX D09302
020 XXXXX D05401
021 XXXXX D05401
020 XXXXX D05402
021 XXXXX D05402
020 XXXXX A19001
021 XXXXX A19001
020 XXXXX A19002
021 XXXXX A19002
010 12345 XXXXXX
010 67890 XXXXXX
011 67890 XXXXXX
010 13579 XXXXXX
//*-+----1----+----2----+----3----+----4----+----5----+----6----+----7
//*
//SORTOUT DD SYSOUT=*
//*....................................................................
//JNF1CNTL DD *
* prepare common match field for both 5 and 6 characters
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(Join_Seq:SEQNUM,8,ZD)), re-number input
IFTHEN=(WHEN=(Mast_Match0,EQ,Use6),
OVERLAY=(Join_Match6:Mast_Match6)), save 6-char value
IFTHEN=(WHEN=(Mast_Match0,EQ,Use5),
OVERLAY=(Join_Match5:Mast_Match5, save 5-char value
Join_Ext6:X)), as 6-char one
IFTHEN=(WHEN=NONE,
OVERLAY=(Join_Match6:6X)) clean-up field
//*....................................................................
//SYSIN DD *
JOINKEYS F1=MASTER,
FIELDS=(Mast_Match0,A, fields to look for
Join_Match6,A) extended 6-char match
JOINKEYS F2=DICT,
FIELDS=(Dict_Match0,A, values to be replaced
Dict_MatchX,A) extended 6-char match
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:Mast_Record, full master record
?, match indicator
F2:Dict_Repl6, value to replace, 5 or 6 chars
F1:Join_Seq) initial record number
INREC IFTHEN=(WHEN=(Join_Ind,EQ,C'B', match found?
AND,Mast_Match0,EQ,Use6), especially marked?
OVERLAY=(Mast_Match6:Join_Repl6)), replace 6-char field
IFTHEN=(WHEN=(Join_Ind,EQ,C'B', match found?
AND,Mast_Match0,EQ,Use5), especially marked?
OVERLAY=(Mast_Match5:Join_Repl5)) replace 5-char field
SORT FIELDS=(Join_Seq,A) restore original order
OUTREC BUILD=(Mast_Record) truncate temporary fields
END
//*....................................................................
//*==================================================================== |
Code: |
********************************* TOP OF DATA ***************************
020 XXXXX 09301
021 XXXXX D09301
020 XXXXX D09302
021 XXXXX D09302
020 XXXXX 05401
021 XXXXX D05401
020 XXXXX D05402
021 XXXXX D05402
020 XXXXX 19001
021 XXXXX A19001
020 XXXXX A19002
021 XXXXX A19002
010 99999 XXXXXX
010 88888 XXXXXX
011 67890 XXXXXX
010 77777 XXXXXX
******************************** BOTTOM OF DATA ************************* |
|
|
Back to top |
|
 |
|
|