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

How to SUM the Fields in SORT


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

New User


Joined: 22 Mar 2007
Posts: 57
Location: India

PostPosted: Tue Jun 24, 2008 10:02 am
Reply with quote

Please help on how to sum the fields corresponding to same value in a particular column.

Example:
Input is -
1111111111111111 100
1111111111111111 200
2222222222222222 600

Output required is -
1111111111111111 300
2222222222222222 600
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Tue Jun 24, 2008 11:53 am
Reply with quote

Hello,

When you have a question, start a new topic rather than posting a reply to some 2-year-old topic.

To do what you want, use "SUM FIELDS=(s,l,t)" where s=start pos, l=lth, and t=type.
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: Tue Jun 24, 2008 8:14 pm
Reply with quote

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN           
//SYSOUT    DD  SYSOUT=*           
//SORTIN DD *                       
1111111111111111 100               
1111111111111111 200               
2222222222222222 600               
/*
//SORTOUT DD SYSOUT=*               
//SYSIN    DD    *                 
  OPTION ZDPRINT                   
  SORT FIELDS=(1,16,CH,A)           
  SUM FIELDS=(18,3,ZD)             
/*
Back to top
View user's profile Send private message
Deepakgoyal2005

New User


Joined: 22 Mar 2007
Posts: 57
Location: India

PostPosted: Wed Jun 25, 2008 8:35 pm
Reply with quote

Suppose i have an input like -
Code:
1111111111 AAAA 100
           BBBB 200
           HHHH 300
2222222222 AAAA 100
           BBBB 100
3333333333 AAAA 100


Required output is -
Code:
1111111111 AAAA 600
2222222222 AAAA 200
3333333333 AAAA 100


The code in the previous reply do not works for this changed requirement.
Can i have a solution for it.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 25, 2008 9:14 pm
Reply with quote

Deepakgoyal2005,

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

Code:

//STEP0100 EXEC PGM=ICETOOL                                       
//TOOLMSG  DD SYSOUT=*                                           
//DFSMSG   DD SYSOUT=*                                           
//IN       DD *                                                   
1111111111 AAAA 100                                               
           BBBB 200                                               
           HHHH 300                                               
2222222222 AAAA 100                                               
           BBBB 100                                               
3333333333 AAAA 100                                               
//OUT      DD SYSOUT=*                                           
//TOOLIN   DD *                                                   
  SPLICE FROM(IN) TO(OUT) ON(81,8,CH) KEEPNODUPS WITHALL -       
  WITH(1,80) KEEPBASE USING(CTL1)                                 
//CTL1CNTL DD *                                                   
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),             
  IFTHEN=(WHEN=(1,10,CH,GT,C' '),OVERLAY=(81:SEQNUM,8,ZD,1,15)), 
  IFTHEN=(WHEN=NONE,OVERLAY=(89:SEQNUM,8,ZD,                     
           81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))                 
                                                                 
  SORT FIELDS=COPY                                               
  OUTFIL FNAMES=OUT,BUILD=(80X),                                 
  REMOVECC,NODETAIL,                                             
  SECTIONS=(89,10,                                               
  TRAILER3=(89,15,X,TOT=(17,3,ZD,M10,LENGTH=8)))                 
/*                                                               


The output from this job is

Code:

1111111111 AAAA      600
2222222222 AAAA      200
3333333333 AAAA      100
Back to top
View user's profile Send private message
Deepakgoyal2005

New User


Joined: 22 Mar 2007
Posts: 57
Location: India

PostPosted: Fri Jun 27, 2008 8:29 pm
Reply with quote

The above Code is giving SOC7.
I had tried with some modifications but haven't got the solution.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jun 27, 2008 9:10 pm
Reply with quote

Deepakgoyal2005 wrote:
The above Code is giving SOC7.
I had tried with some modifications but haven't got the solution.


Well unless you show me the right input or layout of the file or the control cards you used , how do you expect us to help you?

I showed you an example based on the sample input you have shown.

1. What is the LRECL and RECFM of the files.
2. What is the pos and format of the key to be considered?
3. What is the pos and format of the field to be summed?
Back to top
View user's profile Send private message
Deepakgoyal2005

New User


Joined: 22 Mar 2007
Posts: 57
Location: India

PostPosted: Fri Jun 27, 2008 9:20 pm
Reply with quote

Code:

//STEP010 EXEC PGM=ICETOOL                                       
//SYSOUT   DD SYSOUT=*                                           
//TOOLMSG  DD SYSOUT=*                                           
//DFSMSG   DD SYSOUT=*                                           
//IN       DD *                                                 
1111111111 AAAA 100                                             
           BBBB 200                                             
           HHHH 300                                             
2222222222 AAAA 100                                             
           BBBB 100                                             
3333333333 AAAA 100                                             
//OUT      DD DSN=DEAR.DEEPAK.DUMMY.FILE,                       
//            DISP=(NEW,CATLG,DELETE),                           
//            SPACE=(CYL,(01,01),RLSE),                         
//            DCB=(SYS1.DSCB,LRECL=80,RECFM=FB)                 
//TOOLIN   DD *                                                 
  SPLICE FROM(IN) TO(OUT) ON(81,8,CH) KEEPNODUPS WITHALL -       
  WITH(1,80) KEEPBASE USING(CTL1)                               
//CTL1CNTL DD *                                                 
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),             
  IFTHEN=(WHEN=(1,10,CH,GT,C' '),OVERLAY=(81:SEQNUM,8,ZD,1,15)),
  IFTHEN=(WHEN=NONE,OVERLAY=(89:SEQNUM,8,ZD,                     
           81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
                                               
  SORT FIELDS=COPY                             
  OUTFIL FNAMES=OUT,BUILD=(80X),               
  REMOVECC,NODETAIL,                           
  SECTIONS=(89,10,                             
  TRAILER3=(89,15,X,TOT=(17,3,ZD,M10,LENGTH=8)))
/*                                             


The above code was my input which gave me SOC7.
Let me know if i had missed any information.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jun 27, 2008 9:27 pm
Reply with quote

Deepakgoyal2005,

You sure you ran the JOB as is? I get a return code of zero with the job. You mentioned that you made changes to the job, what did you change?

Show me the error messages you are getting. post the contents of DFSMSG DD
Back to top
View user's profile Send private message
Deepakgoyal2005

New User


Joined: 22 Mar 2007
Posts: 57
Location: India

PostPosted: Fri Jun 27, 2008 9:38 pm
Reply with quote

yes i ran the job as is.

The msg i got is -
" 09.02.29 JOB31590 $HASP165 DEARSUM ENDED AT HFNRDC01 - ABENDED S0C7 U0000 CN(INTERNAL) "

DFSMSG shows -
Code:

 SYNCSORT FOR Z/OS  1.2.3.1RI   U.S. PATENTS: 4210961, 5117495   (C) 2005 SYNCSORT INC.   DATE=2008/179   TIME=09.02.29
                                                 HSBC   z/OS   1.8.0                                                   
 PRODUCT LICENSED FOR CPU SERIAL NUMBER 53AF0, MODEL 2094 712              LICENSE/PRODUCT EXPIRATION DATE: 02 MAY 2012
 CTL1CNTL :                                                                                                           
   INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),                    00051004                                     
   IFTHEN=(WHEN=(1,10,CH,GT,C' '),OVERLAY=(81:SEQNUM,8,ZD,1,15)),        00052004                                     
   IFTHEN=(WHEN=NONE,OVERLAY=(89:SEQNUM,8,ZD,                            00053004                                     
            81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))                        00054004                                     
                                                                         00055004                                     
   SORT FIELDS=COPY                                                      00056004                                     
   OUTFIL FNAMES=OUT,BUILD=(80X),                                        00057004                                     
   REMOVECC,NODETAIL,                                                    00058004                                     
   SECTIONS=(89,10,                                                      00059004                                     
   TRAILER3=(89,15,X,TOT=(17,3,ZD,M10,LENGTH=8)))                        00059104                                     
 PARMLIST :                                                                                                           
 OPTION RESINV=0,ARESINV=0,MSGDDN=DFSMSG,SORTIN=IN,SORTDD=CTL1,SORTOUT=OUT,DYNALL                                     
 OC,CMP=CLC,NOVLSHRT,EQUALS                                                                                           
 SORT FIELDS=(00081,0008,CH,A)                                                                                         
 MODS E35=(SYNCT#35,4096,,N)                                                                                           


JESYSMSG shows -

Code:

IEF237I JES2 ALLOCATED TO TOOLIN                         
IEF237I JES2 ALLOCATED TO CTL1CNTL                       
IEA995I SYMPTOM DUMP OUTPUT                               
SYSTEM COMPLETION CODE=0C7  REASON CODE=00000000         
 TIME=09.02.29  SEQ=11585  CPU=0000  ASID=02B1           
 PSW AT TIME OF ERROR  078D1000   80051A30  ILC 4  INTC 07
   NO ACTIVE MODULE FOUND                                 
   NAME=UNKNOWN                                           


JESMSGLG shows -
Code:

09.02.28 JOB31590  IEF403I DEARSUM - STARTED - TIME=09.02.28                     
09.02.29 JOB31590  +WER999A DEARSUM ,STEP010 ,        -  UNSUCCESSFUL SORT 0C7 S
09.02.29 JOB31590  IEA995I SYMPTOM DUMP OUTPUT  721                             
   721             SYSTEM COMPLETION CODE=0C7  REASON CODE=00000000             
   721              TIME=09.02.29  SEQ=11585  CPU=0000  ASID=02B1               
   721              PSW AT TIME OF ERROR  078D1000   80051A30  ILC 4  INTC 07   
   721                NO ACTIVE MODULE FOUND                                     
   721                NAME=UNKNOWN                                               
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Fri Jun 27, 2008 9:43 pm
Reply with quote

Hello,

You are using Syncsort, not DFSORT.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Sat Jun 28, 2008 1:57 am
Reply with quote

Deepakgoyal2005,

Please contact me offline regarding the Abend0C7 you encountered. You can email me at alissa.margulies@syncsort.com. Thank you.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Sat Jun 28, 2008 2:18 am
Reply with quote

Just an FYI , the JOB works fine with DFSORT's ICETOOL and produces the desired output
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Sun Jun 29, 2008 1:25 pm
Reply with quote

Hello Deepak,

Please try the below sort card. It works with syncsort. Our release is Syncsort 1.2.

Code:

//SYSIN DD *                                                         
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),                 
        IFTHEN=(WHEN=(1,10,CH,GT,C' '),OVERLAY=(81:SEQNUM,8,ZD,1,15)),
        IFTHEN=(WHEN=NONE,OVERLAY=(89:1,15,104:SEQNUM,8,ZD,           
                81:81,8,ZD,SUB,104,8,ZD,M11,LENGTH=8))               
  SORT FIELDS=(81,8,CH,A)                                             
  SUM FIELDS=(17,3,ZD)                                               
  OUTREC FIELDS=(89,15,17,3,ZD,M10,LENGTH=8)                         
/*


Thanks,
Arun
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Mon Jun 30, 2008 8:28 pm
Reply with quote

(Maintenance was sent to resolve the Abend0C7).
Back to top
View user's profile Send private message
Deepakgoyal2005

New User


Joined: 22 Mar 2007
Posts: 57
Location: India

PostPosted: Fri Jul 04, 2008 10:02 am
Reply with quote

Thanks to Arun, since the code provided by him worked with SORT utility.

Arun, it would be nice of you if you could provide me a brief explanation of the code been provided by you.
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 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
No new posts SORT on detail record, then repeat he... DFSORT/ICETOOL 3
No new posts FB to .CSV conversion using sort DFSORT/ICETOOL 7
Search our Forums:

Back to Top