|
View previous topic :: View next topic
|
| Author |
Message |
sureshpathi10
Active User

Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
I've a requirement to create two output files from one single file.
| Code: |
ID CODE
11111 AAAA
11111 BBBB
11111 CCCC
11111 EEEE
22222 AAAA
22222 CCCC
22222 DDDD
22222 EEEE
22222 FFFF
|
From the above file,
File 1 should contain:
1. Same ID with code 'AAAA' AND 'BBBB'
2. Same ID with code 'CCCC' AND 'DDDD'
2. Same ID with code 'EEEE' AND 'FFFF'
File 2 should contain all other non-matched records
output should be
File 1
| Code: |
ID CODE
11111 AAAA
11111 BBBB
22222 CCCC
22222 DDDD
22222 EEEE
22222 FFFF
|
File 2
| Code: |
ID CODE
11111 CCCC
11111 EEEE
22222 AAAA
|
Any help would be greatly appreciated. |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
Can there be duplicate CODEs within the same ID ?
Are the wanted CODEs consecutively in the file ?
Gerry |
|
| Back to top |
|
 |
sureshpathi10
Active User

Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
Mr. Gcicchet
1. Yes. there may be duplicate CODE's within same ID.
2. The file is sorted by ID then CODE. |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Hi Suresh,
How many different codes do you expect? |
|
| Back to top |
|
 |
sureshpathi10
Active User

Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
There are only 6 CODE's. They are
AAAA
BBBB
CCCC
DDDD
EEEE
FFFF |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| If there can be duplicate codes within the same ID, please show that in your sample input with the expected output. |
|
| Back to top |
|
 |
sureshpathi10
Active User

Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
Hi Bill,
AAAA & BBBB is one set, so are CCCC & DDDD and EEEE & FFFF.
All the records have set should come in file 1. All others should be written to file1.
if input file contains
11111 AAAA
11111 AAAA
11111 AAAA
11111 BBBB
11111 BBBB
22222 BBBB
Then, File 1 should be
11111 AAAA
11111 AAAA
11111 BBBB
11111 BBBB
File 2 should be
11111 AAAA
22222 BBBB
Code 'AAAA' & 'BBBB' are 1 set. One ID 11111 with code 'AAAA' doesn't have its set. so it should come in file2. So is the last record.
I hope, I'm not confusing more. Thanks all for your efforts. |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
| What is the sort product and version you are using? |
|
| Back to top |
|
 |
sureshpathi10
Active User

Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
Hi Pandora,
I'm using Z/OS DFSORT V1R10.
ICE201I H RECORD TYPE (October, 2010 PTF and are completely up to date on DFSORT functional PTFs )
Please let me know if anything missing or I understood your question wrongly. |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Try this
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD *
11111 AAAA
11111 AAAA
11111 AAAA
11111 BBBB
11111 BBBB
22222 BBBB
//INB DD *
11111 AAAA
11111 AAAA
11111 AAAA
11111 BBBB
11111 BBBB
22222 BBBB
//SORTOUT DD DSN=&&TEMP,DISP=(MOD,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(28,3,A,22,2,A,1,5,A)
JOINKEYS F2=INB,FIELDS=(28,3,A,22,2,A,1,5,A)
JOIN UNPAIRED F1,F2
REFORMAT FIELDS=(F1:1,30,?,F2:1,30)
* INREC IFTHEN=(WHEN=(31,1,CH,EQ,C'B'),BUILD=(1,30,C'B',/,32,30,C'B')),
* IFTHEN=(WHEN=(31,1,CH,EQ,C'1'),BUILD=(32,30,C'I'))
OUTFIL INCLUDE=(31,1,CH,EQ,C'B',OR,31,1,CH,EQ,C'1',
OR,31,1,CH,EQ,C'2'),
BUILD=(1,31,/,1:32,30,31,1)
* OUTFIL FNAMES=OUT2,INCLUDE=(31,1,CH,EQ,C'1'),BUILD=(1,30)
//*
//JNF1CNTL DD *
INCLUDE COND=(16,4,CH,EQ,C'AAAA',OR,16,4,CH,EQ,C'CCCC',OR,
16,4,CH,EQ,C'EEEE')
INREC IFTHEN=(WHEN=INIT,BUILD=(1,20,28:SEQNUM,3,ZD)),
IFTHEN=(WHEN=(16,4,CH,EQ,C'AAAA'),BUILD=(1,20,X,C'AB',
28:28,3)),
IFTHEN=(WHEN=(16,4,CH,EQ,C'CCCC'),BUILD=(1,20,X,C'CD',
28:28,3)),
IFTHEN=(WHEN=(16,4,CH,EQ,C'EEEE'),BUILD=(1,20,X,C'EF',
28:28,3))
//*
//JNF2CNTL DD *
INCLUDE COND=(16,4,CH,EQ,C'BBBB',OR,16,4,CH,EQ,C'DDDD',OR,
16,4,CH,EQ,C'FFFF')
INREC IFTHEN=(WHEN=INIT,BUILD=(1,20,28:SEQNUM,3,ZD)),
IFTHEN=(WHEN=(16,4,CH,EQ,C'BBBB'),BUILD=(1,20,X,C'AB',
28:28,3)),
IFTHEN=(WHEN=(16,4,CH,EQ,C'DDDD'),BUILD=(1,20,X,C'CD',
28:28,3)),
IFTHEN=(WHEN=(16,4,CH,EQ,C'FFFF'),BUILD=(1,20,X,C'EF',
28:28,3))
//*
//STEP0200 EXEC PGM=SORT
//SORTIN DD DSN=&&TEMP,DISP=(MOD,PASS)
//SORTOUT DD SYSOUT=*
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OMIT COND=(1,20,CH,EQ,C' ')
SORT FIELDS=(1,5,CH,A,16,4,CH,A,22,10,CH,A)
SUM FIELDS=NONE
OUTFIL FNAMES=OUT1,INCLUDE=(31,1,CH,EQ,C'B'),BUILD=(1,20) |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Pandora-box,
The data is already sorted. By splitting the data in JNFnCNTL as you do you can make use of the sort order. Use IFTHEN=(WHEN=GROUP with KEYBEGIN (H has it) to give a sequence number as the fourth key (first two keys are the original data, third is the "AB" etc, fourth the sequence number).
B match-marker gives one file, anything else gives the other file. Remember to drop the extension.
One step, no sorts.
When extending records, try to use OVERLAY where possible. If better identifies what is happening, to the next person along, and at times will be more efficient than BUILD (if it doesn't "build" as it extends the record, but OVERLAYs existing data, it will save shuffling stuff about). |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Thanks Bill will try that for my own collection
Just getting to used to speed after quiet some disappointing performances  |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi Pandora-Box,
what is the result using this data ?
| Code: |
11111 01YES AAAA
11111 02YES AAAA
11111 AAAA
11111 01YES BBBB
11111 02YES BBBB
11111 CCCC
11111 EEEE
22222 AAAA
22222 01YES CCCC
22222 CCCC
22222 CCCC
22222 01YES DDDD
22222 02YES EEEE
22222 02YES FFFF
22222 FFFF
22222 FFFF
22222 FFFF
22222 FFFF
|
Using the above data, this is the result I'm getting
| Code: |
11111 01YES AAAA
11111 02YES AAAA
11111 01YES BBBB
11111 02YES BBBB
|
instead of
| Code: |
11111 01YES AAAA
11111 01YES BBBB
11111 02YES AAAA
11111 02YES BBBB
22222 01YES CCCC
22222 01YES DDDD
22222 02YES EEEE
22222 02YES FFFF
|
Gerry |
|
| Back to top |
|
 |
sureshpathi10
Active User

Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
Hi All,
First of all I want to thank everyone for all your efforts.
Pandora-Box - I've single file that needs to be split-ed into 2 files. |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
a different approach
| Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
11111 01YES AAAA
11111 02YES AAAA
11111 AAAA
11111 01YES BBBB
11111 02YES BBBB
11111 CCCC
11111 EEEE
22222 AAAA
22222 01YES CCCC
22222 CCCC
22222 CCCC
22222 01YES DDDD
22222 02YES EEEE
22222 02YES FFFF
22222 FFFF
22222 FFFF
22222 FFFF
22222 FFFF
/*
//T1 DD DSN=&&T1,DISP=(,PASS,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(10,5),RLSE)
//OUT DD SYSOUT=*
//OTHER DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(T1) USING(CTL1)
SELECT FROM(T1) TO(OUT) ON(01,5,CH) -
ON(22,2,CH) -
ON(41,8,CH) EQUAL(2) -
DISCARD(OTHER)
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(31:SEQNUM,8,ZD,
41:SEQNUM,8,ZD,RESTART=(16,4))),
IFTHEN=(WHEN=(16,4,CH,EQ,C'AAAA'),
OVERLAY=(22:C'AB')),
IFTHEN=(WHEN=(16,4,CH,EQ,C'BBBB'),
OVERLAY=(22:C'AB')),
IFTHEN=(WHEN=(16,4,CH,EQ,C'CCCC'),
OVERLAY=(22:C'CD')),
IFTHEN=(WHEN=(16,4,CH,EQ,C'DDDD'),
OVERLAY=(22:C'CD')),
IFTHEN=(WHEN=(16,4,CH,EQ,C'EEEE'),
OVERLAY=(22:C'EF')),
IFTHEN=(WHEN=(16,4,CH,EQ,C'FFFF'),
OVERLAY=(22:C'EF'))
SORT FIELDS=(1,5,BI,A,22,2,BI,A,41,8,BI,A,16,4,BI,A)
/* |
Gerry |
|
| Back to top |
|
 |
sureshpathi10
Active User

Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
Superb Mr.Gcicchet.
Your CTL1 card meets my requirement. Thank you so much.
I was trying with same kind of approach but didn't include the SEQNUM, which caused same ID with same CODE came in File1.
Thanks to Pandora-Box and Bill.
You guys saved my day. Greatly appreciated. |
|
| Back to top |
|
 |
sureshpathi10
Active User

Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
Hi All,
A small change, May be silly yet, needs to be spotted for anyone who needed it in future.
When I use Gerry's JOB, I got proper output but with SEQNUMs in the files. So here is the JOB with small modification for output files without SEQNUMs.
| Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
11111 01YES AAAA
11111 02YES AAAA
11111 AAAA
11111 01YES BBBB
11111 02YES BBBB
11111 CCCC
11111 EEEE
22222 AAAA
22222 01YES CCCC
22222 CCCC
22222 CCCC
22222 01YES DDDD
22222 02YES EEEE
22222 02YES FFFF
22222 FFFF
22222 FFFF
22222 FFFF
22222 FFFF
/*
//T1 DD DSN=&&T1,DISP=(,PASS,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(10,5),RLSE)
//OUT DD SYSOUT=*
//OTHER DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(T1) USING(CTL1)
SELECT FROM(T1) TO(OUT) ON(01,5,CH) -
ON(22,2,CH) -
ON(41,8,CH) EQUAL(2) -
DISCARD(OTHER) USING(CTL2)
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(31:SEQNUM,8,ZD,
41:SEQNUM,8,ZD,RESTART=(16,4))),
IFTHEN=(WHEN=(16,4,CH,EQ,C'AAAA'),
OVERLAY=(22:C'AB')),
IFTHEN=(WHEN=(16,4,CH,EQ,C'BBBB'),
OVERLAY=(22:C'AB')),
IFTHEN=(WHEN=(16,4,CH,EQ,C'CCCC'),
OVERLAY=(22:C'CD')),
IFTHEN=(WHEN=(16,4,CH,EQ,C'DDDD'),
OVERLAY=(22:C'CD')),
IFTHEN=(WHEN=(16,4,CH,EQ,C'EEEE'),
OVERLAY=(22:C'EF')),
IFTHEN=(WHEN=(16,4,CH,EQ,C'FFFF'),
OVERLAY=(22:C'EF'))
SORT FIELDS=(1,5,BI,A,22,2,BI,A,41,8,BI,A,16,4,BI,A)
//CTL2CNTL DD *
OUTFIL FNAMES=OUT,BUILD=(1,19)
OUTFIL FNAMES=OTHER,BUILD=(1,19)
/*
|
Thanks once again Guys. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|