Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8734

Re: How to create dynamic outtab with field_style

$
0
0

Thank it helps, but when I set the field editable it doesn't work.

 

My code is the following:

DATA: it_component TYPE cl_abap_structdescr=>component_table .

   DATA: st_component LIKE LINE OF it_component .

 

   DATA: ob_abap_structdescr TYPE REF TO cl_abap_structdescr,

         ob_abap_tabledescr  TYPE REF TO cl_abap_tabledescr,

         r_data_tab    TYPE REF TO data,

         r_data_str    TYPE REF TO data.

 

 

   CALL FUNCTION 'DDIF_FIELDINFO_GET'

     EXPORTING

       tabname        = if_table_name

     TABLES

       dfies_tab      = it_fields

     EXCEPTIONS

       not_found      = 1

       internal_error = 2

       OTHERS         = 3.

 

   LOOP AT it_fields INTO wa_fields.

 

     st_component-name = wa_fields-fieldname.

     st_component-type ?= cl_abap_elemdescr=>describe_by_name( wa_fields-rollname ).

     APPEND st_component TO it_component .

 

   ENDLOOP.

 

   st_component-name = 'FIELD_STYLE'.

   st_component-type ?= cl_abap_elemdescr=>describe_by_name('LVC_T_STYL').

   APPEND st_component TO it_component .

 

   TRY.

       ob_abap_structdescr = cl_abap_structdescr=>create( it_component ).

     CATCH cx_sy_struct_creation .

   ENDTRY.

 

   TRY.

       ob_abap_tabledescr = cl_abap_tabledescr=>create( ob_abap_structdescr ).

     CATCH cx_sy_table_creation .

   ENDTRY.

 

   CREATE DATA: r_data_tab TYPE HANDLE ob_abap_tabledescr ,

                 r_data_str TYPE HANDLE ob_abap_structdescr .


ASSIGN r_data_tab->* TO <table>.

   ASSIGN r_data_str->* TO <wa_table>.


...


SELECT * FROM (if_table_name) INTO CORRESPONDING FIELDS OF TABLE <table>

     WHERE (cond).

   perform modify_alv_style.

   PERFORM exclude_tb_functions CHANGING lt_exclude.

   call METHOD r_grid->set_ready_for_input

     EXPORTING i_ready_for_input = 1.

 

   CALL METHOD r_grid->set_table_for_first_display

     EXPORTING

       it_toolbar_excluding = lt_exclude

       i_structure_name     = if_table_name

     CHANGING

       it_outtab            = <table>.


 

in form modify_alv_style:

FORM modify_alv_style .

   DATA ls_stylerow TYPE lvc_s_styl .

   DATA lt_styletab TYPE lvc_t_styl .

   FIELD-SYMBOLS: <lt_style> TYPE lvc_t_styl.

 

   LOOP AT <table> INTO <wa_table>.

 

     ASSIGN COMPONENT 'FIELD_STYLE' OF STRUCTURE <wa_table> TO <lt_style>.

 

     ls_stylerow-fieldname = 'ID_KNIZNICE'.

     ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled.

 

     INSERT ls_stylerow INTO TABLE <lt_style>.

     modify <table> from <wa_table>.

 

ENDLOOP.

ENDFORM.

 

but the field IF_KNIZNICE is non editable. What do I do wrong?


Viewing all articles
Browse latest Browse all 8734

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>