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

Copy from alphanumeric to Comp-3


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Gousiya Mulla

New User


Joined: 02 Jun 2008
Posts: 87
Location: Bangalore

PostPosted: Wed May 19, 2010 1:22 pm
Reply with quote

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

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed May 19, 2010 3:26 pm
Reply with quote

Have you looked at Valid and invalid elementary moves?
Back to top
View user's profile Send private message
Gousiya Mulla

New User


Joined: 02 Jun 2008
Posts: 87
Location: Bangalore

PostPosted: Wed May 19, 2010 4:39 pm
Reply with quote

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

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed May 19, 2010 4:43 pm
Reply with quote

how about 1.6.6.3 Converting to numbers (NUMVAL, NUMVAL-C) in the manual.
Back to top
View user's profile Send private message
Gousiya Mulla

New User


Joined: 02 Jun 2008
Posts: 87
Location: Bangalore

PostPosted: Wed May 19, 2010 4:43 pm
Reply with quote

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

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed May 19, 2010 4:50 pm
Reply with quote

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

New User


Joined: 02 Jun 2008
Posts: 87
Location: Bangalore

PostPosted: Wed May 19, 2010 6:01 pm
Reply with quote

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

Senior Member


Joined: 31 Oct 2006
Posts: 1050
Location: Richmond, Virginia

PostPosted: Wed May 19, 2010 6:10 pm
Reply with quote

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

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Wed May 19, 2010 6:11 pm
Reply with quote

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

New User


Joined: 02 Jun 2008
Posts: 87
Location: Bangalore

PostPosted: Wed May 19, 2010 6:19 pm
Reply with quote

Thanks all
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Wed May 19, 2010 7:01 pm
Reply with quote

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

New User


Joined: 02 Jun 2008
Posts: 87
Location: Bangalore

PostPosted: Wed May 19, 2010 8:47 pm
Reply with quote

bit confused now .. vl read the manuals now ..

Thanks all for your time now
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Copy only TEXT or String from a record SYNCSORT 4
No new posts Use Copy Utility DB2 7
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts Need COBOL COPY Help in MVS Environment COBOL Programming 4
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
Search our Forums:

Back to Top