Move data value from VAR 9(9) to VAR 9(9) COMP-3



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Move data value from VAR 9(9) to VAR 9(9) COMP-3

Postby arya_starc » Sun Sep 10, 2017 5:59 pm

Hi All,

What is the o/p if I move a var 'A' which is 9(09) to other var 'B' which is S9(09) comp-3 and to var 'C' which is 9(09) comp-3.
And suppose the value in var 'A' is
000000000.

I am getting value which seems to be junk in the variable C.!!!
arya_starc
 
Posts: 109
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 4 times
Been thanked: 0 time

Re: Move data value from VAR 9(9) to VAR 9(9) COMP-3

 

Re: Move data value from VAR 9(9) to VAR 9(9) COMP-3

Postby Akatsukami » Sun Sep 10, 2017 6:55 pm

And what does that "junk" look like in hexadecimal?
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1052
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Move data value from VAR 9(9) to VAR 9(9) COMP-3

Postby arya_starc » Sun Sep 10, 2017 9:35 pm

don't know exactly it is hexadecimal or not?
arya_starc
 
Posts: 109
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 4 times
Been thanked: 0 time

Re: Move data value from VAR 9(9) to VAR 9(9) COMP-3

Postby Akatsukami » Sun Sep 10, 2017 9:56 pm

Arya-chan, you have been a member of this board for two years, which implies that you have at least that much experience, plus some sort of training. You should know by now, if you didn't already on your first day on your first job, that all computer data are binary, which can be converted to hexadecimal by the simple expedient of grouping four binary digits (or bits; that is where the name comes from) into one hexadecimal digit.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1052
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Move data value from VAR 9(9) to VAR 9(9) COMP-3

Postby Robert Sample » Mon Sep 11, 2017 2:30 am

arya_starc, one thing you apparently have not yet learned in your career but need to is that there is NO such thing as "junk" to a computer. The mainframe uses EBCDIC, which allows 256 possible character values (from X'00' to X'FF') and none of them are "junk" -- every one of them is defined to be something. So when you call something "junk" you are exposing your EXTREME ignorance to the world. Furthermore, why do you not show us what the value of C is instead of calling it "junk"? It is trivial to bring up the data in ISPF edit, use the command HEX ON, and then copy the display to a Coded display on this forum. Then we will be able to tell you why the data you are seeing is not "junk".
Robert Sample
Global moderator
 
Posts: 3363
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 221 times

Re: Move data value from VAR 9(9) to VAR 9(9) COMP-3

Postby Terry Heinze » Mon Sep 11, 2017 9:10 pm

The Language Reference Manual contains everything you need to know about pictures and values.
A simple test program would have answered your question:
      WORKING-STORAGE SECTION.
       01.
           05  A-X.
               10  A                   PIC  9(09) VALUE 000000000.
           05  B-X.
               10  B                   PIC S9(09) COMP-3.
           05  C-X.
               10  C                   PIC  9(09) COMP-3.
       PROCEDURE DIVISION.
           MOVE A TO B
-001-I No Report Writer data entries were found in this program.
           MOVE A TO C
           DISPLAY 'A-X: >' A-X '<'
           DISPLAY 'B-X: >' B-X '<'
           DISPLAY 'C-X: >' C-X '<'
           GOBACK
           .


A-X: >000000000<
B-X: >     <
C-X: >     <


COMMAND INPUT ===> set hex on

COMMAND INPUT =
---+----1----+--
A-X: >000000000<
C6E746FFFFFFFFF4
107A0E000000000C
 ---------------
B-X: >     <
C6E7460000044444
207A0E0000CC0000
 ---------------
C-X: >     <
C6E7460000044444
307A0E0000FC0000
.... Terry
Terry Heinze
 
Posts: 190
Joined: Wed Dec 04, 2013 11:08 pm
Location: Richfield, MN, USA
Has thanked: 10 times
Been thanked: 11 times

Re: Move data value from VAR 9(9) to VAR 9(9) COMP-3

Postby arya_starc » Tue Sep 12, 2017 12:00 am

Thanks Robert and Akatsukami for more details on EBCDIC.
Actually I am not using termival 3270 or any black green screen for spool, because of that I am not able to change the output value into hexadecimal.Otherwise I will put the output in the forum post.

Hi Terry,
Thanks for the output as I can see the output for B-X and C-X when we see in the hex mode on format, there is different in the last position for B it is 0-C and for C it is 0-F.

Could you please more clarify on the output difference in the value of B-X and C-X for last zero.
As per my understanding it is because as B is stored signed bit and C is not stored any value for signed bit.And in terms of cobol these value should be equal. Please tell me if my understanding is correct.
arya_starc
 
Posts: 109
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 4 times
Been thanked: 0 time

Re: Move data value from VAR 9(9) to VAR 9(9) COMP-3

Postby Terry Heinze » Tue Sep 12, 2017 12:29 am

Mathematically, they are equal as far as COBOL is concerned. X'0C' is a signed packed zero. X'0F' is an unsigned packed zero. Again, the Manual explains this.
.... Terry
Terry Heinze
 
Posts: 190
Joined: Wed Dec 04, 2013 11:08 pm
Location: Richfield, MN, USA
Has thanked: 10 times
Been thanked: 11 times

Re: Move data value from VAR 9(9) to VAR 9(9) COMP-3

Postby Akatsukami » Tue Sep 12, 2017 12:32 am

Your understanding is not correct.

A packed decimal number (COBOL COMP-3; other languages use other terms) will have a decimal digit (0-9) in each half-byte (a nybble) except in the least significant nybble (the sign nybble). By convention going back to the introduction of the System 360 in 1964, a value of (hexadecimal) A, C, or E is considered positive (although you will only ever see C these days), and a value of B or D is considered negative (again you will only see D used). A value of F is considered unsigned (and is treated as positive for almost purposes).

In Mr. Heinze's example, moving zero to B causes it to have the value of x'0000C', whilst moving zero to C causes it to have the value x'0000F'; an arithmetic comparison will find these equal, but a bitwise comparison will not. Note that none of these values produce EBCDIC glyphs, which is likely why you mistook them for junk.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1052
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post