cancel
Showing results for 
Search instead for 
Did you mean: 

populate body of the mail when smartform is triggered.

Former Member
0 Kudos

Hi Guru's,

i have configured the smartform, and when i execute the transaction the smartform is being triggered and i am getting the smartform as pdf in a mail.

i want to populate the body of the mail. i am not using the function modules like to convert smartform to pdf then triggering mail. it is triggering from output options.

how to poulate the body of the mail

Best regards,

Chetan.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello all,

I recently did an object which sends an email with the body.

Step 1.

Do not send the email directly by SAP functionality using smartform function module.

Set the parameter control_parameters-getotf = 'X' of the smartform function module.

step 2.

Use function module CONVERT_OTF

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

IMPORTING

bin_filesize = lf_bin_filesize

  • BIN_FILE =

TABLES

otf = gs_job_output_info-otfdata

lines = gt_lines

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

err_bad_otf = 4

OTHERS = 5.

Step 3

Use function module QCE1_CONVERT

CALL FUNCTION 'QCE1_CONVERT'

TABLES

t_source_tab = gt_lines

t_target_tab = outbin.

Step 3.

Fill up the details for Email Body + Attachment for the function module SO_NEW_DOCUMENT_ATT_SEND_API1

internal table objtxt will have body of email (txt format)

DESCRIBE TABLE objtxt LINES tab_lines.

READ TABLE objtxt INDEX tab_lines.

docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).

CLEAR objpack-transf_bin.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = 'HTM'.

APPEND objpack.

  • -----------

  • Packing Info Attachment

  • -----------

att_type = 'PDF'

DESCRIBE TABLE objbin LINES tab_lines.

READ TABLE outbin INDEX tab_lines.

objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).

objpack-transf_bin = 'X'.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = att_type.

objpack-obj_name = 'ATTACHMENT'.

objpack-obj_descr = 'description'.

APPEND objpack.

docdata-obj_name = name.

docdata-obj_descr = description.

step 4 :- use function module 'SO_NEW_DOCUMENT_ATT_SEND_API1'

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = docdata

put_in_outbox = 'X'

TABLES

packing_list = objpack

object_header = objhead

contents_bin = objbin

contents_txt = objtxt

receivers = reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

Hope this helps. Let me know if you have any questions

Former Member
0 Kudos

Thanks for response.

In an earlier attempt to meet this requirement, I tried the solution you proposed. I successfully set the getotf parameter to OTF. But then I was unable to correctly populate the parameters passed to CONVERT_OTF. I received short dump with error referencing invalid file size. So I went back to using the standard open_form, which does send the PDF, but now I can't add text to email.

Can you provide example of your code showing how you create the PDF to be sent, with data declarations?

Former Member
0 Kudos

The program is too big to post here and there are lot of unnecessary program lines for you to go through it. So I just gave the logic.

You might have to pass the correct parameters to the function module 'CONVERT_OTF'

Former Member
0 Kudos

Can you tell me how you declare variable outbin?

When I pass the results of QCE1_CONVERT to SO_NEW_DOCUMENT_ATT_SEND_API1, I get a short dump, indicating the parameter I'm passing into SO_NEW_DOCUMENT_ATT_SEND_API1 Tables: contents_bin is the wrong data type.

Former Member
0 Kudos

I declared parameter outbin as "LIKE SOLISTI1" and the code now works as required.

Thanks for all your help!

Former Member
0 Kudos

Hello,

declare the following

data :

i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,

in the program write the below cod as following

i_objtxt = 'Find attached the output of the smart form.'. --> this is the body of the mail.

APPEND i_objtxt.

now pass this to the call function.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = w_doc_chng

put_in_outbox = 'X'

IMPORTING

sent_to_all = v_sent_all

TABLES

packing_list = i_objpack ...... and also the other parameters

This shall trigger the body.

Former Member
0 Kudos

I am having the same problem.

I am generating an email with a Smart Form attached as PDF. The email is sent successfully, but there is no text in the body of the email.

The email is being built within FM Open_Form, as defined in the procedure for Output Type ZNE2. NACE is configured with medium 5. Everything is working fine.

Since the code is using OPEN_FORM and is not using 'SO_NEW_DOCUMENT_ATT_SEND_API1', is there a parameter I can populate to build the body of the email message?