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
 

 

summation of binary field in dfsort

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

New User


Joined: 18 May 2007
Posts: 27
Location: Hyderabad

PostPosted: Sun Jan 29, 2012 9:58 am    Post subject: summation of binary field in dfsort
Reply with quote

Input file : 10 bytes in length and record format is FB

first field in input file : binary field of 2 bytes in length
second field : character data of 8 bytes in length

first field (binary field in 2 bytes) contains positive and negative values

I need grand total of value present in first field.

Output file should contain only grand total (total value wil not exceed 2 bytes).

Please provide me dfsort job to sum the binary value present in 2 bytes

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

madishpa

New User


Joined: 18 May 2007
Posts: 27
Location: Hyderabad

PostPosted: Sun Jan 29, 2012 10:18 am    Post subject: Reply to: summation of binary field in dfsort
Reply with quote

adding additional information to above query

values in the inut files are:

10
-1
-2

above values in the file are in binary format (first 2 bytes)

resultant value in output file:

7

output file should contain only resultant value, it would be good to have data in output file in readable format

Thanks
Madishpa
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7255

PostPosted: Sun Jan 29, 2012 3:30 pm    Post subject: Reply to: summation of binary field in dfsort
Reply with quote

madishpa,

You could try something like the following. The first step I did to generate the test data. The second I based on something "stolen" from one of Frank's solutions in the beginner's forum a couple of days ago.

This can get you started. Expect a better solution later from San Jose.

I've included both positive and negative signs (and tested their production). I've not bothered chopping the leading zeros, because I suspect there is no need, and it gives you something to do if you are keen and feel it necessary.

Code:
//TSTDATA EXEC PGM=SORT
//SYSIN    DD *
  OPTION COPY
  OUTFIL BUILD=(-1,TO=FI,LENGTH=2,3,8,/,
                -2,TO=FI,LENGTH=2,3,8,/,
                +10,TO=FI,LENGTH=2,3,8)
                                                               
//SYSOUT DD SYSOUT=*
//SORTOUT DD DSN=&&TMP,SPACE=(TRK,1),UNIT=SYSDA,DISP=(,PASS)
//SORTIN DD *
**********************
//SUMSBIN EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&TMP,DISP=(OLD,PASS)
//SORTOUT DD SYSOUT=*
//SYSIN DD *
 OPTION COPY
 OUTFIL REMOVECC,NODETAIL,
    TRAILER1=(TOT=(1,2,FI,EDIT=(STTTT),SIGNS=(+,-)))
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: Tue Jan 31, 2012 12:50 am    Post subject:
Reply with quote

Quote:
Expect a better solution later from San Jose.


madishpa,

If all you want is a grand total of all the FI values, then Bill's TRAILER1 solution should do it. If you want something else, you need to explain more clearly what you want.

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
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 resume binary ftp in z/os meykh2014 All Other Mainframe Topics 6 Sun Jan 22, 2017 10:01 am
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am


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