Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Desktop Office Integration and Email

Former Member
0 Kudos

Dear Colleagues:

I have developed a Desktop Office Integration application that retrieves WORD documents from a BDS Content Server, customizes the document with BP data, emails the document to the BP as an attachment, and associates the document with the BP (Document tab). It works well.

I am now trying to figure out how to process the document and use the text as the body of an email message instead of an attachment - I cannot assume that all email recipients use MS Word.

I have tried several FMs that convert raw data to either strings or RTF format but, inspite of my efforts, I get conversion errors.

If anyone has tried something similar I would appreciate any advice.

Regards,

Steve

5 REPLIES 5

gautam_totekar
Active Participant
0 Kudos

hi.

i dont know if this will be useful to you. because i did not not understand your exact requirement. are you using OAOR tr code?

You mean to say you want to a word document which was uploaded through bds document navigator.

The code given below actually searches for a string and replaces all occurences of it with a new string..

IF old_search_string ne search.

  • get number of document characters.

GET PROPERTY OF document_cntl_handle-obj

'characters' = ocharacters.

GET PROPERTY OF ocharacters 'count' = char_count.

char_position = 0.

old_search_string = search.

ENDIF.

  • set range now

IF char_position >= char_count.

char_position = 0.

ENDIF.

CALL METHOD OF document_cntl_handle-obj 'Range' = orange

EXPORTING #1 = char_position #2 = char_count.

  • search now

GET PROPERTY OF orange 'Find' = ofind.

IF not replace is initial.

DATA: is_available type i.

CALL METHOD proxy->has_wordprocessor_interface

IMPORTING is_available = is_available

retcode = retcode.

IF is_available = 1 .

CALL METHOD proxy->get_wordprocessor_interface

IMPORTING wp_interface = wp_ref

retcode = retcode.

IF RETCODE EQ C_OI_ERRORS=>RET_OK.

CALL METHOD wp_ref->replace

EXPORTING replace_string = replace

search_string = search

pos = 'GLOBAL'

flag = 'ALL'.

ENDIF.

ENDIF.

ELSE.

*search

CALL METHOD OF ofind 'Execute'

EXPORTING #1 = search "FindText

#2 = false "MatchCase

#3 = false "MatchWholeWord

#4 = false "MatchWildCards

#5 = false "MatchSoundsLike

#6 = true "MatchAllWordForms

#7 = true "Forward

#8 = '1' "Wrap

#9 = true.

GET PROPERTY OF ofind 'Found' = string_found.

IF string_found > 0.

GET PROPERTY OF orange 'Font' = ofont.

GET PROPERTY OF ofont 'ColorIndex' = color_index.

IF color_index ne 6.

color_index = 6.

ELSE.

color_index = 11.

ENDIF.

SET PROPERTY OF ofont 'ColorIndex' = color_index.

ENDIF.

GET PROPERTY OF orange 'End' = char_position.

ENDIF.

Former Member
0 Kudos

Hi Gautam.

Thank you for reading and replying to my post. You thoughtful solution is not exactly what I need. Let me be more specific.

I have developed a custom program that used Desktop Office Integration. In the program I use the following class / interfaces: cl_bds_document_set, i_oi_document_proxy, and i_oi_word_processor_document.

I retrieve an existing word document, that I created with my program, customize it with BP data, and email it as a word attachement.

The requirement has changed so that I must send the document as the body of the email instead of as an attachement.

I have tried several FMs to convert the document to text but get short dumps because of conversion errors.

I used one of the available methods to print the document. Then, I retrieved the spool file into an internal table. I am now trying to determine how to convert the spool file to an internal table of text. Then, I will have to convert the text table into a string and pass it to the XI mail interface.

Thanks in advance for any insight you might offer.

Regards,

Steve

0 Kudos

Hi Steve,

You are trying to convert a word document to a plain text which would certainly have some problem as all word objects cannot be converted.

you could simply set word document as the body of the mail, but as you said all users may not have word.

the other closest option would be convert the word to html format and send a html email.

as far the FM you are looking for

use FM RSPO_RETURN_SPOOLJOB to get the spool data in binary format and then use FM SCMS_BINARY_TO_STRING

(for emailing , is there any special reason to use the XI mail interface instead of using ABAP CL_BCS classes)

Regards

Raja

0 Kudos

Hi Steve,

I realize this is replying to a two year old, unresolved, post but maybe(?) you can help me. I have a requirement to email EXISTING word documents as attachments.

That is, I don't need to reflect some text I'm constructing inside SAP as a word document, or manipulate it and add it as an attachment to an email (which is what a lot of blogs/posts demonstrate how to do). I simply want to add an existing document (which happens to be a microsoft word one but which could be anything, an excel spreadsheet, a pdf, a photgraph).

On the face of it you'd expect this to be something which many peiople have done before and would therefore be very easy. Maybe it is (I hope so) but having scoured SDN and the net in general for the last day, at least, I have found nothing to solve my exact problem. The closest was the reference below which you give to achieving what I want to do but then you want to go a step further.

"I have developed a custom program that used Desktop Office Integration. In the program I use the following class / interfaces: cl_bds_document_set, i_oi_document_proxy, and i_oi_word_processor_document.

I retrieve an existing word document, that I created with my program, customize it with BP data, and email it as a word attachement."

I would appreciate it if you could tell me which methods of these classes you used to achieve this. A code snippet would be fantastic.

Regards

Neil

suhas_rao
Explorer
0 Kudos

Hello,

If by using Office Integration document is opened as inplace then it is not possible to send document content as mail. In that case you can send document only as attachment.

This is because OI uses OLETechnology to render document and sendmail is limitation from Microsoft side.

If document is opened as outplace add this macro

Sub SendMail()

'

' SendMail Macro

' Macro recorded 14/Apr/08 by I037636

'

ActiveWindow.EnvelopeVisible = Not ActiveWindow.EnvelopeVisible

End Sub

and run it using "word proxy" you can see that mail can be sent using this macro