×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
On 2025-06-17 2:55 p.m., David Gibbs via RPG400-L wrote:
Folks:
I'm in the process of creating a routine that needs to adjust
different sized numeric fields to be whole integers.
To do this, I'm multiplying the value times 10 raised to the number of
decimal positions.
You can use a procedure with OPTIONS(*CONVERT) to do this easily.
dcl-s intval int(20);
dcl-s decval packed(7:2) inz(12345.67);
p1 (5.7);
p1 (123.45678);
p1 (-123.45678);
p1 (1234567890123132142331434.2352562366);
// Test it for real
intval = p1 (decval);
snd-msg 'intval is ' + %char(intval);
return;
dcl-proc p1;
dcl-pi *n packed(63);
val varchar(65) const options(*convert);
end-pi;
dcl-s temp varchar(65);
dcl-s retval packed(63);
temp = %scanrpl('.' : '' : val);
retval = %dec(temp : 63 : 0);
snd-msg 'Input: ' + val + ' Output ' + %char(retval);
return retval;
end-proc;
The procedure is doing a snd-msg on its parameter and return value.
Here's what it shows in the joblog after. First the output from the
procedure and then the snd-msg from the "real test".
Input: 5.7 Output 57
Input: 123.45678 Output 12345678
Input: -123.45678 Output -12345678
Input: 1234567890123132142331434.2352562366 Output
12345678901231321423314342352562366
Input: 12345.67 Output 1234567
intval is 1234567
As an Amazon Associate we earn from qualifying purchases.