Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
I have a file with numeric data defined as alpha. I am converting it to numeric, I am using arrays to process the data. Here is my problem.
I get the error "the target for a numeric operation is too smal to hold the result"
the code in question is Numb(cnt) = %dec(Alpha(Cnt):9:2)
Cnt = 1, the array Numb is 9.2 dim(24) the array Alpha is 9 dim(24)
Alpha(cnt) = '010606490' it should convert to 0106064.90 (decimal point should be implied).
any thoughts. I converted 499 records before it read this one
thanks
The decimal point is not implied, if it's not there then the assumption is that the data is an integer representation. You either need to scan/check the input field for the decimal point and insert it yourself. OR monitor with on-error trap to catch the garbage and then do something to audit that you could not handle that piece of data.
You don't need arrays to handle the conversion. If the decimal point is never present in the source field (always implied), then this should also work (numberfield is defined as dec(9,2)):
Monitor;
numberfield = %dec(alphafield:9:0) / 100;
Endmon;
The only reason I can see for needing arrays is that there are 24 values per input record that need to be converted in this way.
Oops, I didn't read the post closely enough. For some reason, I thought the arrays were used to break up a single value into individual digits, so never mind about the array comment.