Page 1 of 1

COMP-3 TO ALPHANUMERIC MOVE

Posted: Thu Feb 16, 2006 12:34 pm
by jaydeeppal
Is it possible to move a COMP-3 variable to an Alphanumeric variable directly?
01 A1 PIC S9(3) COMP-3 VALUE 1234.
01 B1 PIC X(4).
....
...
MOVE A1 TO B1.
DISPLAY B1.

.....

What will be displayed and what would be the content of B1?

Posted: Thu Feb 16, 2006 6:24 pm
by Rupesh.KOthari
Hi,

Is it possible to move a COMP-3 variable to an Alphanumeric variable directly?
I believe it will give SOC7 error.

Regards
Rupesh

Posted: Fri Feb 17, 2006 2:20 pm
by pkaushi
Hi Jaydeeppal,

You cannot move a COMP-3 variable to alphanumeric directly. It will not give a SOC7 error but will you give you a return code 12 stating that comp-3 and alphanumeric variables did not follow the move compatibility rule.

The solution

01 A1 PIC S9(4) COMP-3 VALUE 1234.
01 A1-NUM PIC S9(4) VALUE ZEROES.
01 B1 PIC X(4).

MOVE A1 TO A1-NUM.
MOVE A1-NUM TO B1.
DISPLAY B1.


This will work :-)

Happy coboling !!!

Posted: Fri Apr 14, 2006 3:29 pm
by Lingareddy
it is possible to move comp-3 to alphanumeric field.the conversion will be done by compiler automatically.but vice versa is not possible in that case beatiful SOC7 error will come.

Posted: Fri Apr 14, 2006 3:30 pm
by Guest
Lingareddy wrote:It is possible to move comp-3 to alphanumeric field.the conversion will be done by compiler automatically.But vice versa is not possible in that case beautiful SOC7 error will come.

Posted: Tue Dec 04, 2007 10:03 am
by mkk157
Hi All,

Can you try this code.

01 WS-COMP-FIELDS.
05 WS-FIELD1 PIC S9(2) COMP-3.
05 WS-FIELD2 REDEFINES WS-FIELD1 PIC X(2).

Posted: Wed Dec 05, 2007 3:01 am
by NiceGuy
Kumar ,

Whet is it that you question about the code snippet you posted?

NG

Posted: Wed Dec 05, 2007 11:24 am
by mkk157
Hi NiceGuy,

This post is all about the Move an COMP-3 element to a CHAR element.
All are replied that, it results in S0C7 abend.

But the code that I gave above will work to convert the COMP-3 value into a CHAR element.

Posted: Mon Feb 22, 2010 4:41 pm
by ambadiramesh
Hi all,

I didnt got any abend when I used this concept in batch code.PFB code for your reference.

01 WS-COMP3-VAR PIC 9(06) COMP-3.
01 WS-NAME PIC X(09) VALUE 'RAMESH'.


MOVE WS-NAME TO WS-COMP3-VAR
DISPLAY 'comp3 VALUE IS' WS-COMP3-VAR


I got some junk values may converted data.

out put for the same is:

comp3 VALUE IS528000

Please let me know still u have any doubt so that i can share the code which i have for the same

Regards,

Ramesh.Ambadi.

































[img][/img][url][list=][/list][/url][/code][/list]

Topic deleted by Admin

Posted: Wed Jan 27, 2016 8:26 pm
by academyindia4
<< Content deleted By Admin >>

Topic deleted by Admin

Posted: Sat Jan 30, 2016 11:41 pm
by academyindia4
<< Content deleted By Admin >>

Topic deleted by Admin

Posted: Mon Feb 01, 2016 10:08 pm
by academyindia4
<< Content deleted By Admin >>