Comp-3 variables to Comp variables.

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
Sandy6925
Member
Posts: 4
Joined: Sun Nov 28, 2010 12:41 am

Comp-3 variables to Comp variables.

Post by Sandy6925 » Sun Nov 28, 2010 12:52 am

1) Can we move a Comp-3 variable in to a Comp Variable? If Yes how?
2) Can we pass a Comp-3 variable in to a Alphanumeric variable using reference modification? If no than is there any way i can do so?

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Sun Nov 28, 2010 12:53 pm

Hi,

Why don't you just try them?
Regards,
Anuj

Sandy6925
Member
Posts: 4
Joined: Sun Nov 28, 2010 12:41 am

Post by Sandy6925 » Sun Nov 28, 2010 1:22 pm

Hi Anuj,

I tried to Move a Comp-3 variable in to Comp variable or vice versa and was getting SOC-7 Abend. I am not sure what data type should i give for them. For ex i was trying to move A to B where A is defined as PIC S9(18 ) COMP-3 and B defined as S9(10) COMP.

For the second point i tried to move a COMP-3 data in to a Alphanumeric variable but was facing a data truncation error. For ex:

01 A PIC X(300).
01 B PIC S9(18 ) COMP-3.

MOVE 123456789012345678 TO B.
MOVE B TO A(18:10).

The resultant data which got moved to A is 1 2 3 4 5 6 7 8 9

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Mon Nov 29, 2010 12:00 pm

you received a SOC7 because you had non-numberics in your source variable.
that you received a SOC7 had nothing to do with comp to comp-3 and comp-3 to comp,.
MOVE B TO A(18:10)
you only moved 10 bytes. what do you expect?
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

Sandy6925
Member
Posts: 4
Joined: Sun Nov 28, 2010 12:41 am

Post by Sandy6925 » Mon Nov 29, 2010 12:26 pm

Hi Dick,

I want to move the data in Field B to A from 18th Position. I have used A(18:10) because the length of the field B is 10 bytes as it is a COMP-3 variable. But the Data is not getting moved correctly.

Can anybody please help me on this?

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

Post by Natarajan » Mon Nov 29, 2010 12:39 pm

For 2nd point... you may try below.

Code: Select all

MOVE B to temp-alpha-numeric-var.
MOVE temp-alpha-numeric-var(18:10) TO A(18:10).
Natarajan
Chennai

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