Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

Export attachments from CRM documents in background mode

$
0
0

Hello,

 

There is an attempt to extract all attachments from CRM transactional documents to put them onto an external contents management server. By leveraging SAP's functionality of exporting individual attachments, we have programmed to use the CRM document GUID, the business object (Eg.: BUS2000115), to retrieve the CRM KW object type ('P'), class ('CRM_P_ORD') and ID (GUID) of the attachment using CL_CRM_DOCUMENTS=>GET_INFO method.

 

Using the CRM KW object type ('P'), class ('CRM_P_ORD') and ID (GUID) in structure PHIOS in FM 'CRM_KW_DOC_EXPORT', we can download the attachments onto a local (presentation server) folder. However, due to the number of documents involved, we would need to run it as a background job. Hence, we've re-engineered FM CRM_KW_DOC_EXPORT (on a 'Z' version) by removing the call to CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD and putting in its place the following -

 

DATA : lv_buffer     TYPE xstring. 

 

  OPEN DATASET ls_filename IN BINARY MODE FOR OUTPUT MESSAGE mess.
  IF sy-subrc EQ 0.

    CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
      EXPORTING
        input_length = p_size
      IMPORTING
        buffer       = lv_buffer
      TABLES
        binary_tab   = lt_content.

    TRANSFER lv_buffer TO ls_filename.

    CLOSE DATASET ls_filename.

 

The file gets saved onto the application server folder, but the entire contents of the attachment are lost (i.e) the file is a blank document.

 

Have we missed a crucial step ? Has anyone mastered such a scenario ? Would like to hear some viewpoints.

 

 

TIA,

Ashok.

 

We do have a working solution of exporting the attachments as a foreground job.


Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>