IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Can I MOVE PIC X TO PIC 9


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
yadagiri_p

New User


Joined: 11 Sep 2005
Posts: 9
Location: bangalor

PostPosted: Thu Oct 06, 2005 9:39 am
Reply with quote

Hi

i have one doubt in Cobol

can i MOVE PIC X(2) TO PIC 9(2)?


Regards
yadagiri.
Back to top
View user's profile Send private message
Rupesh.Kothari

Member of the Month


Joined: 27 Apr 2005
Posts: 463

PostPosted: Thu Oct 06, 2005 10:01 am
Reply with quote

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
View user's profile Send private message
rikshi

New User


Joined: 03 Oct 2005
Posts: 8

PostPosted: Thu Oct 06, 2005 10:24 am
Reply with quote

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
View user's profile Send private message
Rupesh.Kothari

Member of the Month


Joined: 27 Apr 2005
Posts: 463

PostPosted: Thu Oct 06, 2005 11:52 am
Reply with quote

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
Code:
re
r5

in my case.


Hope this helps

Regards

Rupesh
Back to top
View user's profile Send private message
Push

New User


Joined: 04 Oct 2005
Posts: 1

PostPosted: Thu Oct 06, 2005 12:40 pm
Reply with quote

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
View user's profile Send private message
nitin4.a

New User


Joined: 16 Aug 2005
Posts: 26

PostPosted: Thu Oct 06, 2005 12:45 pm
Reply with quote

hello


By some value here rupesh want to sya some junk value which will be different at different tines
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Oct 07, 2005 5:04 am
Reply with quote

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
View user's profile Send private message
sanya9

New User


Joined: 05 Sep 2005
Posts: 13

PostPosted: Sat Oct 15, 2005 8:05 pm
Reply with quote

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
View user's profile Send private message
Sridevi_C

Active User


Joined: 22 Sep 2005
Posts: 104
Location: Concord, New Hampshire, USA.

PostPosted: Wed Oct 19, 2005 10:25 pm
Reply with quote

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
View user's profile Send private message
kumar456

New User


Joined: 28 Oct 2005
Posts: 2

PostPosted: Fri Oct 28, 2005 2:44 am
Reply with quote

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
---------

Code:

C IS A2
C IS 88



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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Oct 29, 2005 11:05 pm
Reply with quote

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
View user's profile Send private message
paulstephen

New User


Joined: 20 Oct 2005
Posts: 20
Location: Chennai

PostPosted: Mon Oct 31, 2005 2:29 pm
Reply with quote

You can move.
But you will get S0C7 if the variable with X(02) had any special characters like +,-,= etc
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Nov 01, 2005 5:28 am
Reply with quote

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
View user's profile Send private message
charigln

New User


Joined: 29 Dec 2005
Posts: 1
Location: Bangalore

PostPosted: Mon Jan 02, 2006 5:54 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts How to move DB2 Installation HLQ DB2 4
No new posts How to move values from single dimens... COBOL Programming 1
No new posts Reading the CSV data in COBOL and mov... COBOL Programming 4
Search our Forums:

Back to Top