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: 

not able to understand is_variant declaration in alv :(

0 Kudos
319

i am a beginner and just started practicing ALV report and i have been assigned the task to use is_variant in ALV but i am not able to understand how to make it work. A help will be highly appreciated.

5 REPLIES 5

venkateswaran_k
Active Contributor
0 Kudos
272

Did you complete the code? or you want some examples?

venkateswaran_k
Active Contributor
0 Kudos
272

***Step 1 Declaration

DATA       G_VARIANT      LIKE DISVARIANT.
PARAMETERS P_VAR          LIKE DISVARIANT-VARIANT.

***Step 2 F4 Help to select Layout variant

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VAR.
  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
    EXPORTING
      IS_VARIANT             = G_VARIANT
     I_SAVE                  = 'A'
 IMPORTING
   ES_VARIANT                = G_VARIANT
 EXCEPTIONS
   NOT_FOUND                 = 1
   PROGRAM_ERROR             = 2
   OTHERS                    = 3
            .
  IF SY-SUBRC = 0.
    P_VAR = G_VARIANT-VARIANT.
  ELSE.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


***Step 3 - Use the variant in Display ALV grid

  gs_variant = g_variant.                               "<===========================
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = g_repid
      i_callback_pf_status_set = alv_status_set
      i_callback_user_command  = alv_user_comm
      i_grid_title             = grid_title
      i_save                   = g_save
      is_variant               = gs_variant             "<=============================
      is_layout                = alv_layout
      it_fieldcat              = alv_fieldcat[]
      it_events                = gt_events[]
      it_sort                  = alv_sort[]
    IMPORTING
      e_exit_caused_by_caller  = g_exit_caused_by_caller
      es_exit_caused_by_user   = gs_exit_caused_by_user
    TABLES
      t_outtab                 = it_output.

*** Step 4 In order to get the values upon pressing F4 you need to do as follows

After executing the report save the Layout using Save layout option.

Then it will appear in F4 help while executing next time

Hope this will help you.

Regards,

Venkat

0 Kudos
272

Don't forget to also pass the report name (at least, use HANDLE if multiple ALVs in same report) in the disvariant structure

G_REPID = SY-REPID.
GS_variant-REPORT = G_REPID.

Sandra_Rossi
Active Contributor
0 Kudos
272

Nowhere you say what the requirement is. The requirement can't be "use is_variant" without anything else. So, I guess you want to display buttons above the ALV grid, so that the user can save and load layouts. What else? What is your current code?

raymond_giuseppi
Active Contributor
0 Kudos
272

Did you search and look at some SAP demo programs such as BCALV_GRID_09?