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

Moving Alphanumeric to COMP-3


IBM Mainframe Forums -> COBOL Programming
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Wed Jun 11, 2008 5:53 pm
Reply with quote

Hi,

I am attempting to move a alphanumeric to comp-3 and am successfull with the movement. What is weird is that the storage in comp-3 is similar to comp and defeats the purpose of using comp-3. I am not sure if i am missing something very basic , please can you clarify.

Source code:

Code:

IDENTIFICATION DIVISION.                     
PROGRAM-ID. SIGNTEST.                         
AUTHOR.     XXXXXXXXXXXXXX.                   
                                             
ENVIRONMENT DIVISION.                         
DATA DIVISION.                               
WORKING-STORAGE SECTION.                     
                                             
 01  WS-ALPHA.                               
         15 WS-ALPHA-SIGN  PIC X(01).         
         15 WS-ALPHA-INT   PIC X(02).         
         15 FILLER         PIC X(01).         
         15 WS-ALPHA-DEC   PIC X(02).         
 01  WS-COMP3  PIC  S9(2)V99 USAGE IS COMP-3.
 01  WS-COMP   PIC  +ZZ.99 .                 
PROCEDURE DIVISION.                           
0000-MAIN-PARA.                               
     MOVE  '-02.34'       TO WS-ALPHA.   
     PERFORM 1000-ACCEPTDATA-PARA                   
     STOP RUN                                       
     .                                             
1000-ACCEPTDATA-PARA.                               
     MOVE WS-ALPHA  TO WS-COMP                     
     DISPLAY "COMP-"     WS-COMP                   
     MOVE WS-COMP  TO WS-COMP3                     
     DISPLAY "COMP3-"     WS-COMP3.                 
1000-ACCEPTDATA-EXIT-PARA.                         
        EXIT                                           
        .


Output from spool looks like this.

Code:

COMP--02.34
CDDD66FF4FF
36470002B34
-----------
COMP3-023M
CDDDF6FFFD
3647300234
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Jun 11, 2008 6:12 pm
Reply with quote

When you display a COMP-3 field it is translated to character (zoned decimal) in order to make it displayable. If you redefine ws-comp3 as ws-compx pic x(3) and display ws-compx you will see (in hex mode) the actual packed decimal (comp-3) value.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Jun 11, 2008 6:17 pm
Reply with quote

If you would bother to read any of the 10 or 15 threads that have been posted here for the last week or so, about the same subject, you could have learned that the DISPLAY command will convert comp, comp-3 to 'read able' format.

Since the compiler will generate instructions to allow this type of silliness, your conversion moves have been executed correctly.

everything is ok except your understanding of computers.
Back to top
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Wed Jun 11, 2008 6:23 pm
Reply with quote

Bingo. Thats the answer . Changed to the code to test this and you are right.

I knew it had to be something as simple as that. Feel like a real jerk now but what the heck , as long as i don't ask .. it wouldn't have got cleared.

Thanks Craig.
Back to top
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Wed Jun 11, 2008 6:29 pm
Reply with quote

dbzTHEdinosauer wrote:
If you would bother to read any of the 10 or 15 threads that have been posted here for the last week or so, about the same subject, you could have learned that the DISPLAY command will convert comp, comp-3 to 'read able' format.

Since the compiler will generate instructions to allow this type of silliness, your conversion moves have been executed correctly.

everything is ok except your understanding of computers.


If you had read my post correctly, my question was not about displaying the comp or comp3 in readable format.

If all programmers understood computers perfectly we wouldn't have a forum here for people to post their questions and experts answering them.

Though you may/may not have intended i find sarcastic rudeness in your post.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Jun 11, 2008 7:05 pm
Reply with quote

no, your question was why did both appear to be the same when you displayed them. so, you did not know that the display command performed as it did. otherwise you would not have posted the question.

and I did not say that you lacked perfect understanding of computers, I just said you did not understand them enough, nor did you bother to search the forum before posting your question.

by the way, proper construction of your sentence in english would be:

Though you may (or may not) have intended to be so, I found the sarcasm in your post to be rude.
Back to top
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Wed Jun 11, 2008 7:11 pm
Reply with quote

I disagree again. My question was "What is weird is that the storage in comp-3 is similar to comp and defeats the purpose of using comp-3." and not as you had stated.

Thanks for correcting my english and i am happy you got my point out of it.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Jun 11, 2008 7:52 pm
Reply with quote

Manu,

anybody who would say that the storage in comp-3 is similar to comp,
attracts my attention because of the obvious lack of understanding of something.

you based your comment on the results of the display command, and managed to talk yourself into a false trail.
Back to top
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Wed Jun 11, 2008 8:13 pm
Reply with quote

Hi Dick,

I understand the concepts of comp and comp-3 but have never attempted to display it in the past. This is my first attempt to do it and hence it seemed like both were 'stored' similarly although the fact was that both were only 'displayed' similarly . I got the point when Craq mentioned it. But what provoked me is your unwarranted comments attempting to ridicule my knowledge on computers which has allowed this conversation to grow to this extent.

May be you are used to throw in a bit of sarcasm in your posts and i am ok with it as long as it doesn't insult or offend an individual.

May be you are that way and i am this way. Period.
Please can we stop this conversation from growing.

Peace.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Jun 11, 2008 8:20 pm
Reply with quote

Manu you were referring to your WS variables WS-COMP3 and WS-COMP writing it down as comp-3 and comp.

Now as a COBOL programmer what does comp-3 and comp refer to ?

have a look back at your quote

Quote:


What is weird is that the storage in comp-3 is similar to comp and defeats the purpose of using comp-3.


Now you decide who is right and who is wrong ....
Back to top
View user's profile Send private message
Manuneedhi K

Active User


Joined: 07 May 2008
Posts: 115
Location: Chennai

PostPosted: Wed Jun 11, 2008 8:26 pm
Reply with quote

Thanks for attempting to mediate but Craq and Dick understood what i meant when i said comp and comp-3 there. So the whole conversation is not on that. I am sorry but i am in no mood to continue on this topic. I had a query which was resolved long back and i expected that to be the end of it but had gone this far.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. 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 Moving Or setting POINTER to another ... COBOL Programming 2
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 Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
Search our Forums:

Back to Top