星期四, 一月 10, 2013

cl_salv_table 获得 所有internal table 定义field name

FORM alv_fieldcat_reset2
    USING alv_table   TYPE REF TO cl_salv_table.
  DATA: lo_columns TYPE REF TO cl_salv_columns.
  DATA: lo_column TYPE REF TO cl_salv_column.
  "add field authority check
  DATA: alv_fieldcat TYPE slis_fieldcat_alv.
  DATA: cx_exc_ref    TYPE REF TO cx_root.
  DATA error_text TYPE c.
  DATA:
    lta_column_ref TYPE salv_t_column_ref
  .
  FIELD-SYMBOLS:
    <lfs_column> LIKE LINE OF lta_column_ref
  lo_columns = alv_table->get_columns( ).
      lta_column_ref = lo_columns->get( ).
      LOOP AT lta_column_ref ASSIGNING <lfs_column> .
        lo_column = <lfs_column>-r_column.
 write <lfs_column>-columnname.

      ENDLOOP.