moving data from pic 99 to pic 99 
Author Message
 moving data from pic 99 to pic 99

hi all

When copying a numeric number (num1   pic 99).  that has an error in it eg
8x to another (num2 pic99) instead of copying 8x to the new variable, it
changes to 81 or 82 or 83 so on depending on the different errors i type in
(8x,8y so on). Is there anyway of copying the original variable across
without it changing and without have to declare num2 as pic x.

thanx craig



Sat, 11 Sep 2004 03:31:00 GMT  
 moving data from pic 99 to pic 99
I expect that what you are doing (by mistake) is converting all the signed
numbers to unsigned numbers. Are you sure that it is not supposed to be
picture S99.?  If the data is not numeric, then why not describe it as
picture XX, then check it to see if it is numeric before trying to do
something with it?

Donald


Quote:
> hi all

> When copying a numeric number (num1   pic 99).  that has an error in it eg
> 8x to another (num2 pic99) instead of copying 8x to the new variable, it
> changes to 81 or 82 or 83 so on depending on the different errors i type
in
> (8x,8y so on). Is there anyway of copying the original variable across
> without it changing and without have to declare num2 as pic x.

> thanx craig



Sat, 11 Sep 2004 04:15:53 GMT  
 moving data from pic 99 to pic 99
Use reference modification:

MOVE num1 (1:) TO num2 (1:).

Reference modification effectively converts the reference-modified operator
to alphanumeric.

Tom Morrison
Liant Software Corporation


Quote:
> hi all

> When copying a numeric number (num1   pic 99).  that has an error in it eg
> 8x to another (num2 pic99) instead of copying 8x to the new variable, it
> changes to 81 or 82 or 83 so on depending on the different errors i type
in
> (8x,8y so on). Is there anyway of copying the original variable across
> without it changing and without have to declare num2 as pic x.

> thanx craig



Sat, 11 Sep 2004 04:33:36 GMT  
 moving data from pic 99 to pic 99
Note:
  Although Tom's suggestion will work (as an extension) with many compilers
REGARDLESS of the usage of Num1 and Num2, that isn't Standard - unless Num1
and Num2 are both explicitly or implicitly USAGE DISPLAY.

If they are actually COMP-? or Binary or Packed-Decimal, you can do either
of the following:

05 Num1-Alpha.
    10 Num1  Pic 99 Binary.
05 Num2-Alpha.
    10 Num2  Pic 99 Packed-Decimal.
     ...
Move Num1-Alpha to Num2-Alpha

***
or

05 Num1  Pic 99 Binary.
05 Num1-Alpha  Redefines Num1  Pic X.  *> depending on size of Pic 99 Binary
fields
05 Num2  Pic 99 Packed-Decimal.
05 Num2-Alpha redefines Num2  Pic XX.
     ...
Move Num1-Alpha to Num2-Alpha
     ...
Move Num1-Alpha to Num2-Alpha

   ***

The bottom-line is that when you define a "sending field" as numeric, the
data MUST "match" the picture (and USAGE) - or otherwise, results are
"undefined" (conversions, abnormal terminations, whatever may occur)

--
Bill Klein
 wmklein <at> ix.netcom.com

Quote:
> Use reference modification:

> MOVE num1 (1:) TO num2 (1:).

> Reference modification effectively converts the reference-modified
operator
> to alphanumeric.

> Tom Morrison
> Liant Software Corporation



> > hi all

> > When copying a numeric number (num1   pic 99).  that has an error in it
eg
> > 8x to another (num2 pic99) instead of copying 8x to the new variable, it
> > changes to 81 or 82 or 83 so on depending on the different errors i type
> in
> > (8x,8y so on). Is there anyway of copying the original variable across
> > without it changing and without have to declare num2 as pic x.

> > thanx craig



Sat, 11 Sep 2004 04:55:36 GMT  
 moving data from pic 99 to pic 99

:>When copying a numeric number (num1   pic 99).  that has an error in it eg
:>8x to another (num2 pic99) instead of copying 8x to the new variable, it
:>changes to 81 or 82 or 83 so on depending on the different errors i type in
:>(8x,8y so on). Is there anyway of copying the original variable across
:>without it changing and without have to declare num2 as pic x.

Well, technically 8X is a valid signed number so you are not getting a data
check if on an IBM mainframe.

There is no way to directly move a non-numeric into a PIC 99 field. You can
move it to the group container, i.e.,

        05  number-container.
            10  num2  pic 99.

        move num1 to number-container.

--

http://www.dissensoftware.com

Director, Dissen Software, Bar & Grill - Israel



Sat, 11 Sep 2004 05:13:14 GMT  
 moving data from pic 99 to pic 99


Quote:
> hi all

> When copying a numeric number (num1   pic 99).  that has an error in it eg
> 8x to another (num2 pic99) instead of copying 8x to the new variable, it
> changes to 81 or 82 or 83 so on depending on the different errors i type
in
> (8x,8y so on). Is there anyway of copying the original variable across
> without it changing and without have to declare num2 as pic x.

> thanx craig

Why?

If you're going to have to change something, why eliminate one of the
possible fixes?

That said, how about:

   02  ORIG-NUM-X.
      05  ORIG-NUM   PIC 99.
...
   02  NEW-NUM-X.
      05  NEW-NUM   PIC 99.

...

MOVE ORIG-NUM-X TO NEW-NUM-X.



Sat, 11 Sep 2004 08:42:47 GMT  
 moving data from pic 99 to pic 99
When you have "check numeric operands" turned off,
some compiler/runtimes will twist (for lack of a better
term) non numbers into numbers, depending on
the exact picture, runtime, etc, etc when certain
operations are performed.

I am assuming usage display.

To answer your question, NO.

You could do a group move.  Reference modification
turns any move into a group move.


Quote:
> hi all

> When copying a numeric number (num1   pic 99).  that has an error in it eg
> 8x to another (num2 pic99) instead of copying 8x to the new variable, it
> changes to 81 or 82 or 83 so on depending on the different errors i type
in
> (8x,8y so on). Is there anyway of copying the original variable across
> without it changing and without have to declare num2 as pic x.

> thanx craig



Sun, 12 Sep 2004 01:29:29 GMT  
 moving data from pic 99 to pic 99

[snip]

Quote:
> You could do a group move.  Reference modification
> turns any move into a group move.

Not to be too picky, but it is more accurate to say that a reference
modified numeric, numeric edited or alphanumeric edited operand is treated
as if it were an alphanumeric item.

In the particular case of a MOVE statement, consider the following:

01  AA  pic X(10) value "0123456789".
01  BB  pic 9(6).
01  CC  value "012".
    03  DD pic 9 occurs 3.
.....
MOVE AA(1:3) TO BB.

The result in BB is 000012.

MOVE CC to BB.

The results are quite different.

The first MOVE is _not_ turned into a group move.  A group move is not
equivalent to an elementary alphanumeric move.  (ANSI X3.23-1985, 6.19.4,
(4) b.3 and (5))

Tom Morrison
Liant Software Corporation



Sun, 12 Sep 2004 05:00:59 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. ANNOUNCE: pygtk-1.99.15, pyorbit-1.99.3, gnome-python-1.99.15

2. Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field

3. Moving PIC X(06) to PIC 9(06)

4. Moving PIC X(06) to PIC 9(06)

5. oopsla '99 - DesignFest '99, Call for Problems

6. Displaying numbers beyond [E-99,E+99]

7. 99. not 99.0

8. Include pic-data in source & display it

9. TOOLS Europe 99 - Call for Contributions

10. SVC 99 and SMS

 

 
Powered by phpBB® Forum Software