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

Number of occurences of a value in the field using JCL sort.


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

New User


Joined: 05 Jan 2006
Posts: 9
Location: hyderabad

PostPosted: Fri Feb 24, 2012 10:30 am
Reply with quote

Hi,

I have a requirement to print the number of occurences of a particular value of the field in the file using the DFsort.

I/P data

20000000003400000647
20000000003400000645
20000000003400000647
20000000003400000645
20000000003400000647
20000000003400000645
20000000005500000641
20000000003400000647

O/P

0647 4(Number of times 0647 repeated)
0645 3(Number of times 0645 repeated)
0641 1(Number of times 0641 repeated)


Input file is a VB file, record lenght is 394, Field position is from 17 and length is 4 .

Please let me know the procedure to do it using DFsort.

Thanks in Advance.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Fri Feb 24, 2012 10:52 am
Reply with quote

ICETOOL and OCCURS has done similar for me.
Back to top
View user's profile Send private message
lakshmikondur

New User


Joined: 05 Jan 2006
Posts: 9
Location: hyderabad

PostPosted: Fri Feb 24, 2012 11:09 am
Reply with quote

Nic,

Thanks for your reply.

Could you please give me an example for this scenario in ICETOOL so that it will be helpful for me.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Fri Feb 24, 2012 11:29 am
Reply with quote

lakshmikondur,

Is the order of records in the output file important to you?
Back to top
View user's profile Send private message
lakshmikondur

New User


Joined: 05 Jan 2006
Posts: 9
Location: hyderabad

PostPosted: Fri Feb 24, 2012 11:32 am
Reply with quote

Arun,

Order of the records in the output is not important to me. It can be any order.

Regards,
Lakshmi
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Fri Feb 24, 2012 11:51 am
Reply with quote

lakshmikondur,

Eventhough you have mentioned the starting position of the input field as 17, I suspect that it should have been 21 since your input file is VB.
Assuming the output file to be of FB,LRECL=80, this should work for you.
Code:
//STEP01   EXEC PGM=SORT                                 
//SYSOUT   DD  SYSOUT=*                                 
//SORTIN   DD  DISP=SHR,DSN= Input file  --> (VB/394)
//SORTOUT  DD  DISP=SHR,DSN= Output file --> (FB/80)
//SYSIN    DD  *                                         
 INREC BUILD=(1,4,21,4)                                 
 SORT FIELDS=(5,4,CH,A)                                 
 OUTFIL VTOF,REMOVECC,NODETAIL,SECTIONS=(5,4,           
       TRAILER3=(5,4,X,COUNT=(M10,LENGTH=2))),BUILD=(80X)
Back to top
View user's profile Send private message
charanmsrit

New User


Joined: 25 Oct 2007
Posts: 81
Location: Australia

PostPosted: Fri Feb 24, 2012 12:24 pm
Reply with quote

Hi,

here is what i used to create a report. if you dont want the report header and title, use one more step to eliminate those records with INCLUDE operator

JCL
Code:
//STEP020  EXEC PGM=ICETOOL                                       
//TOOLMSG   DD SYSOUT=*                                           
//DFSMSG    DD SYSOUT=*                                           
//INDD     DD  *                                                 
20000000003400000647                                             
20000000003400000645                                             
20000000003400000647                                             
20000000003400000645                                             
20000000003400000647                                             
20000000003400000645                                             
20000000005500000641                                             
20000000003400000647                                             
/*                                                               
//OUTDD    DD  DISP=(NEW,CATLG,DELETE),                           
//             DSN=GT0734.GTS758.PER.JCL.OUTPUT,                 
//             SPACE=(CYL,(20,25),RLSE),                         
//             LRECL=80,BLKSIZE=0,RECFM=FBA,DSORG=PS             
//TOOLIN   DD  *                                                 
 OCCUR FROM(INDD) LIST(OUTDD) -                                   
     LINES(999) -                                           
     TITLE('REPORT OF NUMBER OF OCCURENCES') -               
     HEADER('FIELD VALUE') ON(17,4,CH) -                     
     HEADER('NO OF OCCURENCE') ON(VALCNT,N15)               
/*             



Output file

Code:
********************************* Top of Data **********************************
REPORT OF NUMBER OF OCCURENCES                                                 
                                                                               
FIELD VALUE    NO OF OCCURENCE                                                 
-----------   ----------------                                                 
0641                         1                                                 
0645                         3                                                 
0647                         4                                                 
******************************** Bottom of Data ********************************



Note for your VB input file, you need to add RDW of 4 bytes. so TOOLIN should have ON(21,4,CH)
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Feb 24, 2012 12:40 pm
Reply with quote

Quote:
here is what i used to create a report. if you dont want the report header and title, use one more step to eliminate those records with INCLUDE operator


or possibly just remove the control cards that generate the report headings???????
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Fri Feb 24, 2012 12:44 pm
Reply with quote

exactly this question, ok different record layout , not difficult to change,
has been asked and the solution has been provided
at least three times in the last two days
why in heaven people do not search a bit before asking
Back to top
View user's profile Send private message
charanmsrit

New User


Joined: 25 Oct 2007
Posts: 81
Location: Australia

PostPosted: Fri Feb 24, 2012 12:53 pm
Reply with quote

[quote="dbzTHEdinosauer"]
Quote:


or possibly just remove the control cards that generate the report headings???????



you will still get the default headers anyway

Code:
//OUTDD    DD  SYSOUT=*                   
//TOOLIN   DD  *                           
 OCCUR FROM(INDD) LIST(OUTDD) -           
     ON(17,4,CH) -                         
     ON(VALCNT,N15)                       
/*                                   


output
Code:
********************************* Top of Data **********************************
(17,4,CH)        VALUE COUNT                                                   
0641                       1                                                   
0645                       3                                                   
0647                       4                                                   
******************************** Bottom of Data ********************************
Back to top
View user's profile Send private message
lakshmikondur

New User


Joined: 05 Jan 2006
Posts: 9
Location: hyderabad

PostPosted: Fri Feb 24, 2012 2:58 pm
Reply with quote

Thank you all for the quick responses.

I have tried with the ICETOOl and it is working.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat Feb 25, 2012 1:03 am
Reply with quote

Quote:
you will still get the default headers anyway


You can use the NOHEADER operand to eliminate the headers.
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 Help with SORT - I need to validate d... DFSORT/ICETOOL 7
No new posts Help required to reset decimal points... DFSORT/ICETOOL 10
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Is this possible via sort (in one pass)? SYNCSORT 4
No new posts GDG generation name to GDG Base name ... DFSORT/ICETOOL 3
Search our Forums:

Back to Top