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
 
data conversion error

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

Active User


Joined: 27 Feb 2008
Posts: 103
Location: india

PostPosted: Thu May 09, 2019 10:57 pm    Post subject: data conversion error
Reply with quote

Hi ,
I am getting data conversion error, here is the details:
When converting Fixed Decimal to Pic to Char, the following works fine:

EVENT_AMT_FD = -12345.67;
EVENT_AMT_P4 = EVENT_AMT_FD;
EVENT_AMTCHR = EVENT_AMT_P4;

Where

DCL EVENT_AMT_FD FIXED DEC(13,2);
DCL EVENT_AMT_P4 PIC'(10)ZV.99S';
DCL EVENT_AMTCHR CHAR(14);

Result is EVENT_AMTCHR=' 12345.67-'

But in the below case, I get conversion error.

EVENT_AMTCHR = ' 12345.67-';
EVENT_AMT_P4 = EVENT_AMTCHR; ==> this statement fails with conversion condition
EVENT_AMT_FD = EVENT_AMT_P4;

Where

DCL EVENT_AMT_FD FIXED DEC(13,2);
DCL EVENT_AMT_P4 PIC'(10)ZV.99S';
DCL EVENT_AMTCHR CHAR(14);


Thanks
Back to top
View user's profile Send private message

sergeyken

Active User


Joined: 29 Apr 2008
Posts: 440
Location: Maryland

PostPosted: Fri May 10, 2019 6:20 pm    Post subject:
Reply with quote

I don't have PL/I compiler available. But in theory:
EVENT_AMTCHR is stored as
Code:
' 12345.67-'

EVENT_AMT_P4 is assigned the value extended to its full length (14 chars), using string assignment rules:
Code:
EVENT_AMT_P4 = ' 12345.67-     '


When trying to apply the declared PIC template, it must fail at the first dot in place of expected digit, isn't it?
Code:
EVENT_AMTCHR ' 12345.67-'
EVENT_AMT_P4 ' 12345.67-    '
PIC          'ZZZZZZZZZZV.99S'
Result       ' 12345????????'

I guess right alignment of the value in EVENT_AMTCHR is needed, with total length 14 characters.

P.S.
Conversion from DECIMAL to PICTURE is performed using different rules.
Back to top
View user's profile Send private message
maxsubrat

Active User


Joined: 27 Feb 2008
Posts: 103
Location: india

PostPosted: Tue May 14, 2019 4:37 pm    Post subject: Reply to: data conversion error
Reply with quote

Thanks for the reply sergeyken.

Suppose I declare,

DCL EVENT_AMT_P5          PIC'(10)SV.99';

then during conversion, it dis not fail.

If I declare , EVENT_AMT_P5          PIC'(10)ZV.99S';

then it fails due to :
The CONVERSION condition was raised because a conversion error occurred when converting a character string to an arithmetic with IBM0032S ONCODE=612.

Thanks
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2166
Location: Hampshire, UK

PostPosted: Tue May 14, 2019 5:44 pm    Post subject: Reply to: data conversion error
Reply with quote

Have you read the PL/I Language Reference manual for your compiler level? I have looked at the manual for version 5.2.4 and there is a complete chapter (chapter 4) on data conversion. It is not up to me to read it to help you.
Back to top
View user's profile Send private message
sergeyken

Active User


Joined: 29 Apr 2008
Posts: 440
Location: Maryland

PostPosted: Tue May 14, 2019 7:37 pm    Post subject: Re: Reply to: data conversion error
Reply with quote

maxsubrat wrote:
Thanks for the reply sergeyken.

Suppose I declare,

DCL EVENT_AMT_P5          PIC'(10)SV.99';

then during conversion, it dis not fail.

If I declare , EVENT_AMT_P5          PIC'(10)ZV.99S';

then it fails due to :
The CONVERSION condition was raised because a conversion error occurred when converting a character string to an arithmetic with IBM0032S ONCODE=612.

Thanks

I agree with Nic Clouston: the conversion between character strings, and various numeric formats is usually very tricky. It may depend not only on the used language, but also on the version of the language/compiler. You must read carefully the manual on your specific version of PL/I syntax/compiler. I don't have any PL/I manual on hand, and the last time I used PL/I was about 12-15 years ago.

I mentioned one of possible theoretical conversion problems; this may be true or not.
I suggest you to perform multiple stand-alone tests on CONVERSION-ONLY between various data formats you're interested in, to find out how the actual conversion rules do work? The description from a manual is often very messy; I prefer to try the required options in my own minor tests.

This is your own major task, before asking such questions in the forum, without your own investigation

I do not see if you really tried to think about the origins of your problem, did you?
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 masking data with HPU jzhardy DB2 0 Tue May 14, 2019 2:43 pm
No new posts How to browse RECFM=VBS DSORG=PSE seq... Alan Playford JCL & VSAM 7 Fri May 10, 2019 2:59 pm
No new posts How to Hash a data inCOBOL Log Thangavel COBOL Programming 10 Tue May 07, 2019 8:35 pm
No new posts refresh data from production - update... jzhardy DB2 1 Mon May 06, 2019 5:06 pm
No new posts Line numbers contains last 6 digits o... selvagukan TSO/ISPF 4 Mon Apr 22, 2019 8:32 pm

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