Send Smartforms Output as pdf Attachment in E-Mail

Hi!
I've searched quite a long time and tried to use different examples I've found in the forum but it doesn't work for me.
I tried to do the following:
Send output of smartforms by mail to a specified e-mail adress. Sometimes there have to be sent 2 pdf's (both are output of smartforms) in one e-mail.
The function to download the output of smartform with FM CONVERT_OTF_2_PDF and GUI_DOWNLOAD works fine for me but I couldn't get the FM SO_NEW_DOCUMENT_SEND_API1 to work.
Can someone give me an example or a description to get from the output of the smartform to the e-mail with attachment?
I'm pretty new to this so it maybe is a very simple question.
Regards,
Jacko

Try the following code
report zpp430_report_in_pdf no standard page heading line-size 255.
*& Converts spool request into PDF document and emails it to *
*& recipicant. *
*& Execution *
*& This program must be run as a background job in-order for the write *
*& commands to create a Spool request rather than be displayed on *
*& screen *
tables: tsp01.
parameter: p_email1 like somlreci1-receiver.
p_sender like somlreci1-receiver.
p_repid like sy-repid, " Report to execute
p_linsz like sy-linsz default 132, " Line size
p_paart like sy-paart default 'X_65_132', " Paper Format
p_slset like sy-slset, "Variant name
p_odescr like sodocchgi1-obj_descr,
p_adescr type so_obj_nam,
p_delspl as checkbox.
*DATA DECLARATION
data: gd_recsize type i.
* Spool IDs
types: begin of t_tbtcp.
include structure tbtcp.
types: end of t_tbtcp.
data: it_tbtcp type standard table of t_tbtcp initial size 0,
wa_tbtcp type t_tbtcp.
* Job Runtime Parameters
data: gd_eventid like tbtcm-eventid,
gd_eventparm like tbtcm-eventparm,
gd_external_program_active like tbtcm-xpgactive,
gd_jobcount like tbtcm-jobcount,
gd_jobname like tbtcm-jobname,
gd_stepcount like tbtcm-stepcount,
gd_error type sy-subrc,
gd_reciever type sy-subrc.
data: w_recsize type i,
mc_valid(1) type c.
data: gd_subject like sodocchgi1-obj_descr,
it_mess_bod like solisti1 occurs 0 with header line,
it_mess_att like solisti1 occurs 0 with header line,
gd_sender_type like soextreci1-adr_typ,
gd_attachment_desc type so_obj_nam,
gd_attachment_name type so_obj_des,
mi_rqident like tsp01-rqident.
* Spool to PDF conversions
data: gd_spool_nr like tsp01-rqident,
w_spool_nr like tsp01-rqident,
gd_destination like rlgrap-filename,
gd_bytecount like tst01-dsize,
gd_buffer type string.
data:
mstr_print_parms like pri_params.
* Binary store for PDF
data: begin of it_pdf_output occurs 0.
include structure tline.
data: end of it_pdf_output.
constants: c_dev like sy-sysid value 'DEV',
c_no(1) type c value ' ',
c_device(4) type c value 'LOCL'.
*START-OF-SELECTION.
start-of-selection.
* Write statement to represent report output. Spool request is created
* if write statement is executed in background. This could also be an
* ALV grid which would be converted to PDF without any extra effort
* WRITE 'Hello World'.
* NEW-PAGE.
* COMMIT WORK.
* NEW-PAGE PRINT OFF.
* IF SY-BATCH EQ 'X'.
* PERFORM GET_JOB_DETAILS.
* PERFORM OBTAIN_SPOOL_ID.
*** Alternative way could be to submit another program and store spool
*** id into memory.
*submit ZSPOOLTOPDF2
* to sap-spool
* spool parameters %_print
* archive parameters %_print
* without spool dynpro
* and return.
call function 'GET_PRINT_PARAMETERS'
exporting
authority = space
copies = '1'
cover_page = space
data_set = space
department = space
destination = space
expiration = '1'
immediately = space
* in_archive_parameters = space
* in_parameters = space
layout = space
mode = space
new_list_id = 'X'
no_dialog = 'X'
user = sy-uname
importing
out_parameters = mstr_print_parms
valid = mc_valid
exceptions
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
others = 4.
if mstr_print_parms-pdest = space.
mstr_print_parms-pdest = 'LOCL'.
endif.
mstr_print_parms-linsz = p_linsz.
mstr_print_parms-paart = p_paart.
submit (p_repid) to sap-spool without spool dynpro
spool parameters mstr_print_parms
using selection-set p_slset
and return.
* Get spool id from program called above
perform get_spool_number using sy-repid sy-uname changing mi_rqident.
* IMPORT w_spool_nr FROM MEMORY ID SY-REPID.
perform convert_spool_to_pdf.
perform process_email.
if p_delspl eq 'X'.
perform delete_spool.
endif.
if sy-sysid = c_dev.
wait up to 5 seconds.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
endif.
* ELSE.
* SKIP.
* WRITE:/ 'Program must be executed in background in-order for spool'
* 'request to be created.'.
* ENDIF.
* FORM obtain_spool_id *
form obtain_spool_id.
check not ( gd_jobname is initial ).
check not ( gd_jobcount is initial ).
select * from tbtcp
into table it_tbtcp
where jobname = gd_jobname
and jobcount = gd_jobcount
and stepcount = gd_stepcount
and listident <> '0000000000'
order by jobname
jobcount
stepcount.
read table it_tbtcp into wa_tbtcp index 1.
if sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
message s004(zdd) with gd_spool_nr.
else.
message s005(zdd).
endif.
endform. "OBTAIN_SPOOL_ID
* FORM get_job_details *
form get_job_details.
* Get current job details
call function 'GET_JOB_RUNTIME_INFO'
importing
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
exceptions
no_runtime_info = 1
others = 2.
endform. "GET_JOB_DETAILS
* FORM convert_spool_to_pdf *
form convert_spool_to_pdf.
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = mi_rqident
no_dialog = c_no
dst_device = c_device
importing
pdf_bytecount = gd_bytecount
tables
pdf = it_pdf_output
exceptions
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
others = 12.
check sy-subrc = 0.
* Transfer the 132-long strings to 255-long strings
loop at it_pdf_output.
translate it_pdf_output using ' ~'.
concatenate gd_buffer it_pdf_output into gd_buffer.
endloop.
translate gd_buffer using '~ '.
do.
it_mess_att = gd_buffer.
append it_mess_att.
shift gd_buffer left by 255 places.
if gd_buffer is initial.
exit.
endif.
enddo.
endform. "CONVERT_SPOOL_TO_PDF
* FORM process_email *
form process_email.
describe table it_mess_att lines gd_recsize.
check gd_recsize > 0.
perform send_email using p_email1.
* perform send_email using p_email2.
endform. "PROCESS_EMAIL
* FORM send_email *
* --> p_email *
form send_email using p_email.
check not ( p_email is initial ).
refresh it_mess_bod.
* Default subject matter
gd_subject = p_odescr.
gd_attachment_desc = p_adescr.
* CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'This is an automated report from SAP.'.
append it_mess_bod.
it_mess_bod = 'Please do not reply to this mail id.'.
append it_mess_bod.
*IT_MESS_BOD = 'For any clarification on the details of this report'
* APPEND IT_MESS_BOD.
* IT_MESS_BOD = 'please contact Business Planning. Thank you'.
* APPEND IT_MESS_BOD.
* If no sender specified - default blank
if p_sender eq space.
gd_sender_type = space.
else.
gd_sender_type = 'INT'.
endif.
* Send file by email as .xls speadsheet
perform send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
p_odescr
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
endform. "SEND_EMAIL
* FORM delete_spool *
form delete_spool.
data: ld_spool_nr type tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
check p_delspl <> c_no.
call function 'RSPO_R_RDELETE_SPOOLREQ'
exporting
spoolid = ld_spool_nr.
endform. "DELETE_SPOOL
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
* Send email
form send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
data: ld_error type sy-subrc,
ld_reciever type sy-subrc,
ld_mtitle like sodocchgi1-obj_descr,
ld_email like somlreci1-receiver,
ld_format type so_obj_tp ,
ld_attdescription type so_obj_nam ,
ld_attfilename type so_obj_des ,
ld_sender_address like soextreci1-receiver,
ld_sender_address_type like soextreci1-adr_typ,
ld_receiver like sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
* Fill the document data.
w_doc_data-doc_size = 1.
* Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
* Fill the document data and get size of attachment
clear w_doc_data.
read table it_attach index w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + strlen( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
clear t_attachment.
refresh t_attachment.
t_attachment[] = it_attach[].
* Describe the body of the message
clear t_packing_list.
refresh t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
describe table it_message lines t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
append t_packing_list.
* Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
describe table t_attachment lines t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
append t_packing_list.
* Add the recipients email address
clear t_receivers.
refresh t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
append t_receivers.
call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
importing
sent_to_all = w_sent_all
tables
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
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.
* Populate zerror return code
ld_error = sy-subrc.
* Populate zreceiver return code
loop at t_receivers.
ld_receiver = t_receivers-retrn_code.
endloop.
endform. "SEND_FILE_AS_EMAIL_ATTACHMENT
*& Form GET_SPOOL_NUMBER
* text
* -->P_SY_REPID text
* -->P_SY_UNAME text
* <--P_MI_RQIDENT text
form get_spool_number using f_repid
f_uname
changing f_rqident.
data:
lc_rq2name like tsp01-rq2name.
concatenate f_repid+0(9)
f_uname+0(3)
into lc_rq2name.
select * from tsp01 where rq2name = lc_rq2name
order by rqcretime descending.
f_rqident = tsp01-rqident.
exit.
endselect.
if sy-subrc ne 0.
clear f_rqident.
endif.
endform. " GET_SPOOL_NUMBER
there are lot's of posts available on sdn which u can refer to.
tx
ashwa

Similar Messages

  • Sending smartform output as PDF attachment, Error opening PDF attachment

    Hi Experts,
    I am using the code form the following link to send a smartform output as PDF attachment. I can able to see the message, but can not open PDF document.
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/convertSmartformtoPDFformat&
    The information should be on my smartform are some text, company logo and a barcode.
    With all of these received error: "There was an error opening this document. The file is damaged and could not be repaired."
    I tried different ways like only text, text with company logo, text with barcode. I got the following errors:
    An unrecognized token 'Td0' was found
    There was problem reading this document(16).
    There was problem reading this document(111).
    Does anyone have idea of these ? Your help is greatly appreciated.
    Thank you,
    Surya

    please see this code  ...  for sending the  Email as  PDF attach file,
    *& Report  ZSPOOLTOPDF                                                 *
    *& Converts spool request into PDF document and emails it to           *
    *& recipicant.                                                         *
    *& Execution                                                           *
    *& This program must be run as a background job in-order for the write *
    *& commands to create a Spool request rather than be displayed on      *
    *& screen                                                              *
    REPORT  zspooltopdf.
    PARAMETER: p_email1 LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_sender LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_delspl  AS CHECKBOX.
    *DATA DECLARATION
    DATA: gd_recsize TYPE i.
    * Spool IDs
    TYPES: BEGIN OF t_tbtcp.
            INCLUDE STRUCTURE tbtcp.
    TYPES: END OF t_tbtcp.
    DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
          wa_tbtcp TYPE t_tbtcp.
    * Job Runtime Parameters
    DATA: gd_eventid LIKE tbtcm-eventid,
          gd_eventparm LIKE tbtcm-eventparm,
          gd_external_program_active LIKE tbtcm-xpgactive,
          gd_jobcount LIKE tbtcm-jobcount,
          gd_jobname LIKE tbtcm-jobname,
          gd_stepcount LIKE tbtcm-stepcount,
          gd_error    TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    DATA:  w_recsize TYPE i.
    DATA: gd_subject   LIKE sodocchgi1-obj_descr,
          it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_sender_type     LIKE soextreci1-adr_typ,
          gd_attachment_desc TYPE so_obj_nam,
          gd_attachment_name TYPE so_obj_des.
    * Spool to PDF conversions
    DATA: gd_spool_nr LIKE tsp01-rqident,
          gd_destination LIKE rlgrap-filename,
          gd_bytecount LIKE tst01-dsize,
          gd_buffer TYPE string.
    * Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    CONSTANTS: c_dev LIKE  sy-sysid VALUE 'DEV',
               c_no(1)     TYPE c   VALUE ' ',
               c_device(4) TYPE c   VALUE 'LOCL'.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    * Write statement to represent report output. Spool request is created
    * if write statement is executed in background. This could also be an
    * ALV grid which would be converted to PDF without any extra effort
      WRITE 'Hello World'.
      new-page.
      commit work.
      new-page print off.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
    *** Alternative way could be to submit another program and store spool
    *** id into memory, will be stored in sy-spono.
    *submit ZSPOOLTOPDF2
    *        to sap-spool
    *        spool parameters   %_print
    *        archive parameters %_print
    *        without spool dynpro
    *        and return.
    * Get spool id from program called above
    *  IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
        PERFORM convert_spool_to_pdf.
        PERFORM process_email.
        if p_delspl EQ 'X'.
          PERFORM delete_spool.
        endif.
        IF sy-sysid = c_dev.
          wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
        ENDIF.
      ELSE.
        SKIP.
        WRITE:/ 'Program must be executed in background in-order for spool',
                'request to be created.'.
      ENDIF.
    *       FORM obtain_spool_id                                          *
    FORM obtain_spool_id.
      CHECK NOT ( gd_jobname IS INITIAL ).
      CHECK NOT ( gd_jobcount IS INITIAL ).
      SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                     AND        jobcount    = gd_jobcount
                     AND        stepcount   = gd_stepcount
                     AND        listident   <> '0000000000'
                     ORDER BY   jobname
                                jobcount
                                stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        MESSAGE s004(zdd) WITH gd_spool_nr.
      ELSE.
        MESSAGE s005(zdd).
      ENDIF.
    ENDFORM.
    *       FORM get_job_details                                          *
    FORM get_job_details.
    * Get current job details
      CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    ENDFORM.
    *       FORM convert_spool_to_pdf                                     *
    FORM convert_spool_to_pdf.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount            = gd_bytecount
           TABLES
                pdf                      = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
      CHECK sy-subrc = 0.
    * Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
    *       FORM process_email                                            *
    FORM process_email.
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      PERFORM send_email USING p_email1.
    *  perform send_email using p_email2.
    ENDFORM.
    *       FORM send_email                                               *
    *  -->  p_email                                                       *
    FORM send_email USING p_email.
      CHECK NOT ( p_email IS INITIAL ).
      REFRESH it_mess_bod.
    * Default subject matter
      gd_subject         = 'Subject'.
      gd_attachment_desc = 'Attachname'.
    *  CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
      it_mess_bod        = 'Message Body text, line 1'.
      APPEND it_mess_bod.
      it_mess_bod        = 'Message Body text, line 2...'.
      APPEND it_mess_bod.
    * If no sender specified - default blank
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
    * Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_mess_bod
                                          it_mess_att
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'PDF'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 changing gd_error
                                          gd_reciever.
    ENDFORM.
    *       FORM delete_spool                                             *
    FORM delete_spool.
      DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
      ld_spool_nr = gd_spool_nr.
      CHECK p_delspl <> c_no.
      CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
           EXPORTING
                spoolid = ld_spool_nr.
    ENDFORM.
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
    *       Send email
    FORM send_file_as_email_attachment tables it_message
                                              it_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
    data:   t_packing_list like sopcklsti1 occurs 0 with header line,
            t_contents like solisti1 occurs 0 with header line,
            t_receivers like somlreci1 occurs 0 with header line,
            t_attachment like solisti1 occurs 0 with header line,
            t_object_header like solisti1 occurs 0 with header line,
            w_cnt type i,
            w_sent_all(1) type c,
            w_doc_data like sodocchgi1.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    * Fill the document data.
      w_doc_data-doc_size = 1.
    * Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    * Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    * Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    * Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    * Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           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.
    * Populate zerror return code
      ld_error = sy-subrc.
    * Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    reward  points  if it is usefull ....
    Girish

  • Reg: sending smartform output as PDF attachment

    hii all,
               i am using 'SX_OBJECT_CONVERT_OTF_PDF' func. module to convert my otf data to pdf and using the  func. module 'SO_NEW_DOCUMENT_ATT_SEND_API1'  for sending the mail with the PDF attachment. I am able to send the mail and i can see the mail attachment in my out box  of business work place..i can open the attachment and read it. but after i sent the mail to other e-mail if i open the document..it is showing as the attachment file is corrupted and i am unable to read it.
    can any one help me on this.
    Edited by: sandeep akella on Dec 13, 2008 9:54 AM

    * Transfer the 132-long strings to 255-long strings
        LOOP AT gt_pdf_output INTO wa_pdf_output.
          TRANSLATE wa_pdf_output USING '~'.
          CONCATENATE v_buffer wa_pdf_output INTO v_buffer.
        ENDLOOP.
    * TO CONVERT THE DATA INTO PDF FORMAT
        TRANSLATE v_buffer USING '~'.
        CLEAR : wa_messg_att,
                gt_messg_att.
        DO.
          wa_messg_att = v_buffer.
          APPEND wa_messg_att TO gt_messg_att.
          SHIFT v_buffer LEFT BY 255 PLACES.
          IF v_buffer IS INITIAL.
            EXIT.
          ENDIF.
          CLEAR wa_messg_att.
        ENDDO.
    For the body of the email message, pass doc type as RAW
    for the PDF attachment pass doc type as PDF
    So the internal table for Packing List
    * Describe the body of the message
      lwa_packing_list-transf_bin = space.
      lwa_packing_list-head_start = 1.
      lwa_packing_list-head_num   = 0.
      lwa_packing_list-body_start = 1.
      DESCRIBE TABLE gt_messg_body LINES lwa_packing_list-body_num.
      lwa_packing_list-doc_type = 'RAW'.
      APPEND lwa_packing_list TO lgt_packing_list.
      CLEAR lwa_packing_list.
    * Create attachment notification
      lwa_packing_list-transf_bin = 'X'.
      lwa_packing_list-head_start = 1.
      lwa_packing_list-head_num   = 1.
      lwa_packing_list-body_start = 1.
      DESCRIBE TABLE gt_messg_att LINES lwa_packing_list-body_num.
      lwa_packing_list-doc_type   =  'PDF'.
      lwa_packing_list-doc_size   =  lwa_packing_list-body_num * 255.
      APPEND lwa_packing_list TO lgt_packing_list.

  • Sending Smartform output as a body of the mail not as the attachement

    Hi All,
      my requirement is like this...
      I need to send a smartform output as the body of a mail. and not as the attachment.
      Hope you got my question
    Regards
      Raghu

    Hi,
           I hope the following links might help you,
    Smartform output as Email.
    Smartform to PDF and e_mail? Urgent
    Regards,
    Hema.
    Reward points if it is useful.

  • Send Quotation Output as PDF attached with Quotation output

    Hi All,
    We have developed one smartform and also have the print report assigned to it. It is working fine but now the customer want the quotation to be sent as a PDF attachement.
    Please let us know if you want any further information.
    Regards,
    Swapnil

    Hi,
    I can think of these options. Please explore on the possibilities.
    1) Create one MAIN Report , which will submit your report. Get the List output from memory. Convert the Data to PDF and send the PDF as attachment in mail.
    2)  Create a smartform which will be called in your report. Convert the returned data to PDF and then send the PDF as attachment in mail.
    3) Create one MAIN Report , which will submit your report thorugh a JOB. Wait for the JOB to be completed. Convert the ABAP Spool data to PDF and send the PDF as attachment in mail.
    Regards,
    Abhishek

  • Send report output as pdf attachment (without collecting spool )

    I used to do this requirement by collecting the spool and then convert it to pdf. But in this case we should use the report output ( NOT FROM SPOOL )  and convert it to PDF and send it as email attachment.
    Please help.
    Thanks!

    Hi,
    I can think of these options. Please explore on the possibilities.
    1) Create one MAIN Report , which will submit your report. Get the List output from memory. Convert the Data to PDF and send the PDF as attachment in mail.
    2)  Create a smartform which will be called in your report. Convert the returned data to PDF and then send the PDF as attachment in mail.
    3) Create one MAIN Report , which will submit your report thorugh a JOB. Wait for the JOB to be completed. Convert the ABAP Spool data to PDF and send the PDF as attachment in mail.
    Regards,
    Abhishek

  • Send ALV Grid output as PDF attachment to external mail id?

    Any solution on this please

    Check SOST transaction for external email problem.Is it showing some error there or it has not started external send process.
    If external send process has not started then follow below route :
    Go to sost->eneter selection criteria -> utilities-> start send process
    you are sending attachement as PDF ? or which type o document ?
    Please check the type of document & whether it's been supported by application via which you are trying to view.
    Re: Sending Email  to external email address in Batch mode
    Hope this explanation helps.
    Message was edited by:
            Karthikeyan Pandurangan

  • Sending smartform output as mail attachment (PDF)

    Hi,
    I am trying to send a smartform output in PDF format as a mail attachment. This has to be fired in the save of a Invoice.. configured by the output type.
    Here is the code which i have .. and it does not work.
    DATA: ls_bil_invoice TYPE lbbil_invoice.
    tables: nast.
    DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
    i_tline TYPE TABLE OF tline WITH HEADER LINE,
    i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
    i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
    i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
    i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
    wa_objhead TYPE soli_tab,
    w_ctrlop TYPE ssfctrlop,
    w_compop TYPE ssfcompop,
    w_return TYPE ssfcrescl,
    wa_doc_chng typE sodocchgi1,
    w_data TYPE sodocchgi1,
    wa_buffer TYPE string,"To convert from 132 to 255
    Variables declarations
    v_form_name TYPE rs38l_fnam,
    v_len_in LIKE sood-objlen,
    v_len_out LIKE sood-objlen,
    v_len_outn TYPE i,
    v_lines_txt TYPE i,
    v_lines_bin TYPE i.
    call function 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        formname           = 'ZSDDLB_BIL_INVOICE'
      IMPORTING
        fm_name            = v_form_name
      EXCEPTIONS
        no_form            = 1
        no_function_module = 2
        others             = 3.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    w_ctrlop-getotf = 'X'.
    w_ctrlop-no_dialog = 'X'.
    w_compop-tdnoprev = 'X'.
    CALL FUNCTION v_form_name
      EXPORTING
        control_parameters = w_ctrlop
        output_options     = w_compop
        user_settings      = 'X'
        is_bil_invoice     = ls_bil_invoice
        is_nast            = nast
        is_repeat          = 'X'
      IMPORTING
        job_output_info    = w_return
      EXCEPTIONS
        formatting_error   = 1
        internal_error     = 2
        send_error         = 3
        user_canceled      = 4
        OTHERS             = 5.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    i_otf[] = w_return-otfdata[].
    call function 'CONVERT_OTF'
      EXPORTING
        format                = 'PDF'
        max_linewidth         = 132
      IMPORTING
        bin_filesize          = v_len_in
      TABLES
        otf                   = i_otf
        lines                 = i_tline
      EXCEPTIONS
        err_max_linewidth     = 1
        err_format            = 2
        err_conv_not_possible = 3
        others                = 4.
    if sy-subrc EQ 0.
    endif.
    Convert PDF from 132 to 255.
    loop at i_tline.
      translate i_tline using '~'.
      concatenate wa_buffer i_tline into wa_buffer.
    endloop.
    translate wa_buffer using '~'.
    do.
      i_record = wa_buffer.
      append i_record.
      shift wa_buffer left by 255 places.
      if wa_buffer is initial.
        exit.
      endif.
    enddo.
    refresh:
    i_reclist,
    i_objtxt,
    i_objbin,
    i_objpack.
    clear wa_objhead.
    Object with PDF.
    i_objbin[] = i_record[].
    DESCRIBE TABLE i_objbin LINES v_lines_bin.
    Object with main text of the mail.
    i_objtxt = 'Find attached the output of the smart form.'.
    APPEND i_objtxt.
    DESCRIBE TABLE i_objtxt LINES v_lines_txt.
    Document information.
    wa_doc_chng-obj_name = 'Smartform'.
    wa_doc_chng-expiry_dat = sy-datum + 10.
    wa_doc_chng-obj_descr = 'Smart form output'.
    wa_doc_chng-sensitivty = 'F'. "Functional object
    wa_doc_chng-doc_size = v_lines_txt * 255.
    Pack to main body as RAW.
    Obj. to be transported not in binary form
    CLEAR i_objpack-transf_bin.
    Start line of object header in transport packet Smart Forms
    i_objpack-head_start = 1.
    Number of lines of an object header in object packet
    i_objpack-head_num = 0.
    Start line of object contents in an object packet
    i_objpack-body_start = 1.
    Number of lines of the object contents in an object packet
    i_objpack-body_num = v_lines_txt.
    Code for document class
    i_objpack-doc_type = 'RAW'.
    APPEND i_objpack.
    Packing as PDF.
    i_objpack-transf_bin = 'X'.
    i_objpack-head_start = 1.
    i_objpack-head_num = 1.
    i_objpack-body_start = 1.
    i_objpack-body_num = v_lines_bin.
    i_objpack-doc_type = 'PDF'.
    i_objpack-obj_name = 'Smartform'.
    CONCATENATE 'Smartform_output' '.pdf'
    INTO i_objpack-obj_descr.
    i_objpack-doc_size = v_lines_bin * 255.
    APPEND i_objpack.
    Document information.
    CLEAR i_reclist.
    e-mail receivers.
    i_reclist-receiver = '[email protected]'.
    i_reclist-express = 'X'.
    i_reclist-rec_type = 'U'. "Internet address
    APPEND i_reclist.
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        document_data              = wa_doc_chng
        put_in_outbox              = 'X'
      TABLES
        packing_list               = i_objpack
        object_header              = wa_objhead
        CONTENTS_BIN               = i_objbin
        contents_txt               = i_objtxt
        receivers                  = i_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.
    IF sy-subrc EQ 0.
    ENDIF.

    Hi Aviroop,
      Compare your part of code with the below given code.
    *& Report  YSSN_SIMPLE_SMARTFORM                                       *
    report  zhr_bhaskar_pdf_to_email                   message-id zmsg.
    parameters: p_vbeln type vbak-vbeln default '35'.
    data: it_items type table of vbap,
          v_fm_name type  rs38l_fnam,
          v_tot_lines type i,
          v_sy_tabix           type i,
          output_data        type ssfcrescl. " To hold Output information
    constants:
      c_sep                type c value '-',  " Value -
      c_x                  type c value 'X',  " Value X
      c_space              type c value ' '.  " Space
    *****MAIL START
    include .
    data: g_mail_rec_obj type swotobjid,
          g_mail_sen_obj type swotobjid,
          g_mail_app_obj type swotobjid,
          g_cont_par type  ssfctrlop,
          folder type swc_object,
      begin of sofmfol_key,
          foldertype like sofm-foltp,
          folderyear like sofm-folyr,
          foldernumber like sofm-folno,
          type like sofm-doctp,
          year like sofm-docyr,
          number like sofm-docno,
          forwarder like soub-usrnam,
      end of sofmfol_key,
          bor_key like swotobjid-objkey,
         g_mail TYPE  ppfdmailad VALUE '[email protected]',
          g_mail type  so_name value '[email protected]',
        g_mail TYPE  ppfdmailad VALUE '[email protected]' ,
        g_mail TYPE  ppfdmailad VALUE '[email protected]' ,
          g_rectype type  so_escape value 'U'. " 'B'.
    data: job_output_info type ssfcrescl,
          hotfdata like itcoo  occurs 1 with header line,
          htline like tline    occurs 1 with header line,
          x_objcont like soli  occurs 1 with header line,
          ld_packing_list like soxpl occurs 1 with header line,
          x_object_hd_change like sood1 occurs 1 with header line,
          x_objhead like soli           occurs 1 with header line,
          x_receivers like soos1 occurs 1 with header line,
          format_pdf(10) value 'PDF',
          doc_size(12) type c,
          hltlines type i,
          htabix like sy-tabix,
          fle1(2) type p,
          fle2(2) type p,
          off1 type p,
          hfeld(500) type c.
    tables: soud.
    *****MAIL END
    select *
    into table it_items
    from vbap
    where vbeln = p_vbeln.
    if  it_items[] is initial.
       exit.
    endif.
    perform call_smartform.
    *&      Form  call_smartform
          text
    -->  p1        text
    <--  p2        text
    form call_smartform .
    *DATA: lx_control_parameters TYPE SSFCTRLOP,
         lx_OUTPUT_OPTIONS type SSFCOMPOP.
         lx_OUTPUT_OPTIONS-TDIMMED = ' '.
         lx_OUTPUT_OPTIONS-TDfinal = 'X'.
         lx_OUTPUT_OPTIONS-TDDELETE = 'X'.
         lx_CONTROL_PARAMETERS-NO_CLOSE = 'X'.
         lx_CONTROL_PARAMETERS-NO_OPEN = ' '.
      data: x_ssfcompop type ssfcompop,
            x_ssfctrlop like ssfctrlop,
            x_ssfcrescl type ssfcrescl.
    **MAIL
      g_cont_par-langu = sy-langu.
      g_cont_par-no_dialog = 'X'.
      g_cont_par-getotf = 'X'.
      g_cont_par-device = 'MAIL'.
    Get BOR-Objects for Recipient, Sender und Applikation
      perform mail_recipient_object changing g_mail_rec_obj.
      perform mail_sender_object changing g_mail_sen_obj.
      perform mail_appl_object changing g_mail_app_obj.
    **MAIL
    *--Internal table is having more than 1 record
      if v_tot_lines  gt 1.
        if  v_sy_tabix = 1.
    *--For first record of table
          x_ssfctrlop-no_open  = c_space.
          x_ssfctrlop-no_close = c_x.
        elseif v_sy_tabix = v_tot_lines.
    *--For last record of table
          x_ssfctrlop-no_open  = c_x.
          x_ssfctrlop-no_close = c_space.
        else.
          x_ssfctrlop-no_open  = c_x.
          x_ssfctrlop-no_close = c_x.
        endif.
      endif.
    IF r_previ = c_x.
        x_ssfctrlop-preview  =  c_x.
        x_ssfctrlop-getotf   =  c_x.
    ENDIF.
    call function 'SSF_FUNCTION_MODULE_NAME'
       exporting
         formname                 = 'YSSN_SMARTFORM'
       VARIANT                  = ' '
       DIRECT_CALL              = ' '
      importing
        fm_name                  = v_fm_name
    EXCEPTIONS
       NO_FORM                  = 1
       NO_FUNCTION_MODULE       = 2
       OTHERS                   = 3
    if sy-subrc <> 0.
       message i000 with 'Smart form module name failure'.
       exit.
    endif.
    CALL FUNCTION '/1BCDWB/SF00000199'
    call function v_fm_name
       exporting
       ARCHIVE_INDEX              =
       ARCHIVE_INDEX_TAB          =
       ARCHIVE_PARAMETERS         =
       control_parameters         = g_cont_par
       mail_appl_obj              = g_mail_app_obj
       mail_recipient             = g_mail_rec_obj
       mail_sender                 = g_mail_sen_obj
      OUTPUT_OPTIONS             = lx_OUTPUT_OPTIONS
       USER_SETTINGS              = 'X'
         t_vbap                     = it_items
    IMPORTING
       DOCUMENT_OUTPUT_INFO       =
        job_output_info            = job_output_info
       JOB_OUTPUT_OPTIONS         =
    EXCEPTIONS
       FORMATTING_ERROR           = 1
       INTERNAL_ERROR             = 2
       SEND_ERROR                 = 3
       USER_CANCELED              = 4
       OTHERS                     = 5
      perform send_pdf_mail.
    endform.                    " call_smartform
    *&      Form  send_pdf_mail
          text
    -->  p1        text
    <--  p2        text
    form send_pdf_mail .
      data ld_binfile type xstring.
              pdf_table type  rcl_bag_tline,
      data: ld_originator like soos1-recextnam.
    convert form
      loop at job_output_info-otfdata into hotfdata.
        append hotfdata.
      endloop.
      call function 'CONVERT_OTF'
           exporting
                format                = format_pdf
                max_linewidth         = 132
           importing
                bin_filesize          = doc_size
                bin_file              = ld_binfile
           tables
                otf                   = output_data-otfdata
                lines                 = htline
           exceptions
                err_max_linewidth     = 1
                err_format            = 2
                err_conv_not_possible = 3
                others                = 4.
    *-Itab 134 Zeichen nach 255 Zeichen überführen
      describe table htline    lines  hltlines.
      describe field htline    length fle1 in character mode.
      describe field x_objcont length fle2 in character mode.
      loop at htline.
        htabix = sy-tabix.
        move htline to hfeld+off1.
        if htabix = hltlines.
          fle1 = strlen( htline ).
        endif.
        off1 = off1 + fle1.
        if off1 ge fle2.
          clear x_objcont.
          x_objcont = hfeld(fle2).
          append x_objcont.
          shift hfeld by fle2 places.
          off1 = off1 - fle2.
        endif.
        if htabix = hltlines.
          if off1 gt 0.
            clear x_objcont.
            x_objcont = hfeld(off1).
            append x_objcont.
          endif.
        endif.
      endloop.
      x_object_hd_change-objnam    = 'EMAIL'.
      x_object_hd_change-objdes    = 'Smart Form'.
      x_object_hd_change-objla     = sy-langu.
      x_object_hd_change-objsns    = 'O'.
      x_object_hd_change-objlen    = doc_size.
      x_object_hd_change-file_ext  = 'TXT'.
      ld_packing_list-transf_bin = 'X'.
      ld_packing_list-head_start = 1.
      ld_packing_list-head_num = 0.
      ld_packing_list-body_start = 1.
      describe table x_objcont lines    ld_packing_list-body_num.
      ld_packing_list-objtp = 'EXT'.
      ld_packing_list-objdes    = 'Smart Form'.
      ld_packing_list-objla     = sy-langu.
      ld_packing_list-objlen    = doc_size.
      ld_packing_list-file_ext  = 'PDF'.
      append ld_packing_list.
      x_receivers-recextnam    = g_mail.
      x_receivers-recesc       = 'E'.
      x_receivers-sndart       = 'INT'.
      append x_receivers.
      ld_originator = '[email protected]'.
    ld_originator = FSABE-USRNAM.
      call function 'SO_OBJECT_SEND'
           exporting
                object_hd_change           = x_object_hd_change
                object_type                = 'RAW'
                originator_type            = 'B'  "Einfügen
                originator                 =   ld_originator  "Einfügen
           tables
               objcont                    = ld_text
                receivers                  = x_receivers
                packing_list               = ld_packing_list
                att_cont                   = x_objcont
                att_head                   = x_objhead
           exceptions
                active_user_not_exist      = 1
                communication_failure      = 2
                component_not_available    = 3
                folder_not_exist           = 4
                folder_no_authorization    = 5
                forwarder_not_exist        = 6
                note_not_exist             = 7
                object_not_exist           = 8
                object_not_sent            = 9
                object_no_authorization    = 10
                object_type_not_exist      = 11
                operation_no_authorization = 12
                owner_not_exist            = 13
                parameter_error            = 14
                substitute_not_active      = 15
                substitute_not_defined     = 16
                system_failure             = 17
                too_much_receivers         = 18
                user_not_exist             = 19
                x_error                    = 20
                others                     = 21.
    endform.                    " send_pdf_mail
    *& Form mail_sender_object
    text
    <--P_G_MAIL_SEN_OBJ text
    form mail_sender_object changing p_mail_sen_obj.
      call function 'CREATE_SENDER_OBJECT_PPF'
           exporting
                ip_sender      = sy-uname
           importing
                ep_sender_id   = p_mail_sen_obj
           exceptions
                invalid_sender = 1
                others         = 2.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
        with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform. " mail_sender_object
    *& Form mail_appl_object
    text
    <--P_G_MAIL_APP_OBJ text
    form mail_appl_object changing p_mail_app_obj.
    SELECT * FROM soud WHERE sapnam LIKE sy-uname AND deleted = ' '.
    ENDSELECT.
    IF sy-subrc NE 0.
        call function 'SO_USER_AUTOMATIC_INSERT'
             exporting
                  sapname        = sy-uname
             exceptions
                  no_insert      = 1
                  sap_name_exist = 2
                  x_error        = 3
                  others         = 4.
        if sy-subrc ne 0.
          clear soud.
        else.
          select * from soud where sapnam like sy-uname and deleted = ' '.
          endselect.
        endif.
    ENDIF.
      clear sofmfol_key.
      sofmfol_key-type = 'FOL'.
      sofmfol_key-year = soud-inbyr.
      sofmfol_key-number = soud-inbno.
      bor_key = sofmfol_key.
      if not bor_key is initial.
        swc_create_object folder 'SOFMFOL' bor_key.
        if sy-subrc = 0.
          swc_object_to_persistent folder p_mail_app_obj.
          if sy-subrc ne 0.
            clear p_mail_app_obj.
          endif.
        endif.
      else.
        clear p_mail_app_obj.
      endif.
    endform. " mail_appl_object
    *& Form mail_recipient_object
    text
    <--P_G_MAIL_REC_OBJ text
    form mail_recipient_object changing p_mail_rec_obj.
      call function 'CREATE_RECIPIENT_OBJ_PPF'
      exporting
    IP_COUNTRY =
    IP_FAXNO =
       ip_mailaddr = g_mail
       ip_type_id = g_rectype         " 'U'
      importing
        ep_recipient_id = p_mail_rec_obj
    EP_ADDRESS =
    ET_RECIPIENT =
      exceptions
        invalid_recipient = 1
         others = 2.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
        with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform. " mail_recipient_object
    I hope this code should definitely work and helps you a lot.
    Do reward me if it helps you.
    Cheers,
    Sampath

  • To send the Payload as PDF Attachment in mail in PI 7.1

    Hi All,
    I have to send a file as PDF attachment using a mail adapter. I gave the Content_Type as 'application.pdf'. I am receiving the mail, but I am unable to open the PDF. It says 'Could not open because the type is not supported or unable to decode'. How do I resolve this?
    Thanks,
    Geetha

    Hi,
    You need to perform the conversion usign the PayloadSwapBean in the  Module tab.
    Please refer to the following link
    /people/sravya.talanki2/blog/2006/11/28/e-mail-xml-messages-in-pdf-format-from-sap-xi
    http://help.sap.com/saphelp_nw04/helpdata/en/2e/bf37423cf7ab04e10000000a1550b0/frameset.htm
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/cd/5af7c0c994e24fb0d0088443513de2/content.htm
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/57/0b2c4142aef623e10000000a155106/frameset.htm
    hope this helps,
    Regards,
    Bhanu
    Edited by: nanduri bhanu on May 21, 2009 5:21 AM

  • Smartform Output To PDF And Send It As External Mail

    Dear All,
    I am sending the Smartform Output as an attachment by converting it into PDF. But when I am recieve this attachment I am unable to open the PDF file,it is giving error that FILE IS DAMAGED
    So please suggest a solution.
    Regards,
    Bhavesh

    REPORT ZTEST_PDF_MAIL.
    Internal Table declarations
    PARAMETERS : p_ebeln TYPE ekko-ebeln DEFAULT '4500000003'.
    DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
    I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
    I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
    I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
    I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
    WA_OBJHEAD TYPE SOLI_TAB,
    W_CTRLOP TYPE SSFCTRLOP,
    W_COMPOP TYPE SSFCOMPOP,
    W_RETURN TYPE SSFCRESCL,
    WA_DOC_CHNG TYPE SODOCCHGI1,
    W_DATA TYPE SODOCCHGI1,
    WA_BUFFER TYPE STRING, "To convert from 132 to 255
    Variables declarations
    V_FORM_NAME TYPE RS38L_FNAM,
    V_LEN_IN LIKE SOOD-OBJLEN,
    V_LEN_OUT LIKE SOOD-OBJLEN,
    V_LEN_OUTN TYPE I,
    V_LINES_TXT TYPE I,
    V_LINES_BIN TYPE I.
    DATA:it_pdfdata   TYPE TABLE OF tline.
    DATA:it_pdf       TYPE TABLE OF solisti1.
    BREAK-POINT .
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        FORMNAME           = 'ZCSF_MM_PO_ORIGINAL'
      IMPORTING
        FM_NAME            = V_FORM_NAME
      EXCEPTIONS
        NO_FORM            = 1
        NO_FUNCTION_MODULE = 2
        OTHERS             = 3.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    W_CTRLOP-GETOTF = 'X'.
    W_CTRLOP-NO_DIALOG = 'X'.
    W_COMPOP-TDNOPREV = 'X'.
    CALL FUNCTION V_FORM_NAME
      EXPORTING
        CONTROL_PARAMETERS = W_CTRLOP
        OUTPUT_OPTIONS     = W_COMPOP
        USER_SETTINGS      = 'X'
        P_EBELN            =  P_EBELN
      IMPORTING
        JOB_OUTPUT_INFO    = W_RETURN
      EXCEPTIONS
        FORMATTING_ERROR   = 1
        INTERNAL_ERROR     = 2
        SEND_ERROR         = 3
        USER_CANCELED      = 4
        OTHERS             = 5.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    I_OTF[] = W_RETURN-OTFDATA[].
    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        FORMAT                = 'PDF'
        MAX_LINEWIDTH         = 132
      IMPORTING
        BIN_FILESIZE          = V_LEN_IN
      TABLES
        OTF                   = I_OTF
        LINES                 = I_TLINE
      EXCEPTIONS
        ERR_MAX_LINEWIDTH     = 1
        ERR_FORMAT            = 2
        ERR_CONV_NOT_POSSIBLE = 3
        OTHERS                = 4.
    IF SY-SUBRC <> 0.
    ENDIF.
    LOOP AT I_TLINE.
      TRANSLATE I_TLINE USING '~'.
      CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
    ENDLOOP.
    TRANSLATE WA_BUFFER USING '~'.
    DO.
      I_RECORD = WA_BUFFER.
      APPEND I_RECORD.
      SHIFT WA_BUFFER LEFT BY 255 PLACES.
      IF WA_BUFFER IS INITIAL.
        EXIT.
      ENDIF.
    ENDDO.
    Attachment
    REFRESH: I_RECLIST,
    I_OBJTXT,
    I_OBJBIN,
    I_OBJPACK.
    CLEAR WA_OBJHEAD.
    I_OBJBIN[] = I_RECORD[].
    Create Message Body Title and Description
    I_OBJTXT = 'test with pdf-Attachment!'.
    APPEND I_OBJTXT.
    DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
    READ TABLE I_OBJTXT INDEX V_LINES_TXT.
    WA_DOC_CHNG-OBJ_NAME = 'smartform'.
    WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
    WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
    WA_DOC_CHNG-SENSITIVTY = 'F'.
    WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
    Main Text
    CLEAR I_OBJPACK-TRANSF_BIN.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    I_OBJPACK-BODY_NUM = V_LINES_TXT.
    I_OBJPACK-DOC_TYPE = 'RAW'.
    APPEND I_OBJPACK.
    Attachment (pdf-Attachment)
    I_OBJPACK-TRANSF_BIN = 'X'.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
    READ TABLE I_OBJBIN INDEX V_LINES_BIN.
    I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
    I_OBJPACK-BODY_NUM = V_LINES_BIN.
    I_OBJPACK-DOC_TYPE = 'PDF'.
    I_OBJPACK-OBJ_NAME = 'smart'.
    I_OBJPACK-OBJ_DESCR = 'test'.
    APPEND I_OBJPACK.
    CLEAR I_RECLIST.
    I_RECLIST-RECEIVER = 'XYZ'.
    I_RECLIST-REC_TYPE = 'U'.
    APPEND I_RECLIST.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        DOCUMENT_DATA              = WA_DOC_CHNG
        PUT_IN_OUTBOX              = 'X'
        COMMIT_WORK                = 'X'
      TABLES
        PACKING_LIST               = I_OBJPACK
        OBJECT_HEADER              = WA_OBJHEAD
        CONTENTS_BIN               = I_OBJBIN
        CONTENTS_TXT               = I_OBJTXT
        RECEIVERS                  = I_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.
    IF SY-SUBRC <> 0.
      WRITE:/ 'Error When Sending the File', SY-SUBRC.
    ELSE.
      WRITE:/ 'Mail sent'.
    ENDIF.

  • Problem in sending the Smartform Output as PDF through Mail

    Dear All,
    I am sending the Smartform Output as an attachment by converting it into PDF. But when I am recieve this attachment I am unable to open the PDF file, it is giving error that FILE IS DAMAGED. Below is the code:
    REPORT  Y_SEND_MAIL2.
    TABLES: vbrk, vbrp.
    TYPE-POOLS: abap.
    DATA: it_vbrk TYPE TABLE OF vbrk WITH HEADER LINE.
    DATA: i_formname      TYPE       tdsfname,
          i_fm_name       TYPE       rs38l_fnam,
          it_vbak TYPE TABLE OF vbak WITH HEADER LINE,
          it_ekko TYPE TABLE OF ekko WITH HEADER LINE.
    DATA:  is_bil_invoice TYPE lbbil_invoice,
           output_options      TYPE ssfcompop,
           control_parameters  TYPE ssfctrlop,
           e_devtype           TYPE rspoptype,
           job_output_info     TYPE ssfcrescl,
           bin_file            TYPE xstring,
           lines               TYPE TABLE OF tline WITH HEADER LINE,
           doctab_archive      TYPE TABLE OF docs WITH HEADER LINE,
           filelength          TYPE i,
           bin_filesize        TYPE i,
           docs          TYPE TABLE OF docs WITH HEADER LINE.
    *"Types
    TYPES: t_document_data TYPE sodocchgi1,
           t_packing_list TYPE sopcklsti1,
           t_attachment TYPE solisti1,
           t_body_msg TYPE solisti1,
           t_receivers TYPE somlreci1,
           t_pdf TYPE tline.
    *"Workareas
    DATA :w_document_data TYPE t_document_data,
          w_packing_list TYPE t_packing_list,
          w_attachment TYPE t_attachment,
          w_body_msg TYPE t_body_msg,
          w_receivers TYPE t_receivers,
          w_pdf TYPE t_pdf.
    *internal tables
    DATA : i_document_data TYPE STANDARD TABLE OF t_document_data,
           i_packing_list TYPE STANDARD TABLE OF t_packing_list,
           i_attachment TYPE STANDARD TABLE OF t_attachment,
           i_body_msg TYPE STANDARD TABLE OF t_body_msg,
           i_receivers TYPE STANDARD TABLE OF t_receivers,
           i_pdf TYPE STANDARD TABLE OF t_pdf.
    DATA: BEGIN OF line_bin,
             data(1024) TYPE x,
          END OF line_bin.
    DATA: data_tab_bin LIKE STANDARD TABLE OF line_bin.
    So please suggest a solution.
    Regards,
    Vishal

    Continued:
    SELECT-OPTIONS: s_vbeln FOR vbrk-vbeln,
                    s_fkdat FOR vbrk-fkdat OBLIGATORY DEFAULT sy-datum.
    SELECT * FROM vbrk
    INTO TABLE it_vbrk
    WHERE fkdat IN s_fkdat
          AND vbeln IN s_vbeln.
    i_formname = 'Z_SD_JINDAL_INVOICE10'.
    output_options-tddest        = 'LP02'.
    output_options-tdimmed       = 'X'.
    output_options-tdnewid       = 'X'.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        formname           = i_formname
      IMPORTING
        fm_name            = i_fm_name
      EXCEPTIONS
        no_form            = 1
        no_function_module = 2
        OTHERS             = 3.
    IF sy-subrc <> 0.          "checking subrc
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.                     "IF sy-subrc <> 0
    READ TABLE it_vbrk INDEX 1.
    IF sy-subrc = 0.
      is_bil_invoice-hd_gen-bil_number = it_vbrk-vbeln.
    ENDIF.
    control_parameters-no_dialog = 'X'.
    control_parameters-getotf = 'X'.
    CALL FUNCTION i_fm_name        "'/1BCDWB/SF00000097'
      EXPORTING
       control_parameters         = control_parameters
       output_options             = output_options
       user_settings              = space
       is_bil_invoice             = is_bil_invoice
    IMPORTING
       job_output_info            = job_output_info
    TABLES
       it_vbak                    = it_vbak
    EXCEPTIONS
       formatting_error           = 1
       internal_error             = 2
       send_error                 = 3
       user_canceled              = 4
       OTHERS                     = 5.
    IF sy-subrc <> 0.
    *      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    *FORM convert_otf_2_pdf.
      CALL FUNCTION 'CONVERT_OTF_2_PDF'
    *      EXPORTING
    *        USE_OTF_MC_CMD               = 'X'
    *        ARCHIVE_INDEX                =
        IMPORTING
          bin_filesize                 = bin_filesize
        TABLES
          otf                          = job_output_info-otfdata[]
          doctab_archive               = docs[]
          lines                        = lines[]
        EXCEPTIONS
          err_conv_not_possible        = 1
          err_otf_mc_noendmarker       = 2
          OTHERS                       = 3.
      IF sy-subrc <> 0.
    *      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *ENDFORM.                    "convert_otf_2_pdf

  • Sending smartforms as PDF attachement via e mail

    Hello all:
    I have configured PPF actions to send smartforms as PDF attchment via e mail it works fine in one client.
    But when I copied the transport to another client, the entries in field 'Recipient' in the configuration step 'Define Conditions and Output Parameters for Comm. of Cust.Shipm. & Cust.Dcl'  are not copied to the new client. I had maintained the name of the inbox folder that has e mail addresses in this field. Any one has a similar issue ? Or is this similar to the number ranges and not transportable and we have to maintain them in every client. Any insight into this very much appreciated.

    Hello:
    If you want to send the smartform as a PDF attachment, configure your PPF action as described below:
    Step 1: Define Techn. Medium for Msgs (PPF Actions) f. Cust. Shipm. and Cust. Decl.
                In the action definition, choose processing type as 'External Communication'
                                                             form type:  'Smart Forms'
                                                             format: /SAPSLL/FORM_PROC
                                                             personalization type: 2 object specific....
                Make this action definition partner function dependent and create a Z partner function. Maintain that  
                partner function in this definition.
    Step 2: Define Conditions and Output Parameters for Comm. of Cust.Shipm. & Cust.Dcl
                Select Communication Method: Internet Mail
                          Mail Settings: send status: 3
    Configure the reamaining PFF actions as usual.
    This will work if that configured partner function is maintained in the customs declaration. And for that business partner, maintain the e mail address in the address dependent section via txn BP.

  • To send smartform output in an email without attachment

    Hi All,
      How to send smartform output in an email without attachment?
    Thanks & Regards,
    Mamta Gupta.

    Try this,
    DATA:
    ls_control_param TYPE ssfctrlop, "Control paramters
    ls_output_options TYPE ssfcompop. "Output options
    DATA:
    lv_ip_mailaddr TYPE so_name, "Address of a Mail Recipient
    lv_ip_type_id TYPE so_escape, "Recipient type
    ls_recipient_id TYPE swotobjid, "Structure for recvr obj ID
    ls_sender_id TYPE swotobjid. "Structure for sender obj id
    CONSTANTS:
    lc_ip_type_id TYPE so_escape VALUE 'U', "For internet address.
    lc_smartform TYPE tdsfname VALUE 'ZVSF_ASN_DELNOTE', "Smart form name
    lc_mail TYPE tddevice VALUE 'MAIL'. "Mail device
    Assign recipient
    lv_ip_mailaddr = gv_smtp_addr. "CSAM email id
    lv_ip_type_id = lc_ip_type_id. "External address
    Create Mail title
    CONCATENATE text-001
    nast-objky
    INTO ls_output_options-tdtitle.
    Create recipient object
    CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
    EXPORTING
    ip_mailaddr = lv_ip_mailaddr
    ip_type_id = lv_ip_type_id
    IMPORTING
    ep_recipient_id = ls_recipient_id
    EXCEPTIONS
    invalid_recipient = 1
    OTHERS = 2.
    IF sy-subrc 0.
    cf_retcode = sy-subrc.
    PERFORM protocol_update.
    ENDIF.
    Get sender object id.
    CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
    EXPORTING
    ip_sender = sy-uname
    IMPORTING
    ep_sender_id = ls_sender_id
    EXCEPTIONS
    invalid_sender = 1
    OTHERS = 2.
    IF sy-subrc 0.
    cf_retcode = sy-subrc.
    PERFORM protocol_update.
    ENDIF.
    Assign the smart form name
    w_ssfname = lc_smartform.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    formname = w_ssfname
    IMPORTING
    fm_name = lf_fm_name
    EXCEPTIONS
    no_form = 1
    no_function_module = 2
    OTHERS = 3.
    IF sy-subrc 0.
    cf_retcode = sy-subrc.
    PERFORM protocol_update.
    ENDIF.
    For Print output:
    IF nast-nacha = '1'. "Print output
    ls_control_param-preview = 'X'.
    ls_control_param-no_dialog = 'X'.
    ENDIF.
    For Email output.
    IF nast-nacha = '2'. "Email
    Output options
    ls_output_options-tdteleland = gs_kna1-land1.
    ls_output_options-tdtelenum = gs_kna1-telfx.
    ls_output_options-tdfaxuser = sy-uname.
    ls_output_options-BCS_COMMIT = 'X'.
    ls_control_param-device = lc_mail.
    ENDIF.
    dynamically call Fm behind the Smart form
    CALL FUNCTION lf_fm_name
    EXPORTING
    control_parameters = ls_control_param
    mail_recipient = ls_recipient_id
    mail_sender = ls_sender_id
    output_options = ls_output_options
    user_settings = ' '
    TABLES
    delivery = gt_delivery
    EXCEPTIONS
    formatting_error = 1
    internal_error = 2
    send_error = 3
    user_canceled = 4
    OTHERS = 5.
    IF sy-subrc 0.
    cf_retcode = sy-subrc.
    PERFORM protocol_update.
    ENDIF.
    Regards,
    Joan

  • How to send SMARTFORMS output as attachment through?

    how to send SMARTFORMS output as attachment through e-mail?
    after executing SMARTFORMS how to send that output via e-mail.
    Help me.
    thanks
    surya.
    Moderator Message: Please search for available information first
    Edited by: kishan P on Nov 7, 2010 7:19 PM

    hi Vinod,
    Can you please tell me how you have zipped the file.
    I am having a text file in application server. I need to zip that file. Then the middleware moves it to Legacy system.
    I used the following code. With this I am having the data in Binary format which my midleware cannot understand.
    What I need on the whole is just to reduce the size of the file.
    form ZIP_FILE .
    DATA: lt_data TYPE TABLE OF x255,
          lt_textdata TYPE TABLE OF x255.
    DATA: ls_data LIKE LINE OF lt_data.
    DATA: lv_dsn1(100) VALUE '/ECD/120/GIS/FTP/IB/DNBPAYDEX.TXT'.
    DATA: lv_dsn3(100) VALUE '/ECD/120/GIS/FTP/IB/DNBPAYDEXZIP.zip'.
    *DATA: lv_dsn3(100) VALUE '/interfaces/SM5/test.zip'. " Contains sample1.xls and sample2.xls
    DATA: lv_file_length TYPE i.
    DATA: lv_content TYPE xstring.
    DATA: lo_zip TYPE REF TO cl_abap_zip.
    CREATE OBJECT lo_zip.
    Read the data as a string
    clear lv_content .
    OPEN DATASET lv_dsn1 FOR INPUT IN BINARY MODE.
    READ DATASET lv_dsn1 INTO lv_content .
    CLOSE DATASET lv_dsn1.
    lo_zip->add( name = 'sample.TXT' content = lv_content ).
    lv_content = lo_zip->save( ).
    *clear lv_content .
    Conver the xstring content to binary
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
    buffer = lv_content
    IMPORTING
    output_length = lv_file_length
    TABLES
    binary_tab = lt_data.
    OPEN DATASET lv_dsn3 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    LOOP AT lt_textdata INTO ls_data.
    TRANSFER ls_data TO lv_dsn3.
    ENDLOOP.
    CLOSE DATASET lv_dsn3.
    IF sy-subrc EQ '0'.
        MESSAGE s999(zfi_ap_gl) WITH text-t10.
      ENDIF.
    Can you please help.
    Thanks Aravind

  • Smartform - PDF attachment through E-mail issue

    Hi,
    A custom form and custom program was created to print the Purchase order information through ME21N, 22n and 23n.
    It also has E-mail option. when output medium 5(Simple mail) and 7(External send), email will be send to respective mail-id's with the PDF attachment.
    I have issue at the time of saving PO which processed with medium 5. when i save A popup appears "Express document update was terminated received from author". Brief message about it is
    "Error Info... 00 671: ABAP/4 processor: COMMIT_IN_POSTING"
    In Smartform driver program i am using below function modules to convert OTF into PDF and send through e-mail.
    Function Module: CONVERT_OTF.
    Function Module: SO_DOCUMENT_SEND_API1.
    I am not sure, what i missed out. Can you guys tell is this the correct way to send PDF attachment through E-mail or i missed out any function module for commit.
    Regards,
    Hemanth.
    Edited by: keerthipati hemanth on Jul 31, 2008 1:15 PM
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Jul 31, 2008 3:14 PM

    Hi Hemant,
    Below is the code for the  downloading of the smartform into the PDF Format.
    * Program Name : ZPPREP_SHOPFLOOR_VIEWER_ZOOM
    REPORT zppeerep_shorepfloor_viewer_zoom.
    * T A B L E S    D E C L A R A T I O N
    *---Tables Used.
    TABLES: afpo,
            mara,
            marc,
            aufk,
            afko,
            itcoo,
            nast,                          "Messages
            *nast,                         "Messages
            tnapr,                         "Programs & Forms
            addr_key,
            arc_params,                    "Archive parameters
            toa_dara.                      "Archive parameters
    * I N T E R N A L    T A B L E S     D E C L A R A T I O N
    *--Internal Tables Used.
    * D A T A     D E C L A R A T I O N
    *--Global Variables Used.
    DATA: ws_matnr LIKE afpo-matnr,
          ws_werks LIKE aufk-werks,
          ws_mtart LIKE mara-mtart,
          ws_wrkst LIKE mara-wrkst,
          ws_fname TYPE rs38l_fnam,
          ws_ctrlp TYPE ssfctrlop,
          ws_optns TYPE ssfcompop,
          w_padest LIKE tsp03l-padest.                          "BMC01+
    DATA: da_message_printed(1) TYPE c,
          da_preview_processed(1) TYPE c,
          repeat(1) TYPE c,
          da_subrc LIKE sy-subrc.
    DATA: w_otfdata  TYPE ssfcrescl.
    DATA: BEGIN OF it_itcoo OCCURS 0.
            INCLUDE STRUCTURE itcoo.
    DATA: END OF it_itcoo.
    DATA: w_otf  TYPE itcoo.
    *--Data Declaration for Printing Layout
    DATA: ls_itcpo     TYPE itcpo.
    DATA: lf_repid     TYPE sy-repid.
    DATA: lf_device    TYPE tddevice.
    DATA: cf_retcode   TYPE sy-subrc.
    DATA: ls_recipient TYPE swotobjid.
    DATA: ls_sender    TYPE swotobjid.
    DATA: ls_control_param   TYPE ssfctrlop.
    DATA: ls_composer_param  TYPE ssfcompop.
    DATA: ls_addr_key        LIKE addr_key.
    DATA: w_screen(1) TYPE c.
    DATA: xscreen(1) TYPE c.
    DATA: da_mess LIKE vbfs OCCURS 0 WITH HEADER LINE.
    * C O N S T A N T S
    CONSTANTS: c_fas1(8)  TYPE c VALUE 'PRINTFAS',
               c_fas2(15) TYPE c VALUE 'PRINTFASDRAWING',
               c_wip1(8)  TYPE c VALUE 'PRINTWIP',
               c_wip2(15) TYPE c VALUE 'PRINTWIPDRAWING'.
    * S E L E C T I O N - S C R E E N.
    SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-bl1.
    * Production order
    PARAMETERS: p_aufnr LIKE afpo-aufnr OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK bl1.
    START-OF-SELECTION.
    *--Begin of Commenting                   "
    *--Get Partially processed orders
      MOVE: sy-mandt         TO nast-mandt,
            'V1'             TO nast-kappl,
            p_aufnr          TO nast-objky,
            p_aufnr          TO nast-parnr,
            sy-langu         TO nast-spras,
            sy-datum         TO nast-erdat,
            '1'              TO nast-nacha,
            '3'              TO nast-vsztp,
            'X'              TO nast-manue,
            sy-uname         TO nast-usnam,
            'DFLT'           TO nast-ldest,
            sy-langu         TO nast-tdspras,
            'Shop Floor Papers' TO nast-tdcovtitle,
            '1'              TO nast-tdarmod,
            'BUS2032'        TO nast-objtype.
    *--Printer settings
      CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
        EXPORTING
          pi_nast       = nast
          pi_repid      = sy-repid
        IMPORTING
          pe_returncode = cf_retcode
          pe_itcpo      = ls_itcpo
          pe_device     = lf_device
          pe_recipient  = ls_recipient
          pe_sender     = ls_sender.
      MOVE-CORRESPONDING ls_itcpo TO ls_composer_param.
      ls_control_param-device      = 'PRINTER'.
      ls_control_param-no_dialog   = 'X'.
      ls_control_param-preview     = 'X'.
      ls_control_param-getotf      = ls_itcpo-tdgetotf.
      ls_control_param-langu       = sy-langu.
    *--End   of Commenting                   "
    *--Start of Addition                     "
      CLEAR:   ws_werks.
      SELECT   SINGLE werks
               INTO   ws_werks
               FROM   aufk
               WHERE  aufnr = p_aufnr.
      CLEAR:   ws_matnr.
      SELECT   SINGLE plnbez
               INTO   ws_matnr
               FROM   afko
               WHERE  aufnr = p_aufnr.
      CLEAR:   marc.
      SELECT   SINGLE matgr
               INTO   marc-matgr
               FROM   marc
               WHERE  matnr = ws_matnr
               AND    werks = ws_werks.
    *--End   of Addition                     "
    *  CHECK NOT ws_matnr IS INITIAL.       
      IF NOT ws_matnr IS INITIAL.          
    *--Start of Addition                    
        SELECT   SINGLE matgr
                 INTO   marc-matgr
                 FROM   marc
                 WHERE  matnr = ws_matnr
                 AND    werks = ws_werks.
    *--Start of Addition BY Rapidigm01_01+
      ELSE.
        marc-matgr = c_wip1.
      ENDIF.
    *--End Of Addition BY Rapidigm01_01+
    *--End   of Addition                     "
    END-OF-SELECTION.
      PERFORM call_smartform.
    * F O R M    R O U T I N E S
    *&      Form  call_smartform
    *       text
    FORM call_smartform.
      CLEAR: ws_ctrlp, ws_optns, ws_fname.
    *--Start of Addition                                 "
      TRANSLATE marc-matgr TO UPPER CASE.
      IF marc-matgr = c_fas1 OR
         marc-matgr = c_fas2.
        PERFORM call_paper_a.
      ELSEIF marc-matgr = c_wip1 OR
             marc-matgr = c_wip2.
        PERFORM call_paper_b.
      ENDIF.
    *--End   of Addition                                 "
    ENDFORM.                    "call_smartform
    *&      Form  call_paper_a
    *       text
    FORM call_paper_a.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
    *>>BC SPARTA03    DATE: 19/05/2008
    *      formname           = 'ZPPSF_SHOP_FLOOR_PAPER_A'  "Rapidigm03_01-
          formname           = 'ZPPSF_SHOP_FLOOR_PAPER_C'  "Rapidigm03_01-
    *<<EC SPARTA03    DATE: 19/05/2008
    *       formname  = 'ZPPSF_SHOP_FLOOR_PAPER_A_2893'   "Rapidigm03_01+
        IMPORTING
          fm_name            = ws_fname
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      CHECK NOT ws_fname IS INITIAL.
      CLEAR w_otfdata.
      ls_control_param-getotf = 'X'.
      CALL FUNCTION ws_fname
        EXPORTING
          archive_index      = toa_dara
          archive_parameters = arc_params
          control_parameters = ls_control_param
          mail_recipient     = ls_recipient
          mail_sender        = ls_sender
          output_options     = ls_composer_param
          user_settings      = ' '
          is_nast            = nast
          aufnr              = p_aufnr
          flag_orig          = 'X'
        IMPORTING
          job_output_info    = w_otfdata
        EXCEPTIONS
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4
          OTHERS             = 5.
      LOOP AT w_otfdata-otfdata INTO w_otf.
        APPEND w_otf TO it_itcoo.
      ENDLOOP.
      CALL FUNCTION 'HR_IT_DISPLAY_WITH_PDF'
        TABLES
          otf_table = it_itcoo.
    ENDFORM.                    "call_paper_a
    *&      Form  call_paper_b
    *       text
    FORM call_paper_b.
      DATA: ws_doknr TYPE draw-doknr,
            ws_dokvr TYPE draw-dokvr.
      CLEAR: ws_doknr, ws_dokvr.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = 'ZPPSF_SHOP_FLOOR_PAPER_B'
        IMPORTING
          fm_name            = ws_fname
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      CHECK NOT ws_fname IS INITIAL.
      CLEAR w_otfdata.
      ls_control_param-getotf = 'X'.
      CALL FUNCTION ws_fname
        EXPORTING
          archive_index      = toa_dara
          archive_parameters = arc_params
          control_parameters = ls_control_param
          mail_recipient     = ls_recipient
          mail_sender        = ls_sender
          output_options     = ls_composer_param
          user_settings      = ' '
          is_nast            = nast
          aufnr              = p_aufnr
          doknr              = ws_doknr
          dokvr              = ws_dokvr
          flag_orig          = 'X'
        IMPORTING
          job_output_info    = w_otfdata
        EXCEPTIONS
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4
          OTHERS             = 5.
      LOOP AT w_otfdata-otfdata INTO w_otf.
        APPEND w_otf TO it_itcoo.
      ENDLOOP.
      CALL FUNCTION 'HR_IT_DISPLAY_WITH_PDF'
        TABLES
          otf_table = it_itcoo.
    ENDFORM.                    "call_paper_b

Maybe you are looking for