Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
convertion from char field to dec

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
puzzled_elton

New User


Joined: 09 May 2005
Posts: 7

PostPosted: Sat Jul 07, 2007 6:25 pm    Post subject: convertion from char field to dec
Reply with quote

Please let me know the convertion from char field to DEC. bcoz iam facing probelm while moving a CHAR filed which is containing a value of 9,2 to a DEC(5,2) filed.

iam getting the below error in sysout.
ONCODE=612 The CONVERSION condition was raised because a conversion error occurred when converting a character string to an arithmetic value.

please let me know the answer asap.
Back to top
View user's profile Send private message

krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Tue Jul 10, 2007 8:54 pm    Post subject:
Reply with quote

puzzled_elton

This is a information from a PL/I pdf, this may help you!
Quote:
CHARACTER
The source string must represent a valid arithmetic constant or complex
expression; otherwise, the CONVERSION condition is raised. The constant can
be preceded by a sign and can be surrounded by blanks. The constant cannot
contain blanks between the sign and the constant, or between the end of the
real part and the sign preceding the imaginary part of a complex expression.
The constant has base, scale, mode, and precision attributes. It converts to the
attributes of the target when they are independent of the source attributes, as in
the case of assignment. See the specific target types of coded arithmetic data
using the attributes of the constant as the source.
If an intermediate result is necessary, as in evaluation of an operational
expression, the attributes of the intermediate result are the same as if a decimal
fixed-point value of precision had appeared in place of the string. (This allows
the compiler to generate code to handle all cases, regardless of the attributes of
the contained constant.) Consequently, any fractional portion of the constant
might be lost. See the specific target types of coded arithmetic data using
FIXED DECIMAL as the source.
It is possible that during the initial conversion of the character data item to an
intermediate fixed decimal number, the value might exceed the default size of
the intermediate result. If this occurs, the SIZE condition is raised if it is
enabled.
If a character string representing a complex number is assigned to a real target,
the complex part of the string is not checked for valid arithmetic characters and
CONVERSION cannot be raised, since only the real part of the string is
assigned to the target.
A null string and a string of blanks both give the value zero.
Back to top
View user's profile Send private message
ilanjai

New User


Joined: 11 Jul 2007
Posts: 2
Location: Hyderabad

PostPosted: Wed Jul 11, 2007 4:42 pm    Post subject: Re: convertion from char fiedl to dec
Reply with quote

A simple solution for such conversions is to use a PIC variable.
Example (ignoring programming syntax)

DCL CHAR_FIELD CHAR(9,2);
DCL DEC_FIELD FIXED DEC(5,2);
DCL PIC_FIELD PIC'9(9)V99';

PIC_FIELD = CHAR_FIELD;
DEC_FIELD = PIC_FIELD;

Now the DEC field can be used as it is.
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 998
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Thu Mar 26, 2009 2:22 pm    Post subject:
Reply with quote

Code:
DCL CHAR_FIELD CHAR(9);
DCL PIC_FIELD PIC'(9)9' BASED(ADDR(CHAR_FIELD));
DCL DEC_FIELD DEC FIXED(9,2);

DEC_FIELD = PIC_FIELD;


Works.

Garry.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Partial color change of a field in CI... waseem0424 CICS 5 Fri Sep 29, 2017 7:56 pm
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts JES2 job size field matching Windows ... SRICOBSAS All Other Mainframe Topics 4 Tue Sep 05, 2017 5:49 pm
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us