Skip to Content

Implement the Logical Deletion

test
0 %
Implement the Logical Deletion
Details

Implement the Logical Deletion

Requires Customer/Partner License
September 15, 2020
Created by
September 15, 2020
Implement the logical deletion of your factory calendar.

You will learn

  • How to add delete flag to CDS view
  • How to add UI annotation

Prerequisites

  • You need an SAP Cloud Platform ABAP Environment trial user or a license.


Step 1: Add delete flag to CDS view
  1. Open your CDS view ZCAL_HOLIDAY_XXX and add following UI annotation:

    @UI.hidden: true
    

    userinterface

  2. Add the where condition at the end of your CDS View ZCAL_HOLIDAY_XXX:

    where configdeprecationcode = ''
    

    deprecation

    Save and activate.

  3. Open your behavior definition ZCAL_I_HOLIDAY_XXX and disable the physical deletion.
    Remove the delete property from the root node.

    delete

  4. Add action delete to your behavior definition.

    action delete;
    
  5. Save and activate your behavior definition.
    Set the cursor on the action delete definition and press CTRL+1. Click on Add missing method for action delete in new local handler class to create your action method.

    delete

  6. Insert following code as your delete method in ZBP_CAL_I_HOLIDAY_XXX:

    METHOD delete.
      CONSTANTS no_longer_valid TYPE zconfig_deprecation_code_xxx VALUE 'E'.
      DATA holidayroot_table TYPE TABLE FOR UPDATE zcal_i_holiday_xxx.
    
      LOOP AT keys ASSIGNING FIELD-SYMBOL(<key>).
        APPEND
          VALUE #( holiday_id            = <key>-holiday_id
                   configdeprecationcode = no_longer_valid
                   %control              = VALUE #( configdeprecationcode = cl_abap_behv=>flag_changed ) )
             TO holidayroot_table.
      ENDLOOP.
    
      MODIFY ENTITIES OF zcal_i_holiday_xxx IN LOCAL MODE
        ENTITY HolidayRoot UPDATE FROM holidayroot_table
            MAPPED   DATA(ls_mapped)
            FAILED   DATA(ls_failed)
            REPORTED DATA(ls_reported).
    ENDMETHOD.
    
    delete
  7. Save and activate.

Log on to answer question
Step 2: Add UI annotation
  1. Go to ZCAL_I_HOLIDAY_XXX and search for configdeprecationcode and add following UI annotations:

    @UI.hidden: true
       @UI.lineItem:
         [ { type: #FOR_ACTION, dataAction: 'delete', label: 'Delete' } ]
       @UI.identification:
         [ { type: #FOR_ACTION, dataAction: 'delete', label: 'Delete' } ]
       configdeprecationcode         as ConfigDeprecationCode,
    
    userinterface
  2. Check your result.

    result

Log on to answer question
Step 3: Test yourself
What do you need to do first, in order to set your logical deletion?
×

Next Steps

Back to top