|
View previous topic :: View next topic
|
| Author |
Message |
Balaji Canabady
New User
Joined: 07 Dec 2011 Posts: 19 Location: India
|
|
|
|
Hi,
I have a requirement where I need to abend the JCL when the count in the header is not matching with the total number of records in the input file
HEADER RECORD format in input file
| Code: |
0,2011-04-13-00.30.55.433968,12/04/2011,0000000139,
|
Can anyone help me with the second cntl card for the below JCL or
is there any other way to do this ?
| Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
COUNT FROM(T1) EMPTY USING(CTL2) RC8
/*
//CTL1CNTL DD *
OUTFIL FNAMES=T1,INCLUDE=(1,1,CH,EQ,C'0'),BUILD=(41,10)
/*
//CTL2CNTL DD *
?
/*
|
|
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Balaji Canabady,
1. What is the LRECL and RECFM of the input file?
2. Does the count on header include the header record or is it just the count of detail records.
3. Is there a way to identify the last detail record? |
|
| Back to top |
|
 |
Balaji Canabady
New User
Joined: 07 Dec 2011 Posts: 19 Location: India
|
|
|
|
| Quote: |
1. What is the LRECL and RECFM of the input file?
|
LRECL=142,RECFM=FB
| Quote: |
2. Does the count on header include the header record or is it just the count of detail records.
|
Yes Skolusu, the count on header includes all the records including header
| Quote: |
3. Is there a way to identify the last detail record?
|
No Skolusu, there is no trailer record |
|
| Back to top |
|
 |
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
| This will not ABEND the jcl, it will end the step with a nonzero return code and the remainder of the steps can be skipped. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Balaji Canabady,
Use the following DFSORT JCL which will give you the desired results. If the counts don't match step0200 will abend with U0206.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your input FB 142 byte file,DISP=SHR
//SORTOUT DD DSN=&&T1,DISP=(,PASS),UNIT=SYSDA,SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,BUILD=(1,1,41,10,15:SEQNUM,10,ZD)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'0'),PUSH=(2:2,10))
OUTFIL REMOVECC,NODETAIL,BUILD=(20X),TRAILER1=(2,10,15,10)
//*
//STEP0200 EXEC PGM=SORT,PARM='RC16=ABE'
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&T1,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION NULLOUT=RC16
SORT FIELDS=COPY
INCLUDE COND=(1,10,CH,EQ,11,10,CH)
//* |
| Craq Giegerich wrote: |
| This will not ABEND the jcl, it will end the step with a nonzero return code and the remainder of the steps can be skipped. |
You can force the JCL to abend with RC16=ABE for DFSORT as shown in my example. |
|
| Back to top |
|
 |
Balaji Canabady
New User
Joined: 07 Dec 2011 Posts: 19 Location: India
|
|
|
|
Thanks Skolusu...
It works perfectly well
Just curious to know, how the same can be achieved using ICETOOL features.
Also the detail records in my case starts with 1.
Is it possible to use TOTAL option(TOTAL+1) to check the header count with the total number of records by adding all the first column values ? |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Balaji Canabady wrote: |
| Just curious to know, how the same can be achieved using ICETOOL features. |
Balaji Canabady,
Tough to please. So here we go
| Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//DFSPARM DD *
ABEND
//INP DD DSN=Your input FB 142 byte file,DISP=SHR
//TMP DD DSN=&&TMP,DISP=(,PASS),UNIT=SYSDA,SPACE=(TRK,(1,0),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(INP) TO(TMP) USING(CTL1)
COPY FROM(TMP) TO(OUT) USING(CTL2)
//*
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,BUILD=(1,1,41,10,15:SEQNUM,10,ZD)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'0'),PUSH=(2:2,10))
OUTFIL REMOVECC,NODETAIL,BUILD=(20X),TRAILER1=(2,10,15,10)
//*
//CTL2CNTL DD *
OPTION NULLOUT=RC16
INCLUDE COND=(1,10,CH,EQ,11,10,CH)
//* |
| Balaji Canabady wrote: |
Also the detail records in my case starts with 1.
Is it possible to use TOTAL option(TOTAL+1) to check the header count with the total number of records by adding all the first column values ? |
Ok you can total up the value at 1 , but how you are going to compare with the count on the header? TOTAL is the Reporting feature which is processed at the very end. So your first record is long gone by that time.
If you insist then here is another way to get the desired results in 1 pass but your performance will take a hit as we are SORTING and SUMMING to get the results.
| Code: |
//STEP0100 EXEC PGM=SORT,PARM='RC16=ABE'
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your input FB 142 byte file,DISP=SHR
//OUT DD SYSOUT=*
//SYSIN DD *
OPTION NULLOUT=RC16
INREC BUILD=(C'0',41,10,9C'0',C'1')
SORT FIELDS=(1,1,CH,A),EQUALS
SUM FIELDS=(12,10,ZD)
OUTFIL FNAMES=OUT,NULLOFL=RC16,INCLUDE=(2,10,CH,EQ,12,10,CH)
//* |
|
|
| Back to top |
|
 |
Balaji Canabady
New User
Joined: 07 Dec 2011 Posts: 19 Location: India
|
|
|
|
Kolusu... You are really excellent...Thanks a lot
Why I insisted for ICETOOL is that in some cases I have 2 or 3 input files instead of one. Using a single step we can achieve this using the COUNT feature in ICETOOL.
Just tweaked your version for 2 files
| Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//INP1 DD DSN=Input file1 FB 142 byte file,DISP=SHR
//INP2 DD DSN=Input file2 FB 142 byte file,DISP=SHR
//TMP1 DD DSN=&&TMP1,DISP=(,PASS),UNIT=SYSDA,SPACE=(TRK,(1,0),RLSE)
//TMP2 DD DSN=&&TMP2,DISP=(,PASS),UNIT=SYSDA,SPACE=(TRK,(1,0),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(INP1) TO(TMP1) USING(CTL1)
COPY FROM(INP2) TO(TMP2) USING(CTL1)
COUNT FROM(TMP1) EMPTY USING(CTL2) RC8
COUNT FROM(TMP2) EMPTY USING(CTL2) RC12
//*
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,BUILD=(1,1,41,10,15:SEQNUM,10,ZD)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'0'),PUSH=(2:2,10))
OUTFIL REMOVECC,NODETAIL,BUILD=(20X),TRAILER1=(2,10,15,10)
//*
//CTL2CNTL DD *
INCLUDE COND=(1,10,CH,EQ,11,10,CH)
//*
|
We can set three different RC(8/12/16) for 3 files and immediately identify the error file based on the error code.
(Unfortunately the below PTFs are not installed in our place to check the above JCL completely
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242 ) |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Balaji Canabady wrote: |
Why I insisted for ICETOOL is that in some cases I have 2 or 3 input files instead of one. Using a single step we can achieve this using the COUNT feature in ICETOOL. |
Balaji Canabady,
The obsession of a single step. Did you test your Job thoroughly ? Why did you have to change the requirement from abending to setting a return code?
Simple scenario to break your code.
What happens when INP1 have a mismatch in counts and INP2 ALSO having a mismatch in counts? According to your job and based on the defaults (MODE=SCAN) , your second COUNT operator wouldn't even execute. It will be just scanned for syntax. Assuming you have MODE CONTINUE as default , you would end up 1 return code which is 12.
If you got a return code of 12 , how can you be sure that INP1 did not have a mismatch in counts ? If you have MODE=SCAN and got a return code of 8 , how can you be sure that INP2 have the right counts?
Remember that a single step can only return 1 return code. There is a reason as to why I showed you 2 different steps instead of 1. |
|
| Back to top |
|
 |
Balaji Canabady
New User
Joined: 07 Dec 2011 Posts: 19 Location: India
|
|
|
|
| Fully convinced... Thanks for the enlightenment... |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|