Dear All,
am getting this error message for this coding, can you pls. advise.
The result type of the functional method cannot be converted into the type of TABLE_DESCR.
Kind regards thanks in advanceAlexCLASS lcl_debugger_script DEFINITION*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_debugger_script DEFINITION INHERITING FROM cl_tpda_script_class_super .
PUBLIC SECTION.
METHODS: prologue REDEFINITION,
init REDEFINITION,
script REDEFINITION,
end REDEFINITION.
PRIVATE SECTION.
* Example types for the data to be extracted and displayed
TYPES ty_amount(16) TYPE p DECIMALS 2.
TYPES:
BEGIN OF ty_customer,
name TYPE string,
street TYPE string,
city TYPE string,
accountno TYPE string,
accountbalance TYPE ty_amount,
END OF ty_customer.
DATA it_customer_info TYPE STANDARD TABLE OF ty_customer.
DATA tablename TYPE string.
ENDCLASS. "lcl_debugger_script DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_debugger_script IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_debugger_script IMPLEMENTATION.
METHOD prologue.
* generate abap_source (source handler for ABAP)
super->prologue( ).
ENDMETHOD. "prolog
METHOD init.
* Name of a table containing customer representations in ABAP objects
tablename = 'SFLIGHT'.
ENDMETHOD. "init
METHOD script.
* Variables for metadata on the table from which data is to be
* extracted in the program that is being debugged.
DATA: table_descr TYPE REF TO cl_tpda_script_tabledescr,
content TYPE tpda_scr_table_content_it ,
table_clone TYPE REF TO data,
l_cols_it TYPE tpda_scr_table_comp_it,
l_col_alv_it TYPE tpda_script_service_source_tab,
l_col_alv LIKE LINE OF l_col_alv_it,
l_off TYPE i.
FIELD-SYMBOLS: <table_clone> TYPE table.
FIELD-SYMBOLS: <l_col> LIKE LINE OF l_cols_it.
FIELD-SYMBOLS: <l_comp> TYPE any.
FIELD-SYMBOLS: <l_clone> TYPE any.
DATA l_comp_long TYPE string.
DATA wa_customer TYPE ty_customer.
* Obtain the table metadata via the script reflection interface, available
* in Script Wizard functions.
* First get a handle for accessing the table from the script.
****************************************************************
*Interface (CLASS = CL_TPDA_SCRIPT_DATA_DESCR / METHOD = FACTORY )
*Importing
* REFERENCE( P_VAR_NAME ) TYPE TPDA_VAR_NAME
*Returning
* VALUE( P_DATADESCR ) TYPE REF TO CL_TPDA_SCRIPT_DATA_DESCR
****************************************************************
table_descr = cl_tpda_script_data_descr=>factory(
p_var_name = tablename ).
* Clone the customer object table from the debugged program into the script session
****************************************************************
*Interface (CLASS = CL_TPDA_SCRIPT_TABLEDESCR / METHOD = ELEM_CLONE )
*Importing
* REFERENCE( P_KEYS ) TYPE TPDA_TABLE_VIEW_KEY_COLS_IT OPTIONAL
* REFERENCE( P_UNIQUE ) TYPE FLAG OPTIONAL
* REFERENCE( P_TABLE_KIND ) TYPE I OPTIONAL
* REFERENCE( P_STRING_CLONE ) TYPE FLAG OPTIONAL
*Returning
* VALUE( P_REF_CLONE ) TYPE REF TO DATA OPTIONAL
****************************************************************
table_clone = table_descr->elem_clone( ).
ASSIGN table_clone->* TO <table_clone>.
* Loop through the customer objects and construct the attribute names needed by
* the get_simple_value method of cl_tpda_script_data_descr.
LOOP AT <table_clone> ASSIGNING <l_clone>.
CLEAR wa_customer.
ASSIGN COMPONENT 2 OF STRUCTURE <l_clone> TO <l_comp>.
IF sy-subrc = 0.
FIND '{' IN <l_comp> MATCH OFFSET l_off.
IF sy-subrc = 0.
<l_comp> = <l_comp>+l_off(*).
ELSE.
RAISE EXCEPTION TYPE cx_tpda_varname.
ENDIF.
* Get values from object references using a short form of the
* script wizard function 'Variable value (for simple variables)
CONCATENATE <l_comp> '-ADDRESS-CARRID' INTO l_comp_long.
wa_customer-name = cl_tpda_script_data_descr=>get_simple_value(
p_var_name = l_comp_long ).
CONCATENATE <l_comp> '-ADDRESS-CONNID' INTO l_comp_long.
wa_customer-street = cl_tpda_script_data_descr=>get_simple_value(
p_var_name = l_comp_long ).
CONCATENATE <l_comp> '-ADDRESS-FLDATE' INTO l_comp_long.
wa_customer-city = cl_tpda_script_data_descr=>get_simple_value(
p_var_name = l_comp_long ).
CONCATENATE <l_comp> '-ACCOUNT->PRICE' INTO l_comp_long.
wa_customer-accountno = cl_tpda_script_data_descr=>get_simple_value(
p_var_name = l_comp_long ).
CONCATENATE <l_comp> '-ACCOUNT->PLANETYPE' INTO l_comp_long.
wa_customer-accountbalance = cl_tpda_script_data_descr=>get_simple_value(
p_var_name = l_comp_long ).
APPEND wa_customer TO it_customer_info.
ENDIF.
ENDLOOP.
* Set up the ALV table for displaying the data.
CLEAR l_col_alv_it.
l_col_alv-fieldname = l_col_alv-content = 'CARRID'.
APPEND l_col_alv TO l_col_alv_it.
l_col_alv-fieldname = l_col_alv-content = 'CONNID'.
APPEND l_col_alv TO l_col_alv_it.
l_col_alv-fieldname = l_col_alv-content = 'FLDATE'.
APPEND l_col_alv TO l_col_alv_it.
l_col_alv-fieldname = l_col_alv-content = 'PRICE'.
APPEND l_col_alv TO l_col_alv_it.
l_col_alv-fieldname = l_col_alv-content = 'PLANETYPE'.
APPEND l_col_alv TO l_col_alv_it.
* Give the data to the script wizard ALV function for display
****************************************************************
*Interface (CLASS = CL_TPDA_SCRIPT_DATA_DISPLAY / METHOD = DATA_DISPLAY )
*Importing
* REFERENCE( P_SET_POPUP ) TYPE TPDA_SCRIPT_SET_SCREEN_POPUP OPTIONAL
* REFERENCE( P_LIST_HEADER ) TYPE LVC_TITLE OPTIONAL
* REFERENCE( P_COLUMN_IT ) TYPE TPDA_SCRIPT_SERVICE_SOURCE_TAB OPTIONAL
* REFERENCE( P_POPUP ) TYPE FLAG OPTIONAL
*Changing
* REFERENCE( P_DATA_IT ) TYPE ANY TABLE OPTIONAL
****************************************************************
cl_tpda_script_data_display=>data_display(
p_column_it = l_col_alv_it
p_data_it = it_customer_info ).
ENDMETHOD. "script
ENDCLASS. "lcl_debugger_script IMPLEMENTATION
↧
cannot be converted into the type of TABLE_DESCR
↧