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.
Calculated field needs leading zeros
- Frank Yaeger
- Global moderator
- Posts: 1079
- Joined: Sat Jun 09, 2007 8:44 pm
- Skillset: DFSORT, ICETOOL, ICEGENER
- Referer: Search
- Contact:
Re: Calculated field needs leading zeros
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.
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
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
- claywilly
- Posts: 26
- Joined: Sat Jun 14, 2008 12:01 am
- Skillset: Medium expert in all IBM mainframe stuff.
- Referer: mvshelp.net
Re: Calculated field needs leading zeros
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.
"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.
- Frank Yaeger
- Global moderator
- Posts: 1079
- Joined: Sat Jun 09, 2007 8:44 pm
- Skillset: DFSORT, ICETOOL, ICEGENER
- Referer: Search
- Contact:
Re: Calculated field needs leading zeros
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:
Code: Select all
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
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
- claywilly
- Posts: 26
- Joined: Sat Jun 14, 2008 12:01 am
- Skillset: Medium expert in all IBM mainframe stuff.
- Referer: mvshelp.net
Re: Calculated field needs leading zeros
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
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
- Frank Yaeger
- Global moderator
- Posts: 1079
- Joined: Sat Jun 09, 2007 8:44 pm
- Skillset: DFSORT, ICETOOL, ICEGENER
- Referer: Search
- Contact:
Re: Calculated field needs leading zeros
Ok, I think I finally see what you're doing wrong. You have:
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:
That will give you a 14-byte ZD result.
Code: Select all
(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:
Code: Select all
(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
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
-
- Similar Topics
- Replies
- Views
- Last post
-
-
sort card to add zeros to varying alphanumeric field.
by longfall » Thu Mar 09, 2023 12:03 am » in DFSORT/ICETOOL/ICEGENER - 1
- 1841
-
by sergeyken
View the latest post
Thu Mar 09, 2023 2:04 am
-
-
-
Using nice/renice commands on USS leading to MSG FSUMF022
by Marcels68 » Sat Oct 12, 2024 4:02 pm » in Operating Systems - 0
- 1836
-
by Marcels68
View the latest post
Sat Oct 12, 2024 4:02 pm
-
-
- 1
- 1815
-
by sergeyken
View the latest post
Fri Mar 26, 2021 11:59 pm
-
-
remove leading special chars, space & trailing special char
by srihemz » Tue Jun 30, 2020 8:06 pm » in DFSORT/ICETOOL/ICEGENER - 2
- 3882
-
by sergeyken
View the latest post
Wed Jul 01, 2020 4:55 pm
-
-
- 2
- 1609
-
by sergeyken
View the latest post
Sun Jan 26, 2025 3:07 am