Llamada dinámica de Métodos

 DATA: lv_class_name TYPE string,

      lv_method     TYPE string,

      l_cu          TYPE string VALUE 'PARAMETRO',

      lo_instance   TYPE REF TO object,

      lr_interface  TYPE REF TO if_message.


CONCATENATE 'ZLIN_CL_CU_' l_cu INTO lv_class_name.


TRY.

    CREATE OBJECT lo_instance TYPE (lv_class_name).

  CATCH cx_sy_create_object_error INTO DATA(lx_error).

    " Handle errors if the class does not exist or cannot be instantiated

    WRITE: / 'Error creating object:', lx_error->get_text( ).

  CATCH cx_sy_dyn_call_illegal_class INTO DATA(lx_illegal_class).

    " Handle errors for illegal class usage

    WRITE: / 'Illegal class:', lx_illegal_class->get_text( ).

ENDTRY.


TRY.

    lv_method = 'SEND_ONLINE'.

    CALL METHOD lo_instance->(lv_method)

      EXPORTING

        is_k_cu_x = ls_lin_k_cu_1

      IMPORTING

        es_r_cu_x = ls_lin_r_cu_1.

ENDTRY.