‎2012 Jun 26 1:06 AM
Hi All
I am trying to create a method that will automatically create a field catalog based on INTERNAL TABLE input. I have found the following for determining components within a database structure. I am wondering if there is a equivalent for internal tables?
Does anyone know if there is a function/method available to automatically create a field catalog based on lvc_t_fcat? Yes I know there is the REUSE_ALV_FIELDCATALOG_MERGE but this only works for FM ALV. I have thought about wrapping this function but would prefer to do it the 'tricky' way.
DATA table_descr TYPE REF TO cl_abap_tabledescr.
DATA struct_descr TYPE REF TO cl_abap_structdescr.
DATA columns TYPE abap_compdescr_tab.
table_descr ?= cl_abap_typedescr=>describe_by_data( itab ).
struct_descr ?= table_descr->get_table_line_type( ).
columns = struct_descr->components.
‎2012 Jun 26 4:37 AM
Hi Brad,
What you have written above will work well for determining the components of an Internal table.
If what you need is to create a LVC fieldcatalog from an Internal table, you can go through this link.
Use LVC_TRANSFER_FROM_SLIS after using REUSE_ALV_FIELDCATALOG_MERGE to convert.
Thanks,
Shambu
‎2012 Jun 26 6:23 AM
HI Brad ,
Have a look on following code , this may help you :
*&---------------------------------------------------------------------*
*& Form get_lvc_t_fcat_4_itab
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->IT_TABLE text
* -->RT_FCAT text
*----------------------------------------------------------------------*
FORM get_lvc_t_fcat_4_itab USING it_table CHANGING rt_fcat.
*Importing IT_TABLE TYPE TABLE
*Returning VALUE( RT_FCAT ) TYPE LVC_T_FCAT
DATA:
lo_columns TYPE REF TO cl_salv_columns_table,
lo_aggregations TYPE REF TO cl_salv_aggregations,
lo_salv_table TYPE REF TO cl_salv_table,
lr_table TYPE REF TO data.
FIELD-SYMBOLS:
<table> TYPE STANDARD TABLE.
* create unprotected table from import data
CREATE DATA lr_table LIKE it_table.
ASSIGN lr_table->* TO <table>.
*...New SALV Instance ...............................................
TRY.
cl_salv_table=>factory(
EXPORTING
list_display = abap_false
IMPORTING
r_salv_table = lo_salv_table
CHANGING
t_table = <table> ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
* get columns object (raw fieldcatalog)
lo_columns = lo_salv_table->get_columns( ).
* get aggregationss object (sorts)
lo_aggregations = lo_salv_table->get_aggregations( ).
rt_fcat =
cl_salv_controller_metadata=>get_lvc_fieldcatalog(
r_columns = lo_columns
r_aggregations = lo_aggregations ).
ENDFORM. "get_lvc_t_fcat_4_itab
Thanx n Regards,
Yogendra Bhaskar
‎2016 Aug 05 4:07 PM