Home      Mainframe Forum      Mainfarme Tutorials      IBM Manuals      Mainframe Interview Questions      Mainframe Books      IT News     SiteMap     Downloads


     
 
MAINFRAME - TIP OF THE DAY : All available storage is assigned to the job or jobstep, If REGION is coded 0K or 0M

Google
 
Web mainframegurukul.com

Strange result in SORT Arithmatic Division
Goto page 1, 2  Next
 
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> DFSORT , ICETOOL & Utilities
  View previous topic :: View next topic  
Author Message
Captain Nero
Member


Joined: 20 Jun 2008
Posts: 10
Location: Kolkata, India

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jun 27, 2008 7:04 pm    Post subject: Strange result in SORT Arithmatic Division Reply with quote

Hi all,

I have a file in which the 17th and 18th positions have two numeric fields, I want to divide the first one by the second one and populate the 43rd position with a particular edit.

The card I have used in the OUTREC for this is -

OUTREC OVERLAY=(1,33,34:C'|RATIO = ',
43:(17,6,ZD,MUL,+10000000000),DIV,28,6,ZD,
EDIT=(IIIT.TTTTT),53:C'|')
SORT FIELDS=(1,2,CH,A)

However, I am getting some strange values in the 43rd column like sown.
AK - 000001|F - 000000|M - 000001|RATIO = 0.00000|
AL - 000029|F - 000014|M - 000015|RATIO = 3571.42857|
AR - 000013|F - 000005|M - 000008|RATIO = 1700.68027|
AZ - 000032|F - 000012|M - 000020|RATIO = 1581.02766|
CA - 000242|F - 000100|M - 000142|RATIO = 975.60975|
CO - 000028|F - 000012|M - 000016|RATIO = 1403.50877|
CT - 000070|F - 000030|M - 000040|RATIO = 833.33333|

Can somebody please explain me why is this coming and what can be the remedy. I have multiplied the first field by 10000000000 as this was a requirement.
_________________
Regards,
Captain N.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.

Frank Yaeger
Moderator


Joined: 18 Feb 2006
Posts: 812
Location: San Jose, CA

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sat Jun 28, 2008 1:19 am    Post subject: Reply with quote

I don't know how you got

3571.42857

from 14 and 15 with that statement. When I do it with DFSORT, I get:

3333.33333

which is what I'd expect. Here's why:

DFSORT does integer arithmetic (it throws away the decimal places), so:

(14 * 10000000000)/15 = 9333333333

There are 10 digits in that result but your edit mask of IIIT.TTTTT only has 9 digits, so the digits are mapped right to left and the first digit (the 9 gets dropped). The result is:

3333.33333

If you had 10 digits in your edit mask as IIIIT.TTTTT, the leading digit wouldn't be dropped and you'd get:

93333.3333

But I don't know where you got

3571.42857

You'd have to prove to me that DFSORT produced that result with the input you showed.

By the way, since you're using OVERLAY, you don't need 1,33 - OVERLAY will leave that data as is.
_________________
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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Captain Nero
Member


Joined: 20 Jun 2008
Posts: 10
Location: Kolkata, India

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sat Jun 28, 2008 12:01 pm    Post subject: Reply with quote

Hi Frank,

I have put the result directly from the mainframe. However, i will get you the DFSMSG on Monday. I am really quite perplexed to see the results.

Hope something will turn out.
_________________
Regards,
Captain N.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Frank Yaeger
Moderator


Joined: 18 Feb 2006
Posts: 812
Location: San Jose, CA

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sat Jun 28, 2008 8:13 pm    Post subject: Reply with quote

Well, at the very least you should make the edit mask larger so you can see the full result rather than a truncated result.

It would be helpful to "display" the relevant input fields and the actual output values you received for those input fields with and without truncation, all in the same line, as well as the DFSORT messages.
_________________
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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Captain Nero
Member


Joined: 20 Jun 2008
Posts: 10
Location: Kolkata, India

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sun Jun 29, 2008 8:43 pm    Post subject: Reply with quote

Yes frank I will make the changes on the mask and the Overlay of the first 33 bytes as you have suggested, however, the input file and the output are right in front of you... My input was without the last column and I have added the last column(Ratio) in the output.

Thanks.
_________________
Regards,
Captain N.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Frank Yaeger
Moderator


Joined: 18 Feb 2006
Posts: 812
Location: San Jose, CA

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Mon Jun 30, 2008 10:45 pm    Post subject: Reply with quote

Sanity check. Let's simplify things.

When I run this with DFSORT:

Code:

//S1    EXEC  PGM=ICEMAN                             
//SYSOUT    DD  SYSOUT=*                             
//SORTIN DD *                                       
AK - 000001|F - 000000|M - 000001|                   
AL - 000029|F - 000014|M - 000015|                   
AR - 000013|F - 000005|M - 000008|                   
AZ - 000032|F - 000012|M - 000020|                   
CA - 000242|F - 000100|M - 000142|                   
CO - 000028|F - 000012|M - 000016|                   
CT - 000070|F - 000030|M - 000040|                   
//SORTOUT DD SYSOUT=*                               
//SYSIN    DD    *                                   
  SORT FIELDS=(1,2,CH,A)                             
  OUTREC BUILD=(17,6,ZD,X,28,6,ZD,X,                 
     (17,6,ZD,MUL,+10000000000),DIV,28,6,ZD)         
/*


I get this output:

Code:

     0       1                0   
    14      15       9333333333   
     5       8       6250000000   
    12      20       6000000000   
   100     142       7042253521   
    12      16       7500000000   
    30      40       7500000000   


Please run this job and show what you get along with the //SYSOUT messages. (The output you say you get with the input and control statements you say you use doesn't seem to make any sense, so let's simplify things).
_________________
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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Captain Nero
Member


Joined: 20 Jun 2008
Posts: 10
Location: Kolkata, India

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Tue Jul 01, 2008 10:38 am    Post subject: Reply with quote

Frank I also got output as expected Smile the problem was with an INREC statement which I have put in different control.

Now it is working fine. Cool
_________________
Regards,
Captain N.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Captain Nero
Member


Joined: 20 Jun 2008
Posts: 10
Location: Kolkata, India

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Tue Jul 01, 2008 10:43 am    Post subject: Reply with quote

And Thank you so much for the help.
_________________
Regards,
Captain N.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Frank Yaeger
Moderator


Joined: 18 Feb 2006
Posts: 812
Location: San Jose, CA

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Tue Jul 01, 2008 7:53 pm    Post subject: Reply with quote

You're welcome. Glad to hear it was a "user error". Thanks for letting us know. .
_________________
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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Anies
Member


Joined: 30 Mar 2014
Posts: 2

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sun Mar 30, 2014 6:02 pm    Post subject: DIV - Arithmetic Division in Sort - question Reply with quote

Hi Frank, Good morning!
Is it possbile to round the decimal values which comes as the output while using SORT IN / OUTREC - DIV option.

I am new to this portal, if its posted somewhere else please provide me the URL.

Thank you!
Anies
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
NicC
Active Member


Joined: 24 Jul 2011
Posts: 651
Location: Down on the pig farm

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Mon Mar 31, 2014 2:59 am    Post subject: Reply with quote

1) You should not address posts to individuals.
2) Frank retired some time ago and no longer participates in the forums
3) Generally, posting URLs of other forums is not encouraged.
4) This topic is 6 years old. You should not reply post to old topics.
5) Your requirement is not to do with the topic of this thread - you should have started a new thread. Maybe a moderator will split it off into its own thread.
6) Welcome to the forum!
_________________
Regards
Nic
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
NicC
Active Member


Joined: 24 Jul 2011
Posts: 651
Location: Down on the pig farm

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Mon Mar 31, 2014 2:03 pm    Post subject: Reply with quote

And, from what I have learned from another forum today:
Quote:
Rounding is not a problem for SORT, it just rounds down

_________________
Regards
Nic
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
DikDude
Moderator


Joined: 22 Jul 2011
Posts: 1001
Location: usa

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Tue Apr 01, 2014 11:23 pm    Post subject: Reply with quote

If you are still having problems, please start a new topic (using th4e Code tag to preserve alignment.

Show a bit of sample input data and the output you want when this particular sample data is run thru your process.

Post the sort control statements and the JCL you use to test.
_________________
Have a good one
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Anies
Member


Joined: 30 Mar 2014
Posts: 2

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Mon Apr 07, 2014 10:05 am    Post subject: Reply with quote

I Apologize, i did not get response when i started a new topic.
so writing it up here.
This is my SORT statement

//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FILES=1,
OUTREC=((51,13,ZD,MUL,+10),DIV,40,11,ZD,EDIT=(TT.TT),LENGTH=5)
/*

Input:
51,13 - input - 0000000462018 - PIC 9(12)V9
40,11 - input - 00000030235 - PIC 9(11)

Output:
01.52

Actual Output must be 01.53

I was not able to get the Rounded value.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Mon Apr 07, 2014 1:09 pm    Post subject: Reply with quote

SORT does not have DWIW.

SORT rounds down. If you want something different, you have to do it yourself. Calculate 10 bigger. Look at the rightmost digit o fhe result, and adjust the digit on the left if necessary.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Display posts from previous:   
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> DFSORT , ICETOOL & Utilities All times are GMT + 5 Hours
Goto page 1, 2  Next
Page 1 of 2



 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Related topics
 Topics   Replies   Author   Views   Last Post 
No new posts Getting no of records in a file 13 Rajapriyaa 14579 Wed Feb 03, 2016 12:44 am
academyindia4 View latest post
No new posts Replacing characters Using JCL 7 rachitsethcse 13826 Wed Feb 03, 2016 12:41 am
academyindia4 View latest post
No new posts Getting Error while using ICEMAN tool 6 giri211 13152 Wed Feb 03, 2016 12:40 am
academyindia4 View latest post
No new posts Calling COBOL from C - getting SOC1 2 balajiiinx 9048 Mon Feb 01, 2016 1:26 am
academyindia4 View latest post
No new posts Easytrieve program for getting Recound counts. 1 prakash.subramaniam 7197 Mon Oct 05, 2009 5:09 pm
Natarajan View latest post
 


Cobol Tutorial
This cobol tutorial covers most of the important topics like STRING, UNSTRING, COMP, COMP-3.....
DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. Explains in simple language. Some Chapters are locked, Forum members have free access to these chapters
CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming...
JCL Tutorial
This is most popular JCL tutorial from mainframegurukul. It does contain important jcl ....
SORT Tutorial
This Tutorial covers all important aspects of DFSORT. Has more SORT examples
INTERVIEW Questions
This page covers important interview questions
Mainframe Jobs
Mainframe Jobs posted by members of mainframegurukul forum
FaceBook Page
MainframeGurukul FaceBook Page
LinkedIn Page
MainframeGurkul Linkedin Page

This widget requires Flash Player 9 or better







Go to top of the page
 

Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  DB2 INTERVIEW QUESTIONS ||  COBOL INTERVIEW QUESTIONS  ||  JCL INTERVIEW QUESTIONS ||  JCL2 INTERVIEW QUESTIONS ||  VSAM INTERVIEW QUESTIONS ||  CICS INTERVIEW QUESTIONS  ||  Online tutorials ||  Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  SiteMap  ||  Expeditor Tutorial  ||  FILE-AID Tutorial  ||  Changeman Tutorial  ||  COBOL   ||  DB2   ||  JCL  ||  CICS  ||  VSAM  ||  DB2 Interview Questions ( 110 )   || Simple JCL Tutorials  || JCL Tutorial from MainframeGurukul.com   || Simple JCL Tutorial - Chapter1 ;|| Mainframe Forum - Tutorials  || Mainframe Tutorials || Mainframe CICS tutorial|| Mainframe COBOL Tutorial

Drona Educational Forums - Mainframe Cobol DB2 CICS Board
Powered by phpBB

mainframetopic-3322.html