Skip to Content

I am writing this blog to continuation of my blog Attachment implementation in SAP UI5(CRM and SAP UI5 integration)

In my previous blog I have explained, how to create ODATA for attachment , I have explained create and read attachment operations for both front-end and back-end.

In this blog I am going to explain rename and delete operations for attachment, with the help of these operations you can able to rename and delete your attachment from sap ui5/fiori screen and also you will be able to delete the attachment.When you will perform these operation , they are going to reflect in CRM on premise as well.

Creation of ODATA will be same as I described in my previous blog Attachment implementation in SAP UI5(CRM and SAP UI5 integration, so I am directly explaining rename and delete operations.

ODATA creation for delete an attachment : (Please see entity creation in my previous blog)

Write below code in the method DELETE_ENTITY of DPC_EXT  class.

datals_key_tab type /iwbep/s_mgw_name_value_pair.

data :    ls_loio                type skwf_io,

           ls_loio1                type skwf_io,

           ls_delete_loio type skwf_io,

           ls_key type crmt_object_id,

           lv_cp_guid             type <crm guid type.,

           ls_object_id type swotobjid,

           ls_bor_object type sibflporb,

           lt_loios type table of skwf_io.

* Read key values

read table it_key_tab into ls_key_tab with key name = ‘ComplaintId’.

if sysubrc = 0.

   ls_key = ls_key_tabvalue.

endif.

read table it_key_tab into ls_key_tab with key name = ‘Objtype’.

if sysubrc = 0.

   ls_loioobjtype = ls_key_tabvalue.

  endif.

read table it_key_tab into ls_key_tab with key name = ‘Class’.

if sysubrc = 0.

   ls_loioclass = ls_key_tabvalue.

  endif.

read table it_key_tab into ls_key_tab with key name = ‘Objid’.

if sysubrc = 0.

   ls_loioobjid = ls_key_tabvalue.

  endif.

call function ‘CRM_ORDERADM_H_GUID_GET_OW’

         exporting

           iv_object_id            = ls_key

         importing

           ev_orderadm_h_guid      = lv_cp_guid

         exceptions

           record_not_found        = 1

           object_id_is_not_unique = 2

           others                  = 3.

ls_object_idobjtype = ‘BUS2000120’.

ls_object_idobjkey  = lv_cp_guid.

class cl_swf_utl_convert_por definition load.

ls_bor_object =

        cl_swf_utl_convert_por=>convert_bor_to_ibf( ls_object_id ).

append ls_loio to lt_loios.

   call method cl_crm_documents=>delete

     exporting

       business_object = ls_bor_object

       ios             = lt_loios.



ODATA creation for rename an attachment : (Please see entity creation in my previous blog)


Write below code in the method UPDATE_ENTITY of DPC_EXT  class.


data:

          ls_key_tab            type /iwbep/s_mgw_name_value_pair,

          es_entityset type zcl_zcomplaint_attachm_mpc=>ts_complain_attachments.

data :   ls_loio                type skwf_io,

           ls_loio1                type skwf_io,

           ls_key type crmt_object_id,

           lv_cp_guid             type <crm guid type>,

           lv_attach_name type skwf_descr,

           es_error type skwf_error.

* Read key values

read table it_key_tab into ls_key_tab with key name = ‘ComplaintId’.

if sysubrc = 0.

   ls_key = ls_key_tabvalue.

endif.

read table it_key_tab into ls_key_tab with key name = ‘Objtype’.

if sysubrc = 0.

   ls_loioobjtype = ls_key_tabvalue.

  endif.

read table it_key_tab into ls_key_tab with key name = ‘Class’.

if sysubrc = 0.

   ls_loioclass = ls_key_tabvalue.

  endif.

read table it_key_tab into ls_key_tab with key name = ‘Objid’.

if sysubrc = 0.

   ls_loioobjid = ls_key_tabvalue.

  endif.

call function ‘CRM_ORDERADM_H_GUID_GET_OW’

         exporting

           iv_object_id            = ls_key

         importing

           ev_orderadm_h_guid      = lv_cp_guid

         exceptions

           record_not_found        = 1

           object_id_is_not_unique = 2

           others                  = 3.

* Read request data

     io_data_provider->read_entry_data( importing es_data = es_entityset ).

lv_attach_name    = es_entitysetfile_name.

call method cl_crm_documents=>rename_object

   exporting

     is_io             = ls_loio

     iv_name           = lv_attach_name

   importing

     es_error          = es_error

endif.

To report this post you need to login first.

1 Comment

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

  1. Jay Prakash Singh Post author

    URL for rename attachment :

    “<Server URL>/<ODATA proejct name>/Complain_AttachmentsSet(Class=’CRM_L_ORD’,Objtype=’L’,ComplaintId='” + lComplainId + “‘,Objid='”+ attachmentId +”‘)”

    URL for delete attachment :

    “<Server URL>/<ODATA proejct name>/Complain_AttachmentsSet(Class=’CRM_L_ORD’,Objtype=’L’,ComplaintId='” + oEntry.complaintId + “‘,Objid='”+ oEntry.attachmentId +”‘)”

    (0) 

Leave a Reply