Skip to Content

How to delete/modify variant in ooalv

Hi, i want to allow users to delete their variant using goto > variant > delete... but theses options are greyed.


My toolbar is like this but only the second toolbar works, why ?

Variants are created here :



Thanks for your help.

I use theses form to make variant work :

***------------------------------------------------------------------***
*** Form SUB_VARIANT_INIT ***
***------------------------------------------------------------------***
*** Display default variant ***
***------------------------------------------------------------------***
form SUB_VARIANT_INIT.
I_VARIANT1-REPORT = SY-REPID.
* Search default variant for the report
 CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
 EXPORTING
 i_save = 'A'
 CHANGING
 cs_variant = i_variant1
 EXCEPTIONS
 not_found = 2.
* If default variant is found , use it as default.
* Else , use the variant LAYOUT1.
 IF sy-subrc = 0.
 p_var = i_variant1-variant.
 ELSE.
 p_var = ''.
 ENDIF.
endform. " SUB_VARIANT_INIT

***------------------------------------------------------------------***
*** Form SUB_CHECK_PVAR ***
***------------------------------------------------------------------***
*** Once the user has entered variant, check about its existence ***
***------------------------------------------------------------------***
FORM SUB_CHECK_PVAR.
* If the name of the variable is not blank, check about its existence
if not p_var is initial.
 clear i_variant.
 i_variant-report = sy-repid.
 i_variant-variant = p_var.
 CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
 EXPORTING
 I_SAVE = 'A'
 CHANGING
 CS_VARIANT = I_VARIANT.
* If no such variant found , flash error message
 if sy-subrc ne 0 .
 message e398(00) with 'No such variant exists'.
 else.
* If variant exists , use the variant name to populate structure
* I_VARIANT1 which will be used for export parameter : IS_VARIANT
* in the function module : REUSE_ALV_GRID_DISPLAY
 clear i_variant1.
 move p_var to i_variant1-variant.
 move sy-repid to i_variant1-report.
 endif.
 else.
 clear i_variant.
 endif.
ENDFORM. " SUB_CHECK_PVAR

***------------------------------------------------------------------***
*** Form SUB_VARIANT_F4 ***
***------------------------------------------------------------------***
*** Display a list of various variants of the report when the user ***
*** presses F4 key in the variant field ***
***------------------------------------------------------------------***
form SUB_VARIANT_F4.
i_variant-report = sy-repid.
* Utilising the name of the report , this function module will search for a list of variants and will fetch the selected one
* into the parameter field for variants
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
 EXPORTING
 IS_VARIANT = I_VARIANT
 I_SAVE = 'A'
 I_DISPLAY_VIA_GRID = 'X'
 IMPORTING
 ES_VARIANT = I_VARIANT1
 EXCEPTIONS
 NOT_FOUND = 1
 PROGRAM_ERROR = 2
 OTHERS = 3.
 IF SY-SUBRC = 0.
 P_VAR = I_VARIANT1-VARIANT.
 ENDIF.
ENDFORM. " SUB_VARIANT_F4<br>

capture50.png (11.4 kB)
capture51.png (10.6 kB)
capture52.png (2.7 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 06 at 04:53 PM

    Just a shot in the dark: if you're using REUSE_ALV_GRID_DISPLAY then there is a parameter I_SAVE which determines how the users can manage the variants (documentation available in FM). I'm not aware of special authorization to just delete the variants. But if it exists then a simple authorization trace would find it.

    Add comment
    10|10000 characters needed characters exceeded

    • Jelena Perfiljeva Alexandre HOLZHAMMER

      I think you'll benefit greatly from reading this book that explains all 3 ALV techniques (disclosure: I did a technical review for it) with examples.

      I'm not sure what you mean by "preconfigured menu bar". When we use REUSE_ALV... FM then ALV comes out with a standard menu and toolbar. When using SALV, the "plain" factory method call results in no toolbar and limited menu. You can see it in SALV_DEMO_TABLE_REAL_SIMPLE program. The demo program mentioned above has additional code that handles toolbar, as we can see in the screenshot above. With both FM and SALV we can also apply a custom GUI status. The coding for it differs, of course.

      There is the 3rd ALV technique that I don't use and am not familiar with. AFAIK SALV is the current best practice. You can find more SALV demo programs by searching for SALV*DEMO* in SE38.