Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
Comp-3 field Sum in SORT

Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message

New User

Joined: 15 Mar 2006
Posts: 14

PostPosted: Tue Mar 28, 2006 11:52 am    Post subject: Comp-3 field Sum in SORT
Reply with quote

Hi All,
I have a file like


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
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.
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator

Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Mar 28, 2006 8:44 pm    Post subject:
Reply with quote

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:

Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1


Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to include a particular field val... sakrat DFSORT/ICETOOL 8 Fri Apr 06, 2018 8:27 pm
No new posts Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am
No new posts Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm
No new posts Searching a table for the field name? socker_dad COBOL Programming 8 Sat Mar 31, 2018 2:57 am
No new posts Find & Replace string in CA-SORT mrgnndhmk CA Products 1 Fri Mar 30, 2018 12:58 am

Back to Top
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us