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

Syncsort - Count Records by Type


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

New User


Joined: 02 Mar 2007
Posts: 34
Location: somewhere in the middle

PostPosted: Fri Oct 15, 2010 5:30 pm
Reply with quote

Hi Guys,

I have a file which has some data I need to count.

Example.
Input File:
000A
000A
000B
000A
000C

Output File:
A Recs: 03
B Recs: 01
C Recs: 01

I know how to count the records and put them into a file but in different files. I only want a single output file for this.

Code:
   SORT FIELDS=COPY                             
    OUTFIL FILES=01,                             
           INCLUDE=(4,1,CH,EQ,C'A'),             
           REMOVECC,NODETAIL,                   
           TRAILER1=('A RECS:',COUNT=(EDIT=(TT)))


btw we are using SYNCSORT FOR Z/OS 1.3.2.1R
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Fri Oct 15, 2010 6:13 pm
Reply with quote

Quote:

I need a guide or hint to start with so I won't waste more time and resources in finding the correct answer if there is one.

Michael,

What you want to do can be done (in more than one way).

If you spend your time trying (start with what you have), you are not wasting it. Even if it was not possible, the experience you gain, and the effort you expell makes it worth while.

I may get a dozen or more failed attempts with syncsort before I get it to work.

Thomas Edison had hundreds of failed experiments for something that was not possible for each successful patent.

With regard to wasted resources, in my opinion, the computer sitting idle, instead of helping you with your experiment is the wasted resource, not the other way around.
Back to top
View user's profile Send private message
Michael Angelo Pagala

New User


Joined: 02 Mar 2007
Posts: 34
Location: somewhere in the middle

PostPosted: Fri Oct 15, 2010 6:25 pm
Reply with quote

thanks for the insight dave

I am trying some other methods but I just want to achieve this in a single step.

also, I can only run this on the company's machine and just can't experiment all day because I have some other things to do.

I am not that proficient with SORT (esp new functions), so I just need some guide on how to do it the simplest way.

thanks again
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Fri Oct 15, 2010 6:40 pm
Reply with quote

Quote:

also, I can only run this on the company's machine and just can't experiment all day because I have some other things to do.

Me too.
Back to top
View user's profile Send private message
Michael Angelo Pagala

New User


Joined: 02 Mar 2007
Posts: 34
Location: somewhere in the middle

PostPosted: Fri Oct 15, 2010 6:48 pm
Reply with quote

any other informative comments? icon_lol.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Oct 15, 2010 7:39 pm
Reply with quote

Hello,

Which release of Syncsort is being used?
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Fri Oct 15, 2010 8:32 pm
Reply with quote

Michael,

With the sort card, you show - you'll get
Code:
A RECS:03       
in output and not
Code:
A Recs: 03
B Recs: 01
C Recs: 01


And 'am not sure about this:
Quote:
I know how to count the records and put them into a file but in different files. I only want a single output file for this.
Does the quoted text mean, you want the output like:

Code:
000A
000A
000B
000A
000C
A Recs: 03
B Recs: 01
C Recs: 01
Please explain.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Oct 15, 2010 8:44 pm
Reply with quote

Hi Anuj,

Michael wants the counts of the different "types" all in one output.

He knows how to get a single count in a trailer and does not want to create 3 sets of trailer code. . .
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Fri Oct 15, 2010 10:55 pm
Reply with quote

Michael,

You're almost there. Changing your card as below might help(Untested).
Code:
  SORT FIELDS=(4,1,CH,A)                             
  OUTFIL REMOVECC,NODETAIL,SECTIONS=(4,1,                   
         TRAILER3=(4,1,' RECS:',COUNT=(EDIT=(TT))))
Remember, the output will be routed to SORTOUT as opposed to your job which writes into SORTOF01
Back to top
View user's profile Send private message
Michael Angelo Pagala

New User


Joined: 02 Mar 2007
Posts: 34
Location: somewhere in the middle

PostPosted: Sun Oct 17, 2010 9:10 am
Reply with quote

thank you dick and arun for your assistance.

I will try the sort card above once I get back to the office. I'll try to understand the SECTION parameter on the manual I asked from Ms. Alissa..

but seeing the sort card..is it correct to assume that the SECTION somewhat groups similar string of char based on the sort fields?

again thanks guys
Back to top
View user's profile Send private message
Michael Angelo Pagala

New User


Joined: 02 Mar 2007
Posts: 34
Location: somewhere in the middle

PostPosted: Wed Oct 20, 2010 1:34 pm
Reply with quote

I made a quick test and the sort card is giving me the expected output.

Thank you Arun.


Another question...if my input varies a little bit..like the position fields of the type/value needed to be counted are not the same for all the records

e.g.
Input File:
000A
000A
XXXX000B
000A
XXXX000C

Output File:
A Recs: 03
B Recs: 01
C Recs: 01

Can this still be achieved by a single step?

thanks!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Oct 20, 2010 7:31 pm
Reply with quote

Hello,

Quote:
if my input varies a little bit..
This additional requirement is more than a "little bit". . . It basically negates the working solution. . . icon_sad.gif

Post any additional "requirement info" now so no one wastes time on a solution that won't be used.

What are the rules for finding the "keys". If there are no rules, it probably cannot be done. . .
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Oct 20, 2010 7:39 pm
Reply with quote

the approach has beed discussed a few times
using the BUILD IFTHEN constructs build an auxiliary field
carry on the grouping on that field and as per current approach
when writing the final result just ignore the auxiliary field

for example
if the record is 80 bytes build the auxiliary field at position 81 for the relevant number of bytes

searching the forums for BUILD IFTHEN will give quite a few examples
on how to proceed
Back to top
View user's profile Send private message
Michael Angelo Pagala

New User


Joined: 02 Mar 2007
Posts: 34
Location: somewhere in the middle

PostPosted: Thu Oct 21, 2010 10:45 am
Reply with quote

yes I was aware of that dick and I apologize for that..I will probably do enrico's suggestion.

thanks again guys..you have been so helpful!
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
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 Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top