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
 

 

Sum only certain fields that have an indicator using DFSORT

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

New User


Joined: 03 Mar 2008
Posts: 32
Location: India

PostPosted: Thu Mar 06, 2008 9:53 am    Post subject: Sum only certain fields that have an indicator using DFSORT
Reply with quote

Hi! I need a bit of help on this:

Say I have a file, which contains the following:

f1 f2 f3
------------------
AA SR1789 123
BB SR1678 123
AA SR1789 456
AA SR1234 789

I need to add the f3 fields of all the records with f1=AA and the same f2 field. So my output should be

f1 f2 f3
------------------
AA SR1789 579
BB SR1678 123
AA SR1234 789

Is it possible to do this without splitting the file?

Actually my file is of length 80 and the field coressponding to f3 is present at 61st position in it with length 13. the field f2 is of length 12 at 3rd position and f1 is of length 2 at 1st position. I tried the following:

OPTION EQUALS,ZDPRINT
INREC OVERLAY=(81:61,15,UFF,TO=ZD,LENGTH=13)
INCLUDE COND=(1,2,CH,EQ,C'AA')
SORT FIELDS=(3,12,CH,A)
SUM FIELDS=(81,13,ZD)
OUTREC BUILD=(1,60,61:81,13,ZD)

but this ways, as is obvious, i am losing the BB records, which i need in the output. Can anyone pls help??
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Mar 06, 2008 2:57 pm    Post subject:
Reply with quote

Have you considered using the IFTHEN operand to preserve the BB records?
Back to top
View user's profile Send private message
niks_jude
Warnings : 1

Active User


Joined: 01 Dec 2006
Posts: 144
Location: Mumbai

PostPosted: Thu Mar 06, 2008 5:57 pm    Post subject:
Reply with quote

This should work

SORT FIELDS =(1,12,CH,A)
SUM FIELDS = (61,13,ZD)

This is because fields f1 and f2 are contiguous. So it will SUM all the f3 fields with same f1 and f2 fields.
Back to top
View user's profile Send private message
niks_jude
Warnings : 1

Active User


Joined: 01 Dec 2006
Posts: 144
Location: Mumbai

PostPosted: Thu Mar 06, 2008 5:58 pm    Post subject:
Reply with quote

Oh sorry !! I missed the requirement regarding 'AA'.
Back to top
View user's profile Send private message
darakhshan

New User


Joined: 03 Mar 2008
Posts: 32
Location: India

PostPosted: Thu Mar 06, 2008 6:04 pm    Post subject:
Reply with quote

No i hadn't.. Not very sure as to where it would fit, but will this serve the purpose?
OPTION EQUALS,ZDPRINT
INREC OVERLAY=(81:61,15,UFF,TO=ZD,LENGTH=13)
INCLUDE COND=(1,2,CH,EQ,C'AA')
SORT FIELDS=(3,12,CH,A)
SUM FIELDS=(81,13,ZD)
OUTREC IFTHEN=(WHEN=(1,2,CH,EQ,C'AA'),
BUILD=(1,60,61:131,15,ZD),
IFTHEN=(WHEN=(1,2,CH,EQ,C'BB'),
BUILD=(1,60,61:131,15)

Pls correct me if i'm wrong.. icon_redface.gif
Back to top
View user's profile Send private message
Ajay Baghel

Active User


Joined: 25 Apr 2007
Posts: 205
Location: Bangalore

PostPosted: Thu Mar 06, 2008 6:12 pm    Post subject: Reply to: Sum only certain fields that have an indicator usi
Reply with quote

SORT FIELDS
Quote:
=(1,12,CH,A)


It needs to be:
Quote:

SORT FIELDS =(1,14,CH,A)
,
SUM FIELDS = (61,13,ZD)


-Ajay
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Thu Mar 06, 2008 10:20 pm    Post subject:
Reply with quote

darakhshan,

The INCLUDE is only keeping the 'AA' fields. You shouldn't be using it.

Your posts are confusing. Are you trying to add just the records with f1='AA' and the same f2 field, or are you trying to add all of the records that have the same f1 and f2 field. To illustrate, what output would you expect for these input records?

Code:

AA SR1789 123
BB SR1678 123
AA SR1789 456
AA SR1234 789
FF SR3333 100
FF SR3333 200
FF SR3333 300
EE SR1234 100
EE SR1234 200


Once you answer this question and I know what you want to do, I can show you how to do it with DFSORT.
Back to top
View user's profile Send private message
niks_jude
Warnings : 1

Active User


Joined: 01 Dec 2006
Posts: 144
Location: Mumbai

PostPosted: Thu Mar 06, 2008 10:35 pm    Post subject:
Reply with quote

AA SR1789 579
BB SR1678 123
AA SR1234 789
FF SR3333 600
EE SR1234 300


I believe he wanted this from his post.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Thu Mar 06, 2008 10:44 pm    Post subject:
Reply with quote

Maybe. Maybe not. I'll wait until darakhshan tells me that.
Back to top
View user's profile Send private message
darakhshan

New User


Joined: 03 Mar 2008
Posts: 32
Location: India

PostPosted: Fri Mar 07, 2008 9:30 am    Post subject:
Reply with quote

actually i want to sum up only the AA records and have the rest as it is.. and i have only two kinds of records, AA and BB. So eliminating the EE and FF records, output shud be:

so the output wud be:

AA SR1789 579
BB SR1678 123
AA SR1234 789
Back to top
View user's profile Send private message
darakhshan

New User


Joined: 03 Mar 2008
Posts: 32
Location: India

PostPosted: Fri Mar 07, 2008 9:33 am    Post subject:
Reply with quote

That is the AA records with the same F2 field.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Fri Mar 07, 2008 10:00 pm    Post subject:
Reply with quote

You can use a DFSORT/ICETOOL job like the following to do what you asked for. I added a few more records for a better test.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD *
AASR1789                                                              123
BBSR1678                                                              123
BBSR1678                                                              345
AASR1789                                                              456
AASR1234                                                              789
AASR2000                                                              999
BBSR1520                                                              222
AASR2000                                                              432
/*
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN   DD    *
SORT FROM(IN) TO(T1) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(89:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,2,CH,EQ,C'BB'),OVERLAY=(81:SEQNUM,8,ZD))
  SORT FIELDS=(1,14,CH,A,81,8,ZD,A)
  OPTION ZDPRINT,EQUALS
  SUM FIELDS=(61,13,ZD)
/*
//CTL2CNTL DD *
  SORT FIELDS=(89,8,ZD,A)
  OUTREC BUILD=(1,60,61,13,ZD,M10,LENGTH=13,80:X)
/*


OUT would have:

Code:

AASR1789                                                              579 
BBSR1678                                                              123 
BBSR1678                                                              345 
AASR1234                                                              789 
AASR2000                                                             1431 
BBSR1520                                                              222 
Back to top
View user's profile Send private message
darakhshan

New User


Joined: 03 Mar 2008
Posts: 32
Location: India

PostPosted: Mon Mar 10, 2008 10:58 am    Post subject:
Reply with quote

thanks a lot! icon_smile.gif
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 Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Sum Fields ballaswaroop DFSORT/ICETOOL 4 Tue May 02, 2017 11:07 am
No new posts DFSORT - Overriding default option TU... Steve Ironmonger DFSORT/ICETOOL 3 Tue Apr 04, 2017 3:54 pm
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts Sort two file having same field, one ... himanshu malik DFSORT/ICETOOL 7 Thu Feb 02, 2017 10:09 am


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