Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Deepakgoyal2005

New User

Joined: 22 Mar 2007
Posts: 57
Location: India

 Posted: Tue Jun 24, 2008 10:02 am    Post subject: How to sum fields using Syncsort 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

dick scherrer

Site Director

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

 Posted: Tue Jun 24, 2008 11:53 am    Post subject: 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.
Frank Yaeger

DFSORT Moderator

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

Posted: Tue Jun 24, 2008 8:14 pm    Post subject:

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)              /*
Deepakgoyal2005

New User

Joined: 22 Mar 2007
Posts: 57
Location: India

Posted: Wed Jun 25, 2008 8:35 pm    Post subject: How to sum fields

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.
Skolusu

Senior Member

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

Posted: Wed Jun 25, 2008 9:14 pm    Post subject:

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
Deepakgoyal2005

New User

Joined: 22 Mar 2007
Posts: 57
Location: India

 Posted: Fri Jun 27, 2008 8:29 pm    Post subject: Reply to: How to sum fields The above Code is giving SOC7. I had tried with some modifications but haven't got the solution.
Skolusu

Senior Member

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

Posted: Fri Jun 27, 2008 9:10 pm    Post subject: Re: Reply to: How to sum fields

 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?
Deepakgoyal2005

New User

Joined: 22 Mar 2007
Posts: 57
Location: India

Posted: Fri Jun 27, 2008 9:20 pm    Post subject: Reply to: How to sum fields

 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.
Skolusu

Senior Member

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

 Posted: Fri Jun 27, 2008 9:27 pm    Post subject: 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
Deepakgoyal2005

New User

Joined: 22 Mar 2007
Posts: 57
Location: India

Posted: Fri Jun 27, 2008 9:38 pm    Post subject:

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
dick scherrer

Site Director

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

 Posted: Fri Jun 27, 2008 9:43 pm    Post subject: Hello, You are using Syncsort, not DFSORT.
Alissa Margulies

SYNCSORT Support

Joined: 25 Jul 2007
Posts: 500
Location: USA

 Posted: Sat Jun 28, 2008 1:57 am    Post subject: Deepakgoyal2005, Please contact me offline regarding the Abend0C7 you encountered. You can email me at alissa.margulies@syncsort.com. Thank you.
Skolusu

Senior Member

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

 Posted: Sat Jun 28, 2008 2:18 am    Post subject: Just an FYI , the JOB works fine with DFSORT's ICETOOL and produces the desired output
Arun Raj

Moderator

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

Posted: Sun Jun 29, 2008 1:25 pm    Post subject:

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
Alissa Margulies

SYNCSORT Support

Joined: 25 Jul 2007
Posts: 500
Location: USA

 Posted: Mon Jun 30, 2008 8:28 pm    Post subject: (Maintenance was sent to resolve the Abend0C7).
Deepakgoyal2005

New User

Joined: 22 Mar 2007
Posts: 57
Location: India

 Posted: Fri Jul 04, 2008 10:02 am    Post subject: 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.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Syncsort for field to field comparision Deepti_R SYNCSORT 3 Thu Nov 07, 2019 11:04 pm Formatting bit fields IanWorthington DFSORT/ICETOOL 9 Thu Sep 19, 2019 6:14 pm Training on numeric fields data formats sergeyken SYNCSORT 12 Thu Aug 01, 2019 8:15 pm Need to get the SUM of two fields usi... Poha Eater DFSORT/ICETOOL 7 Tue Jun 18, 2019 1:27 pm Compare fields with decimal chandan.inst SYNCSORT 6 Thu Apr 04, 2019 5:29 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us