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
 

 

Displaying 0001333 as 13.33 in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
YASHO

New User


Joined: 12 Oct 2006
Posts: 6

PostPosted: Wed Nov 14, 2007 2:24 pm    Post subject: Displaying 0001333 as 13.33 in COBOL
Reply with quote

Hi,
The variable has the value 0001333, bt i want the output to displayed as 13.33.. in what way it is possible...


Thanks & Regards,
Yashodha.
Back to top
View user's profile Send private message

vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 276
Location: Bang,iflex

PostPosted: Wed Nov 14, 2007 2:47 pm    Post subject:
Reply with quote

Hi,



Do you manipulating the value you provided here or you want to convert directly the value to some otherform, what is your actual requirement?

Regard's
Vasanth......... icon_smile.gif
Back to top
View user's profile Send private message
madumahe

New User


Joined: 25 Oct 2007
Posts: 2
Location: hyderabad

PostPosted: Wed Nov 14, 2007 2:54 pm    Post subject: Reply to: 0001333 to 13.33
Reply with quote

hi,

i think you can use editing characters!! try once.
Back to top
View user's profile Send private message
VinayCM

New User


Joined: 06 Nov 2007
Posts: 36
Location: Bengaluru

PostPosted: Wed Nov 14, 2007 2:58 pm    Post subject:
Reply with quote

What you are doing actually... generating report or just you want to display the value in that format.... you can divide it by 100 and display using variable of type zz.zz.
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 276
Location: Bang,iflex

PostPosted: Wed Nov 14, 2007 3:10 pm    Post subject:
Reply with quote

Hi,


If u want to implement in scientific notation, it might be possible in PL/1 programming technique, in cobol you can do as suggested above.


Regard's
Vasanth........ icon_smile.gif
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Wed Nov 14, 2007 3:43 pm    Post subject:
Reply with quote

Dear Vasanth,

Could you please explain, how can we implement using in PL/I,

This is just for to know tech,
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Wed Nov 14, 2007 3:47 pm    Post subject:
Reply with quote

Vasanth,

Quote:
If u want to implement in scientific notation, it might be possible in PL/1 programming technique, in cobol you can do as suggested above.

Do you mean scientific notation (i.e., mantissa E exponent) is not possible in COBOL?
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 276
Location: Bang,iflex

PostPosted: Wed Nov 14, 2007 4:00 pm    Post subject:
Reply with quote

Murli,


Not mantissa E exponent notation, while shifting the zeros from left to right side corresspondingly the period will also shift, this is my regard.

regard's
Vasanth...... icon_smile.gif
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Wed Nov 14, 2007 4:27 pm    Post subject: Re: Displaying 0001333 as 13.33 in COBOL
Reply with quote

YASHO wrote:
The variable has the value 0001333, bt i want the output to displayed as 13.33.. in what way it is possible...

Helpful..... icon_rolleyes.gif

Code:
05 number1 pic 9(7).
05 number2 redefines
   number1 pic 9(5)v99.
05 number3 pic z(4.99.

Move 0001333 to number1
move number2 to number3
display '*' number3 '*'

*   13.33*

or
Code:
05 number1 pic x(7).
05 number2 redefines
   number1 pic 9(5)v99.
05 number3 pic z(4.99.

Move '0001333' to number1
move number2 to number3
display '*' number3 '*'

*   13.33*
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Wed Nov 14, 2007 4:30 pm    Post subject:
Reply with quote

CICS Guy,

Did you type the code on fly OR copied from MF session?

Hint: Concentrate on NUMBER3 statements and O/P.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Wed Nov 14, 2007 4:46 pm    Post subject:
Reply with quote

Good point....that's what compiler errors are for, catching such 'finger checks'..... icon_lol.gif
05 number3 pic z(4)9.99.
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Wed Nov 14, 2007 5:07 pm    Post subject:
Reply with quote

Hello CICS Guy,

Quote:
05 number1 pic 9(7).
05 number2 redefines
number1 pic 9(5)v99.
05 number3 pic z(4).99.

Move 0001333 to number1
move number2 to number3
display '*' number3 '*'

* 13.33*


Why you are using Redefining cluase to redefine number1 with number2, the actual requirement is to supress leading zeros from 0001333 number, for that u can push directly 0001333 number to 9(5).99 then to Z(4)9.99 editing item(Why we need one more variable).
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Wed Nov 14, 2007 6:14 pm    Post subject:
Reply with quote

revel wrote:
u can push directly 0001333 number to 9(5).99
OK, how would you "push directly" the integer value into a decimal pic?

Code:
05 number1.
   10 number2 pic 9(5)v99.
05 number3 pic z(4)9.99.

Move '0001333' to number1
move number2 to number3
display '*' number3 '*'

*   13.33*
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Thu Nov 15, 2007 9:45 am    Post subject:
Reply with quote

Hello CICS Guy,


Sorry, It is 9(5)V99 <not 9(5).99>

Ok. Tell me what is the output for below then?

in JCL
-------

Code:
//SYSIN  DD *
0001333
/*


In COBOL
------------
Code:
WORKING-STOARAGE SECTION.
01 WS-A         PIC 9(5)V99.
01 WS-B         PIC Z(4)9.99.

PROCEDURE DIVISION
0000-MAIN.
       ACCEPT WS-A.
       MOVE WS-A   TO WS-B
       DISPLAY WS-A
       DISPLAY WS-B
       STOP RUN.
-----------------------------------------------------------

For WS-A

00013^33
where ^ represent assumed decimal point

For WS-B

BBB13.33 Where B represent Blank space
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Thu Nov 15, 2007 3:22 pm    Post subject:
Reply with quote

Yes, that would "push directly"..........
Did you try to accept ws-b?

Never the less, the OP had a case of "The variable has the value 0001333"....
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Thu Nov 15, 2007 4:04 pm    Post subject:
Reply with quote

Hi CICS Guy,

I didn't get you, could you clear it out.
Back to top
View user's profile Send private message
Nsuma

New User


Joined: 10 Dec 2007
Posts: 13
Location: Hyd

PostPosted: Fri Jan 04, 2008 2:51 pm    Post subject: Blank when zero
Reply with quote

Hi All,
i am also facing same problem...in case of me the value 00001333 im getting from input,but in output i have to send as 1333 ...means eliminating leading zerores and spaces.any one clears this
Back to top
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 276
Location: Bang,iflex

PostPosted: Fri Jan 04, 2008 3:10 pm    Post subject:
Reply with quote

Hi,

As already suggested u can go for LEADING ZERO SUPPRESSION but in case of spaces no on use space leading spaces, also charecters are right justified

or

in case of leading zeros u can go for as CICS GUY explained.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


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