cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
Read only

create dynamically a type containing an include type

marco_sposa
Participant
0 Likes
3,322

Hello Expert,

i've generated a class with the scdo transaction insert changes in z tables in CDHR/POS.

looking into that class the write method, one of the paramter type is 

  types:
     BEGIN OF TY_ZTEST_123 .
      INCLUDE TYPE ZTEST_ABC.
      INCLUDE TYPE IF_CHDO_OBJECT_TOOLS_REL=>TY_ICDIND.
 TYPES END OF TY_ZTEST_123 .

Since they are many tables to manage, and the class name, class method generated by the system has exactly the same parameters ( on the name of the parameters changes but not the type : 

allways the table structure +  include type if+chdo_object_tools_rel=>ty_icdind.

i wanted to create a function module to class the appropriate method by passing the table name, the internal table for the class to recieve.

how should i build the internal class dynamically to have this kind of type?

 

  types:
     BEGIN OF TY_ZTEST_123 .
      INCLUDE TYPE ZTEST_ABC.
      INCLUDE TYPE IF_CHDO_OBJECT_TOOLS_REL=>TY_ICDIND.
 TYPES END OF TY_ZTEST_123 .

 

 

i try by creating a dynamic table like this

 

 

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name       = p_name
    CHANGING
      ct_fieldcat            = p_fieldcat
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.

  CLEAR ls_fieldcat.
  ls_fieldcat-fieldname = 'kz'.
  ls_fieldcat-datatype  = 'CHAR'.
  ls_fieldcat-intlen    = '1'.
  ls_fieldcat-domname   = 'CDCHNGIND'.
  ls_fieldcat-ref_table = 'ICDIND'.
  APPEND ls_fieldcat TO p_fieldcat.

 

 

and

 

 

* Create dynamic internal table and assign to FS
  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog  = lt_fieldcat
      i_length_in_byte = 'X'
    IMPORTING
      ep_table         = dy_table_new.

  ASSIGN dy_table_new->* TO <dyn_table_updt_new>.

 

 

but when i call the method dynamically the  the method i have an illegal cx_sy_dyn_call_error for the <dyn_table_updt_new> as the method parameter expected a table of tt_ztest123 defined as table of ty_ztest_123 . 

How could i solve this?

Thank you in advance

 

 

View Entire Topic
marco_sposa
Participant
0 Likes

Hello Sandra and thanks for your reply, i'm trying to create a type table dynamically i will definitively read the link you gave me.

Thanks