| IBM MAINFRAME HELP & SUPPORT FORUMS Technical Forums for IBM Mainframe Applications like COBOL, JCL, CICS, DB2, FileAid, DFSORT, Endevor, Xpediter, CoolGen, CA-7&11, AbendAid, IMS, IDMS, PL/I, MqSeries, SyncSort, Assembler, ChangeMan, Easytrieve, InterTest, REXX, CLIST etc...
|
| View previous topic :: View next topic |
| Author |
Message |
lanand_hps
Joined: 05 Dec 2007
Posts: 59
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. |
|
| Back to top |
|
Garry Carroll
Joined: 08 May 2006
Posts: 171
Location: Dublin, Ireland
|
| 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 |
|
| Back to top |
|
karthikr44
Joined: 25 Aug 2007
Posts: 172
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 |
|
| Back to top |
|
Garry Carroll
Joined: 08 May 2006
Posts: 171
Location: Dublin, Ireland
|
| 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. |
|
| Back to top |
|
karthikr44
Joined: 25 Aug 2007
Posts: 172
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 |
|
| Back to top |
|
Garry Carroll
Joined: 08 May 2006
Posts: 171
Location: Dublin, Ireland
|
| 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. |
|
| Back to top |
|
Frank Yaeger
Joined: 15 Feb 2005
Posts: 4613
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:
www.ibm.com/systems/support/storage/software/sort/mvs/tricks/ |
|
| Back to top |
|
lanand_hps
Joined: 05 Dec 2007
Posts: 59
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. |
|
| Back to top |
|
Craq Giegerich
Joined: 19 May 2007
Posts: 1001
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. |
|
| Back to top |
|
Frank Yaeger
Joined: 15 Feb 2005
Posts: 4613
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. |
|
| Back to top |
|
lanand_hps
Joined: 05 Dec 2007
Posts: 59
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
-------------------------------------------- |
|
| Back to top |
|
lanand_hps
Joined: 05 Dec 2007
Posts: 59
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.. |
|
| Back to top |
|
Craq Giegerich
Joined: 19 May 2007
Posts: 1001
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. |
|
| Back to top |
|
Frank Yaeger
Joined: 15 Feb 2005
Posts: 4613
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. |
|
| Back to top |
|
lanand_hps
Joined: 05 Dec 2007
Posts: 59
Location: chennai
|
| Posted: Fri Aug 01, 2008 11:44 pm Post subject: |
|
|
| Thanks a lot Frank .! |
|
| Back to top |
|
| |
THIS IS AN ARCIVE FORUM IN READ ONLY MODE. IF YOU WANT TO ASK YOUR DOUBTS USE THE ACTUAL FORUM
|