I am learning ABAP Objects. I'd like to have an object method returning packed number type. I've made that working finally, but I don't know if it is the correct way and I'd need some further explanation which I can't find online.
For integer, it works fine:
METHODS: getamount RETURNING VALUE(r) TYPE i,
For packed number it doesn't:
METHODS: getamount RETURNING VALUE(r) TYPE p,
Error: The type of RETURNING parameter must be fully specified
METHODS: getamount RETURNING VALUE(r) TYPE p LENGTH 10 DECIMALS 3,
Error: The type of RETURNING parameter must be fully specified
(1) Is there way to make it work with p
type?
I made it work by using dec5_2
:
getamount RETURNING VALUE(r) TYPE dec5_2
(2) Is it the correct alternative? Is there a list of similar types?
Also, I found this solution, but it doesn't work for me:
CLASS lcl_rowinvoice DEFINITION.
PUBLIC SECTION.
METHODS:
getamount RETURNING VALUE(r) TYPE typeprice,
PRIVATE SECTION.
TYPES:
typeprice TYPE p LENGTH 10 DECIMALS 2,
Unknown type "TYPEPRICE".
(3) Is there way to make this solution to work?
Returning parameters have to be fully typed, p is a generic type, so you have three options:
METHODS getamount RETURNING value(r) TYPE netwr.
TYPES: lty_p TYPE p LENGTH 15 DECIMALS 2.
METHODS getamount RETURNING value(r) TYPE lty_p.
METHODS getamount RETURNING value(r) TYPE decfloat16.