Download Documents and images for Sap CRM



User Rating:  / 0
PoorBest 
Details
Category: ABAP
Created on Wednesday, 05 December 2012 12:32
Last Updated on Wednesday, 05 December 2012 12:34
Published on Wednesday, 05 December 2012 12:32
Written by Administrator
Hits: 8403

Download product documents ( images, pdf, etc.. ) from Sap Crm with the following ABAP Code :

View source
report export_photo.
 
* www.developerpages.gr
 
parameters : l_OBJID like SKWF_IO-OBJID default '0A9404427FF19D48B71DAD37FF62D948'.
 
PARAMETERS : fname(255) default '\\server\filepath\'.
 
PERFORM download_photo USING l_objid.
 
 
*&---------------------------------------------------------------------*
*&      Form  download_photo
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->OBJID      text
*----------------------------------------------------------------------*
form download_photo USING objid.
 
  DATA: LS_LOIO TYPE SKWF_IO,
        PROPERTIES Type  SDOKPROPTYS,
        PHIOS Type  SKWF_IOS,
        FILE_ACCESS_INFO Type  SDOKFILACIS,
        CONTENT_ASCII Type  SDOKCNTASCS,
        CONTENT_BIN Type  SDOKCNTBINS,
        BUSINESS_OBJECTS Type    SIBFLPORBT,
        LOIO Type    SKWF_IO,
        IO_DOES_NOT_EXIST Type  XFLAG,
        wa_content_bin type LINE OF  SDOKCNTBINS,
        wa_PROPERTIES type LINE OF SDOKPROPTYS.
 
  LS_LOIO-OBJTYPE = 'P'.
  LS_LOIO-CLASS = 'BDS_POC22'.
  LS_LOIO-OBJID = objid.
 
  CALL METHOD CL_CRM_DOCUMENTS=>GET_DOCUMENT
    EXPORTING
      IO                = LS_LOIO
    IMPORTING
      PROPERTIES        = PROPERTIES
      PHIOS             = PHIOS
      FILE_ACCESS_INFO  = FILE_ACCESS_INFO
      CONTENT_ASCII     = CONTENT_ASCII
      CONTENT_BIN       = CONTENT_BIN
      BUSINESS_OBJECTS  = BUSINESS_OBJECTS
      LOIO              = LOIO
      IO_DOES_NOT_EXIST = IO_DOES_NOT_EXIST.
 
  loop at PROPERTIES into wa_PROPERTIES where name = 'EXTENSION'.
    concatenate fname objid '.' wa_PROPERTIES-value into fname.
  endloop.
 
  open DATASET fname for OUTPUT in BINARY MODE.
 
  loop at content_bin INTO wa_content_bin.
    write:/ wa_content_bin-LINE.
    TRANSFER wa_content_bin-LINE to fname.
  endloop.
 
  close DATASET fname.
 
  write :/ 'ok'.
 
endform.                    "download_photo