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 the amounts

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

New User


Joined: 23 Aug 2005
Posts: 24

PostPosted: Tue Jan 06, 2009 3:20 am    Post subject: Sum the amounts
Reply with quote

Frank and all,

this was the solution you have given for my sort situation.

Code:

00000000010005810042000100020003000
00000000010005810044482200030004000
00000000020004568354000300040005000
00000000020004568355000400050004000
00000000030002354243482500060007000


The following DFSORT job would give you what you asked for:

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...   VSAM input file
//SORTOUT DD DSN=...   output file
//SYSIN DD *
  RECORD TYPE=F
  OPTION ZDPRINT                                     
  SORT FIELDS=(1,19,CH,A)                             
  SUM FIELDS=(20,4,ZD,24,4,ZD,28,4,ZD,32,4,ZD)       
/*



It is working fine for the test input. in production the data is coming something different. I am pastig the input file(production).

Code:

0000000001000581004 447G
0000000001000581004 447G
0000000002000456835 496I
0000000002000456835 496I


here I have given only one amount. it should be 4 amounts. for all the amounts the last byte is character.

If you could see the input file the last byte is character. I tried to run with the same sort card, it was giving S0C7. Could you please help me out on this.

Thanks In advance.

Sudhakar.
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 06, 2009 3:45 am    Post subject:
Reply with quote

The 447G amount is equivalent to 4477 and should work fine with ZD. 'G' = X'C7' = 7 and a + sign.

However, it appears that the 447G amount starts in position 21 rather than in position 20. If so, the SUM statement would have to be adjusted accordingly.

What is the starting position of each of the 4 amounts?

What do you want the summed amount in the output to look like? Do you want the last byte to be a character (e.g. 'G' = X'C7') or a number (e.g. '7' = X'F7')?
Back to top
View user's profile Send private message
sudhakar1979

New User


Joined: 23 Aug 2005
Posts: 24

PostPosted: Tue Jan 06, 2009 3:55 am    Post subject: Reply to: Sum the amounts
Reply with quote

the amount1 starts at position 20, 4 bytes in lenght and second amount starts at 24, 4 bytes in lenght and so on.

My file layout is something different, but i will change it accordingly.

the o/p file should be last byte is character.
Back to top
View user's profile Send private message
sudhakar1979

New User


Joined: 23 Aug 2005
Posts: 24

PostPosted: Tue Jan 06, 2009 3:58 am    Post subject: Reply to: Sum the amounts
Reply with quote

Code:
 
  SORT FIELDS=(10,10,CH,A,83,17,CH,A)               
  SUM FIELDS=(118,10,ZD,336,10,ZD,575,6,ZD,581,10,ZD)


Frank, This is my actual sort card.
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 06, 2009 4:35 am    Post subject:
Reply with quote

If you want the last byte of positive summed ZD values to use a C sign (e.g. 'G' = X'C7') rather than an F sign (e.g. '7' = X'F7'), just change

Code:

  OPTION ZDPRINT


to:

Code:

  OPTION NZDPRINT


However, you said you got an S0C7. That would only occur if you had the WRONG starting position or length for one of the SUM fields, or an invalid value in one of the SUM fields. Be sure to check that your starting positions and lengths are correct.
Back to top
View user's profile Send private message
sudhakar1979

New User


Joined: 23 Aug 2005
Posts: 24

PostPosted: Tue Jan 06, 2009 7:34 pm    Post subject: Reply to: Sum the amounts
Reply with quote

Frank,

One of the sort fields (83,17,CH,A) is in redefines clause. Would it make difference while sorting the file.

I am still getting the S0C7 error. Could you please let me know what is your view on this.

Finally i have changed the sort step like this.

Code:

  RECORD TYPE=F                                     
  OPTION NZDPRINT                                   
  SORT FIELDS=(10,10,CH,A,83,17,CH,A)               
  SUM FIELDS=(118,10,ZD,336,10,ZD,575,6,ZD,581,10,ZD)


Regards,
Sudhakar.
Back to top
View user's profile Send private message
sudhakar1979

New User


Joined: 23 Aug 2005
Posts: 24

PostPosted: Tue Jan 06, 2009 9:05 pm    Post subject: Reply to: Sum the amounts
Reply with quote

Frank and all,

Finally I have noticed one thing over here. For field (575,6,ZD) in the sort card the values are coming is null values (there are no values present for the field). So I am getting the SOC7 error. I tried remove the field in the sort card and i was successfull.

Sometimes the field will contain the amounts. That particular instance also i need to add the values for 575,6,ZD this field. Could you please let me know how I can achieve this by using sort.

Thanks In advance.
Regards,
Sudhakar.
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 06, 2009 9:44 pm    Post subject:
Reply with quote

What do you mean by "null values"? Do you mean binary zeros or blanks or what? Show one of the "null values" in hex. Or do you mean that the VSAM record is shorter than 576 bytes?

Quote:
I tried remove the field in the sort card and i was successfull.


It would help if you showed the statement you used to do this.

Also, are the VSAM records all the same length? If so, what is that length? Or are the VSAM records different lengths?
Back to top
View user's profile Send private message
sudhakar1979

New User


Joined: 23 Aug 2005
Posts: 24

PostPosted: Tue Jan 06, 2009 10:14 pm    Post subject: Reply to: Sum the amounts
Reply with quote

Frank,
this is the sort card i was used. earler there was another field 575,6,ZD. I have removed this field in the sort card and tried with the following sort card.

Code:

  RECORD TYPE=F                             
  OPTION NZDPRINT                           
  SORT FIELDS=(10,10,CH,A,83,17,CH,A)       
  SUM FIELDS=(118,10,ZD,336,10,ZD,581,10,ZD)


In file there are blanks for the field 575,6.

the hex format is like this.

Code:

000000
00000C


Quote:
do you mean that the VSAM record is shorter than 576 bytes?


no. the vsam record is 700 bytes.

Hope this helps.

Regards,
Sudhakar.
Back to top
View user's profile Send private message
sudhakar1979

New User


Joined: 23 Aug 2005
Posts: 24

PostPosted: Tue Jan 06, 2009 10:29 pm    Post subject: Reply to: Sum the amounts
Reply with quote

Frank,

For your reference i am pasting the hex decial format of the file

+----8

000000
00000C
------

000000
00000C
------

000010
00000C
------

000010
00000C
------

000003
00001C
------

000003
00000C
------

000000
00000C
------

000000
00000C
------

000031
00007C

Regards,
Sudhakar.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Jan 06, 2009 10:36 pm    Post subject:
Reply with quote

Hello,

The values you posted are not blanks or nulls - they are packed-decimal values (PD).

If you change "575,6,ZD" to "575,6,PD", you should be ok.
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 Displaying records per contract and a... madishpa DFSORT/ICETOOL 2 Mon Feb 16, 2015 7:39 pm
No new posts How to identify +ve and -ve amounts sudhakar_mainframe DFSORT/ICETOOL 2 Thu Dec 04, 2014 8:25 pm
No new posts Error while loading the amounts with ... Kunal Surpurkar DB2 3 Mon Apr 22, 2013 2:25 pm
No new posts DB2 SPUFI amounts presentation vs. DB... Gary McDowell DB2 3 Sat Dec 08, 2012 3:30 am
No new posts Sort card to sum up amounts in charac... ksouren007 DFSORT/ICETOOL 2 Fri Sep 30, 2011 10:21 pm


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