Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Display 1123.34 as 00112324

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

New User


Joined: 20 Jul 2007
Posts: 14
Location: Germany

PostPosted: Tue Oct 04, 2011 6:07 am    Post subject: Display 1123.34 as 00112324
Reply with quote

Hi,
Variable A is Pic9(4)V9(2) Value 1123.34
Variable B is Pic9(8)

Need to move the conents of A to B

I want the leading zeros so output B should look like 00112324

thanks for help
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


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

PostPosted: Tue Oct 04, 2011 7:30 am    Post subject:
Reply with quote

This is a simple question, easily answered in the manuals for which there is a link at the top of the page. So why do you expect us to read the manual for you?

And a simple move will not change 1123.34 to 00112324, no matter what you do -- 3 does not change to 2 just from a move.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Tue Oct 04, 2011 11:48 am    Post subject:
Reply with quote

You have been on this forum since 2007. You are a "Software Analyst". It is diffiult to believe how much confusion you got into one short post.

In any Cobol Picture with a "V", the decimal-point is implied only. There is no actual decimal-point in your field.

Any plain Cobol Picture with "9"s will have leading zeros for all those leading 9s that do not contain 1-9.

Look in the manuals for how to use REDEFINES. Then either redefine the first without the implied decimal-point, or the second with the implied decimal-point.

Do a MOVE.

From the first to the second. Job done.

I even suspect the whole lot is unnecessary, because you don't understand the definitions anyway and won't really know if you need it or not. And note Robert's point.

Next time, consult manuals/colleagues - even your old training materials in this case - before posting. You got an answer so that any failure to understand the simplicity of the question is kept away from here.
Back to top
View user's profile Send private message
ziddiguy

New User


Joined: 20 Jul 2007
Posts: 14
Location: Germany

PostPosted: Tue Oct 04, 2011 3:11 pm    Post subject: Reply to: Display 1123.34 as 00112324
Reply with quote

Thanks for your reply, Yes I did check manual. May be i have asked the question wrongly.

Variable A can have value as 11.22 or 1111.22 or 111.33 so I can not just simply Move using Redefines as one way is to find the length of record using INSPECT but I am wondering if there is any way to accompolish above task using INSPECT REPLACING or something. Because to remove the leading zeros looks simple but in adding leading zeros I am finding complicated

Many Thanks for your replies
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Oct 04, 2011 3:34 pm    Post subject:
Reply with quote

you are never going to be able to suppress leading zeroes in a numeric field.

check the manual again, only this time read it.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Tue Oct 04, 2011 4:12 pm    Post subject: Reply to: Display 1123.34 as 00112324
Reply with quote

With the definitons that you posted, you do not have a physical decimal point and you do have at least two leading zeros in the field which is bigger, if you do a move.

OK, so you could get a "." into the field, but what use would it be?

Have done with it. If you think you have a "." in there, just use NUMVAL (intrinsic function).
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: Tue Oct 04, 2011 8:33 pm    Post subject:
Reply with quote

Hello,

Quote:
Variable A can have value as 11.22 or 1111.22 or 111.33
Why do you believe this? As defined, the field CANNOT contain an actual decimal point. It contains only an implied decimal point.

If you have an actual decimal point in a field, it cannot be defined as you have variableA.

Once we know what you are really working with, we whould be able to make more useful suggestons.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Oct 13, 2011 6:55 am    Post subject: Reply to: Display 1123.34 as 00112324
Reply with quote

Hi ziddiguy,

Using the PICs of your original post, the following should work:
Quote:
A PIC 9(4)V99.
B PIC 9(8).

MOVE ZEROS TO B
MOVE A(1:6) TO B(3:6)

I haven't tested it; no M/F access.
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
No new posts display the sign only if the value is... useit DFSORT/ICETOOL 3 Wed Oct 04, 2017 5:53 pm
No new posts Binary to display characters Roy Ware SYNCSORT 3 Tue Sep 19, 2017 8:46 pm
No new posts DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm
No new posts Suppress value reported by BREAK in D... Learncoholic DFSORT/ICETOOL 3 Wed Aug 16, 2017 6:03 pm
No new posts Display upon console bipinpeter COBOL Programming 1 Thu Jun 22, 2017 12:35 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us