Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Redefining a COMP variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Redefining a COMP variable
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: 686
Location: Earth

PostPosted: Wed May 02, 2007 5:04 pm    Post subject:
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    Post subject: Re: Redefining a COMP variable
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: 686
Location: Earth

PostPosted: Wed May 02, 2007 5:19 pm    Post subject:
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    Post subject: Re: Redefining a COMP variable
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: 686
Location: Earth

PostPosted: Wed May 02, 2007 5:27 pm    Post subject:
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: Chennai

PostPosted: Wed May 02, 2007 5:32 pm    Post subject: Re: Redefining a COMP variable
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: 686
Location: Earth

PostPosted: Wed May 02, 2007 5:37 pm    Post subject:
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: Chennai

PostPosted: Wed May 02, 2007 5:59 pm    Post subject: Re: Redefining a COMP variable
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    Post subject: Re: Redefining a COMP variable
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: 686
Location: Earth

PostPosted: Wed May 02, 2007 6:06 pm    Post subject:
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: Chennai

PostPosted: Wed May 02, 2007 6:06 pm    Post subject: Re: Redefining a COMP variable
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: 8593
Location: Back in jolly old England

PostPosted: Wed May 02, 2007 6:19 pm    Post subject:
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    Post subject: Re: Redefining a COMP variable
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: 686
Location: Earth

PostPosted: Wed May 02, 2007 6:53 pm    Post subject:
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

Active Member


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

PostPosted: Wed May 02, 2007 9:19 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us