cancel
Showing results for 
Search instead for 
Did you mean: 

Question: About sending smartform as Pdf attachment and Fax

Former Member
0 Kudos

While using the Function Modules

CREATE_SENDER_OBJECT_PPF

CREATE_RECIPIENT_OBJ_PPF

SO_USER_AUTOMATIC_INSERT

WFMC_PREPARE_SMART_FORM

SSF_FUNCTION_MODULE_NAME

FM GENERATED

to send e-mail with pdf attachment and Fax.

Is it possible to add mail body to the mail sent?

Kind Regards,

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

check code:

REPORT Z_SCRIPT .

DATA: itcpo LIKE itcpo,

tab_lines LIKE sy-tabix.

Variables for EMAIL functionality

DATA: maildata LIKE sodocchgi1.

DATA: mailpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.

DATA: mailhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.

DATA: mailbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.

DATA: mailtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.

DATA: mailrec LIKE somlrec90 OCCURS 0 WITH HEADER LINE.

DATA: solisti1 LIKE solisti1 OCCURS 0 WITH HEADER LINE.

*PERFORM send_form_via_email.

************************************************************************

FORM SEND_FORM_VIA_EMAIL *

************************************************************************

FORM send_form_via_email.

CLEAR: maildata, mailtxt, mailbin, mailpack, mailhead, mailrec.

REFRESH: mailtxt, mailbin, mailpack, mailhead, mailrec.

Creation of the document to be sent File Name

maildata-obj_name = 'TEST'.

Mail Subject

maildata-obj_descr = 'Subject'.

Mail Contents

mailtxt-line = 'Here is your file'.

APPEND mailtxt.

Prepare Packing List

PERFORM prepare_packing_list.

Set recipient - email address here!!!

mailrec-receiver = 'email.COM'.

mailrec-rec_type = 'U'.

APPEND mailrec.

Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = maildata

put_in_outbox = ' '

TABLES

packing_list = mailpack

object_header = mailhead

contents_bin = mailbin

contents_txt = mailtxt

receivers = mailrec

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

operation_no_authorization = 4

OTHERS = 99.

ENDFORM.

************************************************************************

Form PREPARE_PACKING_LIST

************************************************************************

FORM prepare_packing_list.

CLEAR: mailpack, mailbin, mailhead.

REFRESH: mailpack, mailbin, mailhead.

DESCRIBE TABLE mailtxt LINES tab_lines.

READ TABLE mailtxt INDEX tab_lines.

maildata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( mailtxt ).

Creation of the entry for the compressed document

CLEAR mailpack-transf_bin.

mailpack-head_start = 1.

mailpack-head_num = 0.

mailpack-body_start = 1.

mailpack-body_num = tab_lines.

mailpack-doc_type = 'RAW'.

APPEND mailpack.

Creation of the document attachment

This form gets the OTF code from the SAPscript form.

If you already have your OTF code, I believe that you may

be able to skip this form. just do the following code, looping thru

your SOLISTI1 and updating MAILBIN.

PERFORM get_otf_code.

LOOP AT solisti1.

MOVE-CORRESPONDING solisti1 TO mailbin.

APPEND mailbin.

ENDLOOP.

DESCRIBE TABLE mailbin LINES tab_lines.

mailhead = 'TEST.OTF'.

APPEND mailhead.

Creation of the entry for the compressed attachment

mailpack-transf_bin = 'X'.

mailpack-head_start = 1.

mailpack-head_num = 1.

mailpack-body_start = 1.

mailpack-body_num = tab_lines.

mailpack-doc_type = 'OTF'.

mailpack-obj_name = 'TEST'.

mailpack-obj_descr = 'Subject'.

mailpack-doc_size = tab_lines * 255.

APPEND mailpack.

ENDFORM.

************************************************************************

Form GET_OTF_CODE

************************************************************************

FORM get_otf_code.

DATA: BEGIN OF otf OCCURS 0.

INCLUDE STRUCTURE itcoo .

DATA: END OF otf.

DATA: itcpo LIKE itcpo.

DATA: itcpp LIKE itcpp.

CLEAR itcpo.

itcpo-tdgetotf = 'X'.

Start writing OTF code

CALL FUNCTION 'OPEN_FORM'

EXPORTING

form = 'Z08V3_COLLI'

language = sy-langu

options = itcpo

dialog = ' '

EXCEPTIONS

OTHERS = 1.

CALL FUNCTION 'START_FORM'

EXCEPTIONS

error_message = 01

OTHERS = 02.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

window = 'MAIN'

EXCEPTIONS

error_message = 01

OTHERS = 02.

Close up Form and get OTF code

CALL FUNCTION 'END_FORM'

EXCEPTIONS

error_message = 01

OTHERS = 02.

MOVE-CORRESPONDING itcpo TO itcpp.

CALL FUNCTION 'CLOSE_FORM'

IMPORTING

result = itcpp

TABLES

otfdata = otf

EXCEPTIONS

OTHERS = 1.

Move OTF code to structure SOLI form email

CLEAR solisti1. REFRESH solisti1.

LOOP AT otf.

solisti1-line = otf.

APPEND solisti1.

ENDLOOP.

ENDFORM

Body of the mail may not be possible.

Regards,

If helpful reward with points(Don't forget).

Former Member
0 Kudos

Hello,

Thank you, Shiva.

Actually i need to use the function modules mentioned above. My e-mail is being sent as pdf attachment.

I need to know whether it is possible to add e-mail content(e-mail body) when using the above function modules mentioned .

Can any one please help me?

Kind Regards,