MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Horizontal Summing
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
mfuser
Banned


Joined: 01 Mar 2005
Posts: 105
Topics: 58

PostPosted: Wed Jan 04, 2006 4:15 pm    Post subject: Horizontal Summing Reply with quote

If in the input dataset has records

Code:

ABC A1 JAN 1
ABC A1 JAN 2
ABC A2 JAN 1
ABC A2 JAN 2
ABC A3 JAN 1
ABC A3 FEB 2
ABC A3 MAR 3
ABC A4 JAN 1
ABC A4 FEB 2
ABC A4 MAR 3


How can it be grouped based on ABC code ,then on A1,A2,A3,A4 is there any concept of grouping where in we can achieve the group results like

Code:

ABC A1 JAN 1 2
    A2 JAN 1 2
    A3 JAN 1 2 3
    A4 JAN 1 2 3


Also Can we sum the fields in horizantally like

Code:

                    SUM
ABC A1 JAN 1 2        3
    A2 JAN 1 2        3
    A3 JAN 1 2 3      6
    A4 JAN 1 2 3      6
                   ----
                     18


In the report produced , we do not have 3 rd values for A1 and A2 ,how can we check for blanks using SORT or how to display the fields whose values are blanks.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12395
Topics: 75
Location: San Jose

PostPosted: Thu Jan 05, 2006 9:29 am    Post subject: Reply with quote

mfuser,

Check this link for the first part of the question.

http://www.mvsforums.com/helpboards/viewtopic.php?t=3289

For the second question you can use HORIZONTAL MATH functions(add) to get the desired results. Let us know the format and position of the fields and we will show you how to do it.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mfuser
Banned


Joined: 01 Mar 2005
Posts: 105
Topics: 58

PostPosted: Thu Jan 05, 2006 12:53 pm    Post subject: Reply with quote

Kolusu,

My input dataset looks like this:

ABC is CHARACTER DATA
A1,A2,A3,A4 is CHARACTER DATA
JAN,FEB,MAR is CHARACTER DATA
1,2,3 is NUMERIC DATA (But while displaying on the report numeric data should be edited)

Code:

----+----1---
 ABC A1 JAN 1
 ABC A1 JAN 2
 ABC A2 JAN 1
 ABC A2 JAN 2
 ABC A3 JAN 1
 ABC A3 FEB 2
 ABC A3 MAR 3
 ABC A4 JAN 1
 ABC A4 FEB 2
 ABC A4 MAR 3



My queries:

1.How can we add horizantally the numeric data.
2.In the report produced , we do not have 3 rd values for A1 and A2 ,how can we check for blanks using SORT or how to display the fields whose values are blanks.
3.I have searched the link given by you for grouping the values and i find that ICETOOL / SYNCTOOL is being used.Can we achieve the results using SORT only in a single step as i am using SORT for other purposes and i want to acompilish the task in a single step.
4.I am using the syntax REMOVECC in the control statements ,but still the output spool is of 81 bytes and if i use 40:c'FINISH', the code starts from 41 st column ,why is the output 81 bytes instead of 80 bytes.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12395
Topics: 75
Location: San Jose

PostPosted: Thu Jan 05, 2006 1:15 pm    Post subject: Reply with quote

Quote:

4.I am using the syntax REMOVECC in the control statements ,but still the output spool is of 81 bytes and if i use 40:c'FINISH', the code starts from 41 st column ,why is the output 81 bytes instead of 80 bytes.

Mfuser,

Please do NOT combine questions related to 2 different topics. Your question 4 is not at all related to this question. Please post it in the other topic.

Quote:

1.How can we add horizantally the numeric data.


Check this ex:

Code:

//STEP0100 EXEC PGM=SORT             
//SYSOUT   DD SYSOUT=*               
//SORTIN   DD *                     
----+----1----+----2----+----3----+--
ABC 1 2 3 4                         
DEF 5 6 7 8                         
//SORTOUT  DD SYSOUT=*               
//SYSIN    DD *                     
  SORT FIELDS=COPY                   
  OUTREC FIELDS=(01,4,               
                 05,1,ZD,ADD,       
                 07,1,ZD,ADD,       
                 09,1,ZD,ADD,       
                 11,1,ZD,EDIT=(TTTT))
/*                                   


The output from this step is

Code:

ABC 0010
DEF 0026


The contents at pos 5,7,9,11 each of 1 byte of zoned decimal format is added as a single variable and written as 4 byte sum field.

Quote:

2.In the report produced , we do not have 3 rd values for A1 and A2 ,how can we check for blanks using SORT or how to display the fields whose values are blanks.


There are different ways to do it depending on the max no: of rows present for each key.

Quote:

3.I have searched the link given by you for grouping the values and i find that ICETOOL / SYNCTOOL is being used.Can we achieve the results using SORT only in a single step as i am using SORT for other purposes and i want to acompilish the task in a single step.


If you had read the entire thread completely you would have found this solution posted by frank.

http://www.mvsforums.com/helpboards/viewtopic.php?p=16450#16450

You need to have the Dec, 2004 DFSORT PTF to achieve that.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mfuser
Banned


Joined: 01 Mar 2005
Posts: 105
Topics: 58

PostPosted: Thu Jan 05, 2006 1:42 pm    Post subject: Reply with quote

Kolusu,

My understanding is not very clear about grouping the data.Can you please guide me how to group this sample input data to desired format so that i can proceed ahead further.

Code:

----+----1---
 ABC A1 JAN 1
 ABC A1 JAN 2
 ABC A2 JAN 1
 ABC A2 JAN 2
 ABC A3 JAN 1
 ABC A3 FEB 2
 ABC A3 MAR 3
 ABC A4 JAN 1
 ABC A4 FEB 2
 ABC A4 MAR 3


Desired Output

Code:

ABC A1 JAN 1 2
    A2 JAN 1 2
    A3 JAN 1 2 3
    A4 JAN 1 2 3


In the report produced , we do not have 3 rd values for A1 and A2 ,how can we check for blanks using SORT or how to display the fields whose values are blanks.Please show me a sample syntax from where in i can build my own code.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12395
Topics: 75
Location: San Jose

PostPosted: Thu Jan 05, 2006 2:13 pm    Post subject: Reply with quote

Mfuser,

Quote:

ABC A1 JAN 1 2
A2 JAN 1 2
A3 JAN 1 2 3
A4 JAN 1 2 3


How did you group the records for A3 and A4 keys? They don't have Jan 2 and Jan 3. Post detailed information on what you're trying to accomplish. Do not make people guess what you mean. This will give you a much better chance of getting a good answer to your question.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mfuser
Banned


Joined: 01 Mar 2005
Posts: 105
Topics: 58

PostPosted: Thu Jan 05, 2006 2:47 pm    Post subject: Reply with quote

Kolusu,

Sorry for posting the requirement incorrectly.Here is what i am looking for

Input dataset:

Code:

----+----1---
 ABC A1 JAN 1
 ABC A1 JAN 2
 ABC A2 JAN 1
 ABC A2 JAN 2
 ABC A3 JAN 1
 ABC A3 FEB 2
 ABC A3 MAR 3
 ABC A4 JAN 1
 ABC A4 FEB 2
 ABC A4 MAR 3


I want to be grouped by ABC and then by A1,A2,A3,A4 and add up horizantally and finally individually vertical sum also.

Desired Output:

Code:

----+----1----+----2----+-
        SER1 SER2 SER3 SUM
 ABC A1 1    2         3 
     A2 1    2         3 
     A3 1    2    3    6 
     A4 1    2    3    6 
        ==== ==== ==== ===
        4    8    6    18


In the report produced , we do not have 3 rd values for A1 and A2 ,how can we check in the input dataset whether there is a 3 rd value for individual A1 / A2 / A3 /A4 ? If it is blank display blank in the report ,if it has a non blank data then display non blank data it in the report and the data is numeric ?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12395
Topics: 75
Location: San Jose

PostPosted: Thu Jan 05, 2006 3:43 pm    Post subject: Reply with quote

Mfuser,

Here is a job which will give you the desired results (with exception cosmetic change)

Code:

//STEP0200 EXEC PGM=SORT           
//SYSOUT   DD SYSOUT=*             
//SORTIN   DD *                     
ABC A1 JAN 1                       
ABC A1 JAN 2                       
ABC A2 JAN 1                       
ABC A2 JAN 2                       
ABC A3 JAN 1                       
ABC A3 FEB 2                       
ABC A3 MAR 3                       
ABC A4 JAN 1                       
ABC A4 FEB 2                       
ABC A4 MAR 3                       
//SORTOUT  DD SYSOUT=*             
//SYSIN    DD *                                               
  INREC FIELDS=(1,30,                                         
                31:12,1,CHANGE=(1,C'1',C'1'),NOMATCH=(C'0'),   
                32:12,1,CHANGE=(1,C'2',C'2'),NOMATCH=(C'0'),   
                33:12,1,CHANGE=(1,C'3',C'3'),NOMATCH=(C'0'))   
  SORT FIELDS=(1,6,CH,A)                                       
  SUM FIELDS=(31,3,ZD)                                         
  OUTREC FIELDS=(01,6,                                         
                 12:31,1,CHANGE=(1,C'0',C' '),NOMATCH=(31,1), 
                 17:32,1,CHANGE=(1,C'0',C' '),NOMATCH=(32,1), 
                 22:33,1,CHANGE=(1,C'0',C' '),NOMATCH=(33,1), 
                 24:31,1,ZD,ADD,                               
                 32,1,ZD,ADD,                                 
                 33,1,ZD,EDIT=(IIIT),31,3)                     
  OUTFIL REMOVECC,OUTREC=(1,27),                               
  SECTIONS=(1,3,                                               
  HEADER3=(09:C'SER1',                                         
           14:C'SER2',                                         
           19:C'SER3',                                         
           24:C'SUM ',/,                                       
           09:C'====',                                         
           14:C'====',                                         
           19:C'====',                                         
           24:C'===='),                                       
 TRAILER3=(09:C'====',                                         
           14:C'====',                                         
           19:C'====',                                         
           24:C'====',/,                                       
           09:TOT=(28,1,ZD,EDIT=(IIIT)),                       
           14:TOT=(29,1,ZD,EDIT=(IIIT)),                       
           19:TOT=(30,1,ZD,EDIT=(IIIT)),                       
           24:TOT=(24,4,ZD,EDIT=(IIIT))))                     
/*                                                             


The output from this job is:

Code:

        SER1 SER2 SER3 SUM   
        ==== ==== ==== ==== 
ABC A1     1    2         3 
ABC A2     1    2         3 
ABC A3     1    2    3    6 
ABC A4     1    2    3    6 
        ==== ==== ==== ==== 
           4    8    6   18 


Please do not ask me to explain everything.

Look up the manual and try to understand the job. The manual is here

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA10/CCONTENTS


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Jan 05, 2006 4:26 pm    Post subject: Reply with quote

mfuser,

Does your fourth column of data really have only 1, 2 or 3 in that order or can it be any number, e.g.

Code:

ABC A1 JAN 5
ABC A1 JAN 9
ABC A2 JAN 8
ABC A2 JAN 3
ABC A3 JAN 7
...


Kolusu,

I don't think your solution will work if the fourth column can have any numbers.

In case anyone is interested, here's a DFSORT solution that works with any numbers in the fourth column and also shows the ABC only for the first record as requested. I didn't bother to put in the headers (wasn't sure if they were really wanted), but they're easy enough to add.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD *
 ABC A1 JAN    5
 ABC A1 JAN    9
 ABC A2 JAN    8
 ABC A2 JAN    3
 ABC A3 JAN    7
 ABC A3 FEB   12
 ABC A3 MAR    9
 ABC A4 JAN   15
 ABC A4 FEB   28
 ABC A4 MAR   31
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) TO(T1) USING(CTL1)
SPLICE FROM(T1) TO(T2) ON(2,3,CH) ON(6,2,CH) -
  WITHEACH WITH(14,4) WITH(19,4)
COPY FROM(T2) USING(CTL2)
/*
//CTL1CNTL DD *
  SORT FIELDS=(2,3,CH,A,6,2,CH,A),EQUALS
  OUTREC IFTHEN=(WHEN=INIT,
    BUILD=(1,8,9:4X,14:4X,19:4X,24:4X,
      31:13,4,36:SEQNUM,4,ZD,RESTART=(1,8),41:SEQNUM,4,ZD)),
   IFTHEN=(WHEN=(36,4,ZD,EQ,+1),OVERLAY=(9:31,4)),
   IFTHEN=(WHEN=(36,4,ZD,EQ,+2),OVERLAY=(14:31,4)),
   IFTHEN=(WHEN=(36,4,ZD,EQ,+3),OVERLAY=(19:31,4))
/*
//CTL2CNTL DD *
  OUTREC IFOUTLEN=27,
    IFTHEN=(WHEN=INIT,
      OVERLAY=(24:9,4,ZD,ADD,14,4,ZD,ADD,19,4,ZD,EDIT=(IIIT)),
       HIT=NEXT),
    IFTHEN=(WHEN=(41,4,ZD,GT,+1),OVERLAY=(2:3X))
  OUTFIL FNAMES=OUT,REMOVECC,
   TRAILER1=(9:4C'=',14:4C'=',19:4C'=',24:4C'=',/,
     9:TOT=(9,4,ZD,EDIT=(IIIT)),
    14:TOT=(14,4,ZD,EDIT=(IIIT)),
    19:TOT=(19,4,ZD,EDIT=(IIIT)),
    24:TOT=(24,4,ZD,EDIT=(IIIT)))
/*


OUT has:

Code:

 ABC A1    5    9        14
     A2    8    3        11
     A3    7   12    9   28
     A4   15   28   31   74
        ==== ==== ==== ====
          35   52   40  127

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12395
Topics: 75
Location: San Jose

PostPosted: Thu Jan 05, 2006 5:21 pm    Post subject: Reply with quote

Quote:

Kolusu,

I don't think your solution will work if the fourth column can have any numbers.



Frank I am aware of that, but OP hasn't actually provided complete details. I Knew that restart with overlay will be the best solution for this, which unfortunately I cannot test it.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mfuser
Banned


Joined: 01 Mar 2005
Posts: 105
Topics: 58

PostPosted: Thu Jan 05, 2006 9:32 pm    Post subject: Reply with quote

Thanks Kolusu and Frank for your help provided.

As per Frank's note my fourth column can have any value as it is being retreived from a table not necessarily 1/ 2/3 it can have anything.Morever can the desired result be produced by SORT only instead of ICETOOL as i am using SORT for other purposes.

Kolusu,When i have run the code , i am getting syntax error ,is it because ADD function is not available with the verison of SORT which i am using in my shop and i am using DFSORT REL 14.0

Code:

            INREC FIELDS=(1,30,                                                 
                          31:12,1,CHANGE=(1,C'1',C'1'),NOMATCH=(C'0'),         
                          32:12,1,CHANGE=(1,C'2',C'2'),NOMATCH=(C'0'),         
                          33:12,1,CHANGE=(1,C'3',C'3'),NOMATCH=(C'0'))         
            SORT FIELDS=(1,6,CH,A)                                             
            SUM FIELDS=(31,3,ZD)                                               
            OUTREC FIELDS=(01,6,                                               
                           12:31,1,CHANGE=(1,C'0',C' '),NOMATCH=(31,1),         
                           17:32,1,CHANGE=(1,C'0',C' '),NOMATCH=(32,1),         
                           22:33,1,CHANGE=(1,C'0',C' '),NOMATCH=(33,1),         
                           24:31,1,ZD,ADD,                                     
                                      $                                         
ICE007A E SYNTAX ERROR                                                         
                           32,1,ZD,ADD,                                         
                           $                                                   
ICE007A 0 SYNTAX ERROR                                                         
                           33,1,ZD,EDIT=(IIIT),31,3)                           
                           $                                                   
ICE007A 0 SYNTAX ERROR                                                         
            OUTFIL REMOVECC,OUTREC=(1,27),                                     
                   $                                                           



My desired ouput:

Code:

        SER1 SER2 SER3 SUM
        ==== ==== ==== ====
ABC A1     1    2         3
    A2     1    2         3
    A3     1    2    3    6
    A4     1    2    3    6
        ==== ==== ==== ====
           4    8    6   18

Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12395
Topics: 75
Location: San Jose

PostPosted: Fri Jan 06, 2006 4:18 am    Post subject: Reply with quote

Quote:

i am using DFSORT REL 14.0


That is a very OLD version of DFSORT. So most of the solutions posted here will not work.

Quote:

Morever can the desired result be produced by SORT only instead of ICETOOL as i am using SORT for other purposes.


No.


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mfuser
Banned


Joined: 01 Mar 2005
Posts: 105
Topics: 58

PostPosted: Fri Jan 06, 2006 7:24 am    Post subject: Reply with quote

Thanks Kolusu and Frank,You guys are great.

I have tried out the code provided by both of you in a later version of DFSORT--- Z/OS DFSORT V1R5 and both of the codes have worked out perfectly with the desired inputs and outputs.I have a query whether can i achieve the same results using SORT only instead of ICETOOL because i have am using SORT to display DATE ,TIME and HEADERS and PAGE numbers also and some other processing.I am not well conversant with ICETOOL.How can i achieve the DATE,TIME,PAGE,HEADERS repeating and TRAILER.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12395
Topics: 75
Location: San Jose

PostPosted: Fri Jan 06, 2006 7:45 am    Post subject: Reply with quote

Quote:

I have a query whether can i achieve the same results using SORT only instead of ICETOOL


This has been already answered. May be you missed it. So let me tell you in a programming language

Code:

  DO UNTIL talking parrot = TIRED
     NO NO NO YOU CANNOT GET THE SAME RESULTS USING ONLY SORT INSTEAD OF ICETOOL
  END-DO


Quote:

I am not well conversant with ICETOOL.


Well you can start learning it and trust me it is NOT greek and latin. Frank has made it much easier with an excellent docuementation which can be found here

ICETOOL mini-user guide

Using ICETOOL

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mfuser
Banned


Joined: 01 Mar 2005
Posts: 105
Topics: 58

PostPosted: Fri Jan 06, 2006 10:32 am    Post subject: Reply with quote

Kolusu,

I will try to get the desired results using ICETOOL only and the links provided by you are very good and informative.I will make it as a practise exercise for me and i will surely learn using ICETOOL and it will definetly help me in the future.Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group