Skip to Content
0
Jul 29, 2020 at 04:34 PM

how to declare a fully typed field-symbol based on TYPE REF TO DATA parameter ?

86 Views Last edit Jul 29, 2020 at 04:56 PM 3 rev

Hi Folks, this is driving me crazy, can someone enlight me.

I have this code

Definition

Class-Methods: validate_data IMPORTING t_data TYPE REF TO DATA.

Implementation

METHOD validate.
  TYPES: type_ztabname TYPE TABLE OF ztabname.
  FIELD-SYMBOLS: <fully_typed_table> TYPE type_ztabname.
  ASSIGN t_data->* TO <fully_typed_table>.
* then it uses <fully_typed_table>-fieldname because the field-symbol is fully typed
* validations
ENDMETHOD.

This is in a class with lots of method just like this one (one for each table they want to validate)

I want to change it and make it better creating a subclass for each table than inherit from an Asbtract class where I pass the table name to the constructor and in each method I can deal with the data without having to repeat the table again .

The problem is that I can't find a way to have a fully type <fs_table> in the method without defineing the type in the same scope. I know the tablename (I pass it to the constructor) I don't want in each method declare the type with again the same table name. But also I need the <fully_typed_table> to be fully typed. I cant change all the <fully_typed_table>-fieldname.

FIELD-SYMBOLS: <fully_typed_table> TYPE (me->table_type). "me->table_type = 'ZTABNAME' 

Is there a way to do this ?

Thanks