Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Count from a file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Subhu_Chatterbox

New User


Joined: 25 Feb 2010
Posts: 12
Location: Hyd

PostPosted: Tue Mar 23, 2010 5:33 pm    Post subject: Count from a file
Reply with quote

Hi all,

My requirement is to count number of records from a file (GDG) and write it into a report file.
Like if input file is having 500 data it should come like, in the output file.
Date: 23/05/2010
No of records found in file : 00000500

Also for empty files it should come as 0

for counting I have used the below code.But can anyone help me to show the text 'No of records found in file' before the count?Can I use outfil for this?also I need help for the date,date could be in any format no problem.
Code i am using for count is as below,

//CTRCDS EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SORTIN DD DSN=Input.DATA.G0005V00,DISP=SHR
//SORTOUT DD DSN=OUTPUT.REPORT,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(10,10),RLSE,,ROUND),
// UNIT=SYSDA
//TOOLIN DD *
COUNT FROM(SORTIN) WRITE(SORTOUT) DIGITS(8)
/*
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Tue Mar 23, 2010 5:53 pm    Post subject:
Reply with quote

Hi Subhu,

You can achieve it by using below sort card:

Code:

  OPTION COPY                                                       
  OUTFIL FNAMES=output1,NODETAIL,REMOVECC,                           
  TRAILER1=(C'NO OF RECORDS FOUND IN FILE :',COUNT=(TO=ZD,LENGTH=8))
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Tue Mar 23, 2010 6:09 pm    Post subject:
Reply with quote

Hello Subhu,

If you need Date as well as first line you can use below sort card

Code:

  OPTION COPY                                               
  OUTFIL FNAMES=OUTPUT1,NODETAIL,REMOVECC,                 
  TRAILER1=(C'DATE:',DATE,/,C'NO OF RECORDS FOUND IN FILE :',
  COUNT=(TO=ZD,LENGTH=10))       
Back to top
View user's profile Send private message
Subhu_Chatterbox

New User


Joined: 25 Feb 2010
Posts: 12
Location: Hyd

PostPosted: Tue Mar 23, 2010 6:16 pm    Post subject:
Reply with quote

Thanks a lot Ekta!!!
I was trying the beow one:

//TOOLIN DD *
COUNT FROM(SORTIN) WRITE(SORTOUT) TEXT('COUNT OF RECORDS IS ')-
DIGITS(8)
/*


for the text i want to enter and its working fine,for date I will try your code and let you know..


Regards,
Subhamita
Back to top
View user's profile Send private message
Subhu_Chatterbox

New User


Joined: 25 Feb 2010
Posts: 12
Location: Hyd

PostPosted: Wed Mar 24, 2010 11:55 am    Post subject:
Reply with quote

Hi is there any way to keep appending data in this file which I have donethe count. Because, I have to do the same for many GDG's and make a report, so the report should contain like

File 1 number of records : 500
file 2 number of records : 400
.....
......
.....
file n number of records :100


Is it possible to do this in JCL without writing a cobol program?
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Mar 24, 2010 12:03 pm    Post subject:
Reply with quote

Hello Subhu,

You can achieve it by using MOD Status Subparamter for your output file as

-The data set exists and records are to be added to the end of it. The data set must be sequential.
-A new data set is to be created.
Back to top
View user's profile Send private message
Subhu_Chatterbox

New User


Joined: 25 Feb 2010
Posts: 12
Location: Hyd

PostPosted: Thu Apr 01, 2010 6:33 pm    Post subject:
Reply with quote

I have some additional requirements, I need to mention database name and table name in the same report. I am using a procedure here which looks like,

//MY PROC DB=,N=,T=
//STEP1 EXEC PGM=TEST,
// PARM='SELECT * FROM &DB..&T;'
--
--
--
//CTRCDS EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SORTIN DD DSN=myprefix.&DB..&N..DATA.G0007V00,DISP=SHR
//SORTOUT DD DSN=report file,DISP=MOD
//TOOLIN DD DSN=Toolin hardcoded input,DISP=OLD
--
PEND

Now in toolding file I have written like

//TOOLIN DD *
COUNT FROM(SORTIN) WRITE(SORTOUT) TEXT('COUNT OF RECORDS IS ')-
DIGITS(8)
/*

As in procedure TOOLIN DD * could not be used directly. Now can anyone tell me how to pass database name that is &DB,Table name &T etc dynamically..
SO that the input would be ike,
Number of output in Database.Table is 500...

Please let me know if further details are required.

Thanks in advance!!!
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Apr 01, 2010 9:41 pm    Post subject:
Reply with quote

Subhu_Chatterbox,

Why can't you do the count of records in the Unload step itself? You are just wasting resources to spin thru the whole file once again just to get the counts where it is a just a single sql statement
Back to top
View user's profile Send private message
Subhu_Chatterbox

New User


Joined: 25 Feb 2010
Posts: 12
Location: Hyd

PostPosted: Tue Apr 06, 2010 1:53 pm    Post subject:
Reply with quote

But I need to make one separate file containing report for all the databases. Also I need to print the databse and table name in the output.Please suggest how can I do this.
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 8 Fri Sep 22, 2017 11:35 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us