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
 

 

value movement in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
jaspal

New User


Joined: 22 May 2007
Posts: 68
Location: mumbai

PostPosted: Fri Feb 12, 2010 9:08 pm    Post subject: value movement in cobol
Reply with quote

Hi friends,

what will be the value in field $$$$9.999 if i move 456.67 into it.

thanks,
Jaspal
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Feb 12, 2010 9:25 pm    Post subject:
Reply with quote

RTFM
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: Fri Feb 12, 2010 11:11 pm    Post subject:
Reply with quote

Hello Jaspal,

For questions of this type, it would be far faster to run an experiment on your system. Most programmers have a tiny source module (one for each programming language they use) that is only used for such experiments. If you don't have one, create one - takes about 5 minutes.

Run the experiment and if there are problems that are not clear after looking in the manual, post back here with what you tried, what happened, and your doubt about it.

Someone will be able to clarify.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Sat Feb 13, 2010 7:35 am    Post subject:
Reply with quote

... and if you don't have access to a mainframe, check the MOVE statetement and PICTURE clauses in the COBOL Language Reference Manual.
Back to top
View user's profile Send private message
Kylash V

New User


Joined: 13 Feb 2010
Posts: 5
Location: Chennai

PostPosted: Sat Feb 13, 2010 11:33 pm    Post subject: Reply to: value movement in cobol
Reply with quote

Hi Jaspal
The value would be B$456.67 where B indicates blank spaces. The repeated $ symbol in the PIC clause would indicate that this is a floating sign. So for eg. if you were to move 6.67 to this variable, you would get BBB$6.67
If you wanted a fixed $ symbol (wrt position) to the left of your number, you could declare your variable as $Z(4)9.999.

Hope this clarifies
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Sun Feb 14, 2010 2:15 am    Post subject:
Reply with quote

Kylash, your answer is nearly right -- but still wrong. Code
Code:
           05  WS-VAR1                 PIC $$$$9.999  .
      *
       PROCEDURE DIVISION.
       S1000-INITIALIZE.
           MOVE 456.67                 TO  WS-VAR1.
           DISPLAY 'WS-VAR1:/' WS-VAR1 '/'.
produces output of
Code:
 WS-VAR1:/ $456.670/
Any extra positions after the decimal point will become zero and with three digits specified, you missed the final zero that will be present.
Back to top
View user's profile Send private message
Kylash V

New User


Joined: 13 Feb 2010
Posts: 5
Location: Chennai

PostPosted: Sun Feb 14, 2010 10:51 am    Post subject: Reply to: value movement in cobol
Reply with quote

Hi Robert,
Yes. I had missed the last zero after the decimal. Thanks for correcting the error.
Guess thats where experience comes in icon_smile.gif
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: Sun Feb 14, 2010 11:27 am    Post subject: Reply to: value movement in cobol
Reply with quote

Quote:
Guess thats where experience comes in
Partly.

More importantly, one should test before posting. It only wastes everyone's time to deal with incorrect/untested "solutions". . . icon_sad.gif

Worse, someone else who reads the "solution" before the correction is posted will haved recieved wrong information. . . The intent of our forum is to provide solid information, not just what we might happen to think.

Please do not post anything else without posting the test results proving the solution.

d
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Mar 01, 2010 7:10 am    Post subject:
Reply with quote

One final caution, jaspal:

If you move a numeric variable containing a negative value to the Edited variable you describe, it will be treated as a positive value.
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 -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm


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