Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Syncsort - GET THE RECORD COUNT IN THE FILE

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
Aleksandra Sirota

New User


Joined: 29 Jun 2010
Posts: 12
Location: Mettawa, il

PostPosted: Tue Jun 29, 2010 1:13 am    Post subject: Syncsort - GET THE RECORD COUNT IN THE FILE
Reply with quote

Hi !

I have a data file and a trailer file which has only a trailer record for data file. I need to get the records count from data file and compare it with number of the records in the trailer file. I extracted a number of records from trailer file into a separate file and wanted to add there record count for data file. The JCL is not working. I was thinking when to compare 2 counts in the output file and abend the job if they are different.

This is my JCL :

Code:
//STEP010  EXEC PGM=ICETOOL                                             
//TOOLMSG DD SYSOUT=*                                                   
//DFSMSG DD SYSOUT=*                                                   
//*                                                                     
//IN   DD DSN=INPUT.DLY.A.TST1,DISP=SHR             
//SORTOUT  DD DSN=output.A.TST10,DISP=SHR       
//*                                                                     
//*                                                                   
//TOOLIN   DD *                                                       
 COPY FROM(IN)  USING(CTL1)                                             
 /*                                                                     
 //CTL1CNTL DD *                                                       
   OUTFIL FNAMES=SORTOUT,BUILD=(1,10,11:COUNT=(M11,LENGTH=10))   


Here output.A.TST10 - is the new file I created from trailer file and put the count in the first position. I can't add here the records count from data file - it's giving me the abend.

Thanks a lot for the help
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jun 29, 2010 1:42 am    Post subject: Reply to: GET THE RECORD COUNT IN THE FILE
Reply with quote

Aleksandra Sirota,

What is the format of the count in the trailer file? Show me a sample of the trailer file along with the LRECL and recfm of the trailer file.
Back to top
View user's profile Send private message
Aleksandra Sirota

New User


Joined: 29 Jun 2010
Posts: 12
Location: Mettawa, il

PostPosted: Tue Jun 29, 2010 2:02 am    Post subject:
Reply with quote

Hi Kolusu,

This is the trailer file format :

Code:
Field Level / Name   PICTURE   FLD  START  END  LENGTH  DATA TYPE
10 DATE                X(10)    1    1     10    10     DATE
10 TOTAL_RECORDS       9(10)    2    11    20    10     INT
10 TOTAL_ADDS          9(10)    3    21    30    10     INT
10 TOTAL_DELETES       9(10)    4    31    40    10     INT
10 TOTAL_CHANGES       9(10)    5    41    50    10     INT
10 SUM_FIELD           X(18)    6    51    68    18     INT
10 INTERNAL            X(80)    7    69   148    80     CHAR


I need to compare total_records from here with the number of records in a file.

Edited, don't use tabs!
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jun 29, 2010 2:28 am    Post subject: Reply to: GET THE RECORD COUNT IN THE FILE
Reply with quote

Aleksandra Sirota,

Use the following DFSORT JCL which will give you the desired results. If the counts don't match step0200 will abend with U0206. Count in the trailer file is assumed to be the first record.

Code:

//STEP0100 EXEC PGM=SORT 
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DSN=your input data file,DISP=SHR
//SORTOUT  DD DSN=&&S,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE) 
//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),                   
  TRAILER1=('DATA_COUNT,+',COUNT=(M11,LENGTH=10))         
//*
//STEP0200 EXEC PGM=SORT,PARM='RC16=ABE'   
//SYSOUT   DD SYSOUT=*                     
//SYMNAMES DD DSN=&&S,DISP=SHR             
//SORTIN   DD DSN=Your input 148 byte trailer file,DISP=SHR
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD *                           
  OPTION COPY,NULLOUT=RC16,STOPAFT=1       
  INCLUDE COND=(11,10,BI,EQ,DATA_COUNT)
//*
Back to top
View user's profile Send private message
Aleksandra Sirota

New User


Joined: 29 Jun 2010
Posts: 12
Location: Mettawa, il

PostPosted: Tue Jun 29, 2010 2:53 am    Post subject:
Reply with quote

Hi Skolusu !

Thanks a lot. I'll test it and let you know about the results.

One more question. Can you please give me the version of jcl , where instead of number of records - I can validate the total sum ?

In the trailer it's called SUM_FIELD.

This is it's location in the file:


Code:
Field Level / Name  PICTURE FLD      START  END  LENGTH  DATA TYPE   
10 DETAILED_AMT    S9(9)V99[COMP-3]   135   140    6      DECIMAL

Edited again, what part of "Edited, don't use tabs!" did you not understand?
See Suggestion Whenever indentation representation needed.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jun 29, 2010 3:34 am    Post subject: Reply to: GET THE RECORD COUNT IN THE FILE
Reply with quote

Aleksandra Sirota,

Something doesn't match. You show a layout with picture clause and Data-type of that. The TOTAL_RECORDS has a picture clause of 9(10) which makes it a zoned decimal , but the Data type is INT which makes it a Binary field. Which definition is correct? Similarly for the SUM_FIELD the picture clause is X(18) and the data type is INT . Show me the contents in position 11 thru 20 and also contents in pos 51 thru 68.

Is the Data file a Fixed block file ? Also do you want to validate the count and sum field at the same time? ie. if the both count and sum match the trailer file data , then issue return code of zero or else abend.
Back to top
View user's profile Send private message
Aleksandra Sirota

New User


Joined: 29 Jun 2010
Posts: 12
Location: Mettawa, il

PostPosted: Tue Jun 29, 2010 4:29 am    Post subject:
Reply with quote

Skolusu,

I haven't seen the actual data files yet.

I'm building the jobs based on the Excel Spreadsheet layouts provided to me.

This is the definition for the number of records in trailer file:

Total record count for corresponding data file. So I assume the 9(10) is correct and INT is a comment .

This is the description what I have for SUM field in trailer file :

The Sum total of selected fields on the corresponding data file. The picture field varies depending on the number of decimal places stored in the field being summed. Example: a field being summed that is S9(3)V99 results in this field being redefined as a S9(16)V99 using standard COBOL overpunch for sign on a 18-position field.

Also - the data is fixed block and I want to validate them at the same time
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jun 29, 2010 5:00 am    Post subject: Reply to: GET THE RECORD COUNT IN THE FILE
Reply with quote

Aleksandra Sirota,

Use the following DFSORT JCL. It will validate the record count and the sum of the packed decimal field at pos 135 for a length of 6 bytes. The record count field is compared to contents at pos 11 for 10 bytes and the sum field is compared to the contents at pos 51 for 18 bytes in the trailer file. If BOTH values match with the trailer file contents the return code is set to zero or else step0200 will abend with U0206.

Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*   
//SORTIN   DD DSN=your input data file,DISP=SHR
//SORTOUT  DD DSN=&&S,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN    DD *                                               
  SORT FIELDS=COPY                                             
  OUTFIL REMOVECC,NODETAIL,BUILD=(80X),                       
  TRAILER1=('REC_COUNT,+',COUNT=(M11,LENGTH=10),/,             
            'SUM_TOTAL,C''',TOT=(135,6,PD,ZD,LENGTH=18),C'''')
//*                                                           
//STEP0200 EXEC PGM=SORT,PARM='RC16=ABE'   
//SYSOUT   DD SYSOUT=*                     
//SYMNOUT  DD SYSOUT=*
//SYMNAMES DD DSN=&&S,DISP=SHR             
//SORTIN   DD DSN=Your input 148 byte trailer file,DISP=SHR
//SORTOUT  DD SYSOUT=*                     
//SYSIN    DD *     
  OPTION COPY,NULLOUT=RC16,STOPAFT=1                           
  INCLUDE COND=(11,10,ZD,EQ,REC_COUNT,AND,51,18,CH,EQ,SUM_TOTAL)
//*
Back to top
View user's profile Send private message
Aleksandra Sirota

New User


Joined: 29 Jun 2010
Posts: 12
Location: Mettawa, il

PostPosted: Tue Jun 29, 2010 5:30 am    Post subject:
Reply with quote

Skolusu !

Thank you very much !

Can you please explain to me why are you using all these apostrofies After C :

'SUM_TOTAL,C''',TOT=(135,6,PD,ZD,LENGTH=18),C'''')

Also in this line - INREC OVERLAY=(135:1,5,SFF,PD,LENGTH=6,200:X) what does 5 after 1 means ? And what 200:X means ?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jun 29, 2010 10:11 pm    Post subject:
Reply with quote

Aleksandra Sirota wrote:
Skolusu !

Thank you very much !

Can you please explain to me why are you using all these apostrofies After C :

'SUM_TOTAL,C''',TOT=(135,6,PD,ZD,LENGTH=18),C'''')


Look at the SYMNOUT dd sysout and you will see how the symbols are created. Since your sum total can be positive or negative zoned decimal , i created the symbol creating it as a character. For character symbols you need to enclose the value in single quotes and hence the apostrophes

Quote:

Also in this line - INREC OVERLAY=(135:1,5,SFF,PD,LENGTH=6,200:X) what does 5 after 1 means ? And what 200:X means ?


Oops Sorry. My Bad , it is for my testing as I was setting up the test data . You don't need the INREC statement. Just remove it.
Back to top
View user's profile Send private message
Aleksandra Sirota

New User


Joined: 29 Jun 2010
Posts: 12
Location: Mettawa, il

PostPosted: Fri Jul 09, 2010 4:10 am    Post subject:
Reply with quote

Hi Skolusu !

Thank you very much. I was able to test the jcl and it's working perfectly fine. The only problem that I'm facing now with it , is that the input file comes with the header record , which I shouldn't use in the record count and sum calculation. Can you please modify the jcl, so it will start the necessary calculations from the second record in the file ? Thanks again
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jul 09, 2010 5:21 am    Post subject:
Reply with quote

Aleksandra Sirota wrote:
Hi Skolusu !

Thank you very much. I was able to test the jcl and it's working perfectly fine. The only problem that I'm facing now with it , is that the input file comes with the header record , which I shouldn't use in the record count and sum calculation. Can you please modify the jcl, so it will start the necessary calculations from the second record in the file ? Thanks again


Aleksandra Sirota,

Just add SKIPREC=1 after sort fields=copy in step0100 sysin control cards. This will start calculation values from 2nd record.

Code:

SORT FIELDS=COPY,SKIPREC=1
Back to top
View user's profile Send private message
Aleksandra Sirota

New User


Joined: 29 Jun 2010
Posts: 12
Location: Mettawa, il

PostPosted: Tue Jul 13, 2010 3:08 am    Post subject:
Reply with quote

Thanks a lot . It works.

I'm so sorry but I have another problem with this sort.

When we are doing the SUM in the data file , we are getting the end result in ASCII format :

Command ===>
********************************
SUM_TOTAL,C'00006254618956160'
********************************

In the trailer file the last character of the sum vaue is EBCDIC - col 68.

{ converted to ASCII will be +0 .


Command ===> Scroll ===> PAGE
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
07/01/2010000043626500004362650000000000000000000000000625461895616{PR5474B0DELT
******************************** Bottom of Data ********************************


So the SUM compare is not working.

Is it possible to do something about it in the sort ?
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jul 13, 2010 11:14 pm    Post subject:
Reply with quote

Aleksandra Sirota wrote:
Thanks a lot . It works.

I'm so sorry but I have another problem with this sort.

When we are doing the SUM in the data file , we are getting the end result in ASCII format :

Command ===>
********************************
SUM_TOTAL,C'00006254618956160'
********************************

In the trailer file the last character of the sum vaue is EBCDIC - col 68.

{ converted to ASCII will be +0 .
So the SUM compare is not working.

Is it possible to do something about it in the sort ?


Aleksandra Sirota,

You need to get your basics right. It is NOT ASCII format. zoned decimal numbers have a sign over punch on the last byte. The over punch in hex format looks like this

Code:

{ABCDEFGHI}JKLMNOPQR
CCCCCCCCCCDDDDDDDDDD
01234567890123456789



Hex C0 thru C9 are positive numbers and D0 thru D9 are negative numbers.

If you are getting a C sign for Zd instead of an F sign, then you're using Syncsort, not DFSORT. DFSORT gives an F sign for TO=ZD. Try using TO=ZDF. And since you're using Syncsort, please post in the JCL Forum, not in the DFSORT Forum.
Back to top
View user's profile Send private message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 176
Location: Pune, Maharashtra, India

PostPosted: Mon Aug 22, 2011 8:25 pm    Post subject:
Reply with quote

i have similar problem of counting the record in the trailer,
but i want to map the output of COUNT in trailer to S9(9) comp-3.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Mon Aug 22, 2011 8:35 pm    Post subject:
Reply with quote

rohanthengal wrote:
i have similar problem of counting the record in the trailer,
but i want to map the output of COUNT in trailer to S9(9) comp-3.

Somebody will answer to your this post.. Don't ask same question everywhere..
http://www.ibmmainframes.com/viewtopic.php?t=55760

(Only After you give correct requirement)
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us