Skip to Content

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.

Regards,

Rob

Scope:

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.

Steps:

  1. Add a selection variable to the TVARVC table.
  2. Create a program and variant for the selective deletion of the cube with transaction DELETE_FACTS.
  3. Create an ABAP Program to insert the dynamic variables in the TVARVC table.
  4. Add the ABAP Program from step 3 and step 2 to the process chain.

Step 1: Add a selection variable to the TVARVC table

  1. Go to the TVARVC table with the transaction code STVARV. Click on edit. Make sure to be on the “Selection Options” tab.
    image step 1 1.jpg
  2. Click on create. A blank line is added.
    image step 1 2.jpg
  3. Fill a name for the Selection Option.
    image step 1 3.jpg
  4. 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.

  1. Go to the DELETE_FACTS transaction.
    image step 2 1.jpg
  2. 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.

    image step 2 2.jpg
    image step 2 2 2.jpg

    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.

  3. Take this program name and go to SE38 and insert program name in the Program field. Click on Variants option and click on Change.image step 2 3.jpg
  4. Fill in a name of a variant and click on Create.
    image step 2 4.jpg
  5. 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.
    image step 2 5.jpg
  6. In the help menu, click the “Technical Information” button and note the Screen Field name. In our case this is Screen Field C004.
    image step 2 6 1.jpg
    or

    image step 2 6 2.jpg
    image step 2 6 3.jpg

  7. Go back to the Maintain Variant screen and select the Attributes button.
    image step 2 7.jpg
  8. If not already visible, add technical names to the table. Select C004 or Company Code and select the Selection Variable field on this row.
    image step 2 8 1.jpg
    image step 2 8 2.jpg
  9. Select T: Table Variable from TVARVC (only option available).
    image step 2 9.jpg
  10. Go to the Name of Variable (Input Only Using F4) and select the variable created in Step 1.

    image step 2 10 1.jpg
    image step 2 10 2.jpg

  11. Save the table.
    image step 2 11.jpg
    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.

  1. Go to SE38 and create a new program based on source code.
    image step 3 1.jpg
  2. Forour selection, we used the following code, where ZCCACTIS is an attribute from 0compcode and indicator if the company code needs to be deleted.

    REPORT ZP_VAR_COMPCODE.

    TABLES: tvarvc.

    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.

    FIELDSYMBOLS: <fs_compcode> type /BIC/MZCOMPCODE,
    <fs_it_ compcode >
    type /BIC/MZCOMPCODE.

    STARTOFSELECTION.

    refresh: lt_ compcode.

    select * from /BIC/MZCOMPCODE
    into CORRESPONDING FIELDS OF TABLE lt_compcode
    WHERE OBJVERS = ‘A’
    AND /BIC/ZCCACTIS = ‘Y’.

    DATA :
    gs_tvarvc
    TYPE tvarvc.

    CONSTANTS: c_s TYPE rsscr_kind VALUE ‘S’.

    delete from tvarvc where name = ‘ZSO_COMPCODE’.

    clear wa_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_tvarvcname = ‘ZSO_COMPCODE’.
    gs_tvarvc
    type = c_s.
    gs_tvarvc
    numb = lv_numb.
    lv_numb
    = lv_numb + 1.

    append gs_tvarvc to lt_tvarvc.

    endloop.

    insert tvarvc FROM table lt_tvarvc ACCEPTING DUPLICATE KEYS.

    FREE: gs_tvarvc.

  3. Adjust the report to your own needs and save the report.
  4. 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.

    image step 3 4 1.jpg
    image step 3 4 2.jpg

Step 4: Add the ABAP Programs from step 2 and 3 to the process chain

  1. 1) Add the two programs to the required process chain.
    image step 4.jpg
  2. 2) Run the process chain and check if the selective deletion is done correctl

References:

Using Selective Deletion in Process Chains
by Surendra Kumar Reddy Koduru – 08 March 2009
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/603a9558-0af1-2b10-86a3-c685c60071bc?QuickLink=index&overridelayout=true&39569533701241

ABAP: Dynamic Variant Processing with STVARV
By Anish Kosky Oommen – 24 February 2011
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f05b0f0a-db27-2e10-b4a4-a0272a80f833?QuickLink=index&overridelayout=true


Partial Full Load using Dynamic Infopackage Selection, Selective Deletion and Dynamic Variant Processing
By Shai Greenberg – 20 June 2012
http://scn.sap.com/community/data-warehousing/netweaver-bw/blog/2012/06/20/partial-full-load-using-dynamic-infopackage-selection-selective-deletion-and-dynamic-variant-processing

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply