|
View previous topic :: View next topic
|
| Author |
Message |
i413678 Currently Banned Active User

Joined: 19 Feb 2005 Posts: 112 Location: chennai
|
|
|
|
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 |
|
 |
Aaru
Senior Member

Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
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 |
|
 |
i413678 Currently Banned Active User

Joined: 19 Feb 2005 Posts: 112 Location: chennai
|
|
|
|
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 |
|
 |
murmohk1
Senior Member
.jpg)
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Pavan,
Can we do it using DFSORT/SYNCSORT
ICETOOL is a DFSORT product. |
|
| Back to top |
|
 |
krisprems
Active Member

Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
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 |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10900 Location: italy
|
|
|
|
| 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 |
|
 |
krisprems
Active Member

Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
| 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 |
|
 |
i413678 Currently Banned Active User

Joined: 19 Feb 2005 Posts: 112 Location: chennai
|
|
|
|
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 |
|
 |
Aaru
Senior Member

Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
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 |
|
 |
krisprems
Active Member

Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
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 |
|
 |
i413678 Currently Banned Active User

Joined: 19 Feb 2005 Posts: 112 Location: chennai
|
|
|
|
Thank you very much krisprems,Aaru and enrico-sorichetti for your valueble solutions........
pavan |
|
| Back to top |
|
 |
krisprems
Active Member

Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
i413678
you are welcome  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|