SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

To Get Field Details Saved in Variant Layout



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Wed Dec 15, 2010 2:02 pm    Post subject: To Get Field Details Saved in Variant Layout Reply with quote

To Get Field Details Saved in Variant Layout
Source: http://wiki.sdn.sap.com/wiki/display/ABAP/To+Get+Field+Details+Saved+in+Variant+Layout

We need to get fieldnames which are visible in alv for a layout variant change.

Basically when we change a layout for a alv display, number of fields displayed will change. Our requirement is to read the fieldnames as per the layout variant. For that purpose use following FM created. Here you need to pass default field catalog. This default catalog will have details of maximum fields.

Assumptions: Only we are hiding fields in display and no other functionality.

Code:
CALL FUNCTION 'LVC_VARIANT_SELECT'
  EXPORTING
    i_dialog            = ' '
    i_user_specific     = 'X'
    i_default           = 'X'
    it_default_fieldcat = defaultfield
  IMPORTING
    et_fieldcat         = fieldcat
  CHANGING
    cs_variant          = gw_variant
  EXCEPTIONS
    wrong_input         = 1
    fc_not_complete     = 2
    not_found           = 3
    program_error       = 4
    data_missing        = 5
    OTHERS              = 6.
IF sy-subrc <> 0.
  RAISE others.
ENDIF.

The parameter fieldcat will return the field details for the changed layout. For the fields hidden it will have NO_OUT field set as 'X'. These are fields which are hidden by layout change. You can use this return fieldcatalog to create dynamic tables and then can fetch data from the main table used for alv display.

The requirement where this is useful: We are able to display data in foreground using layout variant in report. We are using 'REUSE_ALV_GRID_DISPLAY_LVC' for ALV grid display. Now in background I need to save data to file only for those fields which were displayed in foreground for that variant. In this case above FM is useful.
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 160
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Wed Dec 15, 2010 2:10 pm    Post subject: Reply with quote

Code:
DATA: ls_varkey TYPE ltdxkey.

ls_varkey-report = sy-repid.
ls_varkey-variant = i_variant.
ls_varkey-type = 'F'.

CALL FUNCTION 'LT_DBDATA_READ_FROM_LTDX'
  EXPORTING
    is_varkey    = ls_varkey
  TABLES
    t_dbfieldcat = lt_fcat
  EXCEPTIONS
    not_found    = 1
    wrong_relid  = 2
    OTHERS       = 3.

DELETE lt_fcat WHERE param = 'NO_OUT'.
DELETE lt_fcat WHERE value = 'X'.

_________________
Молитва - это запрос разработчику на изменение кода программы.
Back to top
View user's profile Send private message Blog Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.