Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Arithmetic Division with zeroes using Syncsort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
surendra_giddaluru

New User


Joined: 17 May 2007
Posts: 8
Location: chennai

PostPosted: Wed Sep 05, 2007 3:15 am    Post subject: Arithmetic Division with zeroes using Syncsort
Reply with quote

Hi,
I am facing some difficulty while doing division operation using DFSORT. I have to calculate the percentage rate. My input looks like as below, and it is an FB file (80 LRECL)
Code:
----+----1----+----2----+----3----+--
AAAAAAAA  000000029     000000456   
BBBBBBBB  000000010     000000050   
CCCCCCCC  000123452     000123452   
DDDDDDDD  000006782     000007986   
EEEEEEEE  000000000     000000010   
FFFFFFFF  000069032     000071236   
GGGGGGGG  000000032     000005405     


My output should be of the form:
Code:
 | Match Rate     6.35964 |    AAAAAAAA
 | Match Rate    20.00000 |    BBBBBBBB
 | Match Rate   100.00000 |    CCCCCCCC
 | Match Rate    84.92361 |    DDDDDDDD
 | Match Rate     0.00000 |    EEEEEEEE
 | Match Rate    96.90605 |    FFFFFFFF
 | Match Rate     0.59204 |    GGGGGGGG


I have used the following SORT to generate the output. It is working fine with all records except for ‘EEEEEEEE’ record, because of all zeroes in the 11 position to 19 position. And I am getting an OUTREC ARITHMETIC OVERFLOW error message. So Please provide me a solution to overcome this problem.
Code:
//STEP001     EXEC PGM=SYNCTOOL,REGION=2048K                           
//SORTWK01 DD  UNIT=SYSDA,SPACE=(TRK,2)                               
//SORTWK02 DD  UNIT=SYSDA,SPACE=(TRK,2)                               
//SYSOUT   DD  SYSOUT=*                                               
//DFSMSG   DD  SYSOUT=*                                               
//TOOLMSG  DD  SYSOUT=*                                               
//SYSUDUMP DD  SYSOUT=*     
//IN1      DD  DISP=SHR,DSN=INPUT FILE       
//*                                                             
//OUTDD    DD DSN=OUTPUT FILE,               
//            DISP=(,CATLG,DELETE),                             
//             UNIT=SYSDA,SPACE=(TRK,(20,20),RLSE),             
//             DCB=(DSORG=PS,RECFM=FB,LRECL=80)                                                           
 //TOOLIN   DD  *                                                       
  COPY FROM(IN1) TO(OUTDD) USING(CTL1)                                 
//CTL1CNTL DD *                                                       
  OUTREC FIELDS=(C' | Match Rate                ',                     
         ((11,9,ZD,MUL,+10000000),DIV,25,9,ZD),EDIT=(IIIIT.TTTTT),     
         C' |',30X,1,8)                                               
/*

Thanks,
Surendra.
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: Wed Sep 05, 2007 5:39 am    Post subject:
Reply with quote

Actually, when I ran this job with DFSORT's ICETOOL, it did not get any error message and produced this output:

Code:

| MATCH RATE                    6.35964 |                              AAAAAAAA
| MATCH RATE                   20.00000 |                              BBBBBBBB
| MATCH RATE                  100.00000 |                              CCCCCCCC
| MATCH RATE                   84.92361 |                              DDDDDDDD
| MATCH RATE                    0.00000 |                              EEEEEEEE
| MATCH RATE                   96.90605 |                              FFFFFFFF
| MATCH RATE                    0.59204 |                              GGGGGGGG


Since you have PGM=SYNCTOOL, it appears you're actually using Syncsort's SYNCTOOL rather than DFSORT's ICETOOL. Syncsort is getting the error message, not DFSORT.

I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.

I'm moving this thread to the JCL Forum.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Wed Sep 05, 2007 11:03 am    Post subject:
Reply with quote

surendra_giddaluru,

I tried with your code and input posted by you with SYNCSORT. It shows the output as FRANK's posted.

Quote:
And I am getting an OUTREC ARITHMETIC OVERFLOW error message.


I got the "OUTREC ARITHMETIC OVERFLOW error message" when i tried to divide a number by zero.

Please check with your input whether you have zeros in 25,9.

Use SYNCSORT instead of SYNCTOOL and reformat the fields in INREC for your requirement. It will be more efficient when doing a run with large number of records.

Code:
// EXEC PGM=SYNCSORT                                           
//SYSOUT DD SYSOUT=*                                           
//SORTIN DD  *                                                 
AAAAAAAA  000000029     000000456                               
BBBBBBBB  000000010     000000050                               
CCCCCCCC  000123452     000123452                               
DDDDDDDD  000006782     000007986                               
EEEEEEEE  000000000     000000010                               
FFFFFFFF  000069032     000071236                               
GGGGGGGG  000000032     000005405                               
/*                                                             
//SORTOUT DD SYSOUT=*                                           
//SYSIN DD  *                                                   
 OPTION COPY                                                   
 INREC FIELDS=(C' | MATCH RATE                ',               
       ((11,9,ZD,MUL,+10000000),DIV,25,9,ZD),EDIT=(IIIIT.TTTTT),
       C' |',30X,1,8)                                           
/*                                                             
// 

Output:
Code:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
******************************** Top of Data ***********************************
 | MATCH RATE                    6.35964 |                              AAAAAAAA
 | MATCH RATE                   20.00000 |                              BBBBBBBB
 | MATCH RATE                  100.00000 |                              CCCCCCCC
 | MATCH RATE                   84.92361 |                              DDDDDDDD
 | MATCH RATE                    0.00000 |                              EEEEEEEE
 | MATCH RATE                   96.90605 |                              FFFFFFFF
 | MATCH RATE                    0.59204 |                              GGGGGGGG
 ******************************* Bottom of Data ********************************
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Sep 05, 2007 6:28 pm    Post subject:
Reply with quote

Hello,

It is also possible that your version of Syncsort is either not up to date or missing some fix(es). I'd suggest opening an issue with Syncsort support to determine why your process did not work correctly.

As suggested, make sure that the input is what it should be.
Back to top
View user's profile Send private message
surendra_giddaluru

New User


Joined: 17 May 2007
Posts: 8
Location: chennai

PostPosted: Wed Sep 05, 2007 7:50 pm    Post subject:
Reply with quote

Hi Frank and Sankar thanks a lot for your suggestions. I tried with SYNCTOOL and SYSNSORT both are working fine, thanks. I have one more issue. My input file will sometimes have all zeroes in both (11,9) and (25,9) positions. I tried using SYNCTOOL and SYNCSORT both the times it got abended with 'ARITHMETIC OVERFLOW' error message. The input I used is as below. Please provide me with some solution.

----+----1----+----2----+----3----+--
AAAAAAAA 000000029 000000456
BBBBBBBB 000000010 000000050
CCCCCCCC 000123452 000123452
DDDDDDDD 000006782 000007986
EEEEEEEE 000000000 000000000
FFFFFFFF 000069032 000071236
GGGGGGGG 000000032 000005405
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Sep 05, 2007 10:37 pm    Post subject:
Reply with quote

Hello,

You need to ensure that there will not be a divide by zero.

What should happen when both numbers are zero?
Back to top
View user's profile Send private message
surendra_giddaluru

New User


Joined: 17 May 2007
Posts: 8
Location: chennai

PostPosted: Wed Sep 05, 2007 11:56 pm    Post subject:
Reply with quote

Hi,

I am rewriting a COBOL program which is currently running for a long time. So now I am doing file processing in the COBOL program and for generating the report, which needs to sum the individual accounts and also needs to calculate the percentage match rate for each account, I am using the SORT. So in my old COBOL program when ever the values in (11,9) and (25,9) positions are zeroes we are moving 0.0000 to the Match Rate without doing any division operation for that perticular account.
Now I think we need to verify these values before calculating the match Rate. Atleast the values in (25,9) position, so that the SORT will not fail. If the values in (25,9) position is zeroes I need to move 0.0000 explicitly without doing the division operation for calculating the Match Rate. Hope I am clear this time.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Sep 06, 2007 12:23 am    Post subject:
Reply with quote

Helllo,

Quote:
I am rewriting a COBOL program which is currently running for a long time.
How many records are being processed? How long is a "long time"?

What does this COBOL code do that the sort does not do or does differently?

If the code is to read the file and create summary statistics, i believe they should run a similar length of time. The COBOL code may use a bit more cpu, but wall-time should be quite similar as most of the time should be spent doing i/o.

I don't know how to tell Syncsort to conditionally bypass the calculation.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Fri Sep 07, 2007 1:31 am    Post subject: Reply to: Division with zeroes using Syncsort
Reply with quote

Quote:
I don't know how to tell Syncsort to conditionally bypass the calculation.


Try this code:
Code:

//SYSIN DD  *
    SORT FIELDS=COPY
    INREC IFTHEN=(WHEN=((11,9,ZD,NE,0),AND,(25,9,ZD,NE,0)),
                  BUILD=(C' | MATCH RATE                ',
                  ((11,9,ZD,MUL,+10000000),DIV,25,9,ZD),
                  EDIT=(IIIIT.TTTTT),C' |',30X,1,8)),
          IFTHEN=(WHEN=((11,9,ZD,EQ,0),AND,(25,9,ZD,EQ,0)),
                  BUILD=(C' | MATCH RATE                    0.00000 |',
                  30X,1,8))
/*
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Fri Sep 07, 2007 1:34 am    Post subject: Reply to: Division with zeroes using Syncsort
Reply with quote

... Forgot to mention that the above code requires SyncSort for z/OS 1.2.1 or later.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Sep 07, 2007 2:35 am    Post subject: Reply to: Division with zeroes using Syncsort
Reply with quote

Hi Alissa,

Which Syncsort publication has the writeup for IFTHEN?

My downloaded doc does not have IFTHEN.

Thanx,

d
Back to top
View user's profile Send private message
surendra_giddaluru

New User


Joined: 17 May 2007
Posts: 8
Location: chennai

PostPosted: Fri Sep 07, 2007 3:00 am    Post subject:
Reply with quote

Thank you so much Alissa Margulies, its working fine.

Thanks,
Surendra.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Fri Sep 07, 2007 3:03 am    Post subject: Re: Reply to: Division with zeroes using Syncsort
Reply with quote

dick scherrer wrote:
Which Syncsort publication has the writeup for IFTHEN? My downloaded doc does not have IFTHEN.

Hi Dick,

The SyncSort for z/OS 1.2 Addendum contains the BUILD, IFTHEN, IFOUTLEN, and OVERLAY Parameters.

If you have a SyncSort Online Customer Support Account, you can download the file named "SyncSort 1.2 Programmers Guide Add.pdf"

Regards,
Back to top
View user's profile Send private message
mmt_bit

New User


Joined: 15 Jan 2009
Posts: 14
Location: Bangalore

PostPosted: Wed May 04, 2011 1:49 am    Post subject: Reply to: Division with zeroes using Syncsort
Reply with quote

There is a field 9(13) comp-3 (7 bytes long).

I need to convert this to a S9(11)v9(2) or DB2 DECIMAL(13,2). (also 7 bytes long)

INPUT: 12868 (X'0000000012868F')

Control statement logic:
1,7,PD,DIV,+100,LENGTH=7

Output: 1.28

Desired output: 128.68

Why its getting divided by 10000, when I am dividing by 100? What is the correct control statement?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7307

PostPosted: Wed May 04, 2011 2:30 am    Post subject: Reply to: Division with zeroes using Syncsort
Reply with quote

Don't tag a new question onto the end of an old topic.

A packed-decimal field on a file has no decimal places, implicit or explicit. You don't have to convert your data. When you define your field in your code, define with the decimal places and everything will be fine (from your example).

With your parameters you are making it 100 times too small, because you are dividing by 100. Leave it alone.

Why is your field unsigned (F in the sign nibble, not C for positive (or D for negative))? If this is correct, make sure you define your data as unsigned as well as having the two decimal places.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SYNCSORT SEQNUM and FI fields. nartcr SYNCSORT 7 Sat Jan 21, 2017 4:02 am
No new posts Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 37 Tue Dec 06, 2016 8:04 pm
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us