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

counting the number of records in input file using some cond


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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: 1287
Location: Chennai, India

PostPosted: Wed Nov 21, 2007 11:16 am
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
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: 1436
Location: Bangalore,India

PostPosted: Wed Nov 21, 2007 12:19 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Wed Nov 21, 2007 7:07 pm
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
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
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: 1287
Location: Chennai, India

PostPosted: Thu Nov 22, 2007 5:00 pm
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Unable to interpret a hex value to De... COBOL Programming 4
No new posts COBOL sorting, with input GDG base COBOL Programming 7
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts Concatenate 2 input datasets and give... JCL & VSAM 2
No new posts how to eliminate null indicator value... DB2 7
Search our Forums:

Back to Top