Page 1 of 1

Alphanumeric to COMP-3 data movement

PostPosted: Thu Nov 08, 2007 8:44 am
by Gaurav Chauhan
Why can't we move Alphanumeric ( PIC X ) data to COMP-3 variables directly without using Display 0r Zoned numeric variables intermediately.....
I want to know how the movement takes place in the variables internally...

Re: Alphanumeric to COMP-3 data movement

PostPosted: Thu Nov 08, 2007 10:50 am
by pooja.jadhav
hi,
In comp-3 data representation is in packed decimal and in alphanum data is stored in ascii form so bcuz of data incompatibility Alphanumeric to COMP-3 data movement is not possible.
Regards,
poojaj

Re: Alphanumeric to COMP-3 data movement

PostPosted: Thu Nov 08, 2007 11:45 am
by Gaurav Chauhan
Yes....but I want to know how data movement takes place internally in these variables...
Take these 2 cases:

a) 05 WS-1 PIC X(03) VALUE 'ABC'.
05 WS-2 PIC 9(03) VALUE ZEROES.
05 WS-3 PIC S9(03) COMP-3 VALUE ZEROES.

b) 05 WS-4 PIC X(03) VALUE '123'.
05 WS-5 PIC 9(03) VALUE ZEROES.
05 WS-6 PIC S9(03) COMP-3 VALUE ZEROES.

MOVE WS-1 to WS-2
Move WS-2 to WS-3

MOVE WS-4 to WS-5
Move WS-5 to WS-6

How will data movement take place for these 2 cases internally ??

Re: Alphanumeric to COMP-3 data movement

PostPosted: Fri Nov 09, 2007 1:38 am
by dick scherrer
Hello,

in alphanum data is stored in ascii form
This is incorrect. Data in files and in programs is almost never stored in ascii on the mainframe.

How will data movement take place for these 2 cases internally ??


In both cases the first "move" generates an assembler move instruction and the second generates an assembler zero-and-add-packed (zap) instruction.

To better understand what happens internally, it may be helpful to look at the actual assembler code generated by the compile.

Re: Alphanumeric to COMP-3 data movement

PostPosted: Tue Nov 13, 2007 7:00 pm
by Gaurav Chauhan
Thnx....It helped !!!

Re: Alphanumeric to COMP-3 data movement

PostPosted: Tue Nov 13, 2007 8:13 pm
by dick scherrer
You're welcome :)

Re: Alphanumeric to COMP-3 data movement

PostPosted: Tue Jan 03, 2012 3:55 pm
by jvinoth
i have code is this correct and how to move alphanueric to comp-3

IDENTIFICATION DIVISION.
PROGRAM-ID PROGRAM1.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A1 PIC 9(5) COMP-3.
01 A1-NUM PIC X(5).
01 WS-COMP3 PIC 9(6)V99 COMP-3.
01 B1 PIC X(5).
PROCEDURE DIVISION.
MOVE 'TESTING' TO WS-COMP3.
DISPLAY WS-COMP3.
STOP RUN.

Re: Alphanumeric to COMP-3 data movement

PostPosted: Tue Jan 03, 2012 4:01 pm
by BillyBoyo
When you have a new question, please start a new topic. If you have found another topic you think relevant, you can link to it.

Why would you want to do this? If you consult your manuals, you'll find that moving alphanumeric literals to comp-3 fields is not allowed.

If you have a numeric value in a PIC X(n) field, redefine it as a PIC 9(n) field. Test that field for being numeric before doing the move. MOVE to the comp-3 field.

Re: Alphanumeric to COMP-3 data movement

PostPosted: Wed Jan 04, 2012 1:34 am
by dick scherrer
Hello,

i have code is this correct and how to move alphanueric to comp-3

01 WS-COMP3 PIC 9(6)V99 COMP-3.

MOVE 'TESTING' TO WS-COMP3.
No, this is not correct. You should not try to force alpha values into a packed-decimal (comp-3) field.