View previous topic :: View next topic
|
Author |
Message |
ziddiguy
New User
Joined: 20 Jul 2007 Posts: 14 Location: Germany
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
ziddiguy
New User
Joined: 20 Jul 2007 Posts: 14 Location: Germany
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
|