‎2007 Mar 12 8:00 PM
hello all,
can someone kindly explain how to get a variant by default into text box on the selection screen of ALV report.
thanks in advance,
seenu
‎2007 Mar 12 8:15 PM
Seenu,
I think we can populate the variant name at the runtime using <b>SY-SLSET</b>.
If at all you want to read from the variant table and display the varaint name then u can check table <b>VARID</b>
Rgds.
‎2007 Mar 12 8:18 PM
We do this with the help of following FMs -
REUSE_ALV_VARIANT_DEFAULT_GET
REUSE_ALV_VARIANT_EXISTENCE
REUSE_ALV_VARIANT_SELECT
REUSE_ALV_VARIANT_F4
REUSE_ALV_VARIANT_SAVE
Check this report -
RIOBJK00
When you run it and save the variant on the ALV screen, next time it will fetch the same from the variant list.
Regards,
Amit
‎2007 Mar 12 8:21 PM
‎2007 Mar 12 11:27 PM
Hi Seenu,
Define these Macros:
----
M A C R O S *
----
define variant_init.
clear: disvariant,
vartext.
if v_pgm is initial.
disvariant-report = sy-cprog.
else.
disvariant-report = v_pgm.
endif.
end-of-definition.
define alv_f4_for_variant.
variant_init.
call function 'REUSE_ALV_VARIANT_F4'
exporting
is_variant = disvariant
i_save = xsave
importing
e_exit = i_exit
es_variant = disvariant
exceptions
not_found = 2.
if sy-subrc = 2.
message id sy-msgid type 'S' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
elseif i_exit = space.
p_vari = disvariant-variant.
vartext = disvariant-text.
refresh i_dynpread.
i_dynpread-fieldname = 'VARTEXT'.
i_dynpread-fieldvalue = disvariant-text.
append i_dynpread.
call function 'DYNP_VALUES_UPDATE'
exporting
dyname = v_pgm
dynumb = '1000'
tables
dynpfields = i_dynpread.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
else.
variant_init.
endif.
end-of-definition.
define alv_pai_of_selection_screen.
if not p_vari is initial.
move p_vari to disvariant-variant.
call function 'REUSE_ALV_VARIANT_EXISTENCE'
exporting
i_save = xsave
changing
cs_variant = disvariant.
vartext = disvariant-text.
else.
variant_init.
endif.
end-of-definition.
define set_text.
wa_fieldcat-scrtext_s = &1.
wa_fieldcat-scrtext_m = &1.
wa_fieldcat-scrtext_l = &1.
wa_fieldcat-reptext = &1.
wa_fieldcat-colddictxt = &2.
wa_fieldcat-outputlen = &3.
end-of-definition.
Fill it_sort with the proper values to set up sort / subtotals.
define fill_sort.
clear wa_sort.
wa_sort-spos = &1. "Sort Positions
wa_sort-tabname = &2. "Table Name
wa_sort-fieldname = &2. "Field Name
wa_sort-up = &3. "Sort Ascending (UP)
wa_sort-down = &4. "Sort Descending (DOWN)
wa_sort-subtot = &5. "Subtotal (X = yes / ' ' = No)
wa_sort-group = &6. "Group
wa_sort-expa = &7. "Expand (X Expand to that level)
append wa_sort to sort.
end-of-definition.
define add_custom_buttons.
data: ls_toolbar type stb_button.
clear ls_toolbar.
move 3 to ls_toolbar-butn_type.
append ls_toolbar to p_e_object->mt_toolbar.
clear ls_toolbar.
move &1 to ls_toolbar-function.
move &2 to ls_toolbar-icon.
move &3 to ls_toolbar-quickinfo.
move &4 to ls_toolbar-text.
move &5 to ls_toolbar-disabled.
move &6 to ls_toolbar-butn_type.
append ls_toolbar to p_e_object->mt_toolbar.
end-of-definition.
define add_menu_buttons.
if p_e_ucomm = &1.
call method p_e_object->add_function
exporting
fcode = &2
text = &3.
endif.
end-of-definition.
Define Color for individual field on a row.
If fieldname is blank, sets entire row to the color.
Color = 1-9;
define set_row_field_color.
wa_fieldcat-emphasize = &1.
end-of-definition.
*Set fields of the rows as Key fields
define set_key_fields.
wa_fieldcat-key = &1.
end-of-definition.
*Set hotspots
define set_field_hotspot.
wa_fieldcat-hotspot = &1.
end-of-definition.
*Hide the columns
define set_hide_col.
wa_fieldcat-no_out = &1.
end-of-definition.
*Refresh the list display
define list_refresh.
call method &1->set_frontend_layout
exporting
is_layout = &2.
call method &1->refresh_table_display.
end-of-definition.
**************************
And call this :
**************************
parameters: p_vari type disvariant-variant.
**// AT SELECTION-SCREEN.
at selection-screen.
if p_vari is initial.
variant_init.
endif.
at selection-screen on value-request for p_vari.
alv_f4_for_variant.
at selection-screen on p_vari.
alv_pai_of_selection_screen.
**************************
Hope this helps.
Let me know if any more questions.
BR
Rakesh