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: 

ALV

Former Member
0 Kudos
136

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

4 REPLIES 4

former_member187255
Active Contributor
0 Kudos
41

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.

amit_khare
Active Contributor
0 Kudos
41

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

Former Member
0 Kudos
41

Hi,

Check the program BALVSD01

Thanks,

Naren

Former Member
0 Kudos
41

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