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

Dynamic table runtime error

Former Member
0 Likes
2,529

Hi everyone.

We are working on upgrading from 4.6c to ECC 6.0 and I've run into a programming problem.

I have a class that I use to convert any internal table based on a dictionary structure to a comma-separated text file. For the most part, I use the dynamic table techniques that are easy to find here and in other code forums.

In 6.0 I can not get it to work. The value assignment of the input table to the field-symbol for the dynamic table causes a "OBJECTS_TABLES_NOT_COMPATIBLE" runtime error. So far what I can find on this error specific to dynamic tables is related to BW and/or PI. And I can't seem to find any alternative ways of dealing with dynamic tables. In debug I can see that decimal number fields in the dynamic table have a different length than what's in the dictionary.

Any help or ideas would be greately appreciated.

Here is part of the method that converts the itab to an dynamic internal table, then creates a csv record for each record (I've hilighted the line that causes the dump) :

  • Get the structure of the table.

ref_table_des ?=

cl_abap_typedescr=>describe_by_name( i_structure ).

idetails[] = ref_table_des->components[].

loop at idetails into xdetails.

clear xfc.

xfc-fieldname = xdetails-name .

xfc-datatype = xdetails-type_kind.

xfc-inttype = xdetails-type_kind.

xfc-intlen = xdetails-length.

xfc-decimals = xdetails-decimals.

append xfc to ifc.

endloop.

  • Create dynamic internal table and assign to FS

call method cl_alv_table_create=>create_dynamic_table

exporting

it_fieldcatalog = ifc

importing

ep_table = dy_table.

assign dy_table->* to <dyn_table>.

  • Create dynamic work area and assign to FS

create data dy_line like line of <dyn_table>.

assign dy_line->* to <dyn_wa>.

  • put data into the dynamic table

<dyn_table> = it_data[]. "<<==the runtime error happens on this line

loop at <dyn_table> into <dyn_wa>.

clear: l_fdata, l_data.

do.

l_index = sy-index.

assign component l_index

of structure <dyn_wa> to <dyn_field>.

if sy-subrc <> 0.

exit.

endif.

read table ifc into xfc index l_index.

if xfc-inttype = 'D'.

*etc...

Thank you,

- George

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,798

Even i faced some similar decimal issues problems while using cl_alv_table_create=>create_dynamic_table

can you change it like this


data:wf_data TYPE REF TO data,
     wf_str TYPE REF TO data,
     i_comp TYPE cl_abap_structdescr=>component_table,
     lf_struct TYPE REF TO cl_abap_structdescr,
     lf_new_type TYPE REF TO cl_abap_structdescr,
     lf_new_tab TYPE REF TO cl_abap_tabledescr.

FIELD-SYMBOLS:<fs_tab> TYPE STANDARD TABLE,
              <fs_line> TYPE ANY.

  lf_struct ?= cl_abap_typedescr=>describe_by_name( i_structure ).
  i_comp = lf_struct->get_components( ).


  TRY.
      lf_new_type = cl_abap_structdescr=>create( i_comp ).
    CATCH cx_sy_struct_creation .                       "#EC NO_HANDLER
  ENDTRY.

  TRY.
      lf_new_tab =
      cl_abap_tabledescr=>create( p_line_type = lf_new_type
      p_table_kind = cl_abap_tabledescr=>tablekind_std p_unique = ' ' ).
    CATCH cx_sy_table_creation .                        "#EC NO_HANDLER
  ENDTRY.

  CREATE DATA wf_data TYPE HANDLE lf_new_tab.
  CREATE DATA wf_str TYPE HANDLE lf_new_type.

  ASSIGN wf_data->* TO <fs_tab>.
  ASSIGN wf_str->* TO <fs_line>.

6 REPLIES 6
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,798

Check for sap notes.

here is one 1225508

Is it_data compatible with the structure of dynamic internal table ?

Read only

0 Likes
1,798

No. That is exactly the issue. The definition of the dynamic internal table for certain kinds of columns (decimal numbers) is different than the one used to build it_data even though they are both using the same dictionary structure name.

Oh, and just incase I wasn't clear, this worked perfectly in 4.6c for any dictionary defined structure. This error is occuring in ECC 6.0.

Thanks,

- George

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,799

Even i faced some similar decimal issues problems while using cl_alv_table_create=>create_dynamic_table

can you change it like this


data:wf_data TYPE REF TO data,
     wf_str TYPE REF TO data,
     i_comp TYPE cl_abap_structdescr=>component_table,
     lf_struct TYPE REF TO cl_abap_structdescr,
     lf_new_type TYPE REF TO cl_abap_structdescr,
     lf_new_tab TYPE REF TO cl_abap_tabledescr.

FIELD-SYMBOLS:<fs_tab> TYPE STANDARD TABLE,
              <fs_line> TYPE ANY.

  lf_struct ?= cl_abap_typedescr=>describe_by_name( i_structure ).
  i_comp = lf_struct->get_components( ).


  TRY.
      lf_new_type = cl_abap_structdescr=>create( i_comp ).
    CATCH cx_sy_struct_creation .                       "#EC NO_HANDLER
  ENDTRY.

  TRY.
      lf_new_tab =
      cl_abap_tabledescr=>create( p_line_type = lf_new_type
      p_table_kind = cl_abap_tabledescr=>tablekind_std p_unique = ' ' ).
    CATCH cx_sy_table_creation .                        "#EC NO_HANDLER
  ENDTRY.

  CREATE DATA wf_data TYPE HANDLE lf_new_tab.
  CREATE DATA wf_str TYPE HANDLE lf_new_type.

  ASSIGN wf_data->* TO <fs_tab>.
  ASSIGN wf_str->* TO <fs_line>.

Read only

Former Member
0 Likes
1,798

Hi,

For Dynamic internal table.u check SM30 Transaction.ther is one simple way to find the code in debugging.

if not possible i will send code which is relatd to dynamic table .


 *&---------------------------------------------------------------------
*&      Form  get_table_structure
*&---------------------------------------------------------------------
*       Get structure of an SAP table
*----------------------------------------------------------------------*
form get_table_structure.
  data : it_tabdescr type abap_compdescr_tab,
         wa_tabdescr type abap_compdescr.
  data : ref_table_descr type ref to cl_abap_structdescr.

* Return structure of the table.
  ref_table_descr ?= cl_abap_typedescr=>describe_by_name( p_table ).
  it_tabdescr[] = ref_table_descr->components[].
  loop at it_tabdescr into wa_tabdescr.
    clear wa_fieldcat.
    wa_fieldcat-fieldname = wa_tabdescr-name .
    wa_fieldcat-datatype  = wa_tabdescr-type_kind.
    wa_fieldcat-inttype   = wa_tabdescr-type_kind.
    wa_fieldcat-intlen    = wa_tabdescr-length.
    wa_fieldcat-decimals  = wa_tabdescr-decimals.
    append wa_fieldcat to it_fieldcat.
  endloop.

endform.                    "get_table_structure

  


*&---------------------------------------------------------------------
*&      Form  create_itab_dynamically
*&---------------------------------------------------------------------
*   Create internal table dynamically
*----------------------------------------------------------------------*
form create_itab_dynamically.
* Create dynamic internal table and assign to Field-Symbol
  call method cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = it_fieldcat
    IMPORTING
      ep_table        = dyn_table.
  assign dyn_table->* to <fs_table>.
* Create dynamic work area and assign to Field Symbol
  create data dyn_line like line of <fs_table>.
  assign dyn_line->* to <fs_wa>.
endform.                    "create_itab_dynamically

Edited by: subrahmanyam24 on Nov 18, 2010 5:12 AM

Edited by: subrahmanyam24 on Nov 18, 2010 5:15 AM

Read only

Former Member
0 Likes
1,798

DATA: field(10) TYPE C.
 
FIELD-SYMBOLS: <fs_from>,  <fs_to>.

UNASSIGN:  <fs_from>,
                    <fs_to>.
 
LOOP AT it_data.  
+add code to populate field+   
    ASSINGN COMPONENT field OF STRUCTURE it_data TO <fs_from>.
    ASSINGN COMPONENT field OF STRUCTURE <dyn_wa> TO <fs_to>.
    <fs_to> = <fs_from>.
   APPEND  <dyn_wa> TO <dyn_table>.
ENDLOOP.
Read only

Former Member
0 Likes
1,798

Thanks for the ideas. I fixed this by creating a data object directly from the structure name of the input internal table and looping on the fields, transferring them individually to the dynamic table:

* Create dynamic work area and assign to FS
  create data dy_line like line of <dyn_table>.
  assign dy_line->* to <dyn_wa>.

* put data into the dynamic table
*  <dyn_table> = it_data[].    <<==== this was causing the error
  create data ls_data type (i_structure).
  loop at it_data reference into ls_data.
    assign ls_data->* to <input_sdata>.
    do.
      l_index = sy-index.
      assign component l_index of structure <input_sdata> to <input_fdata>.
      assign component l_index of structure <dyn_wa> to <dyn_fdata>.
      if sy-subrc ne 0.
        exit.
      endif.
      <dyn_fdata> = <input_fdata>.
    enddo.
    append <dyn_wa> to <dyn_table>.
  endloop.

* now loop at the dynamic table to build .csv output
  loop at <dyn_table> into <dyn_wa>.
    clear: l_fdata, l_data.
    do.
      l_index = sy-index.

etc...