Retrieve mail pdf attachment in xstrinf or otf format.
Hi,
as in the Subjesct I must retrieve from mail the attachments that are in pdf format and convert then in xstring or otf format, then archive the documents in DMS server.
It's possible?
Thanks for answers.
Hi,
In SAP we execute function SX_OBJECT_CONVERT_OTF_PDF which generates binary context for a PDF document.
Or check the below code
data: l_pdf_xstring type xstring,
lt_lines type table of tline,
ls_line type tline,
l_pdf_len type i,
itab type TSFOTF,
witab type ITCOO,
tmp_line type STRING,
tmp_header type STRING.
tmp_header = 'BSP to PDF'.
tmp_line = file_content.
CONCATENATE
tmp_header
tmp_line
INTO tmp_line IN CHARACTER MODE.
APPEND tmp_line TO itab.
call function 'CONVERT_OTF'
exporting
format = 'PDF'
importing
bin_filesize = l_pdf_len
bin_file = l_pdf_xstring
tables
otf = itab
lines = lt_lines
exceptions
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
others = 5
if sy-subrc EQ 0.
response->set_header_field( name = 'content-type'
value = 'application/pdf' ).
response->set_header_field(
name = 'cache-control'
value = 'max-age=0' ).
response->set_header_field(
name = 'content-disposition'
value = 'attachment; filename=test.pdf' ).
l_pdf_len = xstrlen( l_pdf_xstring ).
response->set_data( data = l_pdf_xstring
length = l_pdf_len ).
navigation->response_complete( ).
ENDIF.
Edited by: Raj on Jul 26, 2010 2:02 PM
Similar Messages
-
STO mail : pdf attachment has an error 'file damage' when try to open it
Dear expert,
I need to send an e-mail to the vendor with the sto list as attachment at the email.
I managed to send email to external addresee and made the pdf attachment, BUT somehow when I open the attachment it has an error says "Adobe Reader could not open xx.pdf because it is either not a supported file type or because the file has been damaged(for axample, it was sent as an email attachment and wasn't corectly decoded)."
Really need your experties to help me. Here is my abap coding to send email and do the pdf attachment at the new ouptput type to send email.
TYPES: BEGIN OF lty_drad,
doknr TYPE drad-doknr,
END OF lty_drad,
BEGIN OF lty_recpt,
smtp_addr TYPE ad_smtpadr,
END OF lty_recpt.
DATA: lt_doc TYPE STANDARD TABLE OF docs,
lt_recpt TYPE STANDARD TABLE OF lty_recpt,
lt_tline LIKE tline OCCURS 0 WITH HEADER LINE,
lt_data TYPE solix_tab,
lt_docu TYPE STANDARD TABLE OF lty_drad,
lt_docfiles TYPE STANDARD TABLE OF bapi_doc_files2,
lw_tline LIKE LINE OF lt_tline,
lw_docu LIKE LINE OF lt_docu,
lw_docfiles LIKE LINE OF lt_docfiles,
lw_objdes TYPE tnati-objdes,
lt_text TYPE bcsy_text,
lw_recpt TYPE adr6-smtp_addr,
lw_adrnr TYPE lfa1-adrnr,
lw_object TYPE drad-objky,
lw_doknr TYPE drad-doknr,
lw_return TYPE bapiret2,
lw_xcontent TYPE xstring,
client TYPE REF TO if_http_client,
url TYPE string,
lw_subrc TYPE sysubrc,
response TYPE REF TO if_http_response,
lw_message1 TYPE string,
sent_to_all TYPE os_boolean,
bin_filesize type i.
CONSTANTS: lc_dokar_srm TYPE drad-dokar VALUE 'SRM',
lc_type TYPE so_obj_tp VALUE 'RAW'.
CLASS-DEFINITIONS
DATA: send_request TYPE REF TO cl_bcs.
DATA: document TYPE REF TO cl_document_bcs.
DATA: sender TYPE REF TO cl_sapuser_bcs.
DATA: recipient TYPE REF TO if_recipient_bcs.
DATA: exception_info TYPE REF TO if_os_exception_info,
bcs_exception TYPE REF TO cx_bcs.
RANGES: lr_po_pr FOR drad-objky.
DATA: lw_banfn TYPE ekpo-banfn,
lw_bnfpo TYPE ekpo-bnfpo.
IF nast-nacha = '5'. "8
Create recipient and check if exist
Get email ID
start commented by sapnislina 21.12.06
SELECT SINGLE adrnr FROM lfa1 INTO lw_adrnr
WHERE lifnr = p_ekko-lifnr.
IF sy-subrc NE 0.
PERFORM protocol_update
USING '303' 'Address of Vendor:' ekko-lifnr 'not found' space
p_retco = sy-subrc.
EXIT.
ENDIF.
end commented by sapnislina 21.12.06
SELECT smtp_addr INTO CORRESPONDING FIELDS OF TABLE lt_recpt
FROM adr6
WHERE addrnumber = p_ekko-adrnr. "lw_adrnr.
IF lt_recpt[] IS INITIAL.
PERFORM protocol_update
USING '303' 'Email address(es) does not exist for vendor'
p_ekko-lifnr space space.
p_retco = sy-subrc.
EXIT.
ENDIF.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
EXPORTING
use_otf_mc_cmd = 'X'
IMPORTING
bin_filesize = bin_filesize
TABLES
otf = otfdata[]
doctab_archive = lt_doc
lines = lt_tline
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
IF sy-subrc <> 0.
PERFORM protocol_update
USING '303' 'PO Convertion from OTF to PDF failed'
space space space.
p_retco = sy-subrc.
EXIT.
ENDIF.
Get object description from mail title of output types
SELECT SINGLE objdes INTO lw_objdes
FROM tnati
WHERE spras = sy-langu
AND kappl = nast-kappl
AND kschl = nast-kschl.
CONCATENATE lw_objdes ekko-ebeln INTO lw_objdes SEPARATED BY
space
DATA L_TXT(255) TYPE C.
DATA L_TXT2(255) TYPE C.
CONCATENATE 'STO' EKPO-EBELN 'Created for' EKPO-WERKS '/'
EKPO-LGORT
'Supply Plant' EKKO-RESWK into l_txt separated by space.
lw_objdes = l_txt.
CONCATENATE 'STO' EKKO-EBELN INTO L_TXT2 SEPARATED BY SPACE.
APPEND L_TXT2 TO LT_TEXT.
APPEND lw_objdes TO lt_text.
Instantiate
CLASS cl_cam_address_bcs DEFINITION LOAD.
CLASS cl_abap_char_utilities DEFINITION LOAD.
insert by sapnislina 22.12.06
DATA : CONTENT_OUT TYPE SOLIX,
LINE_WIDTH_SRC TYPE I,
POS_OUT TYPE I,
POS_IN TYPE I,
LEN_OUT TYPE I.
DATA OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF CONTENT_IN,
LINE TYPE TLINE,
DUMMY TYPE TLINE,
END OF CONTENT_IN.
TYPES PDF_RAW TYPE X LENGTH 268.
FIELD-SYMBOLS <PDF_BIN> TYPE PDF_RAW.
DESCRIBE FIELD CONTENT_IN-LINE LENGTH LINE_WIDTH_SRC IN BYTE MODE.
REFRESH lt_data.
CLEAR CONTENT_OUT.
POS_OUT = 0.
LOOP AT OTFDATA INTO CONTENT_IN-LINE.
ASSIGN CONTENT_IN TO <PDF_BIN> CASTING.
MOVE <PDF_BIN> TO CONTENT_OUT-LINE+POS_OUT.
ADD LINE_WIDTH_SRC TO POS_OUT.
WHILE POS_OUT >= 255.
APPEND CONTENT_OUT TO lt_data.
CLEAR CONTENT_OUT.
SUBTRACT 255 FROM POS_OUT.
IF POS_OUT > 0.
POS_IN = LINE_WIDTH_SRC - POS_OUT.
MOVE <PDF_BIN>+POS_IN TO CONTENT_OUT-LINE.
ENDIF.
ENDWHILE.
ENDLOOP.
IF POS_OUT > 0.
APPEND CONTENT_OUT TO lt_data.
ENDIF.
end inserted by sapnislina 22.12.06
starting to create attachment to mail
TRY.
CLEAR send_request .
Create persistent send request
send_request = cl_bcs=>create_persistent( ).
Build the document
document = cl_document_bcs=>create_document(
i_type = lc_type "RAW
i_text = lt_text "def of output type
i_length = '12'
i_subject = lw_objdes ).
Attached the document object
CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = lw_objdes "definition of output
type
i_attachment_size = '12'
i_att_content_hex = lt_data.
completed first part to attached PO (pdf format) as attachment
Now attach the PO related attachments to the mail..
.... need to read from table DRAD and get all the attachment per PO
at run time
REFRESH: lr_po_pr."lt_return.
CLEAR: lr_po_pr,lw_return.
MOVE 'ICP' TO lr_po_pr.
CLEAR: lw_object.
completed second part for PO related attachments
Now prepare to send mail
Add document to send request
CALL METHOD send_request->set_document( document ).
Get sender object
sender = cl_sapuser_bcs=>create( sy-uname ).
Add sender
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
LOOP AT lt_recpt INTO lw_recpt
WHERE NOT smtp_addr IS INITIAL.
recipient = cl_cam_address_bcs=>create_internet_address(
lw_recpt ).
Add recipient with its respective attributes to send request
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
CLEAR recipient.
ENDLOOP.
Send the document
CALL METHOD send_request->send
RECEIVING
result = sent_to_all.
Catch any exception
CATCH cx_bcs INTO bcs_exception.
CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
EXPORTING
msg_arbgb = bcs_exception->msgid
msg_nr = bcs_exception->msgno
msg_ty = bcs_exception->msgty
msg_v1 = bcs_exception->msgv1
msg_v2 = bcs_exception->msgv2
msg_v3 = bcs_exception->msgv3
msg_v4 = bcs_exception->msgv4
EXCEPTIONS
OTHERS = 1.
p_retco = sy-subrc.
ENDTRY.
ENDIF.
IF NOT result-tdfaxid IS INITIAL OR " 422131
NOT result-tdmailid IS INITIAL. " 422131
CLEAR syst-msgv1. " 422131
IF NOT result-tdfaxid IS INITIAL. " 422131
syst-msgv1 = result-tdfaxid. " 422131
ELSEIF result-tdmailid IS INITIAL. " 422131
syst-msgv1 = result-tdmailid. " 422131
ENDIF. " 422131
CALL FUNCTION 'NAST_PROTOCOL_UPDATE' " 422131
EXPORTING " 422131
msg_arbgb = 'VN' " 422131
msg_nr = '095' " 422131
msg_ty = 'I' " 422131
msg_v1 = syst-msgv1 " 422131
EXCEPTIONS " 422131
OTHERS = 1. " 422131
ENDIF. " 422131
IF result-userexit EQ 'C' OR
result-userexit EQ 'E'.
p_retco = '9'.
ENDIF.
ENDFORM. " ENDE
end inserted
Regards
NislinaHi Nislina,
Could you please let me know how do you solve this issue.
Code:
if lt_binary[] is not initial.
* add attachment to document
call method document->add_attachment
exporting
i_attachment_type = 'PDF'
i_attachment_subject = 'My Attachment'
i_att_content_hex = lt_binary.
endif.
Thanks & Regard's
Sateesh -
Mail PDF attachment is not visible
I have just owned a new iPad 4th generation and using it with full energy.
I have a query and if anyone can guide me.
I have configured Gmail in the Mail of my iPad. Now when I am getting an e-bill from Airtel India for payment, the attached PDF bill copy is not there in the mail.
Is it that I have to change any settings, please advice.
Thanks and Regards.
scy123.You should see a paper clip icon next to the senders name in the preview window if there is an attachment in the email. If you do see the icon but can't see the PDF, quit mail, reboot and look again.
From your home screen. Double tap the home button and the recents tray will appear with all of your recent apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the mail app icon. Tap the home button or anywhere above the task bar.
Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up. -
File to mail .pdf attachment
I have a scenario file to Mail and in the file vendor no 1234 then 1234.pdf in the file net. so when vendor no 1234 appears then i have to pick the 1234.pdf from filenet and attached to the mail. How can we do this scenario. Could you please help me this one.
and one more how can i add the link in the mail body. i did one file to mail scenario. body is not showing . that one also showing as attachment. how can i do this.
Advanced Thanks
Regards
SundherHi Sundher,
Hey configure a scenario like this File -> XI -> Mail. In this, u pick up the fiile using file adapter and send it to XI. For sending the files as an attachment, provide the MessageTransformationBean in the receiver mail adapter and pass the parameter 'ContentDispostion' with its value set as attchment.
For more details u can check the following link
<a href="https://websmp209.sap-ag.de/form/sapnet?_SHORTKEY=01200252310000071155&_SCENARIO=01100035870000000202&_OBJECT=011000358700004556712005E">https://websmp209.sap-ag.de/form/sapnet?_SHORTKEY=01200252310000071155&_SCENARIO=01100035870000000202&_OBJECT=011000358700004556712005E</a>
Regards,
Akshay -
Send sales order as mail - pdf attachement - print data
hi folk,
When receiving a Sales Order as PDF document, the name of the document is called "Print data.PDF".
Is it possible to change this name to e.g. sales order number or something else.
Best regards
Linghi,
when I'am receiving the sales order as PDF file the "Subject" of the mail is shown the e.g. sales order number retrieved from the output communication method --> Cover page text --> "Sales order &XNAST-KSCHL&.
But my question is, how I can change the name of the PDF file which is now called "Print data.PDF" .
Best regards.
Ling -
Touchpad mail pdf attachment won't open
regular pdf downloads open ok but when attached to an e-mail an error pops up "can't read mime types". Any idea how I can make this work?
Post relates to: HP TouchPad (WiFi)Right-click on your attached PDF. Select Quick Look Attachment. This opens the PDF with Quick Look in another window. You can scroll your PDF or jump to individual page icons.
Otherwise, the in-place, attachment scroll is history. -
Chinese characters merging in Mail PDF attachment
Hi, I am coverting the ouput of transaction S_ALR_87012976 for a change number into PDF and sending through mail. This is OK for all languages but for Chinese I can see the characters properly but lower row characters are merging with upper row characters. Means I can see the chinese caracters but the missing the format or very few times I am gettin # as chinese characters. I am doing the below things to do this job, suggest me if I am wrong any where.
Creating the spool with the report output using SUBMIT program
SUBMIT rcc00130 WITH SELECTION-TABLE zscreen TO SAP-SPOOL
SPOOL PARAMETERS g_print_parameters
WITHOUT SPOOL DYNPRO
VIA JOB g_name NUMBER g_number
AND RETURN.
I am converting the spool to PDF using FM 'CONVERT_ABAPSPOOLJOB_2_PDF' then for 255 character allignment I am using below FM
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_src = '134'
line_width_dst = '255'
TABLES
content_in = i_pdf[]
content_out = it_mess_att[]
Then using FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' I am sending the mail.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = s_doc_data
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = i_objpack
contents_txt = i_objtxt
contents_bin = it_mess_att
receivers = i_reclistHi Avinash,
Thanks for the reply. In my system (ECC 6.0) I am not seeing the devicetype as you mentioned but I passed one of chinese device type ZHANWIN in print parameters of SUBMIT for creating spool but issue not resolved. Is there any other way?? -
Mail pdf attachment is showing/printing in black and white only
PDF attachments with color in content are now only appearing and printing in black and white. Is this a setting somewhere?
I have the same problem here. A PDF file created in Illustrator and sent to my client via email. I can see the color on my iPhone and on an iPad but under Lion (10.8.3) it displays in black and white. I was going to look at prior versions of the OSX and see that you are running 10.6? and are getting the same thing. I have received other PDF files with color and no problem. I am wondering if it an Illustrator and OSX problem. More to come.
-
Want to Send smartform as pdf attachment with a Email to some mail id
Hi ,
I want to send a smartform as a PDF attachment with a mail to a mail id. And I can send a mail with the PDF attachment.
But I am not able to open the PDF. It is throwing some error (Adobe reader could not open u2018fileu2019 because it is either not a supported file type or because the file has been damaged (for example , it was sent as an email attachment and was not correctly decoded)).
By debugging I come to know that the file which is generating is in some encoding format.
Please help me regard this. This is very urgent.
here is the code,
Main Program :
REPORT Ztest_report.
*--Top Include for Global Data Declarations.
INCLUDE ztest_report_top.
*--Form Include for Form Routines.
INCLUDE ztest_report_form.
START-OF-SELECTION.
START-OF-SELECTION.
*--Display data
Perform display_data.
END-OF-SELECTION.
Top declaration :
Internal table
DATA : i_otfdata TYPE tsfotf, " Smart Forms: Table OTF
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
w_mailaddr TYPE ppfdmailad,
w_mailtype TYPE so_escape,
w_mailrecipient TYPE swotobjid,
w_control 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
wa_objhead TYPE soli_tab,
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.
Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-009.
PARAMETER: p_bukrs TYPE bukrs OBLIGATORY, "Company Code
p_belnr TYPE belnr_d OBLIGATORY, "Document No
p_gjahr TYPE gjahr OBLIGATORY, "document type
p_mailid(50) TYPE c OBLIGATORY.
"Mail Id
SELECTION-SCREEN END OF BLOCK blk1.
Form Logic :
FORM display_data.
*Local Variable declaration
DATA: lc_fm TYPE rs38l_fnam, "local variable to store the
l_i_document_output_info TYPE ssfcrespd,
l_i_struc_job_output_info TYPE ssfcrescl,
l_i_struc_job_output_options TYPE ssfcrescl,
i_lines TYPE TABLE OF tline WITH HEADER LINE,
lv_job_output_info TYPE ssfcrescl,
lv_document_output_info TYPE ssfcrespd,
lv_job_output_options TYPE ssfcresop,
lv_bin_filesize LIKE sood-objlen.
Determine the smartform name
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZTEST_SMARTFORM'
IMPORTING
fm_name = lc_fm
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_control-getotf = 'X'.
w_control-no_dialog = 'X'.
w_control-preview = space.
w_control-device = 'MAIL'.
Call the smartform and pass the selection screen parameter
CALL FUNCTION lc_fm
EXPORTING
control_parameters = w_control
output_options = w_compop
user_settings = 'X'
t_bukrs = p_bukrs
t_belnr = p_belnr
t_gjahr = p_gjahr
IMPORTING
job_output_info = l_i_struc_job_output_info
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.
Moving the Smart Forms: Table OTF into an internal table
i_otfdata[] = l_i_struc_job_output_info-otfdata[].
CONVERT TO OTF TO PDF.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = lv_bin_filesize
TABLES
otf = i_otfdata
lines = i_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-batch EQ l_c_no.
To directly view the print-preview in PDF format
CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'
EXPORTING
i_otf = i_otfdata
EXCEPTIONS
convert_otf_to_pdf_error = 1
cntl_error = 2
OTHERS = 3.
For Sending the PDF file to a Mail ID.
LOOP AT i_lines.
TRANSLATE i_lines USING '~'.
CONCATENATE wa_buffer i_lines 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.
DATA: BEGIN OF zlines OCCURS 0,
tline TYPE char255,
END OF zlines.
*Change the PDF format from 132 to 255.
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
transfer_bin = 'X'
TABLES
content_in = i_lines
content_out = zlines
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Attachment
REFRESH: i_reclist,
i_objtxt,
i_objbin,
i_objpack.
CLEAR wa_objhead.
i_objbin[] = zlines[].
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 = 1.
i_objpack-body_start = 2.
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 = 1.
i_objpack-body_start = 2.
I_OBJPACK-DOC_TYPE = 'RAW'.
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 = p_mailid.
i_reclist-rec_type = 'U'.
APPEND i_reclist.
Send new document with attachments via RFC
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.
ENDFORM. " display_datahi,
i wrote a programm.for me it is working.i think it will help for u.
DATA: t_otfdata TYPE ssfcrescl,
t_lines LIKE tline OCCURS 0 WITH HEADER LINE,
t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
t_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
Objects to send mail.
DATA:T_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
T_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.
DATA: w_filesize TYPE i,
w_bin_filesize TYPE i,
wa_ctrlop TYPE ssfctrlop,
wa_outopt TYPE ssfcompop,
WA_BUFFER TYPE STRING, "To convert from 132 to 255
WA_OBJHEAD TYPE SOLI_TAB,
WA_DOC_CHNG TYPE SODOCCHGI1,
W_DATA TYPE SODOCCHGI1.
DATA: form_name TYPE rs38l_fnam,
V_LINES_TXT TYPE I,
V_LINES_BIN TYPE I,
nast-spras type sy-langu value 'DE'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZSR_DEMO1'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = 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.
wa_ctrlop-LANGU = nast-spras.
wa_ctrlop-getotf = 'X'.
wa_ctrlop-no_dialog = 'X'.
wa_outopt-tdnoprev = 'X'.
CALL FUNCTION form_name
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = wa_ctrlop
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = wa_outopt
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = t_otfdata
JOB_OUTPUT_OPTIONS =
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.
t_otf[] = t_otfdata-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = w_bin_filesize
BIN_FILE =
TABLES
OTF = t_otf
LINES = t_lines
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 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.
loop at t_lines.
TRANSLATE t_lines USING '~'.
CONCATENATE WA_BUFFER T_LINES INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING '~'.
DO.
t_RECORD = WA_BUFFER.
APPEND t_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Attachment
REFRESH: T_RECLIST,
T_OBJTXT,
T_OBJBIN,
T_OBJPACK.
CLEAR WA_OBJHEAD.
T_OBJBIN[] = T_RECORD[].
Create Message Body Title and Description
T_OBJTXT = 'test with pdf-Attachment!'.
APPEND T_OBJTXT.
DESCRIBE TABLE T_OBJTXT LINES V_LINES_TXT.
READ TABLE T_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 T_OBJPACK-TRANSF_BIN.
T_OBJPACK-HEAD_START = 1.
T_OBJPACK-HEAD_NUM = 0.
T_OBJPACK-BODY_START = 1.
T_OBJPACK-BODY_NUM = V_LINES_TXT.
T_OBJPACK-DOC_TYPE = 'RAW'.
APPEND T_OBJPACK.
Attachment (pdf-Attachment)
T_OBJPACK-TRANSF_BIN = 'X'.
T_OBJPACK-HEAD_START = 1.
T_OBJPACK-HEAD_NUM = 0.
T_OBJPACK-BODY_START = 1.
DESCRIBE TABLE T_OBJBIN LINES V_LINES_BIN.
READ TABLE T_OBJBIN INDEX V_LINES_BIN.
T_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
T_OBJPACK-BODY_NUM = V_LINES_BIN.
T_OBJPACK-DOC_TYPE = 'PDF'.
T_OBJPACK-OBJ_NAME = 'smart'.
T_OBJPACK-OBJ_DESCR = 'test'.
APPEND T_OBJPACK.
CLEAR T_RECLIST.
T_RECLIST-RECEIVER = 'mail id'.
T_RECLIST-REC_TYPE = 'U'.
APPEND T_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 = T_OBJPACK
OBJECT_HEADER = WA_OBJHEAD
CONTENTS_BIN = T_OBJBIN
CONTENTS_TXT = T_OBJTXT
RECEIVERS = T_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.
please reward me if helpful. -
Smartform to OTF to PDF attached to an email ERROR
Hi everyone... I have this problem... I need to send a smartform attached to an email... I'm doing the following:
- Create the OTF using the smartform function importing job_output_info.
- Convert the OTF (job_output_info-otfdata) to PDF using CONVERT_OTF_2_PDF.
- Change the table line's width using SX_TABLE_LINE_WIDTH_CHANGE.
- Send the email using SO_NEW_DOCUMENT_ATT_SEND_API1.
Everything seems to be OK. But When I check the PDF file attached in the email and open it, everything there is a mess. The letters are superimposed over each other and the grills are not painted (instead it shows a black block).
Any ideas how to solve this???
Thanks a lot!!!Try this out..!
<removed by moderator>
To convert the script out put to PDF.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF' u201C FOR out put format
max_linewidth = 132 u201CFor ASCII format: Number of lines in LINES-TDLINE
IMPORTING
bin_filesize = gv_bin_filesize u201CFile size reference
TABLES
otf = gt_otf u201CInput table with OTF format
lines = gt_pdf_tab " Output table with target format
To mail Order in PDF format:
Data declaration part :
DATA: gt_reclist TYPE TABLE OF somlreci1, " SAPoffice: Structure of the API Recipient List
gt_pdf_tab TYPE TABLE OF tline, " SAPscript: Text Lines
gt_otf TYPE TABLE OF itcoo, " OTF Structure
gt_objbin TYPE TABLE OF solisti1, " SAPoffice: Single List with Column Length 255
gt_objpack TYPE TABLE OF sopcklsti1. " SAPoffice: Description of Imported Object Components
DATA: gv_form_name TYPE rs38l_fnam, " Used to store the function module generated by Smartform
gv_bin_filesize TYPE i, " Store the file size
gv_pos TYPE i,
gv_len TYPE i,
gv_tab_lines TYPE i.
DATA : gc_text(11) TYPE c VALUE 'Form Output',
gc_tst(3) TYPE c VALUE 'TST',
gc_testing(30) TYPE c VALUE 'Zellar Sales Document'.
1. Assigning the Description of the object sent in the mail
CLEAR gs_docdata.
gs_docdata-obj_name = gc_tst.
gs_docdata-obj_descr = gc_testing.
Assigning the email id to Structure of the API Recipient List table
CLEAR : gt_reclist, gs_reclist. u201C variables used
gs_reclist-receiver = mail address'. u201CTo whom this mail should go
GS_RECLIST-REC_TYPE = 'U'.
APPEND gs_reclist TO gt_reclist. u201C Internal table for storing mail address
2.Passing the Smart form text lines to SAP office: Single List with Column Length 255 table ,this logic is used to get all the data into PDF file while you send an attachment through mail..
CLEAR: gs_objbin, gs_pdf_tab.
LOOP AT gt_pdf_tab INTO gs_pdf_tab. u201CLoop the content of PDF table
gv_pos = 255 - gv_len.
IF gv_pos > 134. "length of pdf_table
gv_pos = 134.
ENDIF.
gs_objbin+gv_len = gs_pdf_tab(gv_pos).
gv_len = gv_len + gv_pos.
IF gv_len = 255. "length of out (contents_bin)
APPEND gs_objbin TO gt_objbin.
CLEAR: gs_objbin, gv_len.
IF gv_pos < 134.
gs_objbin = gs_pdf_tab+gv_pos.
gv_len = 134 - gv_pos.
ENDIF.
ENDIF.
ENDLOOP.
IF gv_len > 0.
APPEND gs_objbin TO gt_objbin. u201CTable contains Single List with Column Length 255 table
ENDIF.
3. Filling the details in SAPoffice: Description of Imported Object Components table
DESCRIBE TABLE gt_objbin LINES gv_tab_lines.
CLEAR gs_objbin.
READ TABLE gt_objbin INTO gs_objbin INDEX gv_tab_lines.
IF sy-subrc = 0.
gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + STRLEN( gs_objbin ).
gs_objpack-transf_bin = 'X'.
gs_objpack-head_start = 1.
gs_objpack-head_num = 0.
gs_objpack-body_start = 1.
gs_objpack-body_num = gv_tab_lines.
gs_objpack-doc_type = 'PDF'.
gs_objpack-obj_name = 'ATTACHMENT'.
gs_objpack-obj_descr = 'test'.
APPEND gs_objpack TO gt_objpack.
ENDIF.
4. Sending the Form Output in the PDF format to email
data: WK_OBJHEAD TYPE SOLI_TAB.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' u201Cfunction module used for sending mail
EXPORTING
document_data = gs_docdata u201CAttributes of new document
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = gt_objpack u201CInformation about structure of data tables
OBJECT_HEADER = WK_OBJHEAD u201CHeader data for document (spec.header)
contents_bin = gt_objbin u201CData which is to be sent as pdf attachment
receivers = gt_reclist u201Cmailing list
EXCEPTIONS u201CException Handling
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.
ELSE.
WRITE 'Sent Successfully'.
ENDIF.
Edited by: Thomas Zloch on Jul 16, 2010 10:38 PM -
Error while Opening PDF attachment from Mail
Hi,
We two Output Types created ZNEU and ZAUF. Two Smartforms are created for the same Output Types. The Issue now is, When ZNEU triggers and send a mail the document is properly decoded and gets opened but for ZAUF it doesn't. It says File damaged.
This is the code we have used for sending mail.
CONSTANTS:
co_pdf(3) TYPE c VALUE 'PDF',
co_raw(3) TYPE c VALUE 'RAW'.
DATA:
it_objbin TYPE STANDARD TABLE OF solisti1,
wa_objbin TYPE solisti1.
DATA:
lv_filesize TYPE i.
DATA:
it_lines TYPE STANDARD TABLE OF tline.
DATA:
wa_mail_body TYPE solisti1,
wa_receipients TYPE somlreci1.
DATA:
document TYPE REF TO cl_document_bcs,
content TYPE solix_tab,
wa_content TYPE solix,
send_request TYPE REF TO cl_bcs,
sender TYPE REF TO if_sender_bcs,
recipient TYPE REF TO if_recipient_bcs,
requested_status TYPE REF TO bcs_rqst,
status_mail TYPE bcs_stml,
bcs_exception TYPE REF TO cx_bcs,
lv_rec TYPE adr6-smtp_addr.
DATA:
wa_attachx TYPE solix,
l_pdf_len TYPE i,
l_con_len TYPE i,
l_pdf_pos TYPE i,
l_con_pos TYPE i.
FIELD-SYMBOLS: <fs_con> TYPE x.
CLASS cl_cam_address_bcs DEFINITION LOAD.
CLASS cl_abap_char_utilities DEFINITION LOAD.
* Get the PDF version of the OTF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_filesize
TABLES
otf = job_output_info-otfdata
lines = it_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 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.
* Convert the PDF format to the table type required for the attachment.
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = it_lines
t_target_tab = it_objbin
EXCEPTIONS
convert_not_possible = 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.
* Convert the data which is in text to binary
l_con_pos = 0.
DESCRIBE FIELD wa_objbin LENGTH l_pdf_len IN BYTE MODE.
DESCRIBE FIELD wa_attachx LENGTH l_con_len IN BYTE MODE.
LOOP AT it_objbin INTO wa_objbin.
ASSIGN wa_objbin TO <fs_con> CASTING.
CHECK sy-subrc EQ 0.
DO l_pdf_len TIMES.
l_pdf_pos = sy-index - 1.
IF l_con_pos = l_con_len.
APPEND wa_attachx TO content.
FREE wa_attachx.
l_con_pos = 0.
ENDIF.
MOVE <fs_con>+l_pdf_pos(1) TO wa_attachx-line+l_con_pos(1).
ADD 1 TO l_con_pos.
ENDDO.
ENDLOOP.
IF l_con_pos > 0.
APPEND wa_attachx TO content.
ENDIF.
TRY .
* -------- create persistent send request ------------------------
send_request = cl_bcs=>create_persistent( ).
* -------- create and set document with attachment ---------------
* create document from internal table with text
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = mail_body_tab
i_subject = email_subject ).
* add attachment to document
CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = attachment_name
i_att_content_hex = content.
* add document to send request
CALL METHOD send_request->set_document( document ).
* Set sender
sender = cl_cam_address_bcs=>create_internet_address( sender_id ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
* Receipients
LOOP AT receipients_tab INTO wa_receipients .
lv_rec = wa_receipients-receiver.
recipient = cl_cam_address_bcs=>create_internet_address( lv_rec ).
* Add recipient with its respective attributes to send request
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient.
ENDLOOP.
* Set that you don't need a Return Status E-mail
status_mail = 'N'.
CALL METHOD send_request->set_status_attributes
EXPORTING
i_requested_status = 'N'
i_status_mail = status_mail.
* set send immediately flag
send_request->set_send_immediately( 'X' ).
* Send document
CALL METHOD send_request->send( ).
* COMMIT WORK.
CATCH cx_bcs INTO bcs_exception.
RAISE EXCEPTION bcs_exception.
ENDTRY.
This is in a Class which is been used in the print program for both the Output Types.
Can somebody throw light upon this.
Note: I tried using
but it is not working properly.
Thanks,
Prashanth
Edited by: Prashanth KR on Jan 5, 2010 6:20 AMHi,
Please paste the part of code where you are getting error.
And if you are not clear about where the error is, try searching sdn or google with the error message that you are getting as this issue has been discussed many times earlier.
Check this link.
Error while opening PDF in mail attachment
Hope it helps.
Regards,
Raj -
Error while opening PDF attachment sent via mail
Hi,
I am attaching PDF file to PO in me22n and sending the same file as attachment in the mail to the vendor using class CL_BCS.
The mail is sent to the vendor successfully and they are able to successfully open the PDF attachment. But in some cases the mail is successfully received but while opening the attachment it is giving the error as file is corrupted.
Please help me to resolve this issue.
Thanks and regards,
JayashreeHi,
I would like to know what font type, you are using in the forms.
Ideally it should be HELVETICA .
If you are using any other font in your style/form,try changing it to HELVETICA & Test.
Also Check the OTF data at the call of gen. FM,before converting it to PDF.
Regds,
AS
Edited by: abheesawant on Oct 12, 2011 7:48 AM -
Problem in sending mail with PDF attachment
Hi all,
Kindly check this code..
I neeed to send the smartform as a PDF attachment..
PDF generated form of smartform is generated successfully..
<b>but PDF going as attachment is showing errors in opening</b> .
Please help me to solve this issue as soon as possible
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
doc_chng-doc_size = tab_lines * 255.
Creation of the entry for the compressed document
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
Creation of the document attachment
DESCRIBE TABLE objbin LINES tab_lines.
Creation of the entry for the compressed document
CLEAR objpack-transf_bin.
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = tab_lines * 255 .
objpack-body_num = tab_lines.
objpack-doc_type = 'PDF'.
objpack-obj_name = 'SMART'.
objpack-obj_descr = 'test'.
APPEND objpack.
Completing the recipient list
target recipent
CLEAR reclist.
reclist-receiver = '[email protected]'.
reclist-express = 'X'.
reclist-rec_type = 'U'.
APPEND reclist.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
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 = 99.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Regards,
ajithHello Ajith,
Use this Code.
Internal Table declarations
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 = 'ZZZ_TEST1'
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'
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.
Fehlerhandling
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
wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )
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.
Länge des Attachment ermitteln
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 = '[email protected]'.
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'
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 helped reward points
Vasanth -
Sending Mail with PDF attachment
Hi Guys ,
if i am getting the script output data in OTF foramt ( by selecting the ITCPO-TDGETOTF = 'X' , which Doc_type i have to use to send it as a PDF attachement.
i am using FM
SO_NEW_DOCUMENT_ATT_SEND_API1
to send message from sap to Xchange server .
Regards
PrabhuRefer to this code, this is working fine in my 4.6c system:
REPORT YBALTEST.
DATA: gd_cnt TYPE i,
gd_sent_all(1) TYPE c,
gd_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc.
DATA OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
DATA: it_message LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
it_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
it_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0,
row(255).
DATA: END OF it_pdf_output.
START-OF-SELECTION.
perform send_email_message .
*& Form SEND_EMAIL_MESSAGE
Send email message
FORM send_email_message.
DATA: tab_lines LIKE SY-TABIX.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\test.pdf'
filetype = 'BIN'
TABLES
data_tab = it_pdf_output .
Populate the subject/generic message attributes
concatenate 'Attached is the '
' are waiting for.' into it_message.
append it_message.
DESCRIBE TABLE it_message LINES tab_lines.
READ TABLE it_message INDEX tab_lines.
gd_doc_data-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( it_message ).
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SENDFILE'.
gd_doc_data-obj_descr = 'Attachement'.
gd_doc_data-sensitivty = 'O'.
describe table it_pdf_output lines tab_lines.
Describe the body of the message
CLEAR it_packing_list-transf_bin.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
it_packing_list-doc_type = 'RAW'.
it_packing_list-body_num = tab_lines.
APPEND it_packing_list.
loop at it_pdf_output.
move it_pdf_output-row to objbin-line.
append objbin.
endloop.
describe table objbin lines tab_lines.
CLEAR it_packing_list.
it_packing_list-transf_bin = 'X'.
it_packing_list-head_start = 1.
it_packing_list-head_num = 1.
it_packing_list-body_start = 1.
it_packing_list-doc_type = 'PDF'.
it_packing_list-body_num = tab_lines.
it_packing_list-doc_size = tab_lines * 255.
it_packing_list-OBJ_DESCR = ' object '.
*it_packing_list-obj_name = 'MAIL'.
APPEND it_packing_list.
it_receivers-receiver = '[email protected]'.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
APPEND it_receivers .
Call the FM to post the message to SAPMAIL
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = gd_doc_data
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = gd_sent_all
TABLES
packing_list = it_packing_list
contents_txt = it_message
contents_bin = objbin
receivers = it_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.
ENDFORM. " SEND_EMAIL_MESSAGE
Cheers -
Payment advisory mail attachment in OTF format unable to open
Hi All,
We have copied the function module from BTE 00002040 and made the changes c_finaa-nacha = '1'. We have also assigned this FM in FIBF transaction.
After doing all the settings we are able to send the payment advisory note copy to vendor email id.
But the issue is vendor is receiving the mail with attachment as SAPscrip.OTF (OTF format) and vendor is not able to open this attachment in his mail.
Please give your valuble suggestions.
Thanks in advance,
DSayaRefer SAP Notes
Note 1391851 - Payment advice note by mail in 4.70: Attachment is incorrect
Note 1033893 - Payt advice note by mail: Introductory text w/ attachment
Note 1168342 - Payment advice notes by e-mail and PDF with Unicode
Note 1223264 - Payt advice notes: No optical archiving and no log
Maybe you are looking for
-
I really need HELP!!! I have a laptop that runs with windows vista, and I have been having issues trying to get it to download the new version of itunes that would be compatible to the new version of ios 7 that I have already updated on my ipad. I ha
-
I just finished a project. I saved It on an external drive, and erase everything related to this project from FCE folder and the library . I was ready to capture from my camera datas for my next project. When I open FCE, the loading of the program st
-
Floating Objects a la Framemaker (CS4ME Win7bit64)
Hello, I'm working on a book with hundreds of anchored objects that are pictures of varying sizes. In Framemaker and LaTex there is a feature called "floating objects." This will take your anchored objects and place them in the nearest vacant top-of-
-
Feature Request for Adobe Reader for Windows Phone 7
Would like to see the ability to open password protected files. Thank you.
-
I have Final Cut 4.5 - Where's DVD Pro?
I was told DVD Pro comes with Final Cut. My 4.5 I just installed doesn't have it at all. Does anyone know how I can get this software? It seems not to be sold separately anywhere, even on eBay.