View previous topic :: View next topic
Author
Message
prateek_nanda New User Joined: 13 Jul 2007Posts: 19 Location: Gurgaon
We have 2 files In first file we have records like 123,678,456 and in second file we are having 123, 456, 677. Now I want to 678 in my 3 rd file. How to do it plz tell.
Thanks
Prateek
Back to top
HappySrinu Active User Joined: 22 Jan 2008Posts: 194 Location: India
Do you want unique data in each record in first file in to 3rd file?
Are those both are CSV files ?
what's the record length/format?
Please be clear with your example to get better solution
Back to top
prateek_nanda New User Joined: 13 Jul 2007Posts: 19 Location: Gurgaon
Thanks for replying back
Both the files are Normal Flat files ( PS datasets ) of record length 80 and is of Fixed Block format.
Example:--
File 1
ABCD12345678
DEFG12345678
HIJK12345678
LMNO12345678
File 2
ABCD12345678
DEFG12345678
BBBB12345678
Now what I want in file 3 is
File 3
HIJK12345678
LMNO12345678
Back to top
expat Global Moderator Joined: 14 Mar 2007Posts: 8797 Location: Welsh Wales
Am I correct im assuming that if the record key appears in file 2 then the record from file 1 is to be ignored.
i.e. The values of file 2 are exclude parameters for file 1
Back to top
prateek_nanda New User Joined: 13 Jul 2007Posts: 19 Location: Gurgaon
Hi,
Yes. If the same record is present in both File 1 and File 2 then it is to be ignored. A record which is present in File 1 only and not present in File 2 should be written to File 3. That's the main requirement.
Thanks!!
Back to top
expat Global Moderator Joined: 14 Mar 2007Posts: 8797 Location: Welsh Wales
Please supply the following information for file 1 and file 2
RECFM=
LRECL=
Key position=
Key length=
Are there duplicate key fields in file 1 or file2
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Prateek,
You can use a DFSORT/ICETOOL job like the following to do what you asked for. I assumed your input files have RECFM=FB and LRECL=80, but you can change the job appropriately for other attributes. I also assumed neither input file has duplicates within it. If either input file has duplicates within it (e.g. two ABCD12345678 records in input file1), show an example of input and output for that (it will require a different solution).
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
ABCD12345678
DEFG12345678
HIJK12345678
LMNO12345678
/*
//IN2 DD *
ABCD12345678
DEFG12345678
BBBB12345678
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SELECT FROM(T1) TO(OUT) ON(1,12,CH) NODUPS USING(CTL3)
//CTL1CNTL DD *
INREC OVERLAY=(81:C'1')
/*
//CTL2CNTL DD *
INREC OVERLAY=(81:C'2')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,INCLUDE=(81,1,CH,EQ,C'1'),
BUILD=(1,80)
/*
Back to top
prateek_nanda New User Joined: 13 Jul 2007Posts: 19 Location: Gurgaon
It Worked for me..
Thanks a lot...
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Hi,
Out of curiosity, I would like to know how many steps does it take if one has to achieve the same result NOT using ICETOOL.
Thank you all.
Back to top
Escapa Senior Member Joined: 16 Feb 2007Posts: 1399 Location: IL, USA
IT depends on number of statements in TOOLIN (SORT\COPY\SELECT)...
Here three...
Back to top
expat Global Moderator Joined: 14 Mar 2007Posts: 8797 Location: Welsh Wales
ramsri wrote:
Hi,
Out of curiosity, I would like to know how many steps does it take if one has to achieve the same result NOT using ICETOOL.
Thank you all.
Do you mean job steps, i.e. programs or as Sambhaji has interpretted it, the number of sub steps within a job step.
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Hi, Sambhaji & expat.
Thanks for the replies. I was thinking as expat correctly caught.....the number of job steps....
This is how I interpreted if one has to do it without using ICETOOL.
Quote:
STEP01 - IN1 - OUTREC=(1,12,15:C'1')
STEP02 - IN2 - OUTREC=(1,12,15:C'2')
STEP03 - OUTPUT FROM IN1 & IN2 AS INPUT - SORT FIELDS=(1,4,CH,A) WITH SUM FIELDS=NONE
STEP04 - OUTPUT FROM STEP03 AS INPUT - INCLUDE=(15,1,CH,EQ,C'1')
I tried this approach but did not save JCL as it produced one extra record from IN1.
Thanks.
Back to top
Escapa Senior Member Joined: 16 Feb 2007Posts: 1399 Location: IL, USA
Quote:
Quote:
STEP01 - IN1 - OUTREC=(1,12,15:C'1')
STEP02 - IN2 - OUTREC=(1,12,15:C'2')
STEP03 - OUTPUT FROM IN1 & IN2 AS INPUT - SORT FIELDS=(1,4,CH,A) WITH SUM FIELDS=NONE
STEP04 - OUTPUT FROM STEP03 AS INPUT - INCLUDE=(15,1,CH,EQ,C'1')
Hi Ramsri, No need of STEP04
You can do STEP03 and STEP04 in one step..
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Sambhaji,
I tried to combine STEP03 & STEP04 into STEP03 itself but was getting 4 records. I've given my full SORT job below that did not work as intended......it will be a great help if you could fine tune it.......
Code:
//STEP0001 EXEC PGM=SORT
//SORTOUT DD DSN=&&T1,DISP=(MOD,PASS,DELETE),SPACE=(TRK,(1,1),RLSE)
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABCD12345678
DEFG12345678
HIJK12345678
LMNO12345678
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1,12,15:C'1')
/*
//STEP0002 EXEC PGM=SORT
//SORTOUT DD DSN=&&T1,DISP=(MOD,PASS,DELETE),SPACE=(TRK,(1,1),RLSE)
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABCD12345678
DEFG12345678
BBBB12345678
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1,12,15:C'2')
/*
//STEP0003 EXEC PGM=SORT
//SORTIN DD DSN=&&T1,DISP=(MOD,DELETE,DELETE),SPACE=(TRK,(1,1),RLSE)
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,4,CH,A)
SUM FIELDS=NONE
INCLUDE COND=(15,1,CH,EQ,C'1')
/*
Output:
Code:
ABCD12345678 1
DEFG12345678 1
HIJK12345678 1
LMNO12345678 1
Thanks.
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Sorry guys.... I would append my altered STEP03 and new step STEP04 here.....
Code:
//STEP0003 EXEC PGM=SORT
//SORTIN DD DSN=&&T1,DISP=(MOD,DELETE,DELETE),SPACE=(TRK,(1,1),RLSE)
//SYSOUT DD SYSOUT=*
//SORTOUT DD DSN=&&T2,DISP=(MOD,PASS,DELETE),SPACE=(TRK,(1,1),RLSE)
//SYSIN DD *
SORT FIELDS=(1,4,CH,A)
SUM FIELDS=NONE
/*
//STEP0004 EXEC PGM=SORT
//SORTIN DD DSN=&&T2,DISP=(MOD,DELETE,DELETE),SPACE=(TRK,(1,1),RLSE)
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(15,1,CH,EQ,C'1')
/*
With this altered STEP03 & STEP04, I got the below output.
Code:
ABCD12345678 1
HIJK12345678 1
LMNO12345678 1
Thanks.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Quote:
it will be a great help if you could fine tune it.......
Why should we waste our time on this? You can do this with SELECT ... NODUPS quite easily. What is the point of figuring out how to do it a more complex way? If you want to do that for "fun", figure it out yourself. Don't ask the rest of us to help. Most of us have better things to do. I'm locking this topic.
Back to top
Please enable JavaScript!