Q

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) 

==================================
MORE INFORMATION ON THIS TOPIC
==================================

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 last published in November 2004

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

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

Please create a username to comment.

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close