Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Move comp-3 values is displaying as abnormal value

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
venosol
Warnings : 1

New User


Joined: 16 Nov 2006
Posts: 43
Location: Bangalore

PostPosted: Wed Apr 04, 2007 1:41 pm    Post subject: Move comp-3 values is displaying as abnormal value
Reply with quote

When I move Comp-3 value to group item it is displaying abnormal value and when the same value is sent it to an elementary item of the group it is giving the correct output.


Please calrify me on this.
Back to top
View user's profile Send private message

priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Wed Apr 04, 2007 1:42 pm    Post subject: Re: move comp-3 values.
Reply with quote

How are these fields defined ?
> Comp-3 value
> group item
> elementary item
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Wed Apr 04, 2007 6:52 pm    Post subject:
Reply with quote

All group items are considered as ALPHANUMERIC, irrespective of their elementary declarations.
See if you get your clarification!
More 'Clarification' needs more 'Information' ! icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Apr 04, 2007 10:10 pm    Post subject:
Reply with quote

Hello,

It is best to not move a packed-decimal field to a group item.

What purpose does moving a comp-3 field to a group field serve?
Back to top
View user's profile Send private message
venosol
Warnings : 1

New User


Joined: 16 Nov 2006
Posts: 43
Location: Bangalore

PostPosted: Thu Apr 05, 2007 12:08 pm    Post subject:
Reply with quote

dick scherrer wrote:
Hello,

It is best to not move a packed-decimal field to a group item.

What purpose does moving a comp-3 field to a group field serve?


01 ws-num1 pic s9(4)v99 comp-3

01 ws-num2.
02 ws-num3 pic s9(6)v99.

compute ws-num1 = 3245.56
move ws-num1 to ws-num3
display ws-num3
move ws-num1 to ws-num2
display ws-num2


ws-num3 is having correct value
ws-num2 is having abormal value

Ofcourse we can use elementary item only but i why we need to use decalre a group item and elementary item.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Thu Apr 05, 2007 1:01 pm    Post subject:
Reply with quote

Quote:
why we need to use decalre a group item and elementary item.

You mean this?
Code:
01 ws-num2.
02 ws-num3 pic s9(6)v99.


You dont have to..
You can always do following.
Code:
01 ws-num3 pic s9(6)v99.
or
77 ws-num3 pic s9(6)v99.

As i said previously, group items are persieved as alphanumeric.
While generating assembly code for the numeric move between variable of different types, COBOL compiler generates code to 'align' two variables (unpacking/packing) so as to have correct computations between numbers with different declarations.
Code:
move ws-num1 to ws-num2

This is considered as an alphanumeric move, so it giving you unexpected results.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Apr 05, 2007 10:11 pm    Post subject:
Reply with quote

Hello,

This "ws-num2 is having abormal value " is incorrect. "ws-num2" has the correct value. What you tried to do was a character display of a packec-decimal field. What you "got" is the alphanumeric characters represented by the packed value.

Rather than spending time trying to find ways to do this, it is far better to use numeric fields for numeric data.
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 Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm
No new posts Working with hex values in Filemanage... Emile Straker IBM Tools 0 Tue Sep 12, 2017 1:42 am
No new posts DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us