----+----1----+----2----+----3----+----4----+----5--
123 5000004001 C ? 1011621000
123 5155005001 D ? 1011621000
123 5000004001 C k? 1011621000
basically i want the sum of the comp-3 field from pos 29-36.
How can I get the sum using sort assuming that I have both +ve and -ve value in the comp-3 field.The output suppose comes as a -ve value 1234 ,the sort should display me as -1234.
To achieve this I follow a second method.I format the input file using fileaid option so that the output file will come as a displayable numeric field and after that I can use this formatted file in the sort jcl to get the sum.The original field is
PIC S9(13)V99 COMP-3 and i am formatting it as
PIC S9(13)V99.
But in this way the last sign bit and its immediate previous bit combine together to give me a charcter bit like A,B,} etc.
I can use this in my sort jcl but the jcl output even though it shows the correct sum ,but it doesnot correctly display the sign bit.Always it is giving as +ve value.
The jcl I use is
TRAILER1=(1:TOT=(29,16,ZD,M11,LENGTH=16))
If I am trying to use rexx to get the sum same problem happens as rexx does not identify the whole field as a numeric field if it contains a character like A,B,{ etc in the last bit.So I can not use rexx also with this formatted file to get a proper sum output with a -ve sign if the sum is actually -ve .
Please provide me the solutions to these problems.
Thanking u all in advance.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You're making this more complicated than it really is.
You can use PD in TOT for a COMP-3 value. You don't have to convert PD to ZD in order to use it. And the reason you're not getting a - sign is because you're using the M11 mask which produces digits without a sign. If you use M26 instead, you'll get a - sign. So your DFSORT TRAILER1 operand would be: