IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Alphanumeric to Comp -3


IBM Mainframe Forums -> HomeWorks & Requests
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
yashj06

New User


Joined: 21 Jun 2023
Posts: 2
Location: India

PostPosted: Wed Jun 21, 2023 4:28 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jun 21, 2023 4:57 pm
Reply with quote

review the application logic
why the application specifications define as alphanumeric something that MUST be converted to a numeric value ???
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Jun 21, 2023 6:16 pm
Reply with quote

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
Code:
>01234<
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
View user's profile Send private message
yashj06

New User


Joined: 21 Jun 2023
Posts: 2
Location: India

PostPosted: Wed Jun 21, 2023 6:23 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Jun 21, 2023 7:17 pm
Reply with quote

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
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2024
Location: USA

PostPosted: Thu Jun 22, 2023 8:36 pm
Reply with quote

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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Fri Jun 23, 2023 9:51 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts convert alphanumeric PIC X(02) to hex... COBOL Programming 3
Search our Forums:

Back to Top