Hi All,
Good Day!!!
my requirement is through custom program we are creating documents. in the out put we will get document numbers. when user check the document number and clock on print preview user can able to see the document. my requirement is when program creates documents I need to download into pdf and need to send to mail. I should not save the pdf in my desktop. it has to convert in program level and as well has to send to mail id.
for this I have written the following code.
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.
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.
CLEAR itcpo.
itcpo-tdgetotf = 'X'.
itcpo-TDDEST = 'LOCL'.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
device = 'PRINTER'
dialog = ''
form = 'ZRFI_NOTA_D_C'
language = sy-langu
OPTIONS = itcpo
EXCEPTIONS
canceled = 1
device = 2
form = 3
OPTIONS = 4
unclosed = 5
mail_options = 6
archive_error = 7
invalid_fax_number = 8
more_params_needed_in_batch = 9
spool_error = 10
OTHERS = 11.
IF sy-subrc = 1.
p_cancelled = 'X'.
ELSEIF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = itcpp
TABLES
otfdata = otf
EXCEPTIONS
unopened = 1
bad_pageformat_for_print = 2
send_error = 3
spool_error = 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.
* *Move OTF code to structure SOLI form email
CLEAR solisti1. REFRESH solisti1.
LOOP AT otf.
solisti1-line = otf.
APPEND solisti1.
ENDLOOP.
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.
mailrec-receiver = 'xxx@gmail.com'.
mailrec-rec_type = 'U'.
APPEND mailrec.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = maildata
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = mailpack
object_header = mailhead
contents_bin = mailbin
contents_txt = mailtxt
receivers = mailrec
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.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
with the above code program is not converting into pdf.
after calling close form or before calling close form do I need to use any FM to convert the data into PDF.
Could anyone please help me in this regards.
Thanks in advance,
Sravan ![]()