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
 

 

How to define decimal variable in Ezytrieve?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CA Products
View previous topic :: :: View next topic  
Author Message
chetanambi

New User


Joined: 21 Jan 2012
Posts: 53
Location: India

PostPosted: Sun Aug 26, 2012 8:26 pm    Post subject: How to define decimal variable in Ezytrieve?
Reply with quote

Hi,

I am new to Ezytrieve programming. I want to know how to define a variable with decimal point in Ezytrieve?. I want to use this field for computations involving decimal values so that my report shows output like 5456.56 etc. I have looked into manuals and found this :-
Code:

       Field-name Location Attributes
DEFINE FIELDA       100        5 A

Appreciate your help!..
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1713
Location: UK

PostPosted: Sun Aug 26, 2012 10:57 pm    Post subject:
Reply with quote

From my Easytrieve notes made a few years ago (and, presumably, taken from the manual)
Code:

* attributes (l dt d) - l - length in bytes           
*
*                      dt - datatype - A - alphanumeric,
                                       P - packed decimal, 
                                       N - zoned decimal
*
*                       d - number of decimals                                             
*
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: Mon Aug 27, 2012 7:18 am    Post subject:
Reply with quote

Hello,

You need to get a copy of the documentation. There are quite a few things that are not difficult but they are surely not intuitive.

If your organization is licensed to use Easytrieve, all of the manuals are downloadable free fro CA Support.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Mon Aug 27, 2012 12:28 pm    Post subject: Reply to: How to define decimal variable in Ezytrieve?
Reply with quote

In your documentation locate references to MASK.

From the documentation, understand that a MASK is only applied when a field is PRINTed or DISPLAYed.
Back to top
View user's profile Send private message
chetanambi

New User


Joined: 21 Jan 2012
Posts: 53
Location: India

PostPosted: Mon Aug 27, 2012 10:53 pm    Post subject:
Reply with quote

Yes, Bill.. I searched in the forum and MASK is only applied if the field is PRINTed or DISPLAYed.

But my requirement is like this: In my input file there are about 5 fields which are defined with S9(7)V99 COMP-3. I need to subtract sum of these 5 fields from the field defined with S9(9) COMP-3 which is also defined in the same input file. When I subtract I am not getting correct result. Please help me out.

I have defined those 5 fields and WS field for computation as below
Code:

FILE INPFILE
     I-CREDIT-LIMIT   1   5  P
     I-AMOUNT1        10  5  P
     I-AMOUNT2        15  5  P
     I-AMOUNT3        06  5  P
     I-AMOUNT4        06  5  P
     I-AMOUNT5        21  5  P

WS-BALALNCE-AMT   W   10  N  2


Suppose if I-CREDIT-LIMIT = 500 and sum of other 5 fields is 465.65 then WS-BALANCE-AMT = I-CREDIT-LIMIT - (Sum of 5 fields) should give 34.35 but I am getting 46065. This is because 500 is being subtracted from 46565 and giving 46065 because I-CREDIT-LIMIT is not defined with decimal point. Can anyone guide me how can I solve this?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Aug 27, 2012 11:00 pm    Post subject:
Reply with quote

if you follow the P with a number, does that not indicate decimal positions?

you are not into testing/experimenting are you?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Mon Aug 27, 2012 11:17 pm    Post subject: Reply to: How to define decimal variable in Ezytrieve?
Reply with quote

As dbz indicates, you have defined all your fields without decimal places. That is like multiplying them by 100. Here your problem.

Put a number after the P indicating the number of decimal places you have. Note that if you have a whole number, and you want it signed, you have to specify 0 decimal places. In Easytrieve Plus, the number of decimals also inidates a signed field.
Back to top
View user's profile Send private message
chetanambi

New User


Joined: 21 Jan 2012
Posts: 53
Location: India

PostPosted: Tue Aug 28, 2012 10:41 am    Post subject:
Reply with quote

dbz,
Ofcourse I am doing trial and error method to find the solution.

All amount fields are actually defined with S9(7)V99 COMP-3 and credit limit as S9(9) COMP-3. So as per your suggestions I have modified the definition as below. When I put display for amount fields it is not considering digits after decimal point.
Code:

FILE INPFILE
     I-CREDIT-LIMIT   1   5  P  0
     I-AMOUNT1        10  5  P  2
     I-AMOUNT2        15  5  P  2
     I-AMOUNT3        20  5  P  2
     I-AMOUNT4        25  5  P  2
     I-AMOUNT5        30  5  P  2

WS-BALALNCE-AMT   W   10  N  2

So its taking only 465 and subtracting from 500 giving result as 35 without decimal points.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 28, 2012 10:58 am    Post subject:
Reply with quote

why not change
Code:
I-CREDIT-LIMIT   1   5  P  0

to
Code:
I-CREDIT-LIMIT   1   7  P  2

?
Back to top
View user's profile Send private message
chetanambi

New User


Joined: 21 Jan 2012
Posts: 53
Location: India

PostPosted: Tue Aug 28, 2012 11:17 am    Post subject:
Reply with quote

dbz,

I-CREDIT-LIMIT is input field and is defined with S9(9) COMP-3. How can you change its definition?.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 28, 2012 11:24 am    Post subject:
Reply with quote

opps, I overlooked that part.

why not move credit limit to your ws-balance-amt
then subtract the others?

ws-balance-amt = credit-amt - (amt1 + amt2 ...)

i do not know of any programming or scripting language,
that will ignore decimal positions when the result of the computation had declared decimal positions.

are you subtracting everything from credit amount and then
moving to ws-balance-amt.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 28, 2012 11:32 am    Post subject:
Reply with quote

it would be helpful to see your arithmetic statements
in addition to the data descriptions that you have already provided.
Back to top
View user's profile Send private message
chetanambi

New User


Joined: 21 Jan 2012
Posts: 53
Location: India

PostPosted: Tue Aug 28, 2012 11:46 am    Post subject:
Reply with quote

dbz,

I am storing sum of all the amounts in one more variable and then subtracting this from credit-amount and storing the result in WS-BALANCE amout as below:
Code:

WS-SUM-AMT        W   10  N  2
WS-BALALNCE-AMT   W   10  N  2


Other information which you have requested:-
Code:

FILE MATCHFL                                     
     MATCH-RECORD                1   80  A       
     MATCH-BALANCE-AMT           1   10  N  2   


Code:

                                                 
IF MATCHED                                         
   WS-SUM-AMT = I-AMOUNT1  +                       
              + I-AMOUNT2  +                       
              + I-AMOUNT3  +                       
              + I-AMOUNT4  +                       
              + I-AMOUNT5                         
   WS-BALANCE-AMT = (I-CREDIT-LIMIT - WS-SUM-AMT) 
   PUT MATCHFL                                     
END-IF                                             
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Tue Aug 28, 2012 12:22 pm    Post subject: Reply to: How to define decimal variable in Ezytrieve?
Reply with quote

Can you do DISPLAY HEX <field-name> for each of your I- fields and post the results/
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Tue Aug 28, 2012 12:40 pm    Post subject: Reply to: How to define decimal variable in Ezytrieve?
Reply with quote

I notice you haven't put anything in the field on MATCHFL.
Back to top
View user's profile Send private message
sandip_mainframe
Warnings : 2

New User


Joined: 20 Sep 2006
Posts: 61
Location: pune

PostPosted: Tue Aug 28, 2012 6:00 pm    Post subject: Reply to: How to define decimal variable in Ezytrieve?
Reply with quote

Hi Chetan,

Display working storage variables in spool area and then copy spool data in the dataset after execution of job.

DISPLAY WS-SUM-AMT WS-BALANCE-AMT

In spool you will be able to view the values in deciamal format. It will surely work. Some days back I had same requirement and I did in the same way.


Thanks,
Sandip Walsinge
Walsinge Technologies Pvt Ltd Pune.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Tue Aug 28, 2012 6:16 pm    Post subject: Reply to: How to define decimal variable in Ezytrieve?
Reply with quote

That's all fine, sandip_mainframe, but pointless. If it worked in that particular program the topic would never have been started.

Until we've seen the code/data which is wrong, there's not much we can do. Inane little bits of code are no help at all, I'm sorry to say.
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 -> CA Products All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts VSAM define for large file jerryte JCL & VSAM 9 Wed Oct 05, 2016 1:51 am
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts OPC JCL Variable passion_sujesh IBM Tools 5 Fri Jul 01, 2016 4:21 am


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