2016 Feb 01 7:14 AM
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.
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.
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.
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.
2016 Feb 01 7:22 AM
Hi,
use WHEN 'S' OR 'B'. instead of WHEN 's' OR 'b'.
Thanks
Sanjeev
2016 Feb 01 7:29 AM
Hi Mishra,
Thanks for your feedback. But actually, we have inttype 's' that INT2 and 'b' that INT1.
2016 Feb 01 7:34 AM
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.
2016 Feb 01 7:40 AM
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.
2016 Feb 01 5:12 PM
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
2016 Feb 02 2:04 AM
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.
2016 Feb 03 6:24 PM
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
2016 Feb 04 2:22 AM
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.
2016 Feb 01 8:16 PM
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
2016 Feb 02 2:34 AM
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.
2016 Feb 02 2:56 PM
Here you are using the INTLEN
WHEN 'P'.
lv_length = <l_wa_dfies>-intlen. "<<<<
lv_decimals = <l_wa_dfies>-decimals.
Regards,
Naimesh Patel
2016 Feb 02 4:12 PM
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.
2016 Feb 04 2:32 AM
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!!
2016 Feb 04 4:19 PM
2016 Feb 05 2:13 AM
2016 Feb 16 3:54 PM
2016 Feb 25 2:57 AM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |