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

Can we move a Alphanumeric to comp, comp-1


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

New User


Joined: 22 Jun 2004
Posts: 1
Location: Chennai

PostPosted: Wed Jun 23, 2004 5:22 pm
Reply with quote

Hai Friends,

Can we move a numeric or aplanumeric or alphabetic variables to a comp, comp-1 or comp-2 variables?
If it so what happened to the pic clause of the sending and receving variable?

Also can you pls provide me some examples for the various possible conditions of move statements?


Thanks in advance
Back to top
View user's profile Send private message
priya

Moderator


Joined: 24 Jul 2003
Posts: 568
Location: Bangalore

PostPosted: Sat Jun 26, 2004 8:08 am
Reply with quote

You can move numeric to comp

But alphanumeric & alphabetic is not possible


Allowed Move

N / NE to AN / ANE

AN / ANE to A

and wise versa, except ANE to NE

Note: N - Numeric
NE - Numeric Edited

AN - Alphanumeric

ANE - AN Edited

A - alphanumeric
Back to top
View user's profile Send private message
DIVAKAR

New User


Joined: 26 Jun 2004
Posts: 3
Location: Trichy

PostPosted: Sat Jun 26, 2004 8:52 am
Reply with quote

hi pandian
we can move numeric value to comp,comp1 comp2 fileds

suppose

77 I pic 9999.
77 J PIC S9(4) COMP.

MOVE I TO J.

DATA :
I - 1234
J - 234

comp1
-------
77 I pic 9999.
77 J COMP1.

MOVE I TO J.

DATA :
I - 1234
J - .12340000E+4

comp2
-------
77 I pic 9999.
77 J COMP1.

MOVE I TO J.

DATA :
I - 1234
J - .1234000000000000E+4

Dhivakar - Trichy
Back to top
View user's profile Send private message
shammiullah

New User


Joined: 13 Jun 2005
Posts: 24

PostPosted: Tue Nov 15, 2005 11:41 pm
Reply with quote

77 I pic 9999.
77 J PIC S9(4) COMP.

MOVE I TO J.

DATA :
I - 1234
J - 234
................here is it for sure that if i display j it'll show 234.comp will internally take 2 bytes for j.so,where the sign will b stored.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Nov 16, 2005 11:32 pm
Reply with quote

Hi Sham,

J will contain 04D2, which is the binary equivilant of 1234. The sign is 0 (pos) in the hi ord bit of the hi ord byte.

If -1234 were moved to J, it would contain FB2E. The sign is 1 (neg) in the hi ord bit of the hi ord byte.
Back to top
View user's profile Send private message
mbr_raja

New User


Joined: 15 Nov 2004
Posts: 26
Location: Chennai, India

PostPosted: Wed Nov 16, 2005 11:55 pm
Reply with quote

You can move numeric or alphanumeric to comp, comp-1 etc, but the difference is as follows:

Move numberic to comp or comp-1 working fine

Move alphanumeric to comp or comp-1 SOC4 error


Since Comp and Comp-1 tries to stores the data in Hex format in the memory, but you cannot process or dispaly, If you try this, i leads SOC4 error.

01 c pic 99 comp.

Ex: move 123 to c

move "ABCD" to C
Back to top
View user's profile Send private message
shammiullah

New User


Joined: 13 Jun 2005
Posts: 24

PostPosted: Thu Nov 17, 2005 12:14 am
Reply with quote

hI MMWIFE,
WAT U'VE SAID IS RIGHT.....PREVIOUSLY SOME ONE HAS WRITTEN THAT I & J WILL CONTAIN 1234 AND 234.
BUT AS U'VE SAID IT'LL B LIKE
I-----1234
J-----123D IF ITZ DELARED AS S9(4)COMP.

IT'LL BE
I------1234
J------1234 IF ITZ DELARED AS 9(4)COMP.

CORRECT ME IF I'M WRONG...........THANK U.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Nov 17, 2005 1:38 am
Reply with quote

I'm assuming both I and J are signed. If you add another field - K with a
PIC S9(4) USAGE DISPLAY and move J to K, then:

The contents of K will be 123D if the 1234 is positive.
The contents of K will be 123M if the 1234 is negative.

If K is defined as PIC 9(4) USAGE DISPLAY, then K will contain
1234 in both cases.
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 Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts How to move DB2 Installation HLQ DB2 4
Search our Forums:

Back to Top