View previous topic :: View next topic
|
Author |
Message |
yashj06
New User
Joined: 21 Jun 2023 Posts: 2 Location: India
|
|
|
|
In The program there is move statement which is giving an error,as i Figured Alphanumeric variable is PIC X(15) is getting moved to comp-3 S9(5)V .How can solve this error as We cannot move alphanumeric to comp-3 .what can I do? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
review the application logic
why the application specifications define as alphanumeric something that MUST be converted to a numeric value ??? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
How can solve this error as We cannot move alphanumeric to comp-3 |
You really need to learn how to read and understand the Language Reference manual. It does not say this in the manual. Code:
Code: |
WORKING-STORAGE SECTION.
77 WS-SENDING PIC X(15) VALUE '012345678901234'.
77 WS-RECEIVING PIC S9(05)V COMP-3.
PROCEDURE DIVISION.
000-START.
MOVE WS-SENDING TO WS-RECEIVING.
DISPLAY '>' WS-RECEIVING '<' . |
gives results of
So whatever your problem is, the problem is NOT an illegal MOVE statement.
Is the error in the compile? While the program is running? And you could give a hint by telling us the specific error message you got (with ID code if there is one). |
|
Back to top |
|
|
yashj06
New User
Joined: 21 Jun 2023 Posts: 2 Location: India
|
|
|
|
They is error illegal character in numeric field. The value is 00000000 which is 8 characters so why it is moving last 5 characters which are spaces |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
The value is 00000000 which is 8 characters so why it is moving last 5 characters which are spaces |
This is fully explained in the Language Reference manual. An alphanumeric field (PIC X) has an implied decimal point at the end of the field. Numeric moves are first aligned to the decimal point, then the move occurs for however many characters will be moved. And if you have the first 8 characters of a 15-byte alphanumeric field having a value, none of those characters will be moved since only the last 5 characters will be moved.
Why are you not using FUNCTION NUMVAL for this move? If you don't know about it, here is a link to the COBOL manuals: www.ibm.com/support/pages/enterprise-cobol-zos-documentation-library |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
Code: |
77 WS-SENDING PIC X(15) VALUE '012345678901234'.
77 WS-RECEIVING PIC S9(05)V COMP-3. |
PIC X(15) is 15-bytes field '0123456789 ' = X'F0F1F2F3F4F5F6F7F8F94040404040'
PIC S9(5)V COMP-3 is 3-bytes field in memory X'01234C' - it includes non-printable bytes, and fits no more than 5 decimal digits plus sign. The letter 'V' at the end is used by default; no need to specify it.
The DISPLAY statement in COBOL (RTFM!) converts non-printable value X'01234C' back to its printable form '01234' = X'F0F1F2F3F4'
P.S.
It is often very-very useful to start with reading technical manuals prior to writing to internet forums. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
yashj06 wrote: |
In The program there is move statement which is giving an error,as i Figured Alphanumeric variable is PIC X(15) is getting moved to comp-3 S9(5)V .How can solve this error as We cannot move alphanumeric to comp-3 .what can I do? |
This is a very basic question and you already got the answers as above but I am moving it to students section. Please research or give a try or read manuals which will clear all basic doubts. |
|
Back to top |
|
|
|