Application Development and Automation 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: 
Read only

SO_DOCUMENT_SEND_API1 send body image

Former Member
0 Likes
2,381

Hi all.

I want to send an image into the mail's body, using the FM SO_DOCUMENT_SEND_API1.

I've created a standard text using the transaction SO10 and read it in to my program using the FMs READ_TEXT (to read it), TEXT_SYMBOL_REPLACE (to replace variables into the text) and CONVERT_ITF_TO_ASCII (to format the text), then I pass the text to the FM SO_DOCUMENT_SEND_API1 through the CONTENTS_TXT parameter. It works fine!

Now I've introduced a graphic into the text with the line BITMAP 'LOGO' OBJECT GRAPHICS ID BMAP TYPE BCOL and I want that this graphic could be introduced into the mail's body. Right now it is sending a blank line.

Is this possible? If so, how can I do it?

Could I get an HTML code from a standard SO10 text ?

Regards.

Gregory.

Edited by: Gregory Mayorga on Mar 28, 2011 8:49 AM

5 REPLIES 5
Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
1,301

I haven't tried it myself, but I think it's possible to send an HTML email and, essentially, put whatever you need in it. Not sure if it could be done using SO10 texts (storing images as text is already obsolete even for the forms, by the way). For HTML the image would need to reside somewhere and you'll need a web link to it.

There is a question about an image in the email just a few posts higher.

Read only

Former Member
0 Likes
1,301

First you need to place your logo using OAER tcode. Once it is there (on application serv) you need to create an url from it.

Then simply add this url to html tab << img src="url" >> . When creating bcs document, pass HTML type as message type and html tab as email body.

DATA: pick_data TYPE TABLE OF w3mime,
          it_query TYPE TABLE OF w3query,
          wa_query TYPE w3query,
          it_html TYPE TABLE OF w3html,
          return_code TYPE  w3param-ret_code,
          content_type TYPE  w3param-cont_type,
          content_length TYPE  w3param-cont_len,
          url(255) TYPE c,
          pic_size TYPE i.
 
 
    REFRESH it_query.
    wa_query-name = '_OBJECT_ID'.
    wa_query-value = 'ENJOYSAP_LOGO'.   "node name in OAER where your picture was placed
    APPEND wa_query TO it_query.
 
 
    CALL FUNCTION 'WWW_GET_MIME_OBJECT'
      TABLES
        query_string        = it_query
        html                = it_html
        mime                = pick_data
      CHANGING
        return_code         = return_code
        content_type        = content_type
        content_length      = content_length
      EXCEPTIONS
        invalid_table       = 1
        parameter_not_found = 2
        OTHERS              = 3.
    IF sy-subrc = 0.
      pic_size = content_length.
    ENDIF.
 
    CLEAR url.
    CALL FUNCTION 'DP_CREATE_URL'
      EXPORTING
        type     = 'image'
        subtype  = 'X-UNKNOWN'
        size     = pic_size
        lifetime = 'T'
      TABLES
        data     = pick_data
      CHANGING
        url      = url
      EXCEPTIONS
        OTHERS   = 1.
 
"2. ------------------------------ adding html tags
data: lt_message TYPE bcsy_text with header line.
 
concatenate: '<<img src="' url '">>' to lt_message.  "use "<">" only once (it can't be displayed here correctly)
append lt_message.
 
"3. ------------------------------ setting message type in email body
data lr_email TYPE REF TO cl_bcs,
 
        lr_email_body = cl_document_bcs=>create_document(
                                         i_type = 'HTM'
                                         i_text = lt_message
                                         i_subject = l_subject ).
 
        lr_email->set_document( lr_email_body ).

Read only

0 Likes
1,301

Hi Rahul.

I've uploaded my image through T-OAER with code ZTEST and it has been uploaded fine, but when I call the FM WWW_GET_MIME_OBJECT manually with

QUERY_STRING-VALUE = 'ZTEST'.

It returns me the exception OBJECT_NOT_FOUND with the message SWWW021.

If I try manually with

QUERY_STRING-VALUE = 'ENJOYSAP_LOGO'.

The FM works fine

Is there anything else that I have to do into T-OAER that allows me to read the image using the FM you suggest?

Also trying to send the email using ENJOYSAP_LOGO and it takes HTML format send ok, but does not shows the image. Show the space for the image but with an 'X' like a web page does it when not found an image. I guess it is not showing the image because the protocol is SAPR3 I mean the URL to image is sapr3://E05AD88B498849F1BAF9000C291A14EF/.

I try generating the URL calling FM BDS_BUSINESSDOCUMENT_GET_URL that generates an HTTP URL and shows the image but after giving it the user and password.

Regards.

Gregory.

Edited by: Gregory Mayorga on Mar 30, 2011 12:17 PM

Read only

0 Likes
1,301

You might want to have a look at this thread:

I don't necessarily agree with the attachment approach but it apparently works. What you really need is to reference an externally accessible location (outside your firewall) where the image is stored with your IMG tag (this is how 'normal' HTML code is written). There are other ways to do it but not really as easy as the MIME folder approach.

Read only

0 Likes
1,301

Hey, sorry about the delay.

I was very busy with others requirements.

I dont like an attachment either and now is when I'm gonna do the test. I have one question:

Considering that I'm using the FM SO_DOCUMENT_SEND_API1 If I already am attaching one file (SAP transaction shortcut) what do I have to do to attach the picture?

Regards.

Gregory.