View previous topic :: View next topic
|
Author |
Message |
Yousuf
New User
Joined: 12 Feb 2010 Posts: 4 Location: hyderabad
|
|
|
|
Hi Friends..
I am facing this problem when I was calculating premium amount.
WORKING-STORAGE SECTION.
01 WS-ALPHA PIC X(10) VALUE '1500 '.
01 WS-INTEGER PIC S9(10) USAGE COMP.
01 WS-ZONED PIC ZZZZZZZZZ9.
PROCEDURE DIVISION.
COMPUTE WS-ZONED = FUNCTION NUMVAL(WS-ALPHA).
DISPLAY 'ZONED=' WS-ZONED
COMPUTE WS-INTEGER = FUNCTION NUM(WS-ALPHA).
DISPLAY 'INTEGER=' WS-INTEGER
When I display it in spool I get
ZONED = 1500
INTEGER = 15000000
But I want to get the value as 1500 in WS-INTEGER Which is a comp.
Please give me a solution for my problem.
Thanks in advance |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Hi Yousuf,
Are u sure you have posted the code correctly and have not missed anything...
Am trying the same code here, but its working fine for me...
Code: |
01 WS-WORKING-VARIABLES.
05 WS-WORK1 PIC X(10) VALUE '1500'.
05 WS-WORK2 PIC S9(10) USAGE COMP.
COMPUTE WS-WORK2 = FUNCTION NUMVAL (WS-WORK1).
DISPLAY WS-WORK2. |
Output
Do let me know if I have coded anything wrong ? |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
I too tried your code, with only 2 minor changes:
1. corrected the FUNCTION NUM to FUNCTION NUMVAL
2. added delimiters in the DISPLAY statements
Code: |
COMPUTE WS-ZONED = FUNCTION NUMVAL(WS-ALPHA).
DISPLAY 'ZONED=/' WS-ZONED '/'
COMPUTE WS-INTEGER = FUNCTION NUMVAL(WS-ALPHA).
DISPLAY 'INTEGER=/' WS-INTEGER '/' |
The result I received was as expected:
Code: |
ZONED=/ 1500/
INTEGER=/0000001500/ |
Maybe you've got a compile error and are running an old version of the program ?? |
|
Back to top |
|
|
Yousuf
New User
Joined: 12 Feb 2010 Posts: 4 Location: hyderabad
|
|
|
|
I apologize Friends!!!!
Actually the following is the declaration for ws-alpha.
1500 is followed by 6 spaces
01 WS-ALPHA PIC X(10) VALUE '1500 '.
Can you please help me in this again....
Thanks in Advance |
|
Back to top |
|
|
Yousuf
New User
Joined: 12 Feb 2010 Posts: 4 Location: hyderabad
|
|
|
|
Hi Friends!!!!
I am declaring 01 WS-ALPHA PIC X(10) VALUE '1500BBBBBB'.
B =spaces. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
That is what I used too in my test program:
Code: |
01 WS-ALPHA PIC X(10) VALUE '1500 '. |
I added a DISPLAY just to be sure:
Code: |
ALPHA=/1500 /
ZONED=/ 1500/
INTEGER=/0000001500/ |
Have you corrected this line of yours:
Code: |
COMPUTE WS-INTEGER = FUNCTION NUM(WS-ALPHA). |
|
|
Back to top |
|
|
Yousuf
New User
Joined: 12 Feb 2010 Posts: 4 Location: hyderabad
|
|
|
|
Hi Marso!!!Thanks for the reply.
I have wrongly written the NUM to NUMVAL
But If I declare ws-work as s9(5) comp
05 WS-WORK2 PIC S9(05) USAGE COMP.
I am getting the display as 15000000.
Thanks for now..... |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Got a feeling that your "self review" time is very minimal... Have a look at your code once again... you would be able to find the problem yourself...
Please do post your code if you are not able to find the problem...
Suggest using BBcode to display your code |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Yousuf,
Use cut&paste to put your example into the thread and use BB Code (this gives you the green text on a black background and preserves the original spacing).
This will faithfully reproduce what you have, including any undetected errors. |
|
Back to top |
|
|
|