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

Author Message
lanand_hps

New User

Joined: 05 Dec 2007
Posts: 82
Location: chennai

 Posted: Fri Aug 01, 2008 5:07 pm    Post subject: Sum FIELDS with decimal Hi, Can we sum fields with decimals? The input file is like... (column 3) (column 68) 003042193 0000009.08 003042193 0000009.08 003042193 0000009.08 007505628 0000001.73 007505628 0000001.73 007505628 0000001.73 I need to sum the amount fields which starts from 68th column and is of 10 digits including decimal. How do we do it? I'm getting S0C7 if i use the control card mentioned below. SORT FIELDS=(3,9,CH,A) SUM FIELDS=(68,10,ZD) Please comment.

Garry Carroll

Senior Member

Joined: 08 May 2006
Posts: 1006
Location: Dublin, Ireland / Edinburgh, Scotland

 Posted: Fri Aug 01, 2008 6:52 pm    Post subject: You need to move the digits to a work-field, dropping the decimal. Then SUM the work-field and edit, if required to reinstate the decimal, to output field. Where do you want to put the result of the SUM ? Regards, Garry
karthikr44

Active User

Joined: 25 Aug 2007
Posts: 235
Location: Chennai

 Posted: Fri Aug 01, 2008 6:54 pm    Post subject: Reply to: Sum FIELDS with decimal Hi, You can use FL format for floating point numbers. That itself u can use only 4, 8, or 16 bytes. i.e. u can use SUM FIELDS=(11,16,FL) But not SUM FIELDS=(11,15,FL) Regards R KARTHIK
Garry Carroll

Senior Member

Joined: 08 May 2006
Posts: 1006
Location: Dublin, Ireland / Edinburgh, Scotland

Posted: Fri Aug 01, 2008 7:00 pm    Post subject:

 Quote: You can use FL format for floating point numbers.

Perhaps, but that's not what the O/P asked for. Floating-point is a totally different kettle of fish to what is described.

Garry.
karthikr44

Active User

Joined: 25 Aug 2007
Posts: 235
Location: Chennai

 Posted: Fri Aug 01, 2008 7:04 pm    Post subject: Reply to: Sum FIELDS with decimal Hi, I posted because the reason for SOC7 abend is he is using ZD format for numbers like 0002.3 Regards R KARTHIK
Garry Carroll

Senior Member

Joined: 08 May 2006
Posts: 1006
Location: Dublin, Ireland / Edinburgh, Scotland

 Posted: Fri Aug 01, 2008 7:08 pm    Post subject: Hi, Yes, he is. but treating the numbers like 0002.3 as floating point won't solve his problem - he'd have to first change the format of the data to floating point. Regards, Garry.
Frank Yaeger

DFSORT Moderator

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

 Posted: Fri Aug 01, 2008 8:56 pm    Post subject: Karthik, FL is floating point format for numbers with a characteristic and fraction. It has nothing to do with values like 'ddddddd.dd' that the OP is asking about - you could have looked up FL format at: http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA20/C.1?DT=20060615185603 lanand_hps, You can use the technique discussed in the "Sum a number with a decimal point" Smart DFSORT Trick at: http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000094
lanand_hps

New User

Joined: 05 Dec 2007
Posts: 82
Location: chennai

 Posted: Fri Aug 01, 2008 10:34 pm    Post subject: Thanks Frank. I had created a jcl with two steps to sum the digits with decimal points. First step to remove decimal and treat that as a ZD. Second step to inser the decimal point in the appropriate postion. FL didnot work. But one more clarification. Under what scenarios can we use PD? For test purpose, i had 3 records in my postion with a packed decimal from 20th postion till 25th. SORT FIELDS=(107,9,CH,A) SUM FIELDS=(20,5,PD) It is resulting in S0C7. Any details? I checked the input file and it had proper values.
Craq Giegerich

Senior Member

Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

Posted: Fri Aug 01, 2008 10:41 pm    Post subject:

 lanand_hps wrote: Thanks Frank. I had created a jcl with two steps to sum the digits with decimal points. First step to remove decimal and treat that as a ZD. Second step to inser the decimal point in the appropriate postion. FL didnot work. But one more clarification. Under what scenarios can we use PD? For test purpose, i had 3 records in my postion with a packed decimal from 20th postion till 25th. SORT FIELDS=(107,9,CH,A) SUM FIELDS=(20,5,PD) It is resulting in S0C7. Any details? I checked the input file and it had proper values.

Show us the hex display of the records.
Frank Yaeger

DFSORT Moderator

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

Posted: Fri Aug 01, 2008 10:47 pm    Post subject:

lanand_hps,

You can only use PD for valid packed decimal data which has the following form in hex:

dd...ds

where d is a digit (0-9) and s is a sign (usually C or F for + or D for -).

For example:

12345C is the PD equivalent of +12345
00030D is the PD equivalent of -30

If you try to SUM with PD for values that are NOT PD, you will get an 0C7 ABEND.

Note that PD values do NOT contain a decimal point internally.

 Quote: For test purpose, i had 3 records in my postion with a packed decimal from 20th postion till 25th. SORT FIELDS=(107,9,CH,A) SUM FIELDS=(20,5,PD)

20-25 is 6 bytes, but you are using 20,5,PD instead of 20,6,PD. If you got an 0C7 ABEND, then the 5 bytes from 20-24 contain invalid PD data.

You can use the VERIFY operator of DFSORT's ICETOOL to display invalid PD values.
lanand_hps

New User

Joined: 05 Dec 2007
Posts: 82
Location: chennai

Posted: Fri Aug 01, 2008 10:54 pm    Post subject:

Hi Craq,
This is how the file is now...

 Code: decimal                           ------ 000001 2003941297 07353LAD    °ðVOL-HERTZW         FFFFFFFFFF4FFFFFDCC000098EDD6CCDEEE44        200394129700735331400000C563085939600 -------------------------------------------- 000002 2003941297 07354LAD      VOL-HERTZW         FFFFFFFFFF4FFFFFDCC000013EDD6CCDEEE44        200394129700735431400007C563085939600 --------------------------------------------
lanand_hps

New User

Joined: 05 Dec 2007
Posts: 82
Location: chennai

 Posted: Fri Aug 01, 2008 11:03 pm    Post subject: Sorry guys.. It is of 6 digits..as Frank pointed out.. 20th to 25th column. One more doubt. ((Please spare me ) I have read in a lot of places that Statement 1: SORT FIELDS=COPY SUM FIELDS=NONE will remove the duplicates. Statement 2: SORT FIELDS=NONE will also avoid duplicates. When i just tested it, the duplicates are not getting removed with the first statement and statement 2 is throwing an error. I guess it is a very basic doubt .. Kindly give your comments..
Craq Giegerich

Senior Member

Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

 Posted: Fri Aug 01, 2008 11:08 pm    Post subject: You either need to use 21,5,PD or 20,6,PD because the byte of the PD is in position 25 not 24.
Frank Yaeger

DFSORT Moderator

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

Posted: Fri Aug 01, 2008 11:27 pm    Post subject:

 Quote: Sorry guys.. It is of 6 digits..as Frank pointed out.. 20th to 25th column.

When I run with your data and use 20,6,PD, it works. When I run using 20,5,PD, it gets an 0C7 ABEND as expected because the sign is invalid in that case.

 Quote: I have read in a lot of places that Statement 1: SORT FIELDS=COPY SUM FIELDS=NONE will remove the duplicates.

I don't know where you read that, but it wasn't written by anyone who knew what they were talking about.

SUM FIELDS=NONE can remove duplicates with:

 Code: SORT FIELDS=(p,m,f,s,...) or   MERGE FIELDS=(p,m,f,s,...)

SUM FIELDS=NONE cannot remove duplicates with:

 Code: SORT FIELDS=COPY or   MERGE FIELDS=COPY or   OPTION COPY

SUM FIELDS=NONE is only valid for sorting or merging, not for copying. SUM FIELDS=NONE removes records with duplicate keys. Since copy does NOT specify a key, SUM FIELDS=NONE cannot be used to remove duplicates when copying. Sort and Merge specify a key, so SUM FIELDS=NONE can be used to remove duplicates when sorting or merging.

 Quote: Statement 2: SORT FIELDS=NONE will also avoid duplicates.

 Code: SORT FIELDS=NONE

is invalid syntax. It will result in an error message.
lanand_hps

New User

Joined: 05 Dec 2007
Posts: 82
Location: chennai

 Posted: Fri Aug 01, 2008 11:44 pm    Post subject: Thanks a lot Frank .!
ksouren007

New User

Joined: 30 Jun 2010
Posts: 85
Location: Toronto, ON

 Posted: Tue Jan 18, 2011 4:49 pm    Post subject: Hi Frank, The below link is no longer working. Could you please provide an alternate link for the document? " You can use the technique discussed in the "Sum a number with a decimal point" Smart DFSORT Trick at: " www.ibm.com/systems/support/storage/software/sort/mvs/tricks/
Frank Yaeger

DFSORT Moderator

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

 Posted: Wed Jan 19, 2011 12:21 am    Post subject: I posted that link back in 2008. It changed later to: http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000094 I've updated the link in the original post.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics How can I convert charactor to fixed ... liying DFSORT/ICETOOL 7 Tue May 22, 2018 3:35 pm Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am How to group and sum the decimal value sakrat DFSORT/ICETOOL 2 Tue Mar 06, 2018 9:13 pm Sum the fields in particular format f... sharana64 DFSORT/ICETOOL 9 Fri Jan 05, 2018 1:11 am

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