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
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.
Back to my case, since CRMSOCPOST is a new BOR type created in CRM7.0 EHP3, the function module does not recognize it, so the code reached line 225, and then the BO instance is regarded as non-exist in DB. So an explicit COMMIT WORK is always necessary to make deletion work.
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/24475491/viewspace-2709632/，如需转载，请注明出处，否则将追究法律责任。