Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

problem understanding SUM function

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Deepa.m
Warnings : 1

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Thu Jun 10, 2010 12:21 pm    Post subject: problem understanding SUM function
Reply with quote

Hello Everyone,

I am facing a peculiar problem while using SUM function in DFSORT.

I have a input file

Lrecl=80

1-45 (card name)
46-48 -Amount field
56-59 -Type

example

aadvantage premium card 400 GOLD
smartplus gold card 453 PLAT
Advantagwe card 1 345 GOLD
XXX featte card 445 PLAT

I want to sum tghe amount group by Type in output file.lrecl =80

i used

//SYSIN DD *
SORT FIELDS=(56,4,CH,A)
SUM FIELDS=(46,3,ZD)

The job ran fine but the o/p file is ame as i/p and the amount field is not summed. Could you pls help me to find out the mistake.

Thanks,
Deepa.
Back to top
View user's profile Send private message

anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Thu Jun 10, 2010 12:36 pm    Post subject:
Reply with quote

Hi Deepa,

When I tried the above sort card you mentioned, it is giving correct results and amount is getting added.

Please post your job, input and output. It might give a clear idea.

Thanks.
Back to top
View user's profile Send private message
Deepa.m
Warnings : 1

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Thu Jun 10, 2010 12:47 pm    Post subject: Reply to: problem understanding SUM function
Reply with quote

please use this example

Code:
********************************* Top of Data *******************
DEMAND COMPUTERS                             69400     BIOL     
STRATEGIC MARKETING INTRODUCTION             56700     BIOL     
TALES EDITING SOFTWARE MANUALS               80100     BIOL     
ADVANCED TOPICS IN PSYCHOANALYSIS            43500     COMP     
ANTHOLOGY OF WOMEN POETS NUMBERING SYSTEMS   65600     COMP     
COMPUTER LANGUAGES                           56700     COMP     
EUROPE SHORT STORIES AND TALL                45800     COMP     
INDUSTRIAL REVOLUTION                        65600     COMP     
VIDEO GAME DESIGN SUPPLYING                  43500     COMP     
AN ANTHOLOGY OF YOUNG POETS MODERN           69700     ENGL     
BIOLOGY INTRODUCTION TO PSYCHOLOGY           65700     ENGL     
CRISES OF THE MIDDLE AGES THE                65600     ENGL     
SYSTEM PROGRAMMING                           45600     ENGL     

o/p is also the same

********************************* Top of Data *******************
DEMAND COMPUTERS                             69400     BIOL     
STRATEGIC MARKETING INTRODUCTION             56700     BIOL     
TALES EDITING SOFTWARE MANUALS               80100     BIOL     
ADVANCED TOPICS IN PSYCHOANALYSIS            43500     COMP     
ANTHOLOGY OF WOMEN POETS NUMBERING SYSTEMS   65600     COMP     
COMPUTER LANGUAGES                           56700     COMP     
EUROPE SHORT STORIES AND TALL                45800     COMP     
INDUSTRIAL REVOLUTION                        65600     COMP     
VIDEO GAME DESIGN SUPPLYING                  43500     COMP     
AN ANTHOLOGY OF YOUNG POETS MODERN           69700     ENGL     
BIOLOGY INTRODUCTION TO PSYCHOLOGY           65700     ENGL     
CRISES OF THE MIDDLE AGES THE                65600     ENGL     
SYSTEM PROGRAMMING                           45600     ENGL     

//SYSIN    DD *               
  SORT FIELDS=(56,4,CH,A)     
  SUM FIELDS=(46,5,ZD)         
Back to top
View user's profile Send private message
Deepa.m
Warnings : 1

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Thu Jun 10, 2010 12:51 pm    Post subject: Reply to: problem understanding SUM function
Reply with quote

I just noticed . it didnot get me the expected result because of overflow error. the sum amount is more than 5 bytes?

How do i do the same for

Code:
ADVANCED TOPICS IN PSYCHOANALYSIS            435       COMP
AN ANTHOLOGY OF YOUNG POETS MODERN           3540      ENGL
AN INTRODUCTION EIGHTEENTH CENTURY           3430      ENGL
ANTHOLOGY OF WOMEN POETS NUMBERING SYSTEMS   656       COMP
BIOLOGY INTRODUCTION TO PSYCHOLOGY           6570      ENGL
COMPUTER LANGUAGES                           567       COMP
CRISES OF THE MIDDLE AGES THE                6560      ENGL
DEMAND COMPUTERS                             238       BIOL
EUROPE SHORT STORIES AND TALL                458       COMP
INDUSTRIAL REVOLUTION                        656       COMP
LIVING WELL ON A SMALL BUDGET                456       BIOL
STRATEGIC MARKETING INTRODUCTION             567       BIOL
SYSTEM PROGRAMMING                           4560      ENGL
TALES EDITING SOFTWARE MANUALS               456       BIOL
THE COMPLETE PROOFREADER INKLINGS            345       BIOL
VIDEO GAME DESIGN SUPPLYING                  435       COMP


Plese note that amount field is not left justified?
Back to top
View user's profile Send private message
anshul_gugnani

New User


Joined: 02 Nov 2009
Posts: 73
Location: Mumbai

PostPosted: Thu Jun 10, 2010 1:28 pm    Post subject:
Reply with quote

Hi Deepa,

You were not getting the correct results due to ovreflow.
Please check the below sort card.
Code:
INREC FIELDS=(01:01,45,46:C'00',48:46,14)
SORT FIELDS=(58,04,CH,A)                 
SUM FIELDS=(46,07,ZD)                     


Have just added leading zeroes to the field to be accumulated.
you can increase this if needed.

Thanks.
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu Jun 10, 2010 10:06 pm    Post subject:
Reply with quote

deepa.m,

The input seems it is already sorted on the key. Instead of padding with zeros and summing , you can use reporting features which will give you the totals

Use the following control cards
Code:

//SYSIN    DD *                                           
  SORT FIELDS=COPY                                         
  OUTFIL REMOVECC,NODETAIL,                               
  SECTIONS=(56,4,                                         
  TRAILER3=(1,45,TOT=(46,5,ZD,M10,LENGTH=8),51,10,80:X))   
//*


will produce

Code:

TALES EDITING SOFTWARE MANUALS                 206200     BIOL
VIDEO GAME DESIGN SUPPLYING                    320700     COMP
SYSTEM PROGRAMMING                             246600     ENGL
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the Extract Function in JCL dharmaraok JCL & VSAM 3 Wed Jun 14, 2017 9:12 am
No new posts Strings with double quotes having pro... raja Arumugam All Other Mainframe Topics 11 Thu Mar 30, 2017 10:34 am
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us