View previous topic :: View next topic
|
Author |
Message |
yadagiri_p
New User
Joined: 11 Sep 2005 Posts: 9 Location: bangalor
|
|
|
|
Hi
i have one doubt in Cobol
can i MOVE PIC X(2) TO PIC 9(2)?
Regards
yadagiri. |
|
Back to top |
|
|
Rupesh.Kothari
Member of the Month
Joined: 27 Apr 2005 Posts: 463
|
|
|
|
HI Yadgirir,
Please give an appropriate title for subject line.
Quote: |
can i m MOVE PIC X(2) TO PIC 9(2)? |
Yes you can move X(2) into 9(2), It will move appropriate value if x(2) contains numeric value else it may give some value.
Hope this helps
Regards
Rupesh |
|
Back to top |
|
|
rikshi
New User
Joined: 03 Oct 2005 Posts: 8
|
|
|
|
Quote: |
Yes you can move X(2) into 9(2), It will move appropriate value if x(2) contains numeric value else it may give some value. |
rupesh,
ELSE IT MAY GIVE SOME VALUE--how do we take this?? |
|
Back to top |
|
|
Rupesh.Kothari
Member of the Month
Joined: 27 Apr 2005 Posts: 463
|
|
|
|
HI,
You can check this by writing some Cobol Pgm
Just declare 2 variable into in Working storage with x(2) and 9(2).
Give X(2) value clause.
MOve x(2) into 9(2)
and display x(2) and 9(2).
You will get what you want.
when I tried for re
It displayed
in my case.
Hope this helps
Regards
Rupesh |
|
Back to top |
|
|
Push
New User
Joined: 04 Oct 2005 Posts: 1
|
|
|
|
Variable of PIC X(2) can be moved to 9(2). It will move same value to 9(2) as in X(2) when the same contains numeric data. In case of Alpha-numeric it will give you some value. |
|
Back to top |
|
|
nitin4.a
New User
Joined: 16 Aug 2005 Posts: 26
|
|
|
|
hello
By some value here rupesh want to sya some junk value which will be different at different tines |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Yadgirir,
You should learn to use the IBM Manuals available at this site. The following is excerpted from the Zos COBOL Ref Manual:
Quote: |
The following rules outline the execution of valid elementary moves. When the receiving field is:
Numeric or Numeric-edited:
Except where zeros are replaced because of editing requirements, alignment by decimal point and any necessary zero filling take place, as described under "Alignment rules" in topic 5.1.6.6.
If the receiving item is signed, the sign of the sending item is placed in the receiving item, with any necessary sign conversion. If the sending item is unsigned, a positive operational sign is generated for the receiving item.
If the receiving item is unsigned, the absolute value of the sending item is moved, and no operational sign is generated for the receiving item.
When the sending item is alphanumeric, the data is moved as if the sending item were described as an unsigned integer.
When the sending item is floating-point, the data is first converted to either a binary or internal decimal representation and is then moved.
De-editing allows moving a numeric-edited data item into a numeric or numeric-edited receiver. The compiler accomplishes this by first establishing the unedited value of the numeric-edited item (this value can be signed), then moving the unedited numeric value to the receiving numeric or numeric-edited data item. |
|
|
Back to top |
|
|
sanya9
New User
Joined: 05 Sep 2005 Posts: 13
|
|
|
|
Hi,
Rupesh,
I agree vth ur ans.but, x(9) is in quotes no!but we're passing numeric values.so,my doubt is,how it vll store ?pls be clear this doubt.
hope u'll clear my doubt..
urs..
friend |
|
Back to top |
|
|
Sridevi_C
Active User
Joined: 22 Sep 2005 Posts: 104 Location: Concord, New Hampshire, USA.
|
|
|
|
Hi Sanya9,
If X(9) has numeric value(say :123456789) then 9(9) gets the same ,after move.Storage depends on USAGE clause. As Jack suggested,please learn to use manual.
Regards,
Sridevi. |
|
Back to top |
|
|
kumar456
New User
Joined: 28 Oct 2005 Posts: 2
|
|
|
|
Hi Sridevi,
I tried out the code :
Code: |
01 A PIC X(02) VALUE 'AB'.
01 B PIC X(02) VALUE '88'.
01 C PIC 9(02).
PROCEDURE DIVISION.
MOVE A TO C.
DISPLAY 'C IS ' C.
MOVE B TO C.
DISPLAY 'C IS ' C.
|
OUTPUT
---------
Important:
------------
If we move numeric value contained in alphanumeric data item ,the contents move exactly to numeric data item because alphanumeric data items can contain both numeric and alphabetic data.So while move operation as numeric data is present 88 , the value moves successfully to C that is why C is also 88.
Now one of the C output is A2 because as we are moving alpabetic data to a numeric data item ,system stores the data in Zoned Decimal numbers and the value A2 can be interpreted as AB.See below the table for zoned decimal numbers.I think by now you can interpret the value of A2.
Code: |
**********************************************************************
* VALUES: *
* 1 = A -1 = J EXAMPLES: NUMBER REPRESENTATION *
* 2 = B -2 = K 10 00000001{ *
* 3 = C -3 = L 105 00000010E *
* 4 = D -4 = M 0 00000000{ *
* 5 = E -5 = N -234 00000023M *
* 6 = F -6 = O -30 00000003} *
* 7 = G -7 = P *
* 8 = H -8 = Q *
* 9 = I -9 = R *
* 0 = { -0 = } *
**********************************************************************
|
|
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Kumar,
The best way to determine the state of data after a move is to use ISPF to look at it. DISPLAY would have displayed the "B" as a "B". not a "2" because, for some reason it doesn't convert the sign byte.
Use the HEX cmd in ISPF. If I'm not mistaken the B (X'C2') was converted by the MOVE to a 2 (X'F2') according to the rule:
Quote: |
When the sending item is alphanumeric, the data is moved as if the sending item were described as an unsigned integer. |
THAT'S why it displayed as a "2" and not a "B".
Check it out and let us know what you found. |
|
Back to top |
|
|
paulstephen
New User
Joined: 20 Oct 2005 Posts: 20 Location: Chennai
|
|
|
|
You can move.
But you will get S0C7 if the variable with X(02) had any special characters like +,-,= etc |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
A move of a pic x field to a pic 9 display format field will NOT cause an 0C7 no matter what is in the X field.
Only when you attempt to perform arithmetic with the pic 9 field containing invalid data will an 0C7 occur.
As I said before try it. |
|
Back to top |
|
|
charigln
New User
Joined: 29 Dec 2005 Posts: 1 Location: Bangalore
|
|
|
|
Hai,
Please refer to the TABLE 42 of 'Enterprise COBOL for z/OS' Language Reference. You will get the appropriate idea.
Thanks and Regards,
Chari G L N |
|
Back to top |
|
|
|