IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Syncsort Check for header, trailer & count


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
viveksurya

New User


Joined: 08 Jun 2009
Posts: 36
Location: Bangalore

PostPosted: Wed Feb 17, 2010 7:23 pm
Reply with quote

Hi,

This may look redundant but could find the relevant post .

Input file - PS, FB, LRECL=100
Input file:

0DATETIMESTAMP
1ABDCDE.....
1EFGHIJK.....
1LMNOPQ.....
1RSTUVX.....
1YZABCD....
26 DATE

Header Record:
1 - '0' record type
2-9 - DATE
10-19 - TIMESTAMP

Detail Record:
1 - '1' record type
2-100 - Data

Trailer Record:
1 - '2' record type
2-10 - Count (right justified - no leading zeros)
11-18 - DATE

Need to:
1) Have RC=16 if no header OR trailer record
2) Have RC=16 if if the count in the trailer is incorrect (i.e it is not equal to total no. of records in the input file excluding the trailer record).

PS: Need to achieve this using SYNCSORT.

Any help would be much appreciated.
Back to top
View user's profile Send private message
viveksurya

New User


Joined: 08 Jun 2009
Posts: 36
Location: Bangalore

PostPosted: Fri Feb 19, 2010 12:29 pm
Reply with quote

OK..Though I intended to achieve above requirement in single step..since no response..I am planning to do it in multiple steps:

i) Segregate input file into 3 files:
a) Header file - only having header - Later check if its empty then abend the job
b) Trailer file - only having trailer - Later check if its empty then abend the job
c) Detail file - for the actual data to be processed later.
Thus, requirement (1) can be achieved.

ii) For the requirement (2), I am taking a count of the input file(excluding trailer) in a new file. Then I am using JOINKEYS to compare the count in this file and the count in the Trailer file. If it is not equal, abend the job.
For this I am using the following sort-card:

Code:
//SORTJNF1 DD DSN=VS059U.INSIGHT.COUN1,DISP=SHR   
//SORTJNF2 DD DSN=VS059U.INSIGHT.TRLR,DISP=SHR   
//SORTOUT  DD DUMMY                               
//SYSIN    DD *                                   
 JOINKEYS FILES=F1,FIELDS=(1,10,A)               
 JOINKEYS FILES=F2,FIELDS=(1,10,A)               
 REFORMAT FIELDS=(F1:1,80,F2:1,80)               
 INCLUDE COND=(2,9,ZD,EQ,82,9,ZD)                 
 SORT FIELDS=COPY                                 
 OPTION NULLOUT=RC16           


Both JNF1 & JNF2 have LRECL=80, FB.

Here the problem is - the count in the trailer file is right justified (no leading zeros as mentioned earlier) while the count in my count file (SORTJNF1) is with leading zeros. So the job is abending.

SORTJNF1:

Code:
=COLS> ----+----1----+----2----+----3----+----4----+--
****** ***************************** Top of Data *****
000001 2000000009                                     
****** **************************** Bottom of Data ***
SORTJNF2:

Code:
 =COLS> ----+----1----+----2----+----3----+----4----
 ****** ***************************** Top of Data **
 000001 29        02172010                         
 ****** **************************** Bottom of Data   


Any suggestions..?
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Feb 22, 2010 5:27 pm
Reply with quote

Vivek,

The below SyncSort job does what you asked for.
Code:
//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN= Input File (FB/200)                             
//HDR      DD DUMMY                                                 
//TLR      DD DUMMY                                                 
//SYSIN    DD *                                                     
  OPTION COPY                                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(201:SEQNUM,9,ZD)),               
        IFTHEN=(WHEN=(1,1,ZD,EQ,2),                                 
                OVERLAY=(201:201,9,ZD,SUB,+2,M10,LENGTH=9))         
  OUTFIL FNAMES=HDR,INCLUDE=(1,1,CH,EQ,C'0'),NULLOFL=RC16           
  OUTFIL FNAMES=TLR,INCLUDE=(1,1,CH,EQ,C'2',AND,2,9,CH,EQ,201,9,CH),
                    NULLOFL=RC16
Back to top
View user's profile Send private message
viveksurya

New User


Joined: 08 Jun 2009
Posts: 36
Location: Bangalore

PostPosted: Tue Feb 23, 2010 7:16 pm
Reply with quote

Thanks much Arun..!!!

Somehow this is ALMOST working but not fully. I think the count matching is causing the problem.

I ran the job using ur Sort card:

Code:
//SYSIN    DD *                                                       
  OPTION COPY                                                         
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,9,ZD)),                   
        IFTHEN=(WHEN=(1,1,ZD,EQ,2),                                   
                OVERLAY=(81:81,9,ZD,SUB,+2,M10,LENGTH=9))             
  OUTFIL FNAMES=HEADER,INCLUDE=(1,1,CH,EQ,C'0'),NULLOFL=RC16           
  OUTFIL FNAMES=DETAIL,INCLUDE=(1,1,CH,EQ,C'1')                       
  OUTFIL FNAMES=TRAILER,INCLUDE=(1,1,CH,EQ,C'2',AND,2,9,CH,EQ,81,9,CH),
                      NULLOFL=RC16                                     
/*                                                                     


Input:

Code:
=COLS> ----+----1----+----2----+----3----+----4
****** ***************************** Top of Dat
000010 0021720101326                           
000100 19458746987456JKDJSJD7845T             
000200 173464587486HJDSFHJKFDGKHFDKK           
000300 183647845JKDGHJDFGHJDFGHJDFGHJ         
000400 183545433IEIEIJJHJHJDFGHJDFGHJ         
000500 1KJSDGSDKFKJ95794679KJDGJKDSFGJK       
000600 25        02172010       


Error:

Code:
WER405I  HEADER   :  DATA RECORDS OUT          1; TOTAL RECORDS OUT          1
WER405I  DETAIL   :  DATA RECORDS OUT          5; TOTAL RECORDS OUT          5
WER405I  TRAILER  :  DATA RECORDS OUT          0; TOTAL RECORDS OUT          0
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                                 
WER461A  SORTOUT/OUTFIL DATA SET CONTAINS NO DATA RECORDS                     
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                                 


As I find, the include for TRAILER is working fine but the count is not matching.Consequently, the Trailer file is empty and the job is abending.

Arun, I dint get the purpose of "SUB,+2" in the sort card. I am not aquainted with this. Can you pls explain this?

NOTE: As mentioned earlier, count in the trailer in Input file is right justified (no leading zeros). Mask M10 will have leading blanks (bbbbbbbT). We dont have any mask (M0 to M25) which can have trailing blanks.
Back to top
View user's profile Send private message
viveksurya

New User


Joined: 08 Jun 2009
Posts: 36
Location: Bangalore

PostPosted: Tue Feb 23, 2010 9:36 pm
Reply with quote

Hi Arun,

Here is why it is abending:

1)

Code:
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,9,ZD)),                   
        IFTHEN=(WHEN=(1,1,ZD,EQ,2),                                   
                OVERLAY=(81:81,9,ZD,SUB,+2,M10,LENGTH=9))


above piece of sort card will count the records in the input (6 in this case) and then subtract 2 from it( to exclude header n trailer). So count will be 4 here.
But the correct count should be total no. of records(excluding trailer record). So we can resolve this by subtracting only 1.

2) Count in trailer is right justified while our count is left justified. So they will mismatch.

Pls correct me if I am wrong anywhere.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Feb 23, 2010 10:28 pm
Reply with quote

Vivek,

Quote:
above piece of sort card will count the records in the input (6 in this case) and then subtract 2 from it( to exclude header n trailer). So count will be 4 here.
But the correct count should be total no. of records(excluding trailer record). So we can resolve this by subtracting only 1
You're right. The sort job provided above assumes the actual count to be the total number of detail records. If you need the header also, you may replace the code to subtract +1 instead of +2.
Quote:
Count in trailer is right justified while our count is left justified
I am not sure what you meant by this. Your initial post said "2-10 - Count (right justified - no leading zeros)", but the count in the sample input in your latest post is left justified. icon_rolleyes.gif
Back to top
View user's profile Send private message
viveksurya

New User


Joined: 08 Jun 2009
Posts: 36
Location: Bangalore

PostPosted: Wed Feb 24, 2010 1:54 pm
Reply with quote

Oops..!! Actually, I am setting up the data and then was testing the sort card. Rightly pointed out. I have corrected the data now.

Still somehow, using the sortcard:

Code:
 OPTION COPY                                                         
 INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,9,ZD)),                   
       IFTHEN=(WHEN=(1,1,ZD,EQ,2),                                   
               OVERLAY=(81:81,9,ZD,SUB,+1,M10,LENGTH=9))             
 OUTFIL FNAMES=HEADER,INCLUDE=(1,1,CH,EQ,C'0'),NULLOFL=RC16           
 OUTFIL FNAMES=DETAIL,INCLUDE=(1,1,CH,EQ,C'1')                       
 OUTFIL FNAMES=TRAILER,INCLUDE=(1,1,CH,EQ,C'2',AND,2,9,CH,EQ,81,9,CH)
                                NULLOFL=RC16                         
*           


INput:

Code:
****** ***************************** Top
000010 0021720101326                   
000100 19458746987456JKDJSJD7845T       
000200 173464587486HJDSFHJKFDGKHFDKK   
000300 183647845JKDGHJDFGHJDFGHJDFGHJ   
000400 183545433IEIEIJJHJHJDFGHJDFGHJ   
000500 1KJSDGSDKFKJ95794679KJDGJKDSFGJK
000600 2        502172010   


I am still getting abend.

Code:
WER164B  8,944K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,           
WER164B     0 BYTES RESERVE REQUESTED, 3,124,440 BYTES USED                   
WER146B  20K BYTES OF EMERGENCY SPACE ALLOCATED                               
WER108I  SORTIN   : RECFM=FB   ; LRECL=    80; BLKSIZE= 27920                 
WER257I  INREC RECORD LENGTH =    89                                         
WER238I  POTENTIALLY INEFFICIENT USE OF INREC                                 
WER110I  HEADER   : RECFM=FB   ; LRECL=    80; BLKSIZE= 27920                 
WER110I  DETAIL   : RECFM=FB   ; LRECL=    80; BLKSIZE= 27920                 
WER110I  TRAILER  : RECFM=FB   ; LRECL=    80; BLKSIZE= 27920                 
WER405I  HEADER   :  DATA RECORDS OUT          1; TOTAL RECORDS OUT          1
WER405I  DETAIL   :  DATA RECORDS OUT          5; TOTAL RECORDS OUT          5
WER405I  TRAILER  :  DATA RECORDS OUT          0; TOTAL RECORDS OUT          0
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                                 
WER461A  SORTOUT/OUTFIL DATA SET CONTAINS NO DATA RECORDS                     
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                                 


Arun,

Can you find anything wrong here??
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Feb 24, 2010 2:15 pm
Reply with quote

Quote:
I am still getting abend.
What abend are you getting? Mention the abend code or post the abend messages. I tried executing the code above, but I am getting an RC=16
as expected. May be this has something to do with your site settings.
Back to top
View user's profile Send private message
skkp2006

New User


Joined: 14 Jul 2006
Posts: 93
Location: Chennai,India

PostPosted: Wed Feb 24, 2010 3:56 pm
Reply with quote

Vivek,

Is that abending with ABENDU0016 ???
Can you try executing the sort as below adding the parm.


Code:
STEP0100 EXEC PGM=SORT,PARM='NORC16'


Found a similar thread here



Syam
Back to top
View user's profile Send private message
viveksurya

New User


Joined: 08 Jun 2009
Posts: 36
Location: Bangalore

PostPosted: Thu Feb 25, 2010 12:37 pm
Reply with quote

My bad...this should not have gone this far...!!!
Actually was calling a customized proc in next step which would abend the job if RC>4.

Syam,
That parm "NORC16" is used when the default in one's system/installation for RC16 is ABE. Anyways, in my case its well set to NOABE. So need to do that. The trivial issue has stated above.

Much thanks Arun..!!! The job is working fine.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Feb 25, 2010 4:29 pm
Reply with quote

You're welcome. Good to hear it's working! icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top