SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

Delete Multiple Variants in ABAP

In order to delete numerous variants for an ABAP report, SAP user can choose different methods like deleting program variants using ABAP code or a better user interface instead of deleting each variant manually one by one.

To delete ABAP report variants will take time if menu options Goto > Variants > Delete selections are followed for a big number of variant deletion is required.

Delete Multiple Variants Programmatically in ABAP

First method to delete multiple variants even for different ABAP reports is creating an ABAP program using code shown below.

ABAP transparent table VARID Variant directory can be queried for fetching the list of target ABAP report variants to delete.

In VARID table, VARID-REPORT field is used for the variant's report name.
If we provide a specific report name here ABAP programmer can select all the variants for that ABAP program by filtering the program name in SELECT statement.

VARID-VARIANT field is for the variant name in VARID Variant directory table.

Following ABAP code fragment is showing how to execute a SELECT query on VARID variant directory ABAP table.
And then how to delete all report variants returned in the result list using ABAP function module RS_VARIANT_DELETE one by one in a ABAP LOOP statement.

DATA lv_report TYPE vari_reprt.
lv_report = 'ZEY_SUBSCREEN'.

SELECT report, variant INTO TABLE @DATA(lt_variants)
 FROM varid WHERE report = @lv_report.

LOOP AT lt_variants REFERENCE INTO DATA(lr_variants).
 WRITE :/ lr_variants->report, lr_variants->variant.

   report = lr_variants->report
   variant = lr_variants->variant
   flag_confirmscreen = 'X'
   flag_delallclient = 'X'
   not_authorized = 1
   not_executed = 2
   no_report = 3
   report_not_existent = 4
   report_not_supplied = 5
   variant_locked = 6
   variant_not_existent = 7
   no_corr_insert = 8
   variant_protected = 9
   OTHERS = 10.
 IF sy-subrc <> 0.
* Implement suitable error handling here


The mass deletion of variants of ABAP programs can be implemented as shown in below screenshot as well. Below sample is used to delete all variants of a specific ABAP report and results listed on screen.

delete all variants of an ABAP program using code

Delete Multiple Variants of an ABAP Report

Second method can be also used by SAP users, to delete multiple report variants. This method does not require additional coding but works only for variants of the same single ABAP program.

Launch SE38 ABAP Editor tcode.
Provide ABAP report name
On menu, follow options: Goto > Variants

variants of ABAP program

When ABAP Variants screen is displayed,
Follow menu options: Variants > Catalog

display all variants of ABAP report

Press "Selection criteria" button
Mark the variants you want to delete
Press F6 or Delete Variant button

delete multiple variants of ABAP program


Install SAP Free
CRM Companies List
Web Based CRM Software

Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.