SORT - COUNT

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
SRI123
Member
Posts: 15
Joined: Wed Aug 12, 2009 12:18 pm

SORT - COUNT

Post by SRI123 » Tue Aug 18, 2009 8:01 pm

Hi,

I have the input file RECL=80 that contains the file name and type-2 constant, and type-3 constant. I need to read the file name between positions 1 and 21 and count the number of '2' 's in that file at position 4 and write the count of type-2 after TYPE-2= and similar way write the count of type-3 after TYPE=3. Out file should contain the file name along with count of 2 & 3's

Input file is like this:
AAAA.BBBB.CCCC.D0301-TYPE-2=---------- TYPE-3=----------
AAAA.BBBB.CCCC.D0302-TYPE-2=---------- TYPE-3=----------

Output file should be like this:
AAAA.BBBB.CCCC.D0301-TYPE-2=0000000254 TYPE-3=0000000890
AAAA.BBBB.CCCC.D0302-TYPE-2=1234567890 TYPE-3=1234567890

Is it possible to do using sort? only DFSORT, we dont have ICETOOL

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Aug 18, 2009 8:41 pm

Your explanation of what you want is a bit confusing, but going by the input and expected output you showed, I believe this DFSORT job will do what you asked for:

Code: Select all

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'00')),
     IFTHEN=(WHEN=(27,1,CH,EQ,C'2'),OVERLAY=(81:C'1'),HIT=NEXT),
     IFTHEN=(WHEN=(45,1,CH,EQ,C'3'),OVERLAY=(82:C'1'))
  SORT FIELDS=(1,21,CH,A)
  OUTFIL REMOVECC,NODETAIL,
    BUILD=(1,80),
    SECTIONS=(1,21,
      TRAILER3=(1,28,29:TOT=(81,1,ZD,TO=ZD,LENGTH=10),
        40:40,7,TOT=(82,1,ZD,TO=ZD,LENGTH=10)))
/*
Is it possible to do using sort? only DFSORT, we dont have ICETOOL
This statement makes no sense. If you have DFSORT, then you have DFSORT's ICETOOL. ICETOOL has been shipped free with DFSORT since 1991!
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

SRI123
Member
Posts: 15
Joined: Wed Aug 12, 2009 12:18 pm

Post by SRI123 » Fri Aug 21, 2009 11:48 am

Thank you frank for the reply.

I am changing the requirement to make it clear:

I have 100 files. I want to get the record counts from each file and write the count along with the file name in the output file. Do I need to code many steps to get the counts from each file? or any simple method by using the sort.

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Aug 21, 2009 8:16 pm

DFSORT can write a count for one file at a time in various ways. You could use ICETOOL with multiple operators to do counts for multiple files in various ways. But DFSORT does not have any built-in function for displaying the file name of the input file.

REXX might be a better choice for this kind of thing.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

SRI123
Member
Posts: 15
Joined: Wed Aug 12, 2009 12:18 pm

Post by SRI123 » Sat Aug 22, 2009 5:11 pm

Ok. Lets say I got all the counts of the files and I need to format it now like this.

File1 contains the file names and its count information. File2 is report, it contains the formatted input file1 information. I want to take the 1st 5 chars from the input file1 and then put the 23 chars (from 7th char) in the next line in the file2 wherever 1st 5 chars matches.

Input File1(RECL=80, FB):

Code: Select all

FILE1:INT=0001234;EXT=0003456
FILE2:INT=0001225;EXT=0008798
FILE3:INT=0000054;EXT=0006798
File2:(RECL=133,FBA) - before update

Code: Select all

DATE:           PAGE#:
------------------------
------------------------
           FILE1

           FILE2

           FILE3


Output:

DATE:           PAGE#:
------------------------
------------------------
           FILE1
           INT=0001234;EXT=0003456
           FILE2
           INT=0001225;EXT=0008798
           FILE3
           INT=0000054;EXT=0006798
If there is any confusion in the requirement, I'll rephrase it.

skolusu
Member
Posts: 43
Joined: Sat Jul 26, 2008 12:38 am

Post by skolusu » Mon Aug 24, 2009 10:19 pm

sri123,

The following DFSORT/ICETOOL JCL will give you the desired results

I assumed the following.

1. The filename in report file starts at pos 12 for 5 bytes.
2. The header is of 3 lines.
3. I assumed that every record in file 1 has a matching record in file 2

Code: Select all

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                            
FILE1:INT=0001234;EXT=0003456                              
FILE2:INT=0001225;EXT=0008798                              
FILE3:INT=0000054;EXT=0006798                              
//SORTOUT  DD DSN=&&F1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE) 
//SYSIN    DD *                                            
  SORT FIELDS=COPY                                         
  INREC BUILD=(12:1,80,133:X)                              
/*                                                         
//STEP0200 EXEC PGM=ICETOOL                               
//TOOLMSG  DD SYSOUT=*                                    
//DFSMSG   DD SYSOUT=*                                    
//IN       DD DSN=your 133 byte report file f2,DISP=SHR
//         DD DSN=&&F1,DISP=SHR                           
//OUT      DD SYSOUT=*                                    
//TOOLIN   DD *                                           
  DATASORT FROM(IN) TO(OUT) HEADER(3) USING(CTL1)         
//CTL1CNTL DD *                                           
  SORT FIELDS=(12,5,CH,A),EQUALS                          
  OUTFIL FNAMES=OUT,                                      
  IFTHEN=(WHEN=(17,5,CH,EQ,C':INT='),OVERLAY=(12:18,75)) 
//*
The output from this job is

Code: Select all

DATE:           PAGE#:              
------------------------            
------------------------            
           FILE1                    
           INT=0001234;EXT=0003456  
           FILE2                    
           INT=0001225;EXT=0008798  
           FILE3                    
           INT=0000054;EXT=0006798  
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

SRI123
Member
Posts: 15
Joined: Wed Aug 12, 2009 12:18 pm

Post by SRI123 » Tue Aug 25, 2009 12:14 pm

Hi Kolusu,

Thank you for reply.

Header consists of not only 3 records and these records not in one after the other. In between, there may be another file names. So, whenever file1 found in the file2, counts need to be copied to the next line at the same position.

For the previous example, I'm getting the below error. Am I missing some thing?

Code: Select all

SYT000I  SYNCTOOL RELEASE 1.5.3 - COPYRIGHT 2004  SYNCSORT INC.                
SYT001I  INITIAL PROCESSING MODE IS "STOP"                                     
SYT002I  "TOOLIN" INTERFACE BEING USED                                         
                                                                               
          DATASORT FROM(IN) TO(OUT) HEADER(3) USING(CTL1)                      
SYT048E  STATEMENT DOES NOT BEGIN WITH A VALID OPERATOR                        
SYT030I  OPERATION COMPLETED WITH RETURN CODE 12                               
                                                                               
SYT015I  PROCESSING MODE CHANGED FROM "STOP" TO "SCAN" DUE TO OPERATION FAILURE
                                                                               
SYT004I  SYNCTOOL PROCESSING COMPLETED WITH RETURN CODE 12

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Tue Aug 25, 2009 2:30 pm

SRI123 wrote:For the previous example, I'm getting the below error. Am I missing some thing?
Well, the message

SYT000I SYNCTOOL RELEASE 1.5.3 - COPYRIGHT 2004 SYNCSORT INC.

indicates that you're using Syncsort/Synctool, not DFSORT/ICETOOL, and that DATASORT is not a valid operator for the Syncsort product. You should be posting to that forum, or reviewing the Syncsort product manuals for an equivalent Syncsort command.

User avatar
arcvns
Member
Posts: 28
Joined: Sat May 30, 2009 10:19 pm
Location: Chennai, India

Post by arcvns » Tue Aug 25, 2009 2:35 pm

MrSpock,

I think this forum represents SyncSort as well.
DFSORT , ICETOOL & Utilities
In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities
DATASORT is not a valid operator for the Syncsort product
The latest SYNCTOOL version - SYNCTOOL RELEASE 1.6.2 (shipped with the SyncSort 1.3.2) supports the DATASORT function.

SRI,

Which SyncSort version do you have there?
Arun

SRI123
Member
Posts: 15
Joined: Wed Aug 12, 2009 12:18 pm

Post by SRI123 » Tue Aug 25, 2009 6:20 pm

I have SYNCSORT FOR Z/OS 1.2.3.1R

Alissa Margulies
Member
Posts: 25
Joined: Tue Apr 28, 2009 10:53 pm
Location: USA
Contact:

Post by Alissa Margulies » Tue Sep 29, 2009 2:50 am

SyncSort for z/OS 1.2.3.1 ships with SYNCTOOL release 1.5. You need to upgrade to SyncSort for z/OS 1.3.2 in order to support the DATASORT function in SYNCTOOL.
Alissa Margulies
SyncSort Mainframe Product Services
zos_tech@syncsort.com
201-930-8260

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