View previous topic :: View next topic
|
Author |
Message |
Vishal Trehan
New User
Joined: 21 Apr 2008 Posts: 5 Location: Mysore
|
|
|
|
hi all,
i have three flat files.
first file has records:
0001
0002
0003
0004
0005
0006
0007
0023
0056
another file has records:
0023
0056
And the third file has records:
0008
0009
0010
I need to create a file which will delete records from file 1 which are present in file 2 and add records whcih are present in file 3 . thus the output would be:
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
Can somebody help me regarding this? |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
What if a record is present in all 3 files? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
And how should duplicates in any/all of the files be handled? |
|
Back to top |
|
|
Vishal Trehan
New User
Joined: 21 Apr 2008 Posts: 5 Location: Mysore
|
|
|
|
records present in file 2 will be present in file 1 but records presnt in file 3 will not be present in file 1.
Its simple deletion and addition of records to the file 1. |
|
Back to top |
|
|
shrivatsa Warnings : 1 Active User
Joined: 17 Mar 2006 Posts: 174 Location: Bangalore
|
|
|
|
Here is the SORT control card which you have asked for
Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
0001
0002
0003
0004
0005
0006
0007
0023
0056
//IN2 DD *
0023
0056
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(5,5)),
// DISP=(MOD,PASS)
//FILEA DD SYSOUT=*
//OUT12 DD SYSOUT=*
//OUT1 DD DSN=&&TEMP1,UNIT=SYSDA,SPACE=(TRK,(5,5)),
// DISP=(MOD,PASS)
//OUT2 DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(OUT12) ON(1,4,CH) WITH(81,1) -
USING(CTL3) KEEPNODUPS
/*
//CTL1CNTL DD *
INREC OVERLAY=(80:C'11')
/*
//CTL2CNTL DD *
INREC OVERLAY=(80:C'22')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT1,INCLUDE=(80,2,CH,EQ,C'11'),BUILD=(1,80)
/*
//STEP2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SORTIN DD DSN=&&TEMP1,DISP=OLD
// DD DSN=SB9642.TEMP.TEST,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,4,CH,A)
/* |
|
|
Back to top |
|
|
Vishal Trehan
New User
Joined: 21 Apr 2008 Posts: 5 Location: Mysore
|
|
|
|
Thanks.
but u havent mentioned how to append the records from the third file.
and i dont want to give the input from the JCl. i has to be from the flat file.
Please let me know that too. The question might be trivial for u but i am stilla novice. So would like to know that in details. |
|
Back to top |
|
|
shrivatsa Warnings : 1 Active User
Joined: 17 Mar 2006 Posts: 174 Location: Bangalore
|
|
|
|
The Step2 is doing the 3rd file appending to the output of 1st and Second |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Vishal Trehan,
The following DFSORT JCL will give you the desired results. I assumed that all files are of the same record length and file1 and file 2 does not have duplicates. The first step concatenates file 1 and file 2 and removes the dupes from them which means that any matching record is deleted. And step0200 concatenates the output from step 1 to file3 and creates 1 single file.
Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=your file 1,DISP=SHR
// DD DSN=your file 2,DISP=SHR
/*
//T1 DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//TOOLIN DD *
SELECT FROM(IN) TO(T1) ON(1,4,CH) NODUPS
/*
//STEP0200 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&T1,DISP=SHR
// DD DSN=your file 2,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION EQUALS
SORT FIELDS=(1,4,CH,A)
/*
|
Hope this helps...
Cheers |
|
Back to top |
|
|
|