View previous topic :: View next topic
|
Author |
Message |
Gousiya Mulla
New User
Joined: 02 Jun 2008 Posts: 87 Location: Bangalore
|
|
|
|
Hi ...
How can we copy alphanumeric variable to Comp-3 variable or vice versa??
Please suggest me any correct reference to get more knwoledge on this !! |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
Back to top |
|
|
Gousiya Mulla
New User
Joined: 02 Jun 2008 Posts: 87 Location: Bangalore
|
|
|
|
Thanks for your reply .
The link is very useful . However it doesn't have information about the movement to COMP-3/COMP fields.
Please can you help me with this . |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
Back to top |
|
|
Gousiya Mulla
New User
Joined: 02 Jun 2008 Posts: 87 Location: Bangalore
|
|
|
|
Code: |
However it doesn't have information about the movement to COMP-3/COMP fields.
|
I am looking for COMP-3 movement !
(option-6 in the link have information about COMP) |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
I am looking for COMP-3 movement ! |
well, you have a link to a manual, as well as the hyperlinks at the top of the page for manuals.
Start looking!!!! |
|
Back to top |
|
|
Gousiya Mulla
New User
Joined: 02 Jun 2008 Posts: 87 Location: Bangalore
|
|
|
|
Thanks for your reply .
I tried to google , I found that ..
We can't really move non-numerical character string into a COMP-3 (packed decimal) field. However compiler doesn't stop .
The difference would be in the end-result .
Does this mean the data resulted will not be accurate ?
Please give me hint for the below .
A PIC X(2)
B PIC 9(2) Comp-3
If I try to move values of variable 'A' , i.e "X " (X and Space) to the variable 'B' , what would be contents of the 'B'?
I think it would be hex of 'X' and Space ..
Please correct me if I am completely incorrect .. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1050 Location: Richmond, Virginia
|
|
|
|
Well for crying out loud - try it already and see what happens.
If your terminal starts smoking, though, we never had this conversation. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
The link is very useful . However it doesn't have information about the movement to COMP-3/COMP fields. |
Actually, the link William Thompson provided tells you exactly this. The second line of the table is alphanumeric sending fields whereas the fourth column is numeric receiving fields -- which is PRECISELY what you want to do. If you check the table, you will find that this is permitted with a footnote. The footnote says
Quote: |
3. Figurative constants and alphanumeric literals must consist only of numeric characters and will be treated as
numeric integer fields. |
so your example of moving an alphanumeric field of X and space into a COMP-3 variable is not permitted under the rules of COBOL as expressed in the table William pointed you to. If you try this, you'll get some form of run-time error (probably a S0C7 abend but others are possible) -- I haven't tested to find out the exact message generated. But in general, if your variable A has all numeric characters in it, the number will be converted and moved to B just fine. |
|
Back to top |
|
|
Gousiya Mulla
New User
Joined: 02 Jun 2008 Posts: 87 Location: Bangalore
|
|
|
|
Thanks all |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
Actually, the footnote referenced speaks only of FIGURATIVE CONSTANTS ( e.g. 'ZERO' ) and ALPHANUMERIC LITERALS ( e.g. '127' ); it does not refer to alphanumeric data elements ( e.g. 'WS-FIELD-X' ).
However, on the previous page of the manual, the rules are given for the situation in question - namely:
Quote: |
When the receiving field is NUMERIC or NUMERIC-EDITED:
When the category of the sending item is alphanumeric, alphanumeric-edited, national, or national-edited, the data is moved as if the sending item were described as an unsigned integer. |
What's the difference? And why would I be so nit-picky as to point out the nuance?
Well, because there IS a difference: an alphanumeric LITERAL can contain a sign, e.g. '-444', whereas an alphanumeric sending item cannot - according to the rules, an alphanumeric sending field is treated as though it were an UNSIGNED integer. Not so for an alphanumeric literal. |
|
Back to top |
|
|
Gousiya Mulla
New User
Joined: 02 Jun 2008 Posts: 87 Location: Bangalore
|
|
|
|
bit confused now .. vl read the manuals now ..
Thanks all for your time now |
|
Back to top |
|
|
|