cancel
Showing results for 
Search instead for 
Did you mean: 

Get the attach file from opportunities and upload in server directory

martin_aguirre
Explorer
0 Kudos

Hi Experts!

I have a problem with the attach documents in opportunities.

I need to get the XLS attached in a opportunity and put it in a server directory for be consumed by a legacy system. But when i try to get it with the method cl_crm_documents=>get_whit_table i get a binary table

CALL METHOD cl_crm_documents=>get_with_table
    EXPORTING
*       loio                = ls_loios
       phio                = ls_phios
        text_as_stream      = 'X'

    IMPORTING
     file_access_info    = lt_file_inf
     file_content_ascii  = lt_file_ascii
     file_content_binary = lt_file_bin
*    error               =
*    bad_ios             =
      .

but i can't reconstruct the XLS file in the server. i try with this ( among thousand other things ) but is not working =(

open DATASET  'data.xls' for output in TEXT MODE ENCODING *?*  .
LOOP AT lt_file_bin into ls_file_bin.
lv_string = ls_file_bin-line .
TRANSFER lv_string to  'data.xls' .
CLEAR ls_file_bin.

ENDLOOP.

CLOSE DATASET 'data.xls'.

Can you help me?

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Don't you have to now the mime type before you read the files?

Can you not use FM CRM_PPM_GET_ATTACHMENT_IL ? - This is to retrieve attachments from opportunities.

martin_aguirre
Explorer
0 Kudos

This FM only give me the info and the URL for the document, not the document itself. My requirement is put the file into the server. even the path for the file can help me, so if you know how to get it please tell me about it. The method get_with_table returns in the info file_type = B, i think this is the problem but i don't know how change it .

Best regards

arunprakash_karuppanan
Active Contributor
0 Kudos

Hi,

Try this. The excel format is binary, not ASCII. It is no use trying to interpret it as string.

open dataset 'data.xls' for output in binary mode.

LOOP AT lt_file_bin into ls_file_bin.

transfer ls_file_bin to 'data.xls'.

endloop.

close dataset 'data.xls'.

Regards,

Arun Prakash

martin_aguirre
Explorer
0 Kudos

Hi Arun! Thanks for ur ask.

I try your code, but when i go to the AL11 directory i see a bunch of symbols. Then how i can reconstruct the xls file exported?

Regards

Martin

Former Member
0 Kudos

Hi Martin,

Convert the binary data to a XSTRING and then do file transfer to application server in BINARY mode.

Refer to my article below, which has solution for your problem-

Get the files attached to CRM Transactions (Activity, Opportunity, Lead etc.,) and upload them to application server

http://divulgesap.com/blog.php?p=MTI2

Hope it helps.

Regards,

Ravikiran

Edited by: Ravikiran C on Apr 17, 2010 4:14 AM

martin_aguirre
Explorer
0 Kudos

Thanks very much Ravikiran!!

I follow your code and work perfect! 10 points for you

Best regards.

Answers (0)