Using Selective deletion in a Process Chain with a filter from the TVARVC table
The issue below took me quite some time to figure out and we needed multiple documents and blogs as a reference. Therefor I thought it would be a good idea to add the information we figured out in a blog post and share it with you all.
Based on the document “Using Selective Deletion in Process Chains” by Surendra Kumar Reddy Koduru (08-03-2009) we tried to selectively delete data from an infocube. However we faced that his document described a variable that was already available and based on a date. We however needed to have a variable based on a regular info object with his attributes. The article from Shai Greenberg provides a reference to how to solve it, but doesn’t provide the full steps. So therefor, this document is a full detailed reference guide on how to build a selective deletion with dynamic variables based on a info object that is not time related.
- Add a selection variable to the TVARVC table.
- Create a program and variant for the selective deletion of the cube with transaction DELETE_FACTS.
- Create an ABAP Program to insert the dynamic variables in the TVARVC table.
- Add the ABAP Program from step 3 and step 2 to the process chain.
Step 1: Add a selection variable to the TVARVC table
- Go to the TVARVC table with the transaction code STVARV. Click on edit. Make sure to be on the “Selection Options” tab.
- Click on create. A blank line is added.
- Fill a name for the Selection Option.
- Note: If you want to transport the changed entries from the TVARVC table, make sure to select the “Include changed entries in transport request” option.
Step 2: Create a program and variant for the selective deletion of the cube
In this step we will use the document from Surendra Kumar Reddy Koduru – Using Selective Deletion in Process Chains.
- Go to the DELETE_FACTS transaction.
- Fill in your data target from where selective deletion needs to be done (cube). Make sure to select “Generate selection program” and click on execute. A Name of report will be shown. Copy this program name in a notepad file.
UPDATE: To get this program in a transport request, we copied the report to a Z object and added it to a transport. This is not perfect, since with that any changes in the Cube aren’t adjusted in the code.
- Take this program name and go to SE38 and insert program name in the Program field. Click on Variants option and click on Change.
- Fill in a name of a variant and click on Create.
- A selection screen will be shown. We want to delete data based on Company Code. Click on Company code and press F1 for info about this screen field.
- In the help menu, click the “Technical Information” button and note the Screen Field name. In our case this is Screen Field C004.
- Go back to the Maintain Variant screen and select the Attributes button.
- If not already visible, add technical names to the table. Select C004 or Company Code and select the Selection Variable field on this row.
- Select T: Table Variable from TVARVC (only option available).
- Go to the Name of Variable (Input Only Using F4) and select the variable created in Step 1.
- Save the table.
We have now created a program with a variable on company code that will delete a selection in the cube.
Step 3: Create an ABAP Program to insert the dynamic variables in the TVARVC table
At this moment the variable will not be inserting data in the TVARVC table. We will do that with a separate ABAP Program.
- Go to SE38 and create a new program based on source code.
- Forour selection, we used the following code, where ZCCACTIS is an attribute from 0compcode and indicator if the company code needs to be deleted.
Data: lv_compcode type /bic/oizcompcode,
lt_compcode type STANDARD TABLE OF /BIC/MZCOMPCODE,
it_compcode type STANDARD TABLE OF /BIC/MZCOMPCODE,
lt_tvarvc type STANDARD TABLE OF tvarvc,
lv_numb type i,
wa_compcode like LINE OF it_compcode.
FIELD–SYMBOLS: <fs_compcode> type /BIC/MZCOMPCODE,
<fs_it_ compcode > type /BIC/MZCOMPCODE.
refresh: lt_ compcode.
select * from /BIC/MZCOMPCODE
into CORRESPONDING FIELDS OF TABLE lt_compcode
WHERE OBJVERS = ‘A’
AND /BIC/ZCCACTIS = ‘Y’.
gs_tvarvc TYPE tvarvc.
CONSTANTS: c_s TYPE rsscr_kind VALUE ‘S’.
delete from tvarvc where name = ‘ZSO_COMPCODE’.
lv_numb = 0.
loop at lt_compcode into wa_compcode.
gs_tvarvc–mandt = ‘120’.
gs_tvarvc–low = wa_compcode–/bic/oizcompcode.
gs_tvarvc–sign = ‘I’.
gs_tvarvc–opti = ‘EQ’.
gs_tvarvc–name = ‘ZSO_COMPCODE’.
gs_tvarvc–type = c_s.
gs_tvarvc–numb = lv_numb.
lv_numb = lv_numb + 1.
append gs_tvarvc to lt_tvarvc.
insert tvarvc FROM table lt_tvarvc ACCEPTING DUPLICATE KEYS.
- Adjust the report to your own needs and save the report.
- If you want, you can run the program. After that go to the TVARVC table and check if the data is correctly loaded in the selection fields.
Step 4: Add the ABAP Programs from step 2 and 3 to the process chain
- 1) Add the two programs to the required process chain.
- 2) Run the process chain and check if the selective deletion is done correctl
Using Selective Deletion in Process Chains
by Surendra Kumar Reddy Koduru – 08 March 2009
ABAP: Dynamic Variant Processing with STVARV
By Anish Kosky Oommen – 24 February 2011
Partial Full Load using Dynamic Infopackage Selection, Selective Deletion and Dynamic Variant Processing
By Shai Greenberg – 20 June 2012