|
View previous topic :: View next topic
|
| Author |
Message |
itzphaniz
New User

Joined: 02 Sep 2005 Posts: 39
|
|
|
|
I've two FB files with 80 record length.
IN1:
| Code: |
ABCDE
DTSSY
XYZAB
12345
23456 |
IN2:
| Code: |
ABCDZ
DTSSY
XYZAB
56789
23457 |
First 4 characters is the key. I need a output file with the records that got changed on the key. The changed records should be from IN1.
For above input files, the output should be:
I'm using the below ICETOOL card, but it is giving me both the changed records from IN1 and IN2.
Toolin:
| Code: |
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL1)
SELECT FROM(T1) TO(T2) ON(1,80,CH) NODUPS USING(CTL5)
COPY FROM(T3) TO(OUT2) USING(CTL1) |
CTL1:
CTL5:
| Code: |
| OUTFIL FNAMES=T3,REMOVECC,NODETAIL,SECTIONS=(1,8,TRAILER3=(1,8)) |
But it is this output:
| Code: |
ABCDE
ABCDZ
12345
23456
23457
56789 |
Any suggestions on how to eliminate
1) Records IN1 not IN2
2) Records IN2 not IN1
Also the output should have only the changed records on the key from IN1. Any help or pointers would be deeply appreciated. |
|
| Back to top |
|
 |
expat
Global Moderator

Joined: 14 Mar 2007 Posts: 8798 Location: Welsh Wales
|
|
|
|
Well, you are most of the way there. You have eliminated all of the duplicated records of length 80, but now you may need a second pass of the data selecting only the first duplicate on the 4 byte key.
Probably not the most elegant or efficient way, but for a quick fix it should work. I am pretty sure that Frank or Kolusu will give a better solution a little later in the day. |
|
| Back to top |
|
 |
itzphaniz
New User

Joined: 02 Sep 2005 Posts: 39
|
|
|
|
Well I just noticed a typo in my control cards, here are the actual control cards that I used. Sorry for the inconvenience
Toolin:
| Code: |
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL1)
SELECT FROM(T1) TO(T2) ON(1,4,CH) NODUPS USING(CTL5)
COPY FROM(T2) TO(OUT2) USING(CTL1) |
CTL1:
CTL5:
| Code: |
| OUTFIL FNAMES=T2,REMOVECC,NODETAIL,SECTIONS=(1,8,TRAILER3=(1,8)) |
|
|
| Back to top |
|
 |
expat
Global Moderator

Joined: 14 Mar 2007 Posts: 8798 Location: Welsh Wales
|
|
|
|
Well, based on your post, the data given and the required result, the code below worked for me.
The first select removes all duplicate records based on the file length of 80. So any unchanged records are deleted. This leaves the task of finding only records with the same key but a different data content.
The second select will pick only the first duplicate record of those that have an identical key value, but a different data content.
| Code: |
//ICETOOL EXEC PGM=ICETOOL
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
ABCDE
DTSSY
XYZAB
12345
23456
/*
//IN2 DD *
ABCDZ
DTSSY
XYZAB
56789
23457
/*
//OUT1 DD DSN=&&TEMP01,DISP=(MOD,PASS,DELETE),
// RECFM=FB,LRECL=80,SPACE=(TRK,(5,5),RLSE)
//OUT2 DD DSN=&&TEMP02,DISP=(MOD,PASS,DELETE),
// RECFM=FB,LRECL=80,SPACE=(TRK,(5,5),RLSE)
//OUT3 DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN1) TO(OUT1) USING(CTL1)
COPY FROM(IN2) TO(OUT1) USING(CTL1)
SELECT FROM(OUT1) TO(OUT2) ON(1,80,CH) NODUPS
SELECT FROM(OUT2) TO(OUT3) ON(1,4,CH) FIRSTDUP
/*
//CTL1CNTL DD *
SORT FIELDS=COPY
/*
|
The result
|
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
OK... I' ll bite
why not simply concatenate the two files in the proper sequence ...
the content of the concatenation of the two input files is the same as the OUT1 content |
|
| Back to top |
|
 |
itzphaniz
New User

Joined: 02 Sep 2005 Posts: 39
|
|
|
|
@Expat - This works just perfect. Thanks a lot!. I didn't know about FIRSTDUP. Thanks for letting me know!
@Enricho - - Yeah, you are right, content after concatenation is same as OUT1. I've modified the step accordingly!
Thanks a lot guys for your valuable time! |
|
| Back to top |
|
 |
expat
Global Moderator

Joined: 14 Mar 2007 Posts: 8798 Location: Welsh Wales
|
|
|
|
Going on the comment from Enrico, a quick rethink of the process .......
But I am sure that Frank or Kolusu will improve on it
| Code: |
//ICETOOL EXEC PGM=ICETOOL
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD *
ABCDE
DTSSY
XYZAB
12345
23456
/*
// DD *
ABCDZ
DTSSY
XYZAB
56789
23457
//OUT1 DD DSN=&&TEMP01,DISP=(MOD,PASS,DELETE),
// RECFM=FB,LRECL=80,SPACE=(TRK,(5,5),RLSE)
//OUT2 DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN1) TO(OUT1) USING(CTL1)
SELECT FROM(OUT1) TO(OUT2) ON(1,4,CH) FIRSTDUP
/*
//CTL1CNTL DD *
SORT FIELDS=(1,80,CH,A),EQUALS
SUM FIELDS=NONE
/* |
|
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
itzphaniz,
concatenate both files together and use the following DFSORT JCL which will give you the desired results
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABCDE
DTSSY
XYZAB
12345
23456
// DD *
ABCDZ
DTSSY
XYZAB
56789
23457
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,4,CH,A),EQUALS
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,1,ZD,RESTART=(1,4))),
IFTHEN=(WHEN=GROUP,BEGIN=(81,1,ZD,EQ,1),PUSH=(82:81,1,1,80))
OUTFIL INCLUDE=(81,2,ZD,EQ,21,AND,1,5,CH,NE,83,5,CH),BUILD=(83,80)
|
|
|
| Back to top |
|
 |
itzphaniz
New User

Joined: 02 Sep 2005 Posts: 39
|
|
|
|
| Thanks a lot for the alternate way Kolusu! :-) |
|
| Back to top |
|
 |
itzphaniz
New User

Joined: 02 Sep 2005 Posts: 39
|
|
|
|
Expat: A quick question to you on the toolin control card that you gave earlier
| Code: |
//TOOLIN DD *
COPY FROM(IN1) TO(OUT1) USING(CTL1)
COPY FROM(IN2) TO(OUT1) USING(CTL1)
SELECT FROM(OUT1) TO(OUT2) ON(1,80,CH) NODUPS
SELECT FROM(OUT2) TO(OUT3) ON(1,4,CH) FIRSTDUP
/*
//CTL1CNTL DD *
SORT FIELDS=COPY
/* |
To be more precise in this part
| Code: |
| SELECT FROM(OUT1) TO(OUT2) ON(1,80,CH) NODUPS |
Here the file is 80 and assumed all are character fields. For ex: if the length of input file was 1000 and had all types of variables such as PD, ZD, BI, C etc., Do I have to include all individual variables after "ON"
i.e. like below? Will it work? if not is there any easier way?
| Code: |
| SELECT FROM(OUT1) TO(OUT2) ON(1,100,CH,101,100,PD,201,800,BI) NODUPS |
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
That is NOT the correct syntax for multiple ON fields. The correct syntax would be:
ON(p,m,f) ON(p,m,f) ON(p,m,f)
However, you cannot use a 100 byte PD field. The maximum length you can use for a PD field is 16 bytes = 31 digits. A 100 byte PD field would have 199 digits ... kind of ridiculous.
As to whether you'd need to break down the large field into smaller fields of different formats, that depends on whether or not each field is "normalized". For example, if your PD fields have a mixture of F, C and D signs, then you'd need to treat them as PD. If they all just had C signs, then you could treat them as BI.
| Code: |
//TOOLIN DD *
COPY FROM(IN1) TO(OUT1) USING(CTL1)
COPY FROM(IN2) TO(OUT1) USING(CTL1)
...
/*
//CTL1CNTL DD *
SORT FIELDS=COPY
/*
|
You DO NOT need CTL1CNTL ... a COPY operator automatically does a COPY operation. You don't have to tell it to do one with SORT FIELDS=COPY. You could write this as:
| Code: |
COPY FROM(IN1) TO(OUT1)
COPY FROM(IN2) TO(OUT1)
|
But using the concatenated data sets as input would eliminate the need for these COPY operators anyway. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|