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...
Alphanumeric to COMP-3 data movement
-
- Posts: 12
- Joined: Mon Nov 05, 2007 1:50 pm
- Skillset: Cobol,DB2,CICS,JCL,VSAM
- Referer: thru friends
-
- Posts: 1
- Joined: Wed Nov 07, 2007 10:49 am
- Skillset: mainframe
- Referer: internet
Re: Alphanumeric to COMP-3 data movement
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
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
-
- Posts: 12
- Joined: Mon Nov 05, 2007 1:50 pm
- Skillset: Cobol,DB2,CICS,JCL,VSAM
- Referer: thru friends
Re: Alphanumeric to COMP-3 data movement
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 ??
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 ??
- dick scherrer
- Global moderator
- Posts: 6268
- Joined: Sat Jun 09, 2007 8:58 am
Re: Alphanumeric to COMP-3 data movement
Hello,
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.
This is incorrect. Data in files and in programs is almost never stored in ascii on the mainframe.in alphanum data is stored in ascii form
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.
Hope this helps,
d.sch.
d.sch.
-
- Posts: 12
- Joined: Mon Nov 05, 2007 1:50 pm
- Skillset: Cobol,DB2,CICS,JCL,VSAM
- Referer: thru friends
Re: Alphanumeric to COMP-3 data movement
Thnx....It helped !!!
- dick scherrer
- Global moderator
- Posts: 6268
- Joined: Sat Jun 09, 2007 8:58 am
Re: Alphanumeric to COMP-3 data movement
You're welcome 

Re: Alphanumeric to COMP-3 data movement
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.
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.
-
- Global moderator
- Posts: 3805
- Joined: Tue Jan 25, 2011 12:02 am
- Skillset: Easytrieve Plus, Cobol, Utilities, that sort of stuff
- Referer: Google
Re: Alphanumeric to COMP-3 data movement
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.
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.
- dick scherrer
- Global moderator
- Posts: 6268
- Joined: Sat Jun 09, 2007 8:58 am
Re: Alphanumeric to COMP-3 data movement
Hello,
No, this is not correct. You should not try to force alpha values into a packed-decimal (comp-3) field.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.
Hope this helps,
d.sch.
d.sch.