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 Use LT_VARIANT_LOAD

Former Member
0 Kudos

Hi Experts,

Can anyone tell me what I need to pass in the parameter i_tabname when I am using function module LT_VARIANT_LOAD?

1 REPLY 1

Former Member
0 Kudos

Ex:

function reuse_alv_variant_select.

*"----


""Lokale Schnittstelle:

*" IMPORTING

*" VALUE(I_DIALOG) DEFAULT 'X'

*" VALUE(I_USER_SPECIFIC) DEFAULT ' '

*" VALUE(I_DEFAULT) DEFAULT 'X'

*" VALUE(I_TABNAME_HEADER) TYPE SLIS_TABNAME OPTIONAL

*" VALUE(I_TABNAME_ITEM) TYPE SLIS_TABNAME OPTIONAL

*" VALUE(IT_DEFAULT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV

*" VALUE(I_LAYOUT) TYPE SLIS_LAYOUT_ALV

*" VALUE(I_BYPASSING_BUFFER) TYPE CHAR01 OPTIONAL

*" VALUE(I_BUFFER_ACTIVE) OPTIONAL

*" EXPORTING

*" VALUE(E_EXIT)

*" VALUE(ET_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV

*" VALUE(ET_SORT) TYPE SLIS_T_SORTINFO_ALV

*" VALUE(ET_FILTER) TYPE SLIS_T_FILTER_ALV

*" VALUE(ES_LAYOUT) TYPE SLIS_LAYOUT_ALV

*" CHANGING

*" VALUE(CS_VARIANT) LIKE DISVARIANT STRUCTURE DISVARIANT

*" EXCEPTIONS

*" WRONG_INPUT

*" FC_NOT_COMPLETE

*" NOT_FOUND

*" PROGRAM_ERROR

*"----


data: ls_layout_lit type kkblo_layout.

data: ls_fieldcat type slis_fieldcat_alv.

data: lt_default_fieldcat_lit type kkblo_t_fieldcat.

data: lt_fieldcat_lit type kkblo_t_fieldcat.

data: lt_sortinfo_lit type kkblo_t_sortinfo.

data: lt_filter_lit type kkblo_t_filter.

data: l_tabname_header type kkblo_tabname.

data: ls_ltdxkey type ltdxkey.

data: l_dialog type char1,

l_user_specific type char1,

l_default type char1,

l_exit type char1.

l_dialog = i_dialog.

l_user_specific = i_user_specific.

l_default = i_default.

  • Deactivate Buffer

  • clear i_buffer_active.

data: l_import type char01,

l_export type char01,

l_delete type char01,

l_buffer_active type char01.

l_buffer_active = i_buffer_active.

call function 'ALV_CHECK_BUFFER'

exporting

i_buffer_type = 'A'

i_buffer_active = l_buffer_active

i_bypassing_buffer = i_bypassing_buffer

i_refresh_buffer = ' '

importing

e_import = l_import

e_export = l_export

e_delete = l_delete.

*

  • Falls Tabname in Fieldcat vorgegeben, nimm diesen, sonst '1' und nur

  • bei einfachen Listen und wenn tabname_header initial.

if i_tabname_item is initial.

if i_tabname_header is initial.

l_tabname_header = gc_tabname.

loop at it_default_fieldcat into ls_fieldcat

where not tabname is initial.

l_tabname_header = ls_fieldcat-tabname.

exit.

endloop.

else.

l_tabname_header = i_tabname_header.

endif.

else.

l_tabname_header = i_tabname_header.

endif.

move-corresponding cs_variant to ls_ltdxkey.

if not l_delete is initial.

call function 'ALV_DELETE_BUFFER'

exporting

is_ltdxkey = ls_ltdxkey

i_type = 'S'

i_langu = sy-langu

exceptions

no_delete = 0

not_found = 0

others = 0.

endif.

  • if i_buffer_active = 'X' and

if ( not l_import is initial ) and

not cs_variant-variant is initial and

( i_dialog is initial or i_dialog = 'N' ).

call function 'ALV_IMPORT_FROM_BUFFER_SLIS'

exporting

is_ltdxkey = ls_ltdxkey

  • I_LANGU = SY-LANGU

importing

et_fieldcat_slis = et_fieldcat

  • E_FIELDCAT_SLIS_STATE =

et_sort_slis = et_sort

  • E_SORT_SLIS_STATE =

et_filter_slis = et_filter

es_layout_slis = es_layout

exceptions

no_import = 1

others = 2

.

if sy-subrc = 0.

exit.

endif.

endif.

call function 'REUSE_ALV_TRANSFER_DATA'

exporting

it_fieldcat = it_default_fieldcat

is_layout = i_layout

importing

es_layout = ls_layout_lit

et_fieldcat = lt_default_fieldcat_lit.

*

call function 'LT_VARIANT_LOAD'

exporting

  • I_TOOL = 'LT'

i_tabname = l_tabname_header

i_tabname_slave = i_tabname_item

i_dialog = l_dialog

i_user_specific = l_user_specific

i_default = l_default

importing

e_exit = l_exit

et_fieldcat = lt_fieldcat_lit

et_sort = lt_sortinfo_lit

et_filter = lt_filter_lit

changing

cs_layout = ls_layout_lit

ct_default_fieldcat = lt_default_fieldcat_lit

cs_variant = cs_variant

exceptions

wrong_input = 1

fc_not_complete = 2

not_found = 3

others = 4.

e_exit = l_exit.

case sy-subrc.

when 0.

call function 'REUSE_ALV_TRANSFER_DATA_BACK'

exporting

it_fieldcat = lt_fieldcat_lit

it_sort = lt_sortinfo_lit

it_filter = lt_filter_lit

is_layout = ls_layout_lit

importing

es_layout = es_layout

et_fieldcat = et_fieldcat

et_sort = et_sort

et_filter = et_filter.

  • if i_buffer_active = 'X'.

if not l_export is initial.

call function 'ALV_EXPORT_TO_BUFFER_SLIS'

exporting

is_ltdxkey = ls_ltdxkey

  • I_LANGU = SY-LANGU

it_fieldcat_slis = et_fieldcat

  • I_FIELDCAT_SLIS_STATE =

it_sort_slis = et_sort

  • I_SORT_SLIS_STATE =

it_filter_slis = et_filter

is_layout_slis = es_layout

exceptions

no_key = 0

no_export = 0

others = 0.

if sy-subrc ne 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

endif.

when 1.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4

raising wrong_input.

when 2.

raise fc_not_complete.

when 3.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4

raising not_found.

when others.

message e534(0k) raising program_error.

endcase.

endfunction.

Reward points..