how to get the count of records providing certain condidtion

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

Post Reply
Hima
Member
Posts: 1
Joined: Mon Aug 20, 2012 12:45 am

how to get the count of records providing certain condidtion

Post by Hima » Mon Aug 20, 2012 12:56 am

Hi All,

I have PS (FB, 113 LRECL) file which contains 2 fields:
Field1 - starts at 1 & 6 bytes in length
Field2 - Starts at 8 & 9 bytes in length

Here is sample data in the file-
ASS002 009878654
ASS002 998634664
ASS002 485781533
ARR003 346583746
ARR003 361764465
AZZ987 346764766


My Requirement is, I want output PS in following format -
ASS002 3
ARR003 2
AZZ987 1


Can some one help me out??

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Mon Aug 20, 2012 3:04 am

Your file is not in sequence, and it seems you want it to stay that way.

So, how about looking at the "reporting functions" available on OUTFIL with your sort product? See what SECTIONS might be able to do for you.

Remember, if you have keys which are not contiguous, you will need to sort if they are to be included all together. Then you'd have to get back to original order, according to your sample output.

Why do you describe the second field? It is only the first that you seem to be using.

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Mon Aug 20, 2012 11:04 am

You cannot do it by JCL alone which I assume you think you can do as you posted in the JCL forum. If you want it done by a sort product then post in the sort forum (the one immediately below this one).
Regards
Nic

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Mon Aug 20, 2012 8:53 pm

Which sort product is used on your system?
Have a good one

User avatar
Gurugars
Active Member
Posts: 107
Joined: Sat Oct 23, 2010 2:17 pm
Location: Chennai,India.

Post by Gurugars » Sat Sep 01, 2012 1:29 pm

Hi Hima -

This can be done thru SORT

Code: Select all

//R020     EXEC PGM=SORT                                      
//SYSOUT   DD SYSOUT=*                                        
//SORTIN   DD  *                                              
ASS002 009878654                                              
ASS002 998634664                                              
ASS002 485781533                                              
ARR003 346583746                                              
AZZ987 346764766                                              
ARR003 361764465                                              
//SORTOUT  DD  SYSOUT=*                                       
//SYSIN    DD  *                                              
    SORT FIELDS=(01,6,CH,A)                                   
    INREC OVERLAY=(17:C'0000001')                             
    SUM FIELDS=(17,7,ZD)                                      
    OUTREC FIELDS=(01,6,X,17,7)                               
Result in the Spool -

Code: Select all

********************************* TOP OF DATA *****
ARR003 0000002                                     
ASS002 0000003                                     
AZZ987 0000001                                     
******************************** BOTTOM OF DATA ***
Guru:-)

You're never fully dressed without a smile :)

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Sat Sep 01, 2012 3:49 pm

Have you correctly distinguished your ARR from your ASS, so to speak, when you look at the original sample output?

User avatar
Gurugars
Active Member
Posts: 107
Joined: Sat Oct 23, 2010 2:17 pm
Location: Chennai,India.

Post by Gurugars » Sat Sep 01, 2012 7:02 pm

William Collins -

Sorry, I didn't give much attention to that sample output order. Sorry for that :(
Guru:-)

You're never fully dressed without a smile :)

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Sun Sep 02, 2012 3:54 am

No penalty in giving this another go 8)

Keep in mind that a more involved solution may depend on which sort product is being used . . .
Have a good one

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others