Calculated field needs leading zeros



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Calculated field needs leading zeros

Postby claywilly » Wed Oct 01, 2008 9:10 pm

Hello,

I have a calculated field in the outrec format:
SORT FIELDS=COPY

OUTREC FIELDS=(1,11,X, . BLANKET-NUMBER(OPPH)
12,11,X, . PA-NUMBER(PASM)
23,14,X, . AUTHORIZED-AMOUNT(P)
37,14,X, . PO-AMOUNT(O)
51,14,X, . EXPENDED-AMOUNT(O)
65,14,X, . CLOSED-AMOUNT(O)
83,02,C'/', . START-DATE-MONTH(P)
85,02,C'/', . START-DATE-DAY(P)
79,04,X, . START-DATE-YEAR(P)
91,02,C'/', . END-DATE-MONTH(P)
93,02,C'/', . END-DATE-DAY(P)
87,04,X, . END-DATE-YEAR(P)
(23,14,ZD,SUB,37,14,ZD,SUB,51,14,ZD,
ADD,65,14,ZD))

... and i need to be able to sumarize this field with sum fields=etc.

The result I am getting from this field is that is has leading spaces (characters) and it will blow up when I try to do sum fields action on it. Is there a better way to summarize this field or calculate and summarize at the same time? Or how to I pad this field with leading zeros?
Thanks for your help.
User avatar
claywilly
 
Posts: 26
Joined: Sat Jun 14, 2008 12:01 am
Has thanked: 0 time
Been thanked: 0 time

Re: Calculated field needs leading zeros

Postby Frank Yaeger » Wed Oct 01, 2008 9:33 pm

Your description is very confusing. You show many fields in your OUTREC statement and then you say "the result I am getting from this field ...". Which field? What does the input data in this field look like? What do you want the output for this field to look like?

You need to do a better job of describing what you want to do. Show an example of your input records (relevant fields only) and what you expect for output. Give the RECFM and LRECL of your input file. Give the starting position, length and format of all relevant fields.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Calculated field needs leading zeros

Postby claywilly » Wed Oct 01, 2008 10:39 pm

Sorry for the confusion.

"this field" refers to the calculated field starting after the End-Date-Year.
... (23,14,ZD,SUB,37,14,ZD,SUB,51,14,ZD,
ADD,65,14,ZD))

Sample input records:
N3000002118 N3000002118 ...00000000000000 06/01/2001 05/31/2002.......... 1250000
N2000002995 N2000002995 ...00000000000000 06/01/2001 05/31/2002.......... 3500000
N1000007125 N1000007125 ...00000000000000 08/02/2005 11/01/2006.......... 40500000
N1000007125 N1000007125 ...00000040500000 08/02/2005 11/01/2006.......... 15000
N1000006769 N1000006769 ...00000000308328 03/23/2005 03/22/2006.......... 32649
N1000006769 N1000006769 ...00000000032648 03/23/2005 03/22/2006.......... 308328
N1000007593 N1000007593 ...00000000114000 02/15/2006 02/14/2007.......... 0

Results should be:
N3000002118 N3000002118 ...00000000000000 06/01/2001 05/31/2002.......... 1250000
N2000002995 N2000002995 ...00000000000000 06/01/2001 05/31/2002.......... 3500000
N1000007125 N1000007125 ...00000000000000 08/02/2005 11/01/2006.......... 40515000
N1000006769 N1000006769 ...00000000308328 03/23/2005 03/22/2006.......... 340977
N1000007593 N1000007593 ...00000000114000 02/15/2006 02/14/2007.......... 0

Each amount field is 14 bytes in length
I need to sum up the last field sorted by the first field, but the last field contains leading spaces.
(sorry, I don't know how to format the records to look right on here)

Thanks.
User avatar
claywilly
 
Posts: 26
Joined: Sat Jun 14, 2008 12:01 am
Has thanked: 0 time
Been thanked: 0 time

Re: Calculated field needs leading zeros

Postby Frank Yaeger » Thu Oct 02, 2008 1:03 am

I need to sum up the last field sorted by the first field, but the last field contains leading spaces.


DFSORT does NOT have a problem using ZD format for fields with leading spaces. It just treats the leading spaces as 0 digits.

ZD would not be ok for values with trailing spaces. I can't tell which you have from your example so that's the first thing we have to verify. It looks like you have trailing spaces in your example.

Run a job against your input file with these control statements to display the fields in hex and show me the results:

  OPTION COPY,STOPAFT=5               
  INREC BUILD=(23,14,HEX,X,37,14,HEX) 
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Calculated field needs leading zeros

Postby claywilly » Thu Oct 02, 2008 11:44 pm

The last field contains leading spaces. There are no trailing spaces.
When I try to do a sum fields=(100,14,zd) on the last field it will blow with a S0C7.
If I pad this field with leading zeros, it will work.

The Hex:
.............3797363 ..
444444444FFFFFFF400
0000000003797363000
-------------------
.............5814295 ..
444444444FFFFFFF400
0000000005814295000
-------------------
.............4526807 ..
444444444FFFFFFF400
0000000004526807000
User avatar
claywilly
 
Posts: 26
Joined: Sat Jun 14, 2008 12:01 am
Has thanked: 0 time
Been thanked: 0 time

Re: Calculated field needs leading zeros

Postby Frank Yaeger » Fri Oct 03, 2008 1:29 am

Ok, I think I finally see what you're doing wrong. You have:

  (23,14,ZD,SUB,37,14,ZD,SUB,51,14,ZD,
   ADD,65,14,ZD))


Since you don't have an output format or length, DFSORT uses the default of the M0 mask which does NOT give a valid ZD value (it has a blank in the 14th digit which is invalid for the sign). The leading blanks are not the cause of the 0C7 - the M0 mask is.

To get what you want, use:

  (23,14,ZD,SUB,37,14,ZD,SUB,51,14,ZD,
   ADD,65,14,ZD,TO=ZD,LENGTH=14))


That will give you a 14-byte ZD result.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post