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

problem understanding SUM function


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Deepa.m

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Thu Jun 10, 2010 12:21 pm
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
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

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Thu Jun 10, 2010 12:47 pm
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

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Thu Jun 10, 2010 12:51 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Calling an Open C library function in... CICS 1
No new posts DATE2 function SYNCSORT 15
No new posts Help on PL/I jsonPutValue function PL/I & Assembler 8
No new posts how to use Tso outtrap external function All Other Mainframe Topics 8
Search our Forums:

Back to Top