Ask the Expert

Removing a comma from an alpha field

Is there a built in function available that allows me to remove a comma from an alpha field so I can move the field value to a numeric field. For example, the alpha field is 10 characters long and has a value of 1,000,000. I need it to look like this: 1000000. Any suggestions would be greatly appreciated.
Use the %DEC BIF with translation to convert the string to a packed number after converting the commas to blanks. The following example is from the WebSphere(R) Development Studio ILE RPG Reference at the IBM Web site and handles the currency symbol $ and the cheque protect symbol * as well as the thousands separator:

D data            s             20a   inz('$1,234,567.89')
D num             s             21p 9 

Eval  num = %dec(%xlate('$*,' : '   ' : data) : 21 : 9) 


The Best Web Links: tips, tutorials and more.

Visit the ITKnowledge Exchange and get answers to your developing questions fast.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

This was first published in November 2004

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

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
Sort by: OldestNewest

Forgot Password?

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

Your password has been sent to: