IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Displaying 0001333 as 13.33 in COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 275
Location: Bang,iflex

PostPosted: Wed Nov 14, 2007 2:47 pm
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
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
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: 275
Location: Bang,iflex

PostPosted: Wed Nov 14, 2007 3:10 pm
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
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: 1436
Location: Bangalore,India

PostPosted: Wed Nov 14, 2007 3:47 pm
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: 275
Location: Bang,iflex

PostPosted: Wed Nov 14, 2007 4:00 pm
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: 2146
Location: At my coffee table

PostPosted: Wed Nov 14, 2007 4:27 pm
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: 1436
Location: Bangalore,India

PostPosted: Wed Nov 14, 2007 4:30 pm
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: 2146
Location: At my coffee table

PostPosted: Wed Nov 14, 2007 4:46 pm
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
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: 2146
Location: At my coffee table

PostPosted: Wed Nov 14, 2007 6:14 pm
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
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: 2146
Location: At my coffee table

PostPosted: Thu Nov 15, 2007 3:22 pm
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
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
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: 275
Location: Bang,iflex

PostPosted: Fri Jan 04, 2008 3:10 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Cobol prog to put an indicator on the... JCL & VSAM 1
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts COBOL program logic for comparisipn o... COBOL Programming 2
No new posts COBOL - create and write to output fi... COBOL Programming 0
No new posts COBOL to JSON COBOL Programming 1
Search our Forums:

Back to Top