Hi
I have a problem with a sort. I have a input file (Recl=113 and Rec format = FB ) with a S9(05) comp-3 field (position 11-13) in it.
---------------
input file:
11-13 .......
36222
0
45154
*****
34214
---------------
I need to copy the file contents to a output file with 20000 added to the comp-3 fields ( in position 11-13 ) which don't have zero or low values. When i used the sort card,
i got the following output:
---------------
output file:
11-13 .......
56222
0
65154
60404
54214
---------------
It took the value of "*****" or spaces as "40404" and added 20000 to it. I need the output to be like this:
--------------
output file:
11-13 ........
56222
0
65154
*****
54214
--------------
Thanks Frank. Does this sort will also deal with low values. That is when the comp-3 field in input file is x'000000' , will 20000 will be added to it? I need not add it to low values.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
When you said
Quote:
which don't have zero or low values
I took "zero" to mean PD'0' (X'00000C') and that's what I coded for. If you want to code for binary zeros (X'000000') instead of PD'0', just use 11,3,BI,NE,X'000000' as follows:
Thanks again Frank. What I had meant was to add the value to fields which don't have zeros, spaces and low values.
I have one question regarding the addition. In the addition process, only digit "2" is having a impact . The addition of rest of the digits of "20000" that is "00000" is useless. Is it possible to add only "2" to the leftmost digit in packed decimal format.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
What I had meant was to add the value to fields which don't have zeros, spaces and low values.
zeros as in PD zeros (P'0')? low values as in binary zeros? Did you figure out how to do this based on what I've said previously or do you need me to show you how to do it?
Quote:
I have one question regarding the addition. In the addition process, only digit "2" is having a impact . The addition of rest of the digits of "20000" that is "00000" is useless. Is it possible to add only "2" to the leftmost digit in packed decimal format.
That doesn't make any sense. The addition looks like this:
|12|34|5C|
|20|00|0C|
-------------
|32|34|5C|
These are 3-byte PD values with the sign in the last nibble, so you can add them as PD values. You're asking if you can add just the first nibble - the answer is no because that doesn't represent any valid type of numeric format. But why do you want to do that? What benefit do you think there would be in adding only "2' to the leftmost nibble instead of adding 20000 to the 3-byte PD value?
zeros as in PD zeros (P'0')? low values as in binary zeros? Did you figure out how to do this based on what I've said previously or do you need me to show you how to do it??
Frank,
With the help of your input I have figured out the logic to do this. But it seems that I don't have to version of Dfsort to run the sort given by you. When I run the sort I am getting "INVALID INREC OR OUTREC STATEMENT OPERAND" for IFTHEN.And "STATEMENT DEFINER ERROR" for overlay.
ICE000I Message is giving dfsort version as DFSORT REL 14.0.
Quote:
|12|34|5C|
|20|00|0C|
-------------
|32|34|5C|
These are 3-byte PD values with the sign in the last nibble, so you can add them as PD values. You're asking if you can add just the first nibble - the answer is no because that doesn't represent any valid type of numeric format. But why do you want to do that? What benefit do you think there would be in adding only "2' to the leftmost nibble instead of adding 20000 to the 3-byte PD value?
I asked the question because I came to know that I need add "20000" only to comp-3 fields which have values starting with "4" and "3". That is if the field is like "4----c" or "3----c" I should add 20000 to it. The "----" be any value between 0-9 for each digit. In short, apart from zeros,binary zeros and spaces all the values other than "4" or "3" in their first nibble are invalid for addition process.
With the earlier logic I was suggesting I will need back to convert all those comp-3 fields which don't have "6" or "5" ( output file after adding "20000") in their first nibble back to their orginal values .
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
TG,
You need DFSORT R14 PTF UQ95213 to use IFTHEN and OVERLAY. This PTF has been available since Dec, 2004. Ask your System Programmer to install it.
If you just want to add 20000 for values that have X'4----C' or X'3----C',
you can use this control statement (of course, you'll need the Dec, 2004 PTF):