Using ABAP, is there a simple way to convert a floating point number to a packed field?
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
You just assign the type f field to a type p field. You must specify the number of decimal places and the size of the packed field, and you should cater to overflows. Take a look at this example:
DATA: p TYPE p(12) DECIMALS 4, f TYPE f. ... TRY. p = f. CATCH cx_sy_conversion_overflow. WRITE:/ 'Overflow'. ENDTRY. WRITE: f,p.
Note that calculations involving type p fields are slower than those using type f and type i, so take care when working on these type of fields.
Dig Deeper on SAP ABAP
Related Q&A from Matthew Billingham
An SAP user is trying to run a report in an SAP ALV Grid online and wants to know how to get the data in the report to appear along with the header.continue reading
An SAP user needs information on how to change the password on several SAP user accounts from a central location.continue reading
An SAP user needs to transfer customer purchase order spreadsheet data to SAP VA01 to create a new sales order.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.