使用代码删除SAP CRM的附件(attachment)数据

简介: 使用代码删除SAP CRM的附件(attachment)数据

In the beginning I consider it is very easy to delete attachments via code, just like below.

I have defined one method with following two importing parameters and one returning parameter:


(1) iv_bor_type type string – the BOR type of your business object

(2) iv_uuid type raw16 – the guid of your business object instance

(3) rv_successful type abap_bool – indicates whether the deletion is successful

DATA:     ls_bo          TYPE SIBFLPORB,

         lt_loios    TYPE SKWF_IOS,

         ls_loios    TYPE SKWF_IO,

         ls_error    TYPE SKWF_ERROR,

         lt_badios   TYPE SKWF_IOERRS,

         lv_del_flag TYPE ABAP_BOOL.

   ls_bo-instid = iv_uuid.

   ls_bo-typeid = iv_bor_type.

   ls_bo-catid  = 'BO'.

   rv_successful = abap_false.

   CALL METHOD cl_crm_documents=>get_info

     EXPORTING

       business_object = ls_bo

     IMPORTING

       loios           = lt_loios.

   LOOP AT lt_loios INTO ls_loios.

     CALL METHOD cl_crm_documents=>lock

       EXPORTING

         is_bo    = ls_bo

         is_loio  = ls_loios

       IMPORTING

         es_error = ls_error.

     IF ls_error IS NOT INITIAL.

        RETURN.

     ENDIF.

   ENDLOOP.

   CALL METHOD cl_crm_documents=>delete

     EXPORTING

        business_object = ls_bo

        ios             = lt_loios

     IMPORTING

        bad_ios         = lt_badios

        error           = ls_error.

   IF ls_error IS INITIAL. " deletion failed

      rv_successful = abap_true.

   ENDIF.

Through testing I found it works perfectly well with most of BOR type like product, IBASE, BP, and one order.


However, it does not work for my new BOR type CRMSOCPOST in CRM7.0 EHP3 – the relationship between my BO and the attachments is not really deleted until an explicit call COMMIT WORK is written in the report. However, for any other standard CRM BOR type, the COMMIT WORK is not needed. Why?

After some debugging finally I find answer. Have you already observed the comments below? It is written quite clearly: if the business object exists in the database, the COMMIT WORK is not needed.

image.pngimage.png

目录
相关文章
|
22天前
|
人工智能 搜索推荐 Serverless
使用金庸的著作,来测试阿里通义千问最新开放的长文档处理功能
使用金庸的著作,来测试阿里通义千问最新开放的长文档处理功能
52 7
使用金庸的著作,来测试阿里通义千问最新开放的长文档处理功能
|
1月前
|
中间件
什么是 SAP CRM 系统里的 Initial Download
什么是 SAP CRM 系统里的 Initial Download
23 0
|
19天前
|
存储
使用 ABAP 代码打印出 SAP CRM 系统里所有维护了 Sales Area 的 business partner id
使用 ABAP 代码打印出 SAP CRM 系统里所有维护了 Sales Area 的 business partner id
19 0
|
22天前
|
数据库
SAP CRM产品主数据无法根据产品描述字段进行搜索的原因
SAP CRM产品主数据无法根据产品描述字段进行搜索的原因
16 5
|
22天前
|
Web App开发 开发者 存储
介绍一个 webp 格式转 png 格式的软件:XNConvert
介绍一个 webp 格式转 png 格式的软件:XNConvert
25 6
介绍一个 webp 格式转 png 格式的软件:XNConvert
|
22天前
什么是 SAP ABAP 里的 Subscreen
什么是 SAP ABAP 里的 Subscreen
16 1
什么是 SAP ABAP 里的 Subscreen
|
1月前
|
中间件
如何在 SAP CRM 系统调试 Product Initial Download
如何在 SAP CRM 系统调试 Product Initial Download
15 0
|
1月前
|
中间件
什么是 SAP CRM Initial Download
什么是 SAP CRM Initial Download
20 0
|
1月前
|
存储 数据管理 数据处理
SAP CRM 里 Attachment 搜索的实现逻辑介绍
SAP CRM 里 Attachment 搜索的实现逻辑介绍
19 0
|
2月前
|
存储 数据库 容器
深入介绍 SAP CRM 附件存储的底层实现机制
深入介绍 SAP CRM 附件存储的底层实现机制
30 0