3.2 OData CRUD – Delete

Bit by bit Method

  • Building Erase activity

1. In SAP exchange SEGW, extend a venture organizer and open TravelAgencySet. Click on Erase and pick Go to ABAP Workbench. As the principal execution, you’ll see the popup.

OData CRUD DELETE steps

2. Click on the *_DPC_EXT organizer. The right sheet ought to show the Class Connection point displayed in the following step.You’ll see the rundown of the techniques. Look down – snap and spotlight on the “…_DELETE_ENTITY” and press the Rethink symbol.

Tip: Ensure assuming your supervisor is in alter mode with theicon. Rethink symbol is.

3. Erase the remarked out lines of code. You have an unfilled execution.

4. Assuming you click “Mark” text, you’ll see the in and out boundaries of this strategy.

Here’s execution:

   Naming convention:
   l - local scope
   t - table
   s - structure
   v - variable

01 method TRAVELAGENCYSET_DELETE_ENTITY.
02
03   DATA: ls_entityset    TYPE stravelag,
04         ls_key_tab      TYPE /iwbep/s_mgw_name_value_pair,
05         lv_error_entity TYPE string.
06
07 * key is TravelAgencySet(agency#)
08   READ TABLE it_key_tab INTO ls_key_tab INDEX 1.
09
10   DELETE FROM stravelag WHERE agencynum = ls_key_tab-value.
11
12   IF ( sy-subrc = 0 ).
13 * delete completed
14   ELSE.
15 * entity not found
16     CONCATENATE iv_entity_name
17                 '('''
18                 ls_key_tab-value
19                 ''')'
20       INTO lv_error_entity.
21     RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
22       EXPORTING
23         textid      = /iwbep/cx_mgw_busi_exception=>resource_not_found
24         entity_type = lv_error_entity.
25   ENDIF.
26
27 endmethod.

#05 proclaims a variable which can have the blunder message on the off chance that the Erase activity fizzled. #08 gets the vital worth of the erasing substance -, for example, ../TravelAgencySet(‘12345678’). #10 does a basic erase order. Assuming the order goes fruitful, the sy-subrc worth ought to be 0. #16 – #24 sets the easy to use mistake message saying the substance doesn’t exist in the TravelAgency table.

Ensure you actuate it byicon.

– Testing Delete operation

1. Do the Inquiry activity. In the question step, set the two HTTP Header boundaries – these are expected to do any information adjustment (either Make/Update/Erase) against OData administrations in SAP Entryway.

X-CSRF-Token = Fetch

Content-Type = application/atom+xml; charset=UTF-8

2. In a reaction header, you’ll track down the symbolic worth in X-CSRF-Token. Duplicate it. (Note: the symbolic will keep substantial until the program gets shut)

3. Supplant the duplicated esteem with “Get” string. Presently your REST client is prepared for Make activity through HTTP POST.

4. Pick one of the substances you need to erase in tag.

5. Run the Delete operation.

6. You ought to get HTTP 204 No Happy. The Erase activity executed effectively!

What’s straightaway? You can pick both of:

– Create operation

– Read operation

– Update operation

WhatsApp WhatsApp us