Moving a numeric field in ILE RPG

10 pts.
Tags:
RPG
RPG ILE
I want to move a numeric field (15,2) to a character field of length 15. I want the character field output with decimal points... For example ...>Input-----> A=123 , B is a character If I move numeric A to character B, character OUTPUT B should be 0000000000123.00

Answer Wiki

Thanks. We'll let you know when a new response is added.

If I’m understanding you correctly, you need to size the character field as one byte larger than the number of numeric digits in order to accommodate the desired decimal point and the edit word one byte larger still in order to avoid suppression of the leading 0. The following will then store the 16 bytes ‘0000000000123.00’ into the character field:

<pre>
dNumber s 15 2 inz(123)
dChar s 16

/free
Char = %triml(%editw(Number :'0 . '));
dsply Char;
*inlr = *on;
return;
/end-free
</pre>

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following