Application Development and Automation 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: 
Read only

Get Fields equalent to ALV Layout Fields

former_member194669
Active Contributor
0 Likes
1,367

I have an ALV report that have ALV layout selected by user. My requirement is i need to get same set of fields from the layout selected. and using this i need to create the internal table at runtime

Any info on this appreciated.

I have an ALV report that have ALV layout selected by user. My requirement is i need to get same set of fields from the layout selected. and using this i need to create the internal table at runtime

Any info on this appreciated.

2 REPLIES 2
Read only

venkat_o
Active Contributor
0 Likes
595

Hi, <li>Check the below sample code how you have to get build internal table at run time.


*----------------------------------------------------------------------*
*       Form  GET_FIELDCAT_FROM_VARIANT
*----------------------------------------------------------------------*
*       Retrieve the fieldcatalog stored for the variant
*----------------------------------------------------------------------*
form get_fieldcat_from_variant using disvar    like disvariant
                                     itab_head type c
                                     itab_item type c.

  data: fieldcat_new type kkblo_t_fieldcat.

  call function 'REUSE_ALV_TRANSFER_DATA'
       exporting
            it_fieldcat = fieldcat
            is_layout   = layout
       importing
            et_fieldcat = fieldcat_kkb
            es_layout   = layout_kkb.

  call function 'LT_VARIANT_LOAD'
       exporting
            i_tabname           = itab_head
            i_tabname_slave     = itab_item
            i_dialog            = space
            i_user_specific     = 'X'
       importing
            et_fieldcat         = fieldcat_new
       changing
            ct_default_fieldcat = fieldcat_kkb
            cs_layout           = layout_kkb
            cs_variant          = disvar
       exceptions
            wrong_input         = 1
            fc_not_complete     = 2
            not_found           = 3
            others              = 4.

  if sy-subrc = 0.
    refresh fieldcat.
    call function 'REUSE_ALV_TRANSFER_DATA_BACK'
         exporting
              it_fieldcat = fieldcat_new
         importing
              et_fieldcat = fieldcat.

    clear: fieldcat_ln.
    modify fieldcat from fieldcat_ln transporting no_out
      where no_out <> 'X'.
  endif.
endform.                               " GET_FIELDCAT_FROM_VARIANT
*----------------------------------------------------------------------*
Thanks Venkat.O

Read only

former_member194669
Active Contributor
0 Likes
595

used fm LVC_VARIANT_SELECT