How to fully specify the type of a returning parameter in method?
abap, parameters
Solution
Returning parameters are passed by the Value. In other words, when the method is being executed, you can always access the returning parameter but your callers can omit receiving the values from the method at all, but the method still has to use the parameter. That would be reason you need to specify fully TYPED type for returning.
As alternative, you can convert your table to Object reference and pass it back to the caller.
class lcl_Test DEFINITION.
PUBLIC SECTION.
methods: to_Table
returning value(ro_tab) type ref to data .
ENDCLASS.
*
class lcl_Test IMPLEMENTATION.
method to_Table.
ENDMETHOD.
ENDCLASS.
Regards,
Problem
I've got a method that imports a structure, creates an internal table out of the structure, and returns this table. I've implemented it as an exporting method, but now I want to do it as a returning parameter. Part of the idea is that I don't know anything about the structure being passed till runtime so I'm using a fair amount of generics. However, "Returning" methods don't like generics. ``` method Parameters: Importing struct_data TYPE any Returning table_data TYPE STANDARD TABLE method STRUCT_TO_TABLE_R. FIELD-SYMBOLS: <f_fs> TYPE any, <table> TYPE STANDARD TABLE . DO. ASSIGN COMPONENT sy-index OF STRUCTURE struct_data TO <f_fs>. IF NOT sy-subrc EQ 0. EXIT. ENDIF. APPEND <f_fs> TO <table>. ENDDO. table_data = <table>. endmethod. ``` what do I need to change to fix this?