Page 1 of 1

Moving Numeric to COmp 3

PostPosted: Fri Nov 19, 2010 1:12 pm
by nm992
I have 9(9)V9(2) .I need to move to S9(9)V((2) Comp 3.How do i move that?

Re: Moving Numeric to COmp 3

PostPosted: Sat Nov 20, 2010 12:41 am
by Akatsukami
Whilst I have not programmed in COBOL in many years, IIRC the statement is:
 MOVE DISPLAY-VAR TO COMP-3-VAR.


You are aware that a COBOL COMP-3 variable is numeric, in fact packed decimal, yes?

Re: Moving Numeric to COmp 3

PostPosted: Tue Nov 23, 2010 3:11 pm
by nm992
hi..


As per my knowlwedge..We cant move directly to comp-3 variable.

Can anyone suggest?

Re: Moving Numeric to COmp 3

PostPosted: Tue Nov 23, 2010 5:57 pm
by Robert Sample
As per my knowlwedge..We cant move directly to comp-3 variable.

Can anyone suggest?
Your knowledge is WRONG. Any numeric variable (USAGE DISPLAY, COMP, COMP-1, COMP-2, COMP-3, COMP-4, or COMP-5) can be moved to a COMP-3 variable with only truncation and overflow issues possible, depending upon the PICTURE clauses involved. You generally cannot move PIC X variables to a COMP-3 variable, but in some special cases even that can work.

Please find the COBOL Language Reference manual and spend a while reading the elementary move rules -- you will learn much that you do not know.

Re: Moving Numeric to COmp 3

PostPosted: Wed Nov 24, 2010 3:12 am
by dick scherrer
Hello,

As per my knowlwedge..We cant move directly to comp-3 variable.

Can anyone suggest?
Suggest you never use the source of that "knowledge" again. . .

If it came from some documentation we may be able to clarify if you post this bit from the material.

If it came from some person, be very careful to never ask for any more technical information from that person. There is no way to know how many other "things" they don't know. . .

Re: Moving Numeric to COmp 3

PostPosted: Wed Nov 24, 2010 11:46 am
by nm992
Thanks RObert and Dick..

How about if I have to move Pic X to COmp-3 variable?

Re: Moving Numeric to COmp 3

PostPosted: Wed Nov 24, 2010 4:08 pm
by Robert Sample
If the PIC X variable does not have purely numeric data, moving it to ANY numeric variable can cause a S0C7 abend.

Assuming that the PIC X variable does have nothing but numeric digits, your best bet is a two-step move: move the PIC X to USAGE DISPLAY variable, then move the USAGE DISPLAY variable to the COMP-3 variable. This will allow COBOL to handle the conversion between the PIC X internal storage format and the COMP-3 internal storage format. Moving a PIC X variable directly to a COMP-3 variable pretty much guarantees an abend as the internal formats are very different.