Skip to Content
0

Display fieldname as technical name in alv

Mar 08, 2017 at 05:59 PM

119

avatar image

Hello,

In one of my alv report i am want to show the fieldname as its technical name from the database. Please let me know if this is possible.

Thanks,

Ankit

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Raghu Govindarajan Mar 08, 2017 at 06:15 PM
0

This example is not directly related, but shows how to get the column information using RTTS http://zevolving.com/2013/09/salv-making-all-columns-invisible-from-a-specific-type/

... and then you can set the text = component-name.

  LOOP AT t_fields INTO lv_field.
    TRY.
        lo_column ?= lo_cols_tab->get_column( lv_field ).
        lo_column->set_short_text( lv_field-name ).
        lo_column->set_medium_text( lv_field-name ).

      CATCH cx_salv_not_found.
    ENDTRY.
  ENDLOOP.
Share
10 |10000 characters needed characters left characters exceeded
Subhajit Roy Mar 09, 2017 at 02:22 PM
0
START-OF-SELECTION.
  DATA: lt_tab   TYPE TABLE OF zemp,
        lt_field TYPE TABLE OF fieldname,
        ls_field TYPE fieldname,
        lt_fcat  TYPE slis_t_fieldcat_alv,
        ls_fcat  TYPE slis_fieldcat_alv,
        col_pos  TYPE i VALUE 1
        .

  SELECT * FROM zemp INTO TABLE lt_tab.
  SELECT fieldname FROM dd03l INTO TABLE lt_field WHERE tabname = 'ZEMP'.
  LOOP AT lt_field INTO ls_field.
    ls_fcat-col_pos = col_pos.
    ls_fcat-fieldname = ls_field.
    ls_fcat-seltext_m = ls_field.
    APPEND ls_fcat TO lt_fcat.
    CLEAR: ls_field, ls_fcat.
    col_pos = col_pos + 1.
  ENDLOOP.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = sy-repid
      it_fieldcat        = lt_fcat
    TABLES
      t_outtab           = lt_tab
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.
Share
10 |10000 characters needed characters left characters exceeded