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

How to display COMP variable


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

New User


Joined: 24 Nov 2004
Posts: 20
Location: chennai

PostPosted: Sat Nov 27, 2004 6:58 pm
Reply with quote

hello
any one plse tell me how to display comp values.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Nov 28, 2004 10:31 am
Reply with quote

Hi Veera,

I'm not sure of what you want to do. If you have a COMP value that looks like X'10' in memory, do you want to display 10 or 16?
Back to top
View user's profile Send private message
veera
Warnings : 1

New User


Joined: 24 Nov 2004
Posts: 20
Location: chennai

PostPosted: Sun Nov 28, 2004 2:33 pm
Reply with quote

[quote="mmwife"]Hi Veera,

I'm not sure of what you want to do. If you have a COMP value that looks like X'10' in memory, do you want to display 10 or 16?[/quote]

hello,
is posible diplay comp-1,com-3.
take this example
77 a pic x(l0) comp-3 value '1234'
77 a pic x(l0) comp-1 value '5678'.
how above values displayed.

veera
Back to top
View user's profile Send private message
lramani

New User


Joined: 03 Nov 2004
Posts: 21
Location: NOIDA, India

PostPosted: Mon Nov 29, 2004 10:47 am
Reply with quote

Hi Veera,
First of all these fields would have pic in 9(10) and not X(10) as was in your example.

COMP-3 stores in packed decimal format and COMP-1 in Binary.

If u need to display them u need to move these to display field (which is the default) and then have a display done.

So for example u have

Field1 pic 9(10) COMP-3.
Field2 pic 9(10) COMP-1.

Move them to some field (field3) with just pic 9(10)...no comp. So that indicates its a display field.

Just have
DISPLAY FIELD3.

You could ofcourse DISPLAY field1 and field2 but its difficult to interpret what they are. Atleast in packed decimal format its easy cos generally the number displays with C or D at the end on the basis of its a postive or a negative number.

But still i would suggest u to have a display done by moving it to a display field.

In case if the COMP-3 field is going to ur file then u could read them by having a HEX ON done.
Back to top
View user's profile Send private message
veera
Warnings : 1

New User


Joined: 24 Nov 2004
Posts: 20
Location: chennai

PostPosted: Mon Nov 29, 2004 6:15 pm
Reply with quote

[quote="lramani"]Hi Veera,
First of all these fields would have pic in 9(10) and not X(10) as was in your example.

COMP-3 stores in packed decimal format and COMP-1 in Binary.

If u need to display them u need to move these to display field (which is the default) and then have a display done.

So for example u have

Field1 pic 9(10) COMP-3.
Field2 pic 9(10) COMP-1.

Move them to some field (field3) with just pic 9(10)...no comp. So that indicates its a display field.

Just have
DISPLAY FIELD3.

You could ofcourse DISPLAY field1 and field2 but its difficult to interpret what they are. Atleast in packed decimal format its easy cos generally the number displays with C or D at the end on the basis of its a postive or a negative number.

But still i would suggest u to have a display done by moving it to a display field.

In case if the COMP-3 field is going to ur file then u could read them by having a HEX ON done.[/quote]


thanks,
veera
one more thing how internal repsentation of comp,comp-3,if we
type hexa on tell with example.

veera
Back to top
View user's profile Send private message
lramani

New User


Joined: 03 Nov 2004
Posts: 21
Location: NOIDA, India

PostPosted: Tue Nov 30, 2004 10:29 am
Reply with quote

Hi Veera,

Regd how to read the HEX ON when its COMP-3 ..would surely tell u. But the best thing u could do is write a small program to experiment on ur own. That will put u in a better and clear place.

For instance a number +123 had been the value which was stored in COMP-3.

Do an HEX ON in the file. They will appear something like the below.

13
2C

Had it been -123 it would have appeared like

13
2D.

Had the number been +1234 it would have appeared as

024
13C.

I hope u got how to read them........
Back to top
View user's profile Send private message
jz1b0c

Active User


Joined: 25 Jan 2004
Posts: 160
Location: Toronto, Canada

PostPosted: Tue Nov 30, 2004 9:31 pm
Reply with quote

hi Ramani,

I guess you are confused between Comp-3 and hex

comp-3 is not hex its a packed decimal.

so 01 ws-cpm2 pic 9(10) value 12345.

it you display this field it will look like

0000012345.

1A,123D, These will come in hex decimal.
Back to top
View user's profile Send private message
lramani

New User


Joined: 03 Nov 2004
Posts: 21
Location: NOIDA, India

PostPosted: Wed Dec 01, 2004 9:45 am
Reply with quote

Hi jz1b0c,
I guess u got the wrong meaning of what i had explained him.

I had already explained about how to have the display. The one i had explained him was with regards to how we could read a comp-3 in a file using HEX ON.

To make it more clear....

for instance a FILE1 had a field which was defined as COMP-3 then they would be stored in half the storage space and one can not read it by just opening the file. they will appear something like ...@.. or something like ..# etc. We need to do a HEX ON and read them.

Veera had asked how to read by doing an HEX ON.

Sorry Veera and jz1b0c if i had confused you.
Back to top
View user's profile Send private message
Ravi gaur

New User


Joined: 12 Jul 2005
Posts: 38

PostPosted: Thu Oct 13, 2005 9:11 am
Reply with quote

This is my Program.
IDENTIFICATION DIVISION.
PROGRAM-ID. COMP3.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 A PIC 9(10) COMP-3 VALUE '1234'.
77 C PIC 9(10).
PROCEDURE DIVISION.
MAIN.
MOVE A TO C.
DISPLAY C.
STOP RUN.

getting this error

IGYGR1080-S A "VALUE" clause literal was not compatible with the data category of the subject data item. The "VALUE" clause was discarded.
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Thu Oct 13, 2005 11:07 am
Reply with quote

Try this:

IDENTIFICATION DIVISION.
PROGRAM-ID. COMP3.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 A PIC 9(10) COMP-3 VALUE '1234'.
77 C PIC 9(10).
PROCEDURE DIVISION.
MAIN.
MOVE A TO C.
DISPLAY C.
STOP RUN.


Dont use quotes with numeric values.
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Thu Oct 13, 2005 12:09 pm
Reply with quote

Sorry my mistake, the program must be:

IDENTIFICATION DIVISION.
PROGRAM-ID. COMP3.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 A PIC 9(10) COMP-3 VALUE 1234.
77 C PIC 9(10).
PROCEDURE DIVISION.
MAIN.
MOVE A TO C.
DISPLAY C.
STOP RUN.


Dont use quotes with numeric values.
Back to top
View user's profile Send private message
spk31980

New User


Joined: 08 Feb 2006
Posts: 6

PostPosted: Wed Feb 08, 2006 4:07 pm
Reply with quote

Comp fields cant be displayed it should be either moved to different variable or use the utility icetool to display it.
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