Ask the Expert

Converting amount fields

In layout - I need to pass an amount field (type curr) by perform command to do some calculations. The problem is that the field, as input parameter to the ABAP form, is of type c. how should I convert it to decimal for the calculations?


    Requires Free Membership to View

You can directly convert. The following code is perfectly valid, as long c_num is a valid representation of a decimal number. and the destination field is defined large enough to contain the source value, otherwise you will get a runtime error.

Data: c_num(16) value '123.45', f_num type f, p_num type p decimals 2. p_num = c_num. f_num = c_num.

Determining that c_num is a valid representation of a decimal number is not always trivial. For your case, using Perform from a layout set, you probably won't have to worry about this - i.e. the field will always be valid, or initial.


This was first published in June 2001

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: