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 delete/modify variant in ooalv

Former Member

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>

1 ACCEPTED SOLUTION

Jelena
Active Contributor

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.

7 REPLIES 7

mmcisme1
Active Contributor

Where are they creating the variant? Please add the code from the screen it is created.

Jelena
Active Contributor

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.

Former Member
0 Kudos

I use OO ALV to set the value of i_save :

I_SAVE = 'A' --> Standard and user-specific save mode

Display variants can be saved both as user-specific and as standard

variants. Users make their choice on the dialog box for saving the

display variant.

https://archive.sap.com/discussions/thread/579675


But there isn't any specific option to delete a variant 😕

Jelena
Active Contributor

Sorry, I don't have any examples of that kind of ALV, we jumped straight from FM to SALV. 🙂

When I run a demo program SALV_DEMO_TABLE_LAYOUT the menu is like that:

Under Administration there is an option to delete a layout. I'm not sure how your screenshots align with what I see, you might want to login in English when making screenshots for SCN.

It would be rather odd if the users were allowed to save the variant but not delete it. And I don't see any evidence of such issues on SCN, so either there is something in your code or there is an odd bug in your system. Search for the SAP notes or use ANST transaction, if available.

Jelena
Active Contributor
0 Kudos

Well, this is just another shot in the dark but quick search in SAP Notes for "alv delete layout not possible" finds this FAQ note and p.6 says something about passing the report name to FM/method when there is a problem with layouts. Does not look like your exact scenario but as I said - shot in the dark. Can't really tell more without debugging in your system directly, I'm afraid.

Former Member
0 Kudos

okay, i have found something, it looks like my issue come from my 'GUI statut' in 'SE80'. Does it exist any preconfigured Menu bar for oo alv ? Or a function witch assign every menu bar's code to usercommand ? I tried to get one of an existing sap program using ooalv but i haven't found the code's part where user's command are triggered...

In fact, i only want a standard sap page as if i use the 'reuse alv_grid' module fonction where i can display my data and get an after refresh event. Am i obligated to use OO ALV to do this ?

Thanks for your answer.

Jelena
Active Contributor
0 Kudos

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.