COMP-3 TO ALPHANUMERIC MOVE

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
jaydeeppal
Member
Posts: 4
Joined: Thu Feb 16, 2006 12:24 pm

COMP-3 TO ALPHANUMERIC MOVE

Post by jaydeeppal » Thu Feb 16, 2006 12:34 pm

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?

User avatar
Rupesh.KOthari
Member
Posts: 17
Joined: Thu Feb 16, 2006 5:27 pm

Post by Rupesh.KOthari » Thu Feb 16, 2006 6:24 pm

Hi,

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

Regards
Rupesh

pkaushi
Member
Posts: 9
Joined: Mon Feb 06, 2006 1:45 pm

Post by pkaushi » Fri Feb 17, 2006 2:20 pm

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 !!!
Thanks and Regards,
Prashant

Lingareddy

Post by Lingareddy » Fri Apr 14, 2006 3:29 pm

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.

Guest

Post by Guest » Fri Apr 14, 2006 3:30 pm

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.

mkk157
Member
Posts: 37
Joined: Wed Feb 07, 2007 2:00 pm
Location: Hyderabad

Post by mkk157 » Tue Dec 04, 2007 10:03 am

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).
Kumar
If u can dream it, U can do it.

NiceGuy
Member
Posts: 6
Joined: Mon Oct 15, 2007 3:17 am

Post by NiceGuy » Wed Dec 05, 2007 3:01 am

Kumar ,

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

NG

mkk157
Member
Posts: 37
Joined: Wed Feb 07, 2007 2:00 pm
Location: Hyderabad

Post by mkk157 » Wed Dec 05, 2007 11:24 am

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.
Kumar
If u can dream it, U can do it.

ambadiramesh
Member
Posts: 1
Joined: Mon Feb 22, 2010 4:31 pm

Post by ambadiramesh » Mon Feb 22, 2010 4:41 pm

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]

academyindia4

Topic deleted by Admin

Post by academyindia4 » Wed Jan 27, 2016 8:26 pm

<< Content deleted By Admin >>

academyindia4

Topic deleted by Admin

Post by academyindia4 » Sat Jan 30, 2016 11:41 pm

<< Content deleted By Admin >>

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Feb 01, 2016 10:08 pm

<< Content deleted By Admin >>

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others