Numeric to character conversion in AS/400

5 pts.
Tags:
Alphanumeric conversion
AS/400 numeric fields
Conversion functions
Probably a simple question: I have a numeric field, 14 decimal positions, and i want to copy this value to a character field of 14 positions, and keep the leading (left) zeroes in place. How do I do so in free-form coding?

Software/Hardware used:
rpg iv, AS400

Answer Wiki

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

Alpha = %Editc(numeric : ‘3’);
That should do it for you.

Discuss This Question: 2  Replies

 
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
  • philpl1jb
    Try Alpha = %Editc(numeric : 'X'); This will give you leading zero's, no comma's, no decimal point, no sign. Phil
    51,365 pointsBadges:
    report
  • TomLiotta
    Also, a character variable and a zoned-decimal variable can occupy the same memory. Just EVAL the zoned field to the numeric value, and the character field will automatically become the character value of the digits. The best method might depend on whether or not editing characters are needed, fractional positions exist or negative values will be present. But those should also be considered for other methods because the character length might need adjustment. A redefinition is probably fastest if performance is critical. Tom
    125,585 pointsBadges:
    report

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