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

Redefining a COMP variable


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

New User


Joined: 24 Apr 2007
Posts: 23
Location: India

PostPosted: Wed May 02, 2007 4:49 pm
Reply with quote

Hi,

I have redefined a COMP variable as follows:

01 WS-TEST-VAR1 PIC S9(6) COMP.
01 WS-TEST-VAR2 REDEFINES WS-TEST-VAR1.
05 WS-TEST-VAR3 PIC X(2).

I moved +123456 to WS-TEST-VAR1

when I used display option against WS-TEST-VAR3, it is showing spaces. What could be the possible reason? I have used the compiler option TRUNC(STD) and TRUNC(BIN)
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Wed May 02, 2007 5:04 pm
Reply with quote

Are you sure of this?
I guess you should get WS-TEST-VAR3 = x'0001'..
Back to top
View user's profile Send private message
Vedam

New User


Joined: 24 Apr 2007
Posts: 23
Location: India

PostPosted: Wed May 02, 2007 5:06 pm
Reply with quote

Yeah..i am sure that nothng is displayed when I display the variable WS-TEST-VAR3
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Wed May 02, 2007 5:19 pm
Reply with quote

Did you do hex on while looking in spool.
Sometimes you get confused when nothing is displayed but in actual there may be some o/p. icon_smile.gif
Back to top
View user's profile Send private message
Vedam

New User


Joined: 24 Apr 2007
Posts: 23
Location: India

PostPosted: Wed May 02, 2007 5:24 pm
Reply with quote

I think hex is off. What should be the correct output? should the variable value be truncated while displaying?
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Wed May 02, 2007 5:27 pm
Reply with quote

I repeat,you should get WS-TEST-VAR3 = x'0001'.
Try doing hex on in spool o/p
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Wed May 02, 2007 5:32 pm
Reply with quote

Vedam,
This is the piece of code and output i got
Code:
Code:
01  A1   PIC S9(6).                 
01  X1  REDEFINES A1.               
    05  D1  PIC X(2).               
PROCEDURE DIVISION.                 
0000-INIT.                         
    MOVE +123456 TO A1             
    DISPLAY 'VALUE OF D: ' , D1     
    GOBACK                         
    .                               
0000-EXIT.                         
    EXIT                           
    .         


and my job output is

Code:
********************************
VALUE OF D: 12                               
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Wed May 02, 2007 5:37 pm
Reply with quote

Muthu,
It's good that you tried but not with correct variable declaration.
Try with -
01 A1 PIC S9(6) COMP. And please let us know..
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Wed May 02, 2007 5:59 pm
Reply with quote

Abhijit,
I am sorry man.I tried both the code and pasted the wrong one :lol:

You are right the output in hexadecimal is D=x'0001'
Back to top
View user's profile Send private message
Vedam

New User


Joined: 24 Apr 2007
Posts: 23
Location: India

PostPosted: Wed May 02, 2007 6:02 pm
Reply with quote

can you please tell me the syntax to do hex on in Spool. I am not able to do so.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Wed May 02, 2007 6:06 pm
Reply with quote

Quote:
I am sorry man.
Don't be. icon_smile.gif
it is always better to try something instead of waiting for an answer.
Now explanation, why I was so sure of my answer..
COMP = Binary
1 bit sign and rest binary representation of number.
Now +123456 = 0000 0000 0000 0001 1110 0010 0100 0000

X(02) will overlap with first two bytes- so X'0001'. icon_cool.gif
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Wed May 02, 2007 6:06 pm
Reply with quote

Copy the Sysout to a Flat File of Record length 80 using XDC .

In the copied file ,open it in view mode and type "HEX ON " in command window.

You will see the required output in the below format

Code:
4004444444444444444444444444444444444444444444444444444444444
0010000000000000000000000000000000000000000000000000000000000


See it in up-down fashion,and you will get the need.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed May 02, 2007 6:19 pm
Reply with quote

For SDSF it's SET HEX ON and SET HEX OFF

Quote:

Don't be.
it is always better to try something instead of waiting for an answer.

Yes, an excellent philosophy. WELL SAID.
Back to top
View user's profile Send private message
Vedam

New User


Joined: 24 Apr 2007
Posts: 23
Location: India

PostPosted: Wed May 02, 2007 6:38 pm
Reply with quote

In HEX mode I got the required output. Thanks all for l your clarification.

One more question, when the hex is off, why should the data be shown as spaces?
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Wed May 02, 2007 6:53 pm
Reply with quote

Quote:
why should the data be shown as spaces?

X'00' and X'01' are non displayable characters in EBCDIC code.
Space is X'40' so dont mistake non displayable characters with spaces.
see EBCDIC chart present in downloads section of this site.
Good luck. icon_smile.gif
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


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

PostPosted: Wed May 02, 2007 9:19 pm
Reply with quote

If you browse or view/edit a dataset, as opposed to SYSOUT, then the non-printing chars show as periods "." (as in a core dump).

HEX ON shows three rows:
top = display
2nd = left nibbles
3rd = right nibbles
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
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 parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top