Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get which fields are currently displayed by ALV?

Former Member
0 Kudos

Hi ,

I have a program which displays list in the form of ALV . I have a parameter on the screen which takes the layout name from the user. At the same time I have the parameter which takes the filename from the user.

Now the program should write only those fields to the file which are displayed on the screen depending on the layout.

How can I get the names of the fields which are displayed on the ALV layout so that I can write only those fields to the file ?

[Here the requirement is such that we have to provide seperate download to file option even if we have the same functionality provided by the ALV]

Please suggest.

Naina

2 REPLIES 2

naimesh_patel
Active Contributor
0 Kudos

YOu can use one these FMs before filling up your download table:

REUSE_ALV_GRID_LAYOUT_INFO_GET

REUSE_ALV_LIST_LAYOUT_INFO_GET

  IF g_grid IS INITIAL.
    CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
         IMPORTING
              es_layout      = g_layout
              et_fieldcat    = g_fieldcat_tab[]
              et_sort        = g_sortfields_tab[]
              et_filter      = g_filter_tab[]
*           ES_LIST_SCROLL = G_SCROLL
              es_variant     = g_variant
         EXCEPTIONS
              no_infos       = 1
              program_error  = 2
              OTHERS         = 3.
  ELSE.
    CALL FUNCTION 'REUSE_ALV_LIST_LAYOUT_INFO_GET'
      IMPORTING
        es_layout      = g_layout
        et_fieldcat    = g_fieldcat_tab[]
        et_sort        = g_sortfields_tab[]
        et_filter      = g_filter_tab[]
        es_list_scroll = g_scroll
        es_variant     = g_variant
      EXCEPTIONS
        no_infos       = 1
        program_error  = 2
        OTHERS         = 3.
  ENDIF.

Regards,

Naimesh Patel

0 Kudos

Hi Naimesh ,

Can you please let me know where exactly we have to place this FM ?

Because if I place it after the REUSE_ALV_LIST_DISPLAY then the FM is not returning any information . Its returning SY-SUBRC = 1.

Please Suggest.

Naina