Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
sudhakar1979

New User

Joined: 23 Aug 2005
Posts: 24

Posted: Tue Jan 06, 2009 3:20 am    Post subject: Sum the amounts

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.

Sudhakar.

Frank Yaeger

DFSORT Moderator

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

 Posted: Tue Jan 06, 2009 3:45 am    Post subject: 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')?
sudhakar1979

New User

Joined: 23 Aug 2005
Posts: 24

 Posted: Tue Jan 06, 2009 3:55 am    Post subject: Reply to: Sum the amounts 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.
sudhakar1979

New User

Joined: 23 Aug 2005
Posts: 24

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

 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.
Frank Yaeger

DFSORT Moderator

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

Posted: Tue Jan 06, 2009 4:35 am    Post subject:

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.
sudhakar1979

New User

Joined: 23 Aug 2005
Posts: 24

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

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.
sudhakar1979

New User

Joined: 23 Aug 2005
Posts: 24

 Posted: Tue Jan 06, 2009 9:05 pm    Post subject: Reply to: Sum the amounts 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.
Frank Yaeger

DFSORT Moderator

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

Posted: Tue Jan 06, 2009 9:44 pm    Post subject:

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?
sudhakar1979

New User

Joined: 23 Aug 2005
Posts: 24

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

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.
sudhakar1979

New User

Joined: 23 Aug 2005
Posts: 24

 Posted: Tue Jan 06, 2009 10:29 pm    Post subject: Reply to: Sum the amounts 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.
dick scherrer

Site Director

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

 Posted: Tue Jan 06, 2009 10:36 pm    Post subject: 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.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Displaying records per contract and a... madishpa DFSORT/ICETOOL 2 Mon Feb 16, 2015 7:39 pm How to identify +ve and -ve amounts sudhakar_mainframe DFSORT/ICETOOL 2 Thu Dec 04, 2014 8:25 pm Error while loading the amounts with ... Kunal Surpurkar DB2 3 Mon Apr 22, 2013 2:25 pm DB2 SPUFI amounts presentation vs. DB... Gary McDowell DB2 3 Sat Dec 08, 2012 3:30 am Sort card to sum up amounts in charac... ksouren007 DFSORT/ICETOOL 2 Fri Sep 30, 2011 10:21 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us