View previous topic :: View next topic |
Author |
Message |
WallaceC Beginner
Joined: 17 Dec 2002 Posts: 22 Topics: 10
|
Posted: Fri Apr 18, 2008 8:34 am Post subject: Check header and trailer existence |
|
|
I would like to use SORT to validate header (record with 1HDR) and trailer (record with 9TRL) existence on a file. If both header and trailer are on file, step gives return code of 0; otherwise, step gives return code of 16 . Is it possible to do all in one step?
Sample File Layout
Code: | 1HDR
2DTLAAAAA
2DTLBBBBB
2DTLCCCCC
9TRL 00000003 |
Thanks. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Apr 18, 2008 10:10 am Post subject: |
|
|
Wallace,
The following DFSORT JCL will give you the desired results. A brief explanation of the job. We use an include statement to just include the header and trailer record. Using an Inrec statement we pad +1 in packed decimal format in byte 6 initially. If the record is a trailer record we flip that value to be -1. Now when sum these 2 records the total would be zero , which essentially proves that both header and trailer are present. if the file is empty or it has 2 headers or 2 trailers, the return code will be 16.
Code: |
//STEP0100 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1HDR
2DTLAAAAA
2DTLBBBBB
2DTLCCCCC
9TRL 00000003
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INCLUDE COND=(1,4,SS,EQ,C'1HDR,9TRL')
INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,X,X'1C')),
IFTHEN=(WHEN=(1,4,CH,EQ,C'9TRL'),OVERLAY=(6:X'1D'))
SORT FIELDS=(5,1,CH,A)
SUM FIELDS=(6,1,PD)
OUTFIL NULLOFL=RC16,INCLUDE=(6,1,PD,EQ,0)
/* |
Hope this helps...
Cheers _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
WallaceC Beginner
Joined: 17 Dec 2002 Posts: 22 Topics: 10
|
Posted: Fri Apr 18, 2008 1:33 pm Post subject: |
|
|
Thank you, Kolusu. I tested your suggestion and it worked!
Wallace |
|
Back to top |
|
 |
shash_modi Beginner

Joined: 22 Apr 2008 Posts: 26 Topics: 9 Location: Mumbai
|
Posted: Thu Jun 19, 2008 3:07 am Post subject: |
|
|
Kolusu,
What if I want a return code as 04 and not 16? |
|
Back to top |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Thu Jun 19, 2008 4:25 am Post subject: |
|
|
Read the manual for NULLOFL _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
 |
shash_modi Beginner

Joined: 22 Apr 2008 Posts: 26 Topics: 9 Location: Mumbai
|
Posted: Thu Jun 19, 2008 4:47 am Post subject: |
|
|
Nic,
I read that but not got anything from it. |
|
Back to top |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Thu Jun 19, 2008 4:59 am Post subject: |
|
|
Code: |
|_NULLOFL=_ _RC0__ ___________________________________________| |
| | |_RC4__| | |
| | |_RC16_|
|
Which part don't you get anythng from? Read about NULLOFL and look at Kolusu's solution. Oh, try looking up Condition Code in the index - I didn't - I just searched for NULLOFL and took a look at the first hit. " different manuals, 2 searches on the same keyword, two different bits of the manuals but either should give you your answer if you take into consideration your question and what you are being pointed at. _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
 |
shash_modi Beginner

Joined: 22 Apr 2008 Posts: 26 Topics: 9 Location: Mumbai
|
Posted: Thu Jun 19, 2008 5:16 am Post subject: |
|
|
Nic,
Still I didn't got the answer. Can you please give me the link in which I can find so? |
|
Back to top |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Thu Jun 19, 2008 5:22 am Post subject: |
|
|
You use NULLOFL to set the RC to 0,4 or 16 when the OUTFIL is empty. Kolusu used NULLOFL=RC16 to set a return code of 16. Your question was how to set it to 4. Can you work it out from that? If you want DFSORT to set a RC=4 no matter what - not just an empty OUTFIL dataset then read the manual. You won't find anything because it is not a facility provided by DFSORT. BTW DFSORTs return codes are listed in the manual and you can see which ones may have been set by NULLOFL.
Now don't ask me why you cannot set any old RC eg 8 or 1 or 2 etc. Ask Frank/Kolusu. Probably reserved for future use. _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
 |
shash_modi Beginner

Joined: 22 Apr 2008 Posts: 26 Topics: 9 Location: Mumbai
|
Posted: Thu Jun 19, 2008 5:27 am Post subject: |
|
|
Nic,
Thanks for providing the same. |
|
Back to top |
|
 |
|
|