DFSORT - Overlay with multiple files - Help

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
JackOnRocks
Member
Posts: 4
Joined: Tue Mar 03, 2009 1:47 am

DFSORT - Overlay with multiple files - Help

Post by JackOnRocks » Tue Mar 03, 2009 3:07 am

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!

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Mar 03, 2009 4:11 am

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.
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

JackOnRocks
Member
Posts: 4
Joined: Tue Mar 03, 2009 1:47 am

Post by JackOnRocks » Tue Mar 03, 2009 5:17 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

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Mar 03, 2009 5:38 am

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?
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

JackOnRocks
Member
Posts: 4
Joined: Tue Mar 03, 2009 1:47 am

Post by JackOnRocks » Tue Mar 03, 2009 8:16 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!

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Mar 03, 2009 11:04 pm

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 &#40;VB/28672&#41;
//IN2 DD DSN=...  input file2 &#40;FB/80&#41;
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=&#40;CYL,&#40;5,5&#41;&#41;,DISP=&#40;MOD,PASS&#41;
//OUT DD LRECL=28672,DSN=...  output file &#40;VB/28672&#41;
//TOOLIN DD *
COPY FROM&#40;IN1&#41; TO&#40;T1&#41; USING&#40;CTL1&#41;
COPY FROM&#40;IN2&#41; TO&#40;T1&#41; USING&#40;CTL2&#41;
SPLICE FROM&#40;T1&#41; TO&#40;OUT&#41; ON&#40;379,9,CH&#41; KEEPNODUPS -
  WITH&#40;5,1&#41; WITH&#40;7,8&#41; USING&#40;CTL3&#41;
/*
//CTL1CNTL DD *
  INREC BUILD=&#40;1,4,5&#58;C'BB',15&#58;5&#41;
//CTL2CNTL DD *
  OUTFIL FNAMES=T1,FTOV,BUILD=&#40;1&#58;C'VV',3&#58;25,8,375&#58;1,9&#41;
//CTL3CNTL DD *
  OUTFIL FNAMES=OUT,
    IFTHEN=&#40;WHEN=&#40;5,2,CH,EQ,C'VB',AND,625,1,CH,EQ,C'Y',AND,
       883,8,CH,EQ,C'00000000'&#41;,
      OVERLAY=&#40;883&#58;7,8&#41;,HIT=NEXT&#41;,
    IFTHEN=&#40;WHEN=ANY,BUILD=&#40;1,4,15&#41;&#41;,
    IFTHEN=&#40;WHEN=NONE,BUILD=&#40;1,4,15&#41;&#41;
/*
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

JackOnRocks
Member
Posts: 4
Joined: Tue Mar 03, 2009 1:47 am

Post by JackOnRocks » Wed Mar 04, 2009 12:04 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!

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Wed Mar 04, 2009 12:25 am

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).
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

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Jan 25, 2016 10:33 pm

<< Content deleted By Admin >>

Post Reply

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



Other References
Mainframe Tools and others