2014 Apr 02 1:47 PM
Hi all,
In java, when we have a parameter/variable of a generic type, we can use the "type of" to check what is the correct type to make some attribution.
In abap, i have a function with generic table parameter, and in the function i want to check about what structure is the referencing parameter.
Somebody know how to check it?
Best regards,
Gustavo
2014 Apr 02 4:10 PM
Thanks to all, with the cl_abap_tabledescr i did it.
Regards,
Gustavo
2014 Apr 02 2:00 PM
Hi Gustavo,
you can find out using Field symbols.
1. Declare variable field-symbols : <fs_struct> type any.
2. Get reference of the Table parameter and assign to field symbol declared above.
ex: lt_table is table parameter then
ASSIGN lt_table->* TO <fs_struct>.
Now fs_struct will be pointing to structure of the Lt_table. Check structure in debug mode for more detail.
Regards,
Ravikiran.K
2014 Apr 02 2:00 PM
2014 Apr 02 2:18 PM
Well,
The real situation is:
FM Table parameter:
IT_GEN TYPE STANDARD TABLE.
This IT_GEN can be structure ST_INVOICE or ST_SALESORD.
When the FM is called, i have to check about what structure is the parameter.
Thanks,
Gustavo
2014 Apr 02 2:25 PM
Hi Gustavo,
check this code:
DATA: lcl_typedescr TYPE REF TO cl_abap_typedescr,
lva_absolute_name TYPE abap_abstypename.
lcl_typedescr = cl_abap_typedescr=>describe_by_data( IT_GEN ).
lva_absolute_name = lcl_typedescr->absolute_name.
Regards,
Angelo.
2014 Apr 02 2:21 PM
2014 Apr 02 4:10 PM
Thanks to all, with the cl_abap_tabledescr i did it.
Regards,
Gustavo