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
 

 

Count no of records in a file using SORT
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
Ankita Maheshwari

New User


Joined: 12 May 2010
Posts: 24
Location: Pune

PostPosted: Wed May 12, 2010 3:24 pm    Post subject: Count no of records in a file using SORT
Reply with quote

Hi,

I want to count no. of records in a file using JCL sort and need to copy them to a specific position in a file.

Please suggest how can this be done.

Thanks
Ankita
Back to top
View user's profile Send private message

Escapa

Senior Member


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

PostPosted: Wed May 12, 2010 3:27 pm    Post subject:
Reply with quote

Welcome...

show sample records and expected output.

Quote:
count no. of records in a file using JCL sort and need to copy them to a specific position in a file


Your wording is not clear to me.

What is LRECL\RECFM of the file?
What is the sort product you are using?
Back to top
View user's profile Send private message
Ankita Maheshwari

New User


Joined: 12 May 2010
Posts: 24
Location: Pune

PostPosted: Wed May 12, 2010 3:34 pm    Post subject: Reply to: JCL to count no. of records in a file.
Reply with quote

I want to use simple sort to count number of records in a file. And then want to copy that count in a file at a specific position.
Back to top
View user's profile Send private message
Ankita Maheshwari

New User


Joined: 12 May 2010
Posts: 24
Location: Pune

PostPosted: Wed May 12, 2010 3:36 pm    Post subject: Reply to: JCL to count no. of records in a file.
Reply with quote

Input file: Has 11 records
Output file needs to be in the format:

TRAILER 'some date' 'some date' 000000011(this is the count of records)
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Wed May 12, 2010 4:58 pm    Post subject:
Reply with quote

Still did not understand what is 'some date' 'some date' but below step will assist you.

Code:
//S1    EXEC  PGM=SORT                                       
//SYSOUT    DD  SYSOUT=*                                     
//SORTIN DD *                                                 
DETAIL RECORD 1                                               
DETAIL RECORD 2                                               
DETAIL RECORD 3                                               
DETAIL RECORD 4                                               
DETAIL RECORD 5                                               
/*                                                           
//SORTOUT DD SYSOUT=*                                         
//SYSIN    DD    *                                           
 SORT FIELDS=COPY                                             
 OUTFIL REMOVECC,                                             
 TRAILER1=('NUMBER OF RECORDS ARE:',COUNT=(M11,LENGTH=8))     
/*     


Output

Code:


DETAIL RECORD 1                     
DETAIL RECORD 2                     
DETAIL RECORD 3                     
DETAIL RECORD 4                     
DETAIL RECORD 5                     
NUMBER OF RECORDS ARE:00000005
Back to top
View user's profile Send private message
Ankita Maheshwari

New User


Joined: 12 May 2010
Posts: 24
Location: Pune

PostPosted: Wed May 12, 2010 5:08 pm    Post subject: Reply to: JCL to count no. of records in a file.
Reply with quote

In the output i do not want:

DETAIL RECORD 1
DETAIL RECORD 2
DETAIL RECORD 3
DETAIL RECORD 4
DETAIL RECORD 5
NUMBER OF RECORDS ARE:00000005

I only want:

NUMBER OF RECORDS ARE:00000005

Please tell me what changes to be made for expected output.
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Wed May 12, 2010 5:13 pm    Post subject:
Reply with quote

use..
Code:

//SYSIN    DD    *                                           
 SORT FIELDS=COPY                                             
 OUTFIL REMOVECC,NODETAIL,                                             
 TRAILER1=('NUMBER OF RECORDS ARE:',COUNT=(M11,LENGTH=8))     
/*     
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Wed May 12, 2010 5:14 pm    Post subject:
Reply with quote

Hi,

just change to
Code:
  OUTFIL REMOVECC,NODETAIL,   



Gerry
Back to top
View user's profile Send private message
Ankita Maheshwari

New User


Joined: 12 May 2010
Posts: 24
Location: Pune

PostPosted: Wed May 12, 2010 5:21 pm    Post subject: Reply to: JCL to count no. of records in a file.
Reply with quote

THANKS, it is working, i am placing total count into a file. Now the requirement is to place that count at 30th position in the file. Can this sort card be changed to add the specific position? Also can i specify two files in sortin?
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Wed May 12, 2010 6:22 pm    Post subject:
Reply with quote

Change this to....
Code:
TRAILER1=(30:'NUMBER OF RECORDS ARE:',COUNT=(M11,LENGTH=8))   
How many files do you have? Did you try concatenating all of them?
Back to top
View user's profile Send private message
Ankita Maheshwari

New User


Joined: 12 May 2010
Posts: 24
Location: Pune

PostPosted: Wed May 12, 2010 6:35 pm    Post subject: Reply to: JCL to count no. of records in a file.
Reply with quote

actually, i have two files........

one contain data as:

000000011

and other contain data as:

TRAILER 20100202 20100202

The output file i require is

TRAILER 20100202 20100202 000000011.

Please tell me how can i concatenate these two files in the format which is needed in output file.

Thanks
Ankita
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Wed May 12, 2010 6:42 pm    Post subject:
Reply with quote

Ankita Maheshwari,

You have not shown how your input records look like. Now it looks like a change in requirement. Till now it was like you are trying to count the records in the input file, but it looks like the input file itself has the 'COUNT'.

Tell exactly what you're trying to do if you are looking for some useful suggestions.
Back to top
View user's profile Send private message
Ankita Maheshwari

New User


Joined: 12 May 2010
Posts: 24
Location: Pune

PostPosted: Wed May 12, 2010 6:53 pm    Post subject: Reply to: JCL to count no. of records in a file.
Reply with quote

ok.....

i count no. of records and placed them in a input file.

Now i need to concat that input file to another file.

Formats of all the file are:

File with count:

000000011

File with other data:

TRAILER 20100202 20100202

The output file should look like:

TRAILER 20100202 20100202 000000011

Please help.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu May 13, 2010 2:36 pm    Post subject:
Reply with quote

Code:
TRAILER 20100202 20100202
Where is this data coming from? Looks like date fields. How do you generate this file? There may be a possiblity where you can get your final output file from your original input file itself rather than concatenating intermediate outputs.(Only if you are willing to explain more)
Back to top
View user's profile Send private message
Ankita Maheshwari

New User


Joined: 12 May 2010
Posts: 24
Location: Pune

PostPosted: Thu May 13, 2010 3:43 pm    Post subject: Reply to: JCL to count no. of records in a file.
Reply with quote

As you can see there are two files from where i am recieving the data, and the dates can only be taken from the file i have mentioned. Date file is generated after running a SQL query. This SQL query fetches the date from a table. The two input files are:

File with count:

000000011

File with other data:

TRAILER 20100202 20100202


I am not finiding a way to concat both the files this way:

TRAILER 20100202 20100202 000000011
Back to top
View user's profile Send private message
Ankita Maheshwari

New User


Joined: 12 May 2010
Posts: 24
Location: Pune

PostPosted: Thu May 13, 2010 4:11 pm    Post subject:
Reply with quote

Code:
//*********************************************************************
//* STEP TO COUNT NO. OF RECORDS IN A FILE                             
//*                                                                     
//*********************************************************************
//S002    EXEC PGM=ICETOOL                                             
//IN3     DD  DSN=PFC0010.EXTRACT.REPROCES.BLANK,                 
//            DISP=SHR                                                 
//CT3     DD  DSN=PFC0010.EXTRACT.REPROCES.BLANK1,               
//            DISP=(NEW,CATLG,DELETE),                                 
//            UNIT=SYSDA,                                               
//            SPACE=(80,(100,50),RLSE),                                 
//            AVGREC=K,                                                 
//            DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS)               
//TOOLMSG DD  SYSOUT=*                                                 
//DFSMSG  DD  SYSOUT=*                                                 
//TOOLIN  DD  *                                                         
COUNT FROM(IN3) WRITE(CT3)                                             
/*                                                                     
//**********************************************************************
//*                    GENERATE OUTPUT HEADER FILE                     
//**********************************************************************
//S004    EXEC PGM=SORT                                                 
//SORTIN  DD  DSN=PFC0010.EXTRACT.REPROCES.DATE,                 
//            DISP=SHR                                                 
//SORTOUT DD DSN=PFC0010.EXTRACT.REPROCES.BLANK3.HEADER,         
//            DISP=(NEW,CATLG,DELETE),                                 
//            UNIT=SYSDA,                                               
//            SPACE=(80,(100,50),RLSE),                                 
//            AVGREC=K,                                                 
//            DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS)               
//SYSOUT   DD  SYSOUT=*                                                 
//SYSUDUMP DD  SYSOUT=*                                                 
//SYSIN    DD  *                                                       
  SORT FIELDS=COPY                                                     
  OUTREC  FIELDS=(3:C'HEADER',11:1,8,20:9,8,29:C'SBT')                 
/*                                                                     
//**********************************************************************
//*                    GENERATE OUTPUT TRAILER FILE                     
//**********************************************************************

In this step i want to add one more file which contain the counts and then want to merge the file.


Code:
//S005    EXEC PGM=SORT                                                 
//SORTIN  DD  DSN=PFC0010.EXTRACT.REPROCES.BLANK3.HEADER,         
//            DISP=SHR                                                 
//SORTOUT DD  DSN=PFC0010.EXTRACT.REPROCES.TRAILER,               
//            DISP=(NEW,CATLG,DELETE),                                 
//            UNIT=SYSDA,                                               
//            SPACE=(80,(100,50),RLSE),                                 
//            AVGREC=K,                                                 
//            DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS)               
//SYSOUT   DD  SYSOUT=*                                                 
//SYSUDUMP DD  SYSOUT=*                                                 
//SYSIN    DD  *                                                       
  SORT FIELDS=COPY                                                     
  OUTREC  FIELDS=(4:C'TRAILER',12:11,8,21:20,8)                         
/*                                                                     
//**********************************************************************

Please refer this JCL
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu May 13, 2010 9:37 pm    Post subject: Reply to: JCL to count no. of records in a file.
Reply with quote

if You will learn to use the code tags people willing to answer will have less trouble in understanding You JCLs
Back to top
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 182
Location: hyderabad

PostPosted: Thu May 13, 2010 11:56 pm    Post subject:
Reply with quote

Hi,
Search for SYMNAMES in the forum.It may help to get the desired results.

Thanks
Krishy
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Fri May 14, 2010 8:49 am    Post subject: Re: Reply to: JCL to count no. of records in a file.
Reply with quote

Ankita Maheshwari wrote:
As you can see there are two files from where i am recieving the data, and the dates can only be taken from the file i have mentioned. Date file is generated after running a SQL query. This SQL query fetches the date from a table. The two input files are:

File with count:

000000011

File with other data:

TRAILER 20100202 20100202


I am not finiding a way to concat both the files this way:

TRAILER 20100202 20100202 000000011


Ankita, there is no need of two step solution for this.
Concatenate both files(one with data, other with one record with date)
Use below step to to get desired result.
Code:

//S1    EXEC  PGM=SORT                                                 
//SYSOUT    DD  SYSOUT=*                                               
//SORTIN DD *                *THIS IS YOUR DATA FILE                   
DETAIL RECORD 1                                                       
DETAIL RECORD 2                                                       
DETAIL RECORD 3                                                       
DETAIL RECORD 4                                                       
DETAIL RECORD 5                                                       
/*                                                                     
//       DD *                *THIS IS YOUR DATE FILE WITH ONE RECORD   
TRAILER 20100202 20100202                                             
//SORTOUT DD SYSOUT=*                                                 
//SYSIN    DD    *                                                     
 SORT FIELDS=COPY                                                     
 OUTFIL REMOVECC,NODETAIL,                                             
 TRAILER1=(1,26,COUNT-1=(M11,LENGTH=8))  *NOTE HERE COUNT IS SUBTRACTED
/*                                       *BY 1                                                       

Output will be
Code:

TRAILER 20100202 20100202 00000005   
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Fri May 14, 2010 11:21 am    Post subject:
Reply with quote

Ankita Maheshwari,

SyncSort provides DB2 SQL query support since its 1.2 release. May be if you let us know what is this all about, we can offer some useful suggestions. Show us the SQL which you are running. And how are these dates related to the count which you obtain from the other file?
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 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