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

summation of binary field in dfsort


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

New User


Joined: 18 May 2007
Posts: 28
Location: Hyderabad

PostPosted: Sun Jan 29, 2012 9:58 am
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: 28
Location: Hyderabad

PostPosted: Sun Jan 29, 2012 10:18 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Jan 29, 2012 3:30 pm
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 Developer


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

PostPosted: Tue Jan 31, 2012 12:50 am
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:

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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
No new posts Join 2 files according to one key field. JCL & VSAM 3
Search our Forums:

Back to Top