|
View previous topic :: View next topic
|
| Author |
Message |
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Hi,
Input1 - FB, 11 Bytes, First 1 to 8 Key Field, last 3 bytes are ZD data.
Input2 - FB, 11 Bytes, First 1 to 8 Key Field, last 3 bytes are zeros(ZD format)
Both inputs wont have duplicates and sorted on Key Fileld (1 to 8 Bytes)
Input1
| Code: |
12345678010
12345679000
21212121009
43434343700
|
Input2:
| Code: |
12345678000
12345679000
21212121000
33333333000
43434343000
99999999000
|
Output expected:
| Code: |
12345678010
12345679000
21212121009
33333333000
43434343700
99999999000
|
I need to get all the records from Input2 and if any record matches with input1, sum of last 3 bytes should be in output record.
ICETOOL is in my installation with ICE201I F RECORD TYPE ...
I have been looking into the matching and non matching examples of "Smart DFSORT Tricks"; but no idea for my case.
Your help is appreciated! |
|
| Back to top |
|
 |
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Hi ,
I used the below ICETOOL.
| Code: |
//TOOLIN DD *
COPY FROM(INPUT1) TO(T1) USING(CTL1)
COPY FROM(INPUT2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(O1) ON(1,8,CH) WITH(17,1) -
USING(CTL6) KEEPNODUPS
COPY FROM(O1) TO(O3)
COPY FROM(O2) TO(O3)
COPY FROM(O3) TO(OUT)
/*
//CTL1CNTL DD *
INREC OVERLAY=(17:C'BB')
/*
//CTL2CNTL DD *
INREC OVERLAY=(17:C'VV')
/*
//CTL6CNTL DD *
* MATCHED
OUTFIL FNAMES=O1,INCLUDE=(17,2,CH,EQ,C'VB'),BUILD=(1,16)
* FROM INPUT 2
OUTFIL FNAMES=O2,INCLUDE=(17,2,CH,EQ,C'VV'),BUILD=(1,16)
/* |
O1, O2, O3 and T1 are temp data sets.
Please check and let me know whether it is correct ot not.
Thank you very much. |
|
| Back to top |
|
 |
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Hi,
One correction...
| Quote: |
| I need to get all the records from Input2 and if any record matches with input1, sum of last 3 bytes should be in output record. |
Above should be as below.
I need to get all the records from Input2 and if any record matches, get the matched record from Input1. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Gnana Sekaran Nallathambi,
Since both files do not have duplicates , you can simply concatenate both files and sum the last 3 bytes which will give you the desired results.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=your input 11 byte FB file 1,DISP=SHR
// DD DSN=your input 11 byte FB file 2,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,8,CH,A)
SUM FIELDS=(9,3,ZD)
//*
|
What happens if there is a record in file 1 and does not have a matching record in file 2? |
|
| Back to top |
|
 |
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Hi Kolusu,
Thanks for your reply.
I guess I have not explained the requirement clear.
I want matched records and unmatched records from File 2, ie, Input2. No need to get unmatched records from File 1, ie, Input1.
For matched records, the last three bytes should be from File 1, ie, Input1. In fact, there is no need to SUM since all the records in File2, ie, Input2 will have zeros in the last 3 bytes.
Input1
| Code: |
12345678010
12345679000
21212121009
43434343700
57897777999
76543333333
78777777000
|
Input2:
| Code: |
12345678000
12345679000
21212121000
33333333000
43434343000
99999999000
|
Output expected:
| Code: |
12345678010
12345679000
21212121009
33333333000
43434343700
99999999000
|
Please let me know whether the ICETOOL step what I mentioned in my second post will work as I expect or not.
Thank you very much. Have a good day! |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Gnana Sekaran Nallathambi,
Use the following DFSORT JCL which will give you the desired results. You really don't need 3 passes of data when it can be done in just 1 pass.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
//SORTOUT DD DSN=&&HDR,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
OPTION COPY
INREC BUILD=(11X)
OUTFIL REMOVECC,NODETAIL,HEADER1=(3C'$')
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&HDR,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT
// DD DSN=your input 11 byte FB file 1,DISP=SHR
// DD DSN=&&HDR,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT
// DD DSN=your input 11 byte FB file 3,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(12:ID=1))
SORT FIELDS=(1,8,CH,A),EQUALS
SUM FIELDS=(12,1,ZD)
OUTFIL BUILD=(1,11),INCLUDE=(12,1,ZD,GE,2,AND,1,3,CH,NE,C'$$$')
//* |
|
|
| Back to top |
|
 |
anshul_gugnani
New User

Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
Hi,
I tried the below sort card for the above req -
| Code: |
JOINKEYS FILES=F1,FIELDS=(1,08,A)
JOINKEYS FILES=F2,FIELDS=(1,08,A)
JOIN UNPAIRED,F2
REFORMAT FIELDS=(F1:1,11,F2:1,11)
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(01,08,CH,EQ,12,08,CH),BUILD=(1,11)),
IFTHEN=(WHEN=NONE,BUILD=(12,11)) |
and result was also as it is required.
Can any of the seniour members please tell me if the sort card is correct.
Thanks for your help. |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
anshul_gugnani,
I am sure Frank or Kolusu can give you better insight but here is what I thought.
Question on your sort card and probably that might help clear some clouds.
What will be the value of F1 fields in your REFORMAT FIELDS if the there is no matching records in File1? In the other words for what will be the value for File1 fields for the Unique F2 records?
If my understanding is correct, it will be BLANKS (X'40') and then your IFTHEN condition would fail.
Thanks, |
|
| Back to top |
|
 |
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Thank you, Kolusu.
It worked as expected for the above requirement.
I tried to implement the same for other set.
Input1 record will have key, amount along with some Headers.
I need to extract the records from Input1 based on below condition.
First byte should be numeric 1 to 9 and 9 to 12 bytes should be greater than zero. And SUM the field - 55 to 62 bytes, PD Field based on Key field(1 to 8 bytes)
Input2 will have only 8 bytes key field.
Compare the above formatted Input1 record with Input2, if it is matched, write the amount(SUMmed field above), if not matched, have amount field as zeros in output.
At last, I should have all the records from Input2. If a input2 record is matched with input1 record, get the amount(SUMmed field above), if not matched, have amount field as zeros in output.
Input1(RA), FB, Length=216 Bytes, Key --> 1 to 8 bytes
| Code: |
SNG945345......
0934 .....
4345 .....
J3434....
G3556....
SJ.......
123456780000........AAAAAAAA
123456780008........00000001(It is PD field - 55 to 62 bytes, Length - 8 bytes - I showed it as ZD here)
123456780009........00000002(It is PD field - 55 to 62 bytes, Length - 8 bytes - I showed it as ZD here)
555555550000........GGGGGGGG
555555550002........00000001(It is PD field - 55 to 62 bytes, Length - 8 bytes - I showed it as ZD here)
555555550009........00000002(It is PD field - 55 to 62 bytes, Length - 8 bytes - I showed it as ZD here)
555555550009........00000009(It is PD field - 55 to 62 bytes, Length - 8 bytes - I showed it as ZD here)
666666660000........SSSSSSSS
666666660001........00000007(It is PD field - 55 to 62 bytes, Length - 8 bytes - I showed it as ZD here)
666666660002........00000008(It is PD field - 55 to 62 bytes, Length - 8 bytes - I showed it as ZD here)
999999990000........JJJJJJJJ
999999990006........00000001(It is PD field - 55 to 62 bytes, Length - 8 bytes - I showed it as ZD here) |
Input2(AC), FB, Length=8 Bytes, Key --> 1 to 8 bytes
| Code: |
12345678
22222222
44444444
55555555
88888888
99999999 |
Output expected: FB, 16 BYTES
| Code: |
1234567800000003(It is PD field - 9 to 16 bytes, Length - 8 bytes - I showed it as ZD here)
2222222200000000(It is PD field - 9 to 16 bytes, Length - 8 bytes - I showed it as ZD here)
4444444400000000(It is PD field - 9 to 16 bytes, Length - 8 bytes - I showed it as ZD here)
5555555500000012(It is PD field - 9 to 16 bytes, Length - 8 bytes - I showed it as ZD here)
8888888800000000(It is PD field - 9 to 16 bytes, Length - 8 bytes - I showed it as ZD here)
9999999900000001(It is PD field - 9 to 16 bytes, Length - 8 bytes - I showed it as ZD here) |
I tried below steps, But is giving JCL error while running STEP15. In fact, STEP05 and STEP10 are successful.
| Code: |
IEF212I jobname STEP15 SORTIN +002 - DATA SET NOT FOUND
IEF272I jobname STEP15 - STEP WAS NOT EXECUTED. |
| Code: |
//STEP05 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
//SORTOUT DD DSN=&&HDR,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
OPTION COPY
INREC BUILD=(16X)
OUTFIL REMOVECC,NODETAIL,HEADER1=(3C'$')
/*
//STEP10 EXEC PGM=ICETOOL
//*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//*
//RA DD DISP=SHR, FB, 216 BYTES
//AC DD DISP=SHR, FB, 8 BYTES
//*
//RT DD DSN=&&RT,DISP=(NEW,PASS),SPACE=(TRK,(2300,900),RLSE)
//AT DD DSN=&&AT,DISP=(NEW,PASS),SPACE=(TRK,(2300,900),RLSE)
//*
//TOOLIN DD *
COPY FROM(RA) TO(RT) USING(CTL1)
COPY FROM(AC) TO(AT) USING(CTL2)
/*
//CTL1CNTL DD *
INCLUDE COND=(1,1,CH,GE,C'1',AND,1,1,CH,LE,C'9',AND,9,4,ZD,GT,0)
SORT FIELDS=(1,8,CH,A)
SUM FIELDS=(55,8,PD)
OUTREC FIELDS=(1:1,8,9:55,8)
/*
//CTL2CNTL DD *
INREC OVERLAY=(9:X'000000000000000C')
/*
//STEP15 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&HDR,DISP=SHR
// DD DSN=&&RT,DISP=(OLD,PASS)
// DD DSN=&&HDR,DISP=SHR
// DD DSN=&&AT,DISP=(OLD,PASS)
//SORTOUT DD DISP=(NEW,CATLG,DELETE), FB, 16 BYTES
//SYSIN DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(17:ID=1))
SORT FIELDS=(1,8,CH,A),EQUALS
SUM FIELDS=(17,1,ZD)
OUTFIL BUILD=(1,16),INCLUDE=(17,1,ZD,GE,2,AND,1,3,CH,NE,C'$$$')
/* |
Please let me know where I'm wrong. |
|
| Back to top |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
| Quote: |
| //SORTOUT DD DISP=(NEW,CATLG,DELETE), FB, 16 BYTES |
what's this?
also, jcl error does not quite hit the mark for explaining your problem. |
|
| Back to top |
|
 |
anshul_gugnani
New User

Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
Hi sqlcode1,
The above input-output samples already contain a record where file2 key does not match with file1 key. And when I tried my sort card with above sample it gave output as needed.
And if the first IFTHEN fails then I think it goes for IFTHEN condition with WHEN=NONE.
Please correct me if I am wrong.
Thanks. |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
anshul_gugnani,
Sorry I didn't check WHEN=NONE condition and yes to me I does satisfy the requirements. But hey, I am not a genious like Frank or Kolusu.
We may have to wait for their final word on this.
Thanks, |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
The JCL error occurs because you used &HDR twice in the SORTIN concatenation for STEP15:
| Code: |
//SORTIN DD DSN=&&HDR,DISP=SHR
// DD DSN=&&RT,DISP=(OLD,PASS)
// DD DSN=&&HDR,DISP=SHR
// DD DSN=&&AT,DISP=(OLD,PASS)
|
The system does NOT allow that. You need to use different temporary data sets in the concatenation.
I'd suggest changing STEP05 to:
| Code: |
//STEP05 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
//HDR1 DD DSN=&&HDR1,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//HDR2 DD DSN=&&HDR2,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
OPTION COPY
INREC BUILD=(16X)
OUTFIL REMOVECC,NODETAIL,HEADER1=(3C'$'),
FNAMES=(HDR1,HDR2)
/*
|
and then you can use the following SORTIN concatenation in STEP15:
| Code: |
//SORTIN DD DSN=&&HDR1,DISP=SHR
// DD DSN=&&RT,DISP=(OLD,PASS)
// DD DSN=&&HDR2,DISP=SHR
// DD DSN=&&AT,DISP=(OLD,PASS)
|
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| Quote: |
| Sorry I didn't check WHEN=NONE condition |
You only need to use WHEN=NONE if you need to change the record when it doesn't meet the previous conditions. If you are just going to write the record as is in that case, you don't need WHEN=NONE. |
|
| Back to top |
|
 |
anshul_gugnani
New User

Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
Hello Frank,
Thanks, So the sort card which I posted for the above requirement is correct?
| Code: |
JOINKEYS FILES=F1,FIELDS=(1,08,A)
JOINKEYS FILES=F2,FIELDS=(1,08,A)
JOIN UNPAIRED,F2
REFORMAT FIELDS=(F1:1,11,F2:1,11)
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=(01,08,CH,EQ,12,08,CH),BUILD=(1,11)),
IFTHEN=(WHEN=NONE,BUILD=(12,11)) |
Please suggest. |
|
| Back to top |
|
 |
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Hi Frank,
Thanks for your reply.
I used &HDR1 and &HDR2 as you suggested. This time I'm getting the below error from STEP15.
| Code: |
| ICE043A 3 INVALID DATA SET ATTRIBUTES: SORTIN LRECL - REASON CODE IS 05 |
It seems that BLOCK SIZE is inconsistency in SORTIN concatenation of STEP15. Please let me know how to overcome this error. |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest you post the actual jcl and control statements used when the error is generated. . .
You have ensured the DCBs of all of the sortin datasets is consistent? |
|
| Back to top |
|
 |
CICS Guy
Senior Member

Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
| Back to top |
|
 |
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Hi,
This is the actual JCL used.
| Code: |
//STEP05 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
//HDR1 DD DSN=&&HDR1,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE),BLKSIZE=0
//HDR2 DD DSN=&&HDR2,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE),BLKSIZE=0
//SYSIN DD *
OPTION COPY
INREC BUILD=(16X)
OUTFIL REMOVECC,NODETAIL,HEADER1=(3C'$'),
FNAMES=(HDR1,HDR2)
/*
//STEP10 EXEC PGM=ICETOOL COND=(0,LE)
//*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//*
//RA DD DISP=SHR,DSN=GNANAS.RA.TEST FB, 216 BYTES
//AC DD DISP=SHR,DSN=GNANAS.AC.TEST FB, 8 BYTES
//*
//RT DD DSN=&&RT,DISP=(,PASS),SPACE=(TRK,(10,15),RLSE),BLKSIZE=0
//AT DD DSN=&&AT,DISP=(,PASS),SPACE=(TRK,(10,15),RLSE),BLKSIZE=0
//*
//TOOLIN DD *
COPY FROM(RA) TO(RT) USING(CTL1)
COPY FROM(AC) TO(AT) USING(CTL2)
/*
//CTL1CNTL DD *
INCLUDE COND=(1,1,CH,GE,C'1',AND,1,1,CH,LE,C'9',AND,9,4,ZD,GT,0)
SORT FIELDS=(1,8,CH,A)
SUM FIELDS=(55,8,PD)
OUTREC FIELDS=(1:1,8,9:55,8)
/*
//CTL2CNTL DD *
INREC OVERLAY=(9:X'000000000000000C')
/*
//STEP15 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&HDR1,DISP=SHR
// DD DSN=&&RT,DISP=(OLD,PASS)
// DD DSN=&&HDR2,DISP=SHR
// DD DSN=&&AT,DISP=(OLD,PASS)
//SORTOUT DD DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// DCB=(LRECL=16,BLKSIZE=0,RECFM=FB),
// SPACE=(TRK,(10,15),RLSE),
// DSN=GNANAS.RAAC.RESULT
//SYSIN DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(17:ID=1))
SORT FIELDS=(1,8,CH,A),EQUALS
SUM FIELDS=(17,1,ZD)
OUTFIL BUILD=(1,16),INCLUDE=(17,1,ZD,GE,2,AND,1,3,CH,NE,C'$$$')
/* |
|
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Gnana Sekaran Nallathambi,
Remove one of the zeros in STEP10.CTL2CNTL. Re-run and see if it works.
| Code: |
//CTL2CNTL DD *
INREC OVERLAY=(9:X'000000000000000C')
/* |
Thanks, |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| anshul_gugnani wrote: |
Hello Frank,
Thanks, So the sort card which I posted for the above requirement is correct? |
Anshul gugani,
There is a reason as to why a JOINKEYS solution isn't posted. If you have read OP's initial post , he mentioned that he does NOT have the latest PTF which supports Joinkeys. If you want a joinkeys solution open another topic and continue with your questions.
| Gnana Sekaran Nallathambi wrote: |
I need to get all the records from Input2 and if any record matches with input1, sum of last 3 bytes should be in output record.
ICETOOL is in my installation with ICE201I F RECORD TYPE ...
|
|
|
| Back to top |
|
 |
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Hi sqlcode1,
Using CTL2, I'm OVERLAYing zeros as 8 byte - PD field. I guess it is fine. Please let me know if I miss anything. Thank you! |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Gnana Sekaran Nallathambi,
You just can't apply the same logic of concatenating the header for every other requirement. In your first requirement you have both input files of the same LRECL and hence the header solution would be an optimal solution.
The second requirement is totally different. It deals with 2 different LRECL datasets and the output LRECL is also different. In this case the concatenating of header record solution is plain useless. Also notice how I used the referback to use the header dataset once again. Try to understand the JCL and change it according to your requirements.
Use the following DFSORT/ICETOOL JCL
| Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//FB008 DD DSN=Your input FB 8 byte file,DISP=SHR
//FB216 DD DSN=Your input FB 216 byte file,DISP=SHR
//TEMP DD DSN=&&TEMP,DISP=(MOD,PASS),SPACE=(CYL,(X,Y),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(FB216) USING(CTL1)
COPY FROM(FB008) USING(CTL2)
SORT FROM(TEMP) USING(CTL3)
//CTL1CNTL DD *
INCLUDE COND=(9,4,ZD,GT,0)
INREC BUILD=(1,8,55,8,C'1')
SORT FIELDS=(1,8,CH,A),EQUALS
SUM FIELDS=(9,8,PD)
OUTFIL FNAMES=TEMP
//*
//CTL2CNTL DD *
OUTFIL FNAMES=TEMP,BUILD=(1,8,+0,TO=PD,LENGTH=8,C'2')
//*
//CTL3CNTL DD *
SORT FIELDS=(1,8,CH,A),EQUALS
SUM FIELDS=(17,1,ZD)
OUTFIL FNAMES=OUT,BUILD=(1,16),INCLUDE=(17,1,ZD,GE,2)
//* |
|
|
| Back to top |
|
 |
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Hi Kolusu,
Thank you very much. The code works perfectly with slight modification. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|