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

data conversion error


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
maxsubrat

Active User


Joined: 27 Feb 2008
Posts: 110
Location: india

PostPosted: Thu May 09, 2019 10:57 pm
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

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Fri May 10, 2019 6:20 pm
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: 110
Location: india

PostPosted: Tue May 14, 2019 4:37 pm
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: 2455
Location: Hampshire, UK

PostPosted: Tue May 14, 2019 5:44 pm
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

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Tue May 14, 2019 7:37 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top