DFSORT - Overlay with multiple files - Help
Moderators: Frank Yaeger, Moderator Group
-
- Member
- Posts: 4
- Joined: Tue Mar 03, 2009 1:47 am
DFSORT - Overlay with multiple files - Help
DISP=(NEW,CATLG,CATLG),
DCB=(MODLDSCB,LRECL=28672,RECFM=VB)
File 1: If '00000000' in position 869 and Y in pos 611, then pull date from file 2 and post to position 869. (@0365 SSN).
File 2: SSN, date
I need to merge the files by SSN and update File 1 if position 868 has '00000000' and position 611 has 'Y' otherwise output the record as is. I need the output file to be in the same order as the original file. Is it possible to use an overlay stmt that overlays the date from file 2 to position 869 in file 1 when the criteria is met?
Thanks in advance!
DCB=(MODLDSCB,LRECL=28672,RECFM=VB)
File 1: If '00000000' in position 869 and Y in pos 611, then pull date from file 2 and post to position 869. (@0365 SSN).
File 2: SSN, date
I need to merge the files by SSN and update File 1 if position 868 has '00000000' and position 611 has 'Y' otherwise output the record as is. I need the output file to be in the same order as the original file. Is it possible to use an overlay stmt that overlays the date from file 2 to position 869 in file 1 when the criteria is met?
Thanks in advance!
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
You can use an IFTHEN clause to do an OVERLAY if a WHEN condition is met.
Your description is too confusing for me to tell you how to do it. If you want more specific help, give an example of the records in each input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input files. Give the starting position, length and format of each relevant field.
Your description is too confusing for me to tell you how to do it. If you want more specific help, give an example of the records in each input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input files. Give the starting position, length and format of each relevant field.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
-
- Member
- Posts: 4
- Joined: Tue Mar 03, 2009 1:47 am
Sorry, hopefully this will make more sense.
File 1:
@0365 SSN (Char9)
@0869 Date (YYYYMMDD)
@0611 Flag (Char1)
VB LRECL=28672
900,000 records
File 2:
@0001 SSN (Char9)
@0025 Date (YYYYMMDD)
FB LRECL=80
600,000 records
(No duplicates)
The key to join both files is SSN. I need to update the Date variable on File 1 with the Date variable on File 2 using this criteria: (Date on File 1 = '00000000' and Flag = 'Y'). If the criteria is not met or the SSN on File 1 is NOT found in File 2, then the entire record should be sent to the output as is.
If in File 1 then do;
If File1.Date = '00000000' and File1.Flag ='Y' then do;
If ssn exist on file 2 then move File2.Date to File1.Date.
Output entire record;
Else;
Output entire record;
End;
File 1:
record 1:
@0365 SSN 111223333
@0869 Date 20081120
@0611 Flag Y
record 2:
@0365 SSN 111224444
@0869 Date 00000000
@0611 Flag Y
record 3:
@0365 SSN 111225555
@0869 Date 00000000
@0611 Flag Y
File 2:
record 1:
@0001 SSN 111223333
@0025 Date 20091005
record 2:
@0001 SSN 111225555
@0025 Date 20090227
Output:
record 1 (Entire Record from file 1):<---No action taken (date not ='00000000')
@0365 SSN 111223333
@0869 Date 20081120
@0611 Flag Y
record 2: (Entire record from file 1):<--No action taken (SSN doesn't exist in file 2, record gets outputted as is)
@0365 SSN 111224444
@0869 Date 00000000
@0611 Flag Y
record 3: (Entire record from file 1):<--File2.Date moved to File1.Date
@0365 SSN 111225555
@0869 Date 20090227
@0611 Flag Y
File 1:
@0365 SSN (Char9)
@0869 Date (YYYYMMDD)
@0611 Flag (Char1)
VB LRECL=28672
900,000 records
File 2:
@0001 SSN (Char9)
@0025 Date (YYYYMMDD)
FB LRECL=80
600,000 records
(No duplicates)
The key to join both files is SSN. I need to update the Date variable on File 1 with the Date variable on File 2 using this criteria: (Date on File 1 = '00000000' and Flag = 'Y'). If the criteria is not met or the SSN on File 1 is NOT found in File 2, then the entire record should be sent to the output as is.
If in File 1 then do;
If File1.Date = '00000000' and File1.Flag ='Y' then do;
If ssn exist on file 2 then move File2.Date to File1.Date.
Output entire record;
Else;
Output entire record;
End;
File 1:
record 1:
@0365 SSN 111223333
@0869 Date 20081120
@0611 Flag Y
record 2:
@0365 SSN 111224444
@0869 Date 00000000
@0611 Flag Y
record 3:
@0365 SSN 111225555
@0869 Date 00000000
@0611 Flag Y
File 2:
record 1:
@0001 SSN 111223333
@0025 Date 20091005
record 2:
@0001 SSN 111225555
@0025 Date 20090227
Output:
record 1 (Entire Record from file 1):<---No action taken (date not ='00000000')
@0365 SSN 111223333
@0869 Date 20081120
@0611 Flag Y
record 2: (Entire record from file 1):<--No action taken (SSN doesn't exist in file 2, record gets outputted as is)
@0365 SSN 111224444
@0869 Date 00000000
@0611 Flag Y
record 3: (Entire record from file 1):<--File2.Date moved to File1.Date
@0365 SSN 111225555
@0869 Date 20090227
@0611 Flag Y
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
Ok, I think I understand.
A few more questions:
Can input file1 have duplicate SSN numbers?
Do the positions you gave for input file1 include the RDW in positions 1-4?
For example, does @365 for the SSN include the RDW, or is it really @369 when we add 4 bytes for the RDW?
The output file should only contain records from input file1 (not input file2) - right?
The output file should have RECFM=VB and LRECL=28672 like the input file - right?
A few more questions:
Can input file1 have duplicate SSN numbers?
Do the positions you gave for input file1 include the RDW in positions 1-4?
For example, does @365 for the SSN include the RDW, or is it really @369 when we add 4 bytes for the RDW?
The output file should only contain records from input file1 (not input file2) - right?
The output file should have RECFM=VB and LRECL=28672 like the input file - right?
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
-
- Member
- Posts: 4
- Joined: Tue Mar 03, 2009 1:47 am
Can input file1 have duplicate SSN numbers?
They can have duplicate SSNs, but they will not have
@0869 Date
@0611 Flag
There may be other record types with SSN at position 365(+4).
Do the positions you gave for input file1 include the RDW in positions 1-4?
For example, does @365 for the SSN include the RDW, or is it really @369 when we add 4 bytes for the RDW?
Good question...The VB positions will need to be incremented by 4 to account for the RDW. Ex: 365 will need to be 369.
The output file should only contain records from input file1 (not input file2) - right?
Correct.
The output file should have RECFM=VB and LRECL=28672 like the input file - right?
Correct.
(Took me three times to get the requirements communicated...I should move into mangement!!!)
Thanks for you help!
They can have duplicate SSNs, but they will not have
@0869 Date
@0611 Flag
There may be other record types with SSN at position 365(+4).
Do the positions you gave for input file1 include the RDW in positions 1-4?
For example, does @365 for the SSN include the RDW, or is it really @369 when we add 4 bytes for the RDW?
Good question...The VB positions will need to be incremented by 4 to account for the RDW. Ex: 365 will need to be 369.
The output file should only contain records from input file1 (not input file2) - right?
Correct.
The output file should have RECFM=VB and LRECL=28672 like the input file - right?
Correct.
(Took me three times to get the requirements communicated...I should move into mangement!!!)
Thanks for you help!
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
Here's a DFSORT/ICETOOL job that will do what you asked for:
Code: Select all
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file1 (VB/28672)
//IN2 DD DSN=... input file2 (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD LRECL=28672,DSN=... output file (VB/28672)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(379,9,CH) KEEPNODUPS -
WITH(5,1) WITH(7,8) USING(CTL3)
/*
//CTL1CNTL DD *
INREC BUILD=(1,4,5:C'BB',15:5)
//CTL2CNTL DD *
OUTFIL FNAMES=T1,FTOV,BUILD=(1:C'VV',3:25,8,375:1,9)
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,
IFTHEN=(WHEN=(5,2,CH,EQ,C'VB',AND,625,1,CH,EQ,C'Y',AND,
883,8,CH,EQ,C'00000000'),
OVERLAY=(883:7,8),HIT=NEXT),
IFTHEN=(WHEN=ANY,BUILD=(1,4,15)),
IFTHEN=(WHEN=NONE,BUILD=(1,4,15))
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
-
- Member
- Posts: 4
- Joined: Tue Mar 03, 2009 1:47 am
Mr. Yaeger,
Thank you so much for your reply. Pieces of this code kind of flew over my head. (Ok, most of it)!
If have a moment, would you mind just talking through whats going on in the CNTL1CNTL, CNTL2CNTL and CNTL3CNTL sections of the code? I really want to understand what is going on. This would help us out so much!
I really appreciate your time!
Thank you so much for your reply. Pieces of this code kind of flew over my head. (Ok, most of it)!
If have a moment, would you mind just talking through whats going on in the CNTL1CNTL, CNTL2CNTL and CNTL3CNTL sections of the code? I really want to understand what is going on. This would help us out so much!
I really appreciate your time!
- Frank Yaeger
- Moderator
- Posts: 812
- Joined: Sat Feb 18, 2006 5:45 am
- Location: San Jose, CA
- Contact:
CTL1CNTL - reformats the VB input records to look like this:
|RDW|BB|blanks|... ssn ... flag ... date1 |
BB is an id used to identify that the records came from file1. The blanks leave room in the spliced record for date2 from file2 (see below).
CTL2CNTL - reformats the FB input records as VB records to look like this:
|RDW|VV|date2| ... ssn|
VV is an id used to identify that the records came from file2. date2 will replace date1 when the conditions are met (see below).
ssn here is in the same positions as ssn in file1.
CTL3CNTL - the 'VB' id indicates records from file1 and file2 have matching ssns. The IFTHEN WHEN=(cond) clause replaces date1 with date2 when your conditions are satisfied. The IFTHEN WHEN=ANY clause removes the id and date1 fields for records that were updated (the original data now starts at position 5 again). The IFTHEN WHEN=NONE clause removes the id and date1 for all the other output records (the original data now starts at position 5 again).
|RDW|BB|blanks|... ssn ... flag ... date1 |
BB is an id used to identify that the records came from file1. The blanks leave room in the spliced record for date2 from file2 (see below).
CTL2CNTL - reformats the FB input records as VB records to look like this:
|RDW|VV|date2| ... ssn|
VV is an id used to identify that the records came from file2. date2 will replace date1 when the conditions are met (see below).
ssn here is in the same positions as ssn in file1.
CTL3CNTL - the 'VB' id indicates records from file1 and file2 have matching ssns. The IFTHEN WHEN=(cond) clause replaces date1 with date2 when your conditions are satisfied. The IFTHEN WHEN=ANY clause removes the id and date1 fields for records that were updated (the original data now starts at position 5 again). The IFTHEN WHEN=NONE clause removes the id and date1 for all the other output records (the original data now starts at position 5 again).
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page