Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Type conflict in a function module call when I use RTTS

0 Likes
5,589

Hi Experts

Just encountered a strange issue that I use RTTS created a dynamic internal table as a parameter of function module, but I got a runtime error ‘Type conflict in a function module call’ when I execute it. But I compared it in the debug, the same field quantity, same field type and same field length. I think maybe problem is, that referenced structure have many include structure and append structure, it’s just guess, but not sure.

Do you have any idea for this situation?

CONSTANTS:

lc_fm_name TYPE rs38l-name VALUE '/NSL/ABP_SVC_POLICY_RETRIEVE'.

DATA:  gt_abwacov   TYPE REF TO data.

FIELD-SYMBOLS:

  <ft_abwacov>   TYPE STANDARD TABLE.

DATA:

  l_tab_exception_list TYPE STANDARD TABLE OF rsexc,

  l_tab_export_param   TYPE STANDARD TABLE OF rsexp,

  l_tab_import_param   TYPE STANDARD TABLE OF rsimp,

  l_tab_tables_param   TYPE STANDARD TABLE OF rstbl.

DATA:

  l_tab_dfies     TYPE TABLE OF dfies,

  lv_tabname      TYPE typename,

  l_tab_comp      TYPE cl_abap_structdescr=>component_table,

  ls_comp         LIKE LINE OF  l_tab_comp,

  l_ref_typedescr TYPE REF TO   cl_abap_typedescr,

  lv_length       TYPE          i,

  lv_decimals     TYPE          i.

DATA:

  l_ref_type_struct TYPE REF TO cl_abap_structdescr,

  l_ref_type_table  TYPE REF TO cl_abap_tabledescr,

  l_ref_data_str    TYPE REF TO data,

  l_ref_data_tab    TYPE REF TO data.

DATA:

  lv_msg_text     TYPE dmc_rfc_error_msg.

FIELD-SYMBOLS:

  <l_wa_tables_param> LIKE LINE OF l_tab_tables_param,

  <l_wa_dfies>        LIKE LINE OF l_tab_dfies.

* Get BAPI interface of function /BA1/BAPI_FIN_TRANS_MODIFY from IA system

CALL FUNCTION 'FUNCTION_IMPORT_INTERFACE'

*  DESTINATION iv_rfc_receiver

  EXPORTING

    funcname              = lc_fm_name

  TABLES

    exception_list        = l_tab_exception_list[]

    export_parameter      = l_tab_export_param[]

    import_parameter      = l_tab_import_param[]

    tables_parameter      = l_tab_tables_param[]

  EXCEPTIONS

    error_message         = 1

    function_not_found    = 2

    invalid_name          = 3

    communication_failure = 12

    system_failure        = 16.

LOOP AT l_tab_tables_param[] ASSIGNING <l_wa_tables_param>

  WHERE parameter = 'ET_ABWACOV'.

  CLEAR:

  l_tab_dfies[],

  lv_tabname,

  l_tab_comp[].

  FREE:

  l_ref_data_tab,

  l_ref_data_str.

  IF <l_wa_tables_param>-dbstruct IS NOT INITIAL.

    lv_tabname = <l_wa_tables_param>-dbstruct.

  ELSE.

    lv_tabname = <l_wa_tables_param>-typ.

  ENDIF.

  "Get field info for table type

  CALL FUNCTION 'DDIF_FIELDINFO_GET'

    EXPORTING

      tabname        = '/PM0/ABWACOV'

      all_types      = 'X'

    TABLES

      dfies_tab      = l_tab_dfies[]

    EXCEPTIONS

      not_found      = 1

      internal_error = 2

      OTHERS         = 3.

  LOOP AT l_tab_dfies[] ASSIGNING <l_wa_dfies>.

* TODO: what about deep structures?

    CLEAR ls_comp.

    ls_comp-name = <l_wa_dfies>-fieldname.

    CASE <l_wa_dfies>-inttype.

      WHEN 'C'.

        lv_length = <l_wa_dfies>-leng.

        TRY.

            ls_comp-type ?= cl_abap_elemdescr=>get_c( p_length = lv_length ).

          CATCH cx_parameter_invalid_range.

* TODO: error handling

        ENDTRY.

      WHEN 'D'.

        ls_comp-type ?= cl_abap_elemdescr=>get_d( ).

      WHEN 'I'.

        ls_comp-type ?= cl_abap_elemdescr=>get_i( ).

      WHEN 'N'.

        lv_length = <l_wa_dfies>-leng.

        TRY.

            ls_comp-type ?= cl_abap_elemdescr=>get_n( p_length = lv_length ).

          CATCH cx_parameter_invalid_range.

* TODO: error handling

        ENDTRY.

      WHEN 'T'.

        ls_comp-type ?= cl_abap_elemdescr=>get_t( ).

      WHEN 's' OR 'b'.

        CALL METHOD cl_abap_elemdescr=>describe_by_name

          EXPORTING

            p_name         = <l_wa_dfies>-datatype

          RECEIVING

            p_descr_ref    = l_ref_typedescr

          EXCEPTIONS

            type_not_found = 1

            OTHERS         = 2.

        IF sy-subrc = 0.

          ls_comp-type ?= l_ref_typedescr.

        ELSE.

* TODO: error handling

        ENDIF.

      WHEN 'P'.

        lv_length = <l_wa_dfies>-intlen.

        lv_decimals = <l_wa_dfies>-decimals.

        TRY.

            ls_comp-type ?= cl_abap_elemdescr=>get_p( p_length   = lv_length

p_decimals = lv_decimals ).

          CATCH cx_parameter_invalid_range.

* TODO: error handling

        ENDTRY.

      WHEN OTHERS.

* TODO: error handling

        ASSERT 1 = 2.

    ENDCASE.

    APPEND ls_comp TO l_tab_comp[].

  ENDLOOP.

  CHECK l_tab_comp IS NOT INITIAL.

  TRY.

      l_ref_type_struct = cl_abap_structdescr=>create( p_components = l_tab_comp[] ).

    CATCH cx_sy_struct_creation.

* TODO: error handling

      ASSERT 1 = 2.

  ENDTRY.

  CREATE DATA:

       l_ref_data_str TYPE HANDLE l_ref_type_struct.

  TRY.

      l_ref_type_table = cl_abap_tabledescr=>create( l_ref_type_struct ).

    CATCH cx_sy_table_creation.

* TODO: error handling

      ASSERT 1 = 2.

  ENDTRY.

  CREATE DATA:

        l_ref_data_tab TYPE HANDLE l_ref_type_table.

  IF gt_abwacov IS INITIAL.

    CREATE DATA :

          gt_abwacov         LIKE l_ref_data_tab.

  ENDIF.

  CASE <l_wa_tables_param>-parameter.

    WHEN 'ET_ABWACOV'.

      gt_abwacov = l_ref_data_tab.

    WHEN OTHERS.

* Nothing to do. We just skip unused table parameteres

  ENDCASE.

  1. ENDLOOP.

ASSIGN:

  gt_abwacov->*   TO <ft_abwacov>.

DATA:

  gv_policynr TYPE /pm0/abd_prop_policynr.

gv_policynr = '10000000000044309'.

CALL FUNCTION '/NSL/ABP_SVC_POLICY_RETRIEVE'

  EXPORTING

    im_policynr     = gv_policynr

    im_effective_dt = '20150101'

  TABLES

    et_abwacov      = <ft_abwacov>.

IF sy-subrc EQ 0.

  1. ENDIF.

Hi Experts

Just encountered a strange issue that I use RTTS created a dynamic internal table as a parameter of function module, but I got a runtime error ‘Type conflict in a function module call’ when I execute it. But I compared it in the debug, the same field quantity, same field type and same field length. I think maybe problem is, that referenced structure have many include structure and append structure, it’s just guess, but not sure.

Do you have any idea for this situation?

CONSTANTS:

lc_fm_name TYPE rs38l-name VALUE '/NSL/ABP_SVC_POLICY_RETRIEVE'.

DATA:  gt_abwacov   TYPE REF TO data.

FIELD-SYMBOLS:

  <ft_abwacov>   TYPE STANDARD TABLE.

DATA:

  l_tab_exception_list TYPE STANDARD TABLE OF rsexc,

  l_tab_export_param   TYPE STANDARD TABLE OF rsexp,

  l_tab_import_param   TYPE STANDARD TABLE OF rsimp,

  l_tab_tables_param   TYPE STANDARD TABLE OF rstbl.

DATA:

  l_tab_dfies     TYPE TABLE OF dfies,

  lv_tabname      TYPE typename,

  l_tab_comp      TYPE cl_abap_structdescr=>component_table,

  ls_comp         LIKE LINE OF  l_tab_comp,

  l_ref_typedescr TYPE REF TO   cl_abap_typedescr,

  lv_length       TYPE          i,

  lv_decimals     TYPE          i.

DATA:

  l_ref_type_struct TYPE REF TO cl_abap_structdescr,

  l_ref_type_table  TYPE REF TO cl_abap_tabledescr,

  l_ref_data_str    TYPE REF TO data,

  l_ref_data_tab    TYPE REF TO data.

DATA:

  lv_msg_text     TYPE dmc_rfc_error_msg.

FIELD-SYMBOLS:

  <l_wa_tables_param> LIKE LINE OF l_tab_tables_param,

  <l_wa_dfies>        LIKE LINE OF l_tab_dfies.

* Get BAPI interface of function /BA1/BAPI_FIN_TRANS_MODIFY from IA system

CALL FUNCTION 'FUNCTION_IMPORT_INTERFACE'

*  DESTINATION iv_rfc_receiver

  EXPORTING

    funcname              = lc_fm_name

  TABLES

    exception_list        = l_tab_exception_list[]

    export_parameter      = l_tab_export_param[]

    import_parameter      = l_tab_import_param[]

    tables_parameter      = l_tab_tables_param[]

  EXCEPTIONS

    error_message         = 1

    function_not_found    = 2

    invalid_name          = 3

    communication_failure = 12

    system_failure        = 16.

LOOP AT l_tab_tables_param[] ASSIGNING <l_wa_tables_param>

  WHERE parameter = 'ET_ABWACOV'.

  CLEAR:

  l_tab_dfies[],

  lv_tabname,

  l_tab_comp[].

  FREE:

  l_ref_data_tab,

  l_ref_data_str.

  IF <l_wa_tables_param>-dbstruct IS NOT INITIAL.

    lv_tabname = <l_wa_tables_param>-dbstruct.

  ELSE.

    lv_tabname = <l_wa_tables_param>-typ.

  ENDIF.

  "Get field info for table type

  CALL FUNCTION 'DDIF_FIELDINFO_GET'

    EXPORTING

      tabname        = '/PM0/ABWACOV'

      all_types      = 'X'

    TABLES

      dfies_tab      = l_tab_dfies[]

    EXCEPTIONS

      not_found      = 1

      internal_error = 2

      OTHERS         = 3.

  LOOP AT l_tab_dfies[] ASSIGNING <l_wa_dfies>.

* TODO: what about deep structures?

    CLEAR ls_comp.

    ls_comp-name = <l_wa_dfies>-fieldname.

    CASE <l_wa_dfies>-inttype.

      WHEN 'C'.

        lv_length = <l_wa_dfies>-leng.

        TRY.

            ls_comp-type ?= cl_abap_elemdescr=>get_c( p_length = lv_length ).

          CATCH cx_parameter_invalid_range.

* TODO: error handling

        ENDTRY.

      WHEN 'D'.

        ls_comp-type ?= cl_abap_elemdescr=>get_d( ).

      WHEN 'I'.

        ls_comp-type ?= cl_abap_elemdescr=>get_i( ).

      WHEN 'N'.

        lv_length = <l_wa_dfies>-leng.

        TRY.

            ls_comp-type ?= cl_abap_elemdescr=>get_n( p_length = lv_length ).

          CATCH cx_parameter_invalid_range.

* TODO: error handling

        ENDTRY.

      WHEN 'T'.

        ls_comp-type ?= cl_abap_elemdescr=>get_t( ).

      WHEN 's' OR 'b'.

        CALL METHOD cl_abap_elemdescr=>describe_by_name

          EXPORTING

            p_name         = <l_wa_dfies>-datatype

          RECEIVING

            p_descr_ref    = l_ref_typedescr

          EXCEPTIONS

            type_not_found = 1

            OTHERS         = 2.

        IF sy-subrc = 0.

          ls_comp-type ?= l_ref_typedescr.

        ELSE.

* TODO: error handling

        ENDIF.

      WHEN 'P'.

        lv_length = <l_wa_dfies>-intlen.

        lv_decimals = <l_wa_dfies>-decimals.

        TRY.

            ls_comp-type ?= cl_abap_elemdescr=>get_p( p_length   = lv_length

p_decimals = lv_decimals ).

          CATCH cx_parameter_invalid_range.

* TODO: error handling

        ENDTRY.

      WHEN OTHERS.

* TODO: error handling

        ASSERT 1 = 2.

    ENDCASE.

    APPEND ls_comp TO l_tab_comp[].

  ENDLOOP.

  CHECK l_tab_comp IS NOT INITIAL.

  TRY.

      l_ref_type_struct = cl_abap_structdescr=>create( p_components = l_tab_comp[] ).

    CATCH cx_sy_struct_creation.

* TODO: error handling

      ASSERT 1 = 2.

  ENDTRY.

  CREATE DATA:

       l_ref_data_str TYPE HANDLE l_ref_type_struct.

  TRY.

      l_ref_type_table = cl_abap_tabledescr=>create( l_ref_type_struct ).

    CATCH cx_sy_table_creation.

* TODO: error handling

      ASSERT 1 = 2.

  ENDTRY.

  CREATE DATA:

        l_ref_data_tab TYPE HANDLE l_ref_type_table.

  IF gt_abwacov IS INITIAL.

    CREATE DATA :

          gt_abwacov         LIKE l_ref_data_tab.

  ENDIF.

  CASE <l_wa_tables_param>-parameter.

    WHEN 'ET_ABWACOV'.

      gt_abwacov = l_ref_data_tab.

    WHEN OTHERS.

* Nothing to do. We just skip unused table parameteres

  ENDCASE.

  1. ENDLOOP.

ASSIGN:

  gt_abwacov->*   TO <ft_abwacov>.

DATA:

  gv_policynr TYPE /pm0/abd_prop_policynr.

gv_policynr = '10000000000044309'.

CALL FUNCTION '/NSL/ABP_SVC_POLICY_RETRIEVE'

  EXPORTING

    im_policynr     = gv_policynr

    im_effective_dt = '20150101'

  TABLES

    et_abwacov      = <ft_abwacov>.

IF sy-subrc EQ 0.

  1. ENDIF.
17 REPLIES 17
Read only

sanjeev_mishra_15aug
Active Participant
0 Likes
5,134

Hi,

use WHEN 'S' OR 'B'. instead of WHEN 's' OR 'b'.

Thanks

Sanjeev

Read only

0 Likes
5,134

Hi Mishra,

Thanks for your feedback. But actually, we have inttype 's' that INT2 and 'b' that INT1.

Read only

former_member197132
Participant
0 Likes
5,134

Hello Jack Li

Refer below code.

data : tab_name type standard table of DDOBJNAME value '/PM0/ABWACOV'.

  "Get field info for table type

  CALL FUNCTION 'DDIF_FIELDINFO_GET'

    EXPORTING

      tabname        = tab_name.

hope this would help.

Read only

0 Likes
5,134

Hi Karada,

The FM 'DDIF_FIELDINFO_GET' is no problem, the runtime error encountered in

CALL FUNCTION '/NSL/ABP_SVC_POLICY_RETRIEVE'

  EXPORTING

    im_policynr     = gv_policynr

    im_effective_dt = '20150101'

  TABLES

    et_abwacov      = <ft_abwacov>.

The root cause is type conflict between et_abwacov and <ft_abwacov>.

I guess whether need to handle the include structure/append structure for reference structure '/PM0/ABWACOV'(Please see the screen-shot in attachment)? If yes, how to handle it. Thanks.

Read only

ThomasKruegl
Participant
0 Likes
5,134

Hi Jack Li,

Maybe i miss what you are trying to achieve.

With

CREATE DATA:

        l_ref_data_tab TYPE HANDLE l_ref_type_table.

you finally want to have a variable of the same type as required? You just want to provide an empty table to the function module, with appropriate type? You can get such a table with

DATA: lr_dref TYPE REF TO data.

CREATE DATA lr_dref TYPE (lv_tabname).

ASSIGN lr_dref->* TO FIELD-SYMBOL(<lt_parameter>).

Why do you on the other hand create a structure explicitly from '/PM0/ABWACOV'? If you know that you want a table of that type, just use DATA: lt_abwacov TYPE /PM0/ABWACOV_T, and provide that instead of <ft_abwacov>.

kind regards,

Thomas

Read only

0 Likes
5,134

Hi Thomas,

My achieve is: want to have a same type of internal table with FM '/NSL/ABP_SVC_POLICY_RETRIEVE'.

In order to debug and check the issue, so I put the same code in this system. Actually I will call this FM in other system by RFC, you know, in other system, don't have /PM0/ABWACOV or /PM0/ABWACOV_T, so I have to create it dynamically.

Read only

0 Likes
5,134

Hi Jack,

I can test on a system where /pm0/ is available. So i copied all fields of that structure into a new structure, not using the includes in the original structure, but every field directly into the new structure.

A function module with that new structure as table parameter can be called with your code, so the problem is related to includes.

I did a bit more testing with a simplified example. A single include caused no problem, but when i tried a nested include, it dumped.

Unfortunately, i have no idea how to get around this using cl_abap_tabledescr=>create directly.

EDIT: I just saw ls_comp-as_include, with this flag it should be possible to provide includes to the create method. /EDIT

If you know what structures you will need, maybe you could create structures in your DDIC, rebuilding the include structure of /pm0/abwacov or other structures you need. Where available in your system, you can use the original data elements, when not you can create elements using suitable domains/data types.

Side note about  type P: Their origin are dictionary types CURR, DEC, and QUAN. to translate them to abap type P, the length has to be (dictionary type length + 1 ) / 2, which is the same as INTLEN, that's correct here.

regards,

Thomas

Read only

0 Likes
5,134

Hi Thomas,

Thank you very much for your information. I also guess this problem caused by many include structure/append structure, and we need to know how to handle include structure/append structure when create internal table dynamiclly using RTTS.

As you say, currently, my work around is create related structures in the remote system. But there are 50+ paramters of table in the function module, and many fields in each table, and customer often change the field of structure during the development phase, so I think the best practice is create all the internal table dynamiclly.

Read only

naimesh_patel
Active Contributor
0 Likes
5,134

I think you are taking incorrect Length. Instead of INTLENGTH, you need to use LENG.

Moreover, Instead of using the FM DDIF_FIELDINFO_GET, use the RTTS classes (CL_ABAP_TYPEDESCR) to get the field information.

Like what Thomas suggested in earlier reply, , you can try to use the structure directly to get the data object referenced to that structure.

Regards,
Naimesh Patel

Read only

0 Likes
5,134

Hi Patel,

Thanks for your update.

Sorry, I didn't get your mean, in the code, I used LENG, not INTLENGTY.

BTW, Actually, I will call this FM in other system by RFC, so I cannot use the structure directly to get the data object referenced to that structure. In here, just for debug and check the issue easier, then I put the code in same system.

Read only

0 Likes
5,134

Here you are using the INTLEN


      WHEN 'P'.

        lv_length = <l_wa_dfies>-intlen.                         "<<<<

        lv_decimals = <l_wa_dfies>-decimals.

Regards,

Naimesh Patel

Read only

0 Likes
5,134

Patel,

I tried to change intlen to leng for type P, but got the dump for Assert. So maybe use intlen for this type is correct.

Regards.

Read only

0 Likes
5,134

Hi,

Anyone have experience for handle nested include structure/append structure when create internal table dynamically using RTTS(like below picture)?

I have searched it in scn, but didn't find out this topic. If you have any idea, kindly please share it to me. Many thanks in advance!!

Read only

0 Likes
5,134

This sounds exactly like what you need:

Read only

0 Likes
5,134

Thomas, Thanks so much.

Read only

0 Likes
5,134

So did it work?

Read only

0 Likes
5,134

Not yet.