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
 

 

counting the number of records in input file using some cond

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

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Wed Nov 21, 2007 10:52 am    Post subject: counting the number of records in input file using some cond
Reply with quote

I have the following requirement. I have one input file which has the following type of records.

1. Header records have first byte as H.
2. Detail records have first byte as D.
3. Trailer records have first byte as T.

The requirement is to just count number of records seperately header, detail and trailer records in the input file using SORT.

I want just counts of header, detail and trailer records in the input file.

if Input is:
Hxxxxxx
Htttttt
Hyyyyyyy
Dddddddd
Deeeeeee
Dffffffff
Dgggggg
Deeeeee
Tnnnnn
Tbbbbb

My output should be as follows and it should be directed to SYSOUT or to a DATASET:
No. of Header Records in input file : 3
No. of Detail Records in input file : 5
No. of Trailer Records in input file : 2

pavan
Back to top
View user's profile Send private message

Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Wed Nov 21, 2007 11:16 am    Post subject: Reply to: counting the number of records in input file using
Reply with quote

i413678,

Try this for your requirement.

Code:
//STEP     EXEC PGM=ICETOOL                                   
//TOOLMSG  DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//IN1      DD *                                               
HXXXXXX                                                       
HTTTTTT                                                       
HYYYYYYY                                                     
DDDDDDDD                                                     
DEEEEEEE                                                     
DFFFFFFFF                                                     
DGGGGGG                                                       
DEEEEEE                                                       
TNNNNN                                                       
TBBBBB                                                       
/*                                                           
//OUT      DD SYSOUT=*                                       
//TOOLIN   DD *                                               
 OCCUR FROM(IN1) LIST(OUT) BLANK -                           
 HEADER('RECORDS') HEADER('COUNT') -                         
 ON(1,1,CH) ON(VALCNT)                                       
/*   



output:

Code:
1RECORDS             COUNT       
 -------   ---------------       
 D                       5       
 H                       3       
 T                       2       
Back to top
View user's profile Send private message
i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Wed Nov 21, 2007 12:00 pm    Post subject:
Reply with quote

Hi Aaru,

Thanks for the solution.....

Can we do it using DFSORT/SYNCSORT......as I should use DFSORT/SYNCSORT only.....

One more thing...how to remove the 1 before RECORDS in the output....

Pavan
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Wed Nov 21, 2007 12:19 pm    Post subject:
Reply with quote

Pavan,

Can we do it using DFSORT/SYNCSORT
ICETOOL is a DFSORT product.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Nov 21, 2007 6:53 pm    Post subject:
Reply with quote

Here is the SORT JCL

Code:
//*******************************************************
//STEP1    EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD *                                         
HXXXXXX                                                 
HTTTTTT                                                 
HYYYYYYY                                                 
DDDDDDDD                                                 
DEEEEEEE                                                 
DFFFFFFFF                                               
DGGGGGG                                                 
DEEEEEE                                                 
TNNNNN                                                   
TBBBBB                                                   
/*                                                       
//SORTOUT  DD SYSOUT=*                                   
//SYSIN    DD *                                         
 SORT FIELDS=(1,1,CH,A)                                 
  OUTFIL REMOVECC,NODETAIL,                             
    HEADER2=('SOURCE',16:'COUNT'),                       
    SECTIONS=(1,1,                                       
      TRAILER3=(1,1,16:COUNT=(EDIT=(IIIIT))))
/*                                           


SORTOUT:
Code:
SOURCE         COUNT
D                  5
H                  3
T                  2
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

PostPosted: Wed Nov 21, 2007 7:07 pm    Post subject: Reply to: counting the number of records in input file using
Reply with quote

Quote:
Hi Aaru,

Thanks for the solution.....

Can we do it using DFSORT/SYNCSORT......as I should use DFSORT/SYNCSORT only.....

One more thing...how to remove the 1 before RECORDS in the output....

Pavan


ICETOOL and SYNCTOOL ARE sort components,
what' s wrong in using them ?? ...
don' t tell me that those are corporate directives :-)
I might make some comments on people stupidity and incompetence...

since You asked for a "SYSOUT" dataset, the first byte of SYSOUTs is
by tradition the printer control character, the 1 means skip to new page
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Nov 21, 2007 8:51 pm    Post subject:
Reply with quote

Quote:
since You asked for a "SYSOUT" dataset, the first byte of SYSOUTs is
even if it was written in to a Dataset it would have that 1.

You canuse this to CARD avoid the same
Code:
//TOOLIN   DD *             
 OCCUR FROM(IN1) LIST(OUT) -
 NOHEADER -                 
 ON(1,1,CH) ON(VALCNT)     
/*                         
Back to top
View user's profile Send private message
i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Thu Nov 22, 2007 10:02 am    Post subject: Reply to: counting the number of records in input file using
Reply with quote

Thank you krisprems for your answer...

May I know whether we can print the output as follows:

Output:
No. of records in Header : 10
No. of records in Detail : 5
No. of records in Trailer : 3


Thx in advance....

Pavan
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Thu Nov 22, 2007 5:00 pm    Post subject: Reply to: counting the number of records in input file using
Reply with quote

Pavan,

Use this JCl for your requirement if you are OK with 2 passes. Else wait for frank for a better solution.

Code:
//STEP     EXEC PGM=ICETOOL                                           
//TOOLMSG  DD SYSOUT=*                                               
//DFSMSG   DD SYSOUT=*                                               
//IN1      DD *                                                       
HXXXXXX                                                               
HTTTTTT                                                               
HYYYYYYY                                                             
DDDDDDDD                                                             
DEEEEEEE                                                             
DFFFFFFFF                                                             
DGGGGGG                                                               
DEEEEEE                                                               
TNNNNN                                                               
TBBBBB                                                               
/*                                                                   
//OUT      DD DSN=HLQ.OUT.GAR2,DISP=(,CATLG,DELETE)               
//TOOLIN   DD *                                                       
 OCCUR FROM(IN1) LIST(OUT) BLANK -                                   
 HEADER('RECORDS') HEADER('COUNT') -                                 
  ON(1,1,CH) ON(VALCNT)                                               
/*                                                                   
//S1    EXEC  PGM=ICEMAN                                         
//SYSOUT    DD  SYSOUT=*                                         
//SORTIN DD DSN=HLQ.OUT.GAR2,DISP=SHR                         
//SORTOUT DD DSN=HLQ.GOP2,DISP=(,CATLG,DELETE)           
//SYSIN    DD    *                                               
  SORT FIELDS=COPY                                               
  INREC IFTHEN=(WHEN=(2,1,CH,EQ,C'D'),                           
        BUILD=(1:C'NO OF RECORDS IN DETAIL:',26,1)),             
        IFTHEN=(WHEN=(2,1,CH,EQ,C'H'),                           
        BUILD=(1:C'NO OF RECORDS IN HEADER:',26,1)),             
        IFTHEN=(WHEN=(2,1,CH,EQ,C'T'),                           
        BUILD=(1:C'NO OF RECORDS IN TRAILER:',26,1))             
/*                                                   



Final Output:

Code:
1RECORDS             COUNT             
 -------   ---------------             
NO OF RECORDS IN DETAIL:5             
NO OF RECORDS IN HEADER:3             
NO OF RECORDS IN TRAILER:2 
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Nov 22, 2007 6:40 pm    Post subject:
Reply with quote

Here is a single pass solution:
Code:
//SYSIN    DD *                                 
 SORT FIELDS=(1,1,CH,A)                         
 OUTREC IFTHEN=(WHEN=(1,1,CH,EQ,C'H'),           
        OVERLAY=(C'NO. OF RECORDS IN HEADER :')),
        IFTHEN=(WHEN=(1,1,CH,EQ,C'D'),           
        OVERLAY=(C'NO. OF RECORDS IN DETAIL :')),
        IFTHEN=(WHEN=(1,1,CH,EQ,C'T'),           
        OVERLAY=(C'NO. OF RECORDS IN TRAILER :'))
  OUTFIL REMOVECC,NODETAIL,                     
    SECTIONS=(1,27,                             
      TRAILER3=(1,27,30:COUNT=(EDIT=(IIIIT))))   
/*                                               
Back to top
View user's profile Send private message
i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Sat Nov 24, 2007 8:51 am    Post subject:
Reply with quote

Thank you very much krisprems,Aaru and enrico-sorichetti for your valueble solutions........

pavan
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Sat Nov 24, 2007 12:32 pm    Post subject:
Reply with quote

i413678
you are welcome icon_smile.gif
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
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm


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