Send email with PDF attachements (Smartform/SAP script)
Hello All,
I have 3 existing programs A, B & C whose output is in SAP Script/Smartform. Now I need to create new program D which needs to execute program A, B & C and then convert their smartform/SAP script output into PDF format and send email with attachements (PDF files). Any pointers how I can proceed. Thanks a lot.
hi Sarita,
v_ctrlparams-no_dialog = 'X'.
v_ctrlparams-getotf = 'X'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Smartform name'
IMPORTING
fm_name = v_func_mod.
CALL FUNCTION v_func_mod
EXPORTING
control_parameters = v_ctrlparams
IMPORTING
job_output_info = v_joboutput
TABLES
t_nonsigner = t_nonsigner.
fill the document
doc_chng-obj_name = 'Descriptoipn'.
Fill the subject line
doc_chng-obj_descr = 'Manpowe'.
doc_chng-obj_descr = 'Reminder .
doc_chng-sensitivty = 'P'.
Fill the content of the mail
objcont = 'Dear all,'.
APPEND objcont.
CLEAR objcont.
APPEND objcont.
CLEAR objcont.
objcont =
'The manpower sign-off is pending for the list of employees as per th' &
'e attached sheet.'
APPEND objcont.
CLEAR objcont.
APPEND objcont.
CLEAR objcont.
objcont =
'Please click on the following link for the manpower sign-off:'.
APPEND objcont.
CLEAR objcont.
APPEND objcont.
CLEAR objcont.
DESCRIBE TABLE objcont LINES entries.
READ TABLE objcont INDEX entries.
doc_chng-doc_size = ( entries - 1 ) * 255 + STRLEN( objcont ).
Creating 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 = entries.
objpack-doc_type = 'RAW'.
APPEND objpack.
Creating the document attachment
(Assume the data in OBJBIN are given in BMP format)
LOOP AT v_joboutput-otfdata INTO wa_otfdata.
APPEND wa_otfdata TO objbin.
CLEAR wa_otfdata.
ENDLOOP.
DESCRIBE TABLE objbin LINES tab_lines.
objhead = 'NonSignerDetails.otf'. APPEND objhead.
Creating the entry for the compressed attachment
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'OTF'.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = 'NonSignerDetails'.
objpack-doc_size = tab_lines * 255.
APPEND objpack.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objcont
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
hope this will help u..
regards,
Santosh Thorat
Similar Messages
-
Sending email with pdf attachment
I have a need to save several screens from within my flash
projector into a
multi page pdf document and then email the pdf to an address
that the user
types in.
Is this at all possible?
Many thanks
davehi
can u provide any sample code to send attachment from oracle mail
any attachment html/text/pdf..
is java mailnecessary for that or object should me stored in database -
Custome FM to create Email with PDF attachment
Hi Experts,
I am working in Smart form. my requriment is to create a Custom Function module , for sending email with PDF attachment to the customer. PDF is nothing but which ever I create smart form.
How can I approach , please give me a suggestion or send me a sample code, if any one create.
1. This FM should work like : convert form to PDF and send Email to particular customer.Hi,
Steps to convert Smartform to PDF,
1 Call smartform through FM SSF_FUNCTION_MODULE_NAME.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
2 Converting Smartform to OTF and in turn to PDF
Set Following parameter in order to convert Smartform into OTF.
gs_cparam-no_dialog = 'X'. " Suppressing the dialog box
gs_cparam-preview = 'X'. " for print preview
gs_cparam-getotf = 'X'. " To get Output in OTF
CALL FUNCTION g_fmodule
EXPORTING
control_parameters = gs_cparam
output_options = gs_outoptions
IMPORTING
job_output_info = gt_otf_from_fm
TABLES
gt_final = gt_final
gt_otf[] = gt_otf_from_fm-otfdata [].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = g_bin_filesize
TABLES
otf = gt_otf
lines = gt_pdf_tab
CHECK sy-subrc = 0.
g_bin_filesize = g_bin_filesize + 1.
Transfer the 132-long strings to 255-long strings
LOOP AT gt_pdf_tab into gs_pdf_tab.
TRANSLATE gs_pdf_tab USING ' ~'.
CONCATENATE g_buffer gs_pdf_tab INTO g_buffer.
ENDLOOP.
TRANSLATE g_buffer USING '~ '.
DO.
gs_mess_att = g_buffer.
APPEND gs_mess_att to gt_mess_att.
SHIFT g_buffer LEFT BY 255 PLACES.
IF g_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
3 For Sending Mail use following mail,
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = ls_doc_data
put_in_outbox = 'X'
sender_address = l_sender_address
sender_address_type = l_sender_address_type
commit_work = 'X'
TABLES
packing_list = lt_packing_list
contents_bin = lt_attachment
contents_txt = lt_message
receivers = lt_receivers
I hope this could help you,
Please let me know if any issue.
Thanks & regards,
ShreeMohan
Edited by: ShreeMohan Pugalia on Jul 18, 2009 8:02 AM
Edited by: ShreeMohan Pugalia on Jul 18, 2009 8:03 AM
Edited by: ShreeMohan Pugalia on Jul 18, 2009 8:05 AM -
Sending an email with pdf attachment in Ecc6
we were in 4.6 c and recentely upgraded to ECC6. we have a program which we are sending email with pdf attachments. now it is breaking, we are able to display the pdf in the screen, but once it became the attachment , it is not going.
we are running the program in forground and not reading the spool and sending it. any ideahttp://www.sap-img.com/abap/sending-email-with-attachment.htm
Sending mail to an external maild with PDF attachment.
Creating a PDF attachment and send it via Email
Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface
How to send a ttachment with email.
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap-Sendthespooldatatoanemail+address.
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/convertSpoolrequesttoPDFandsendase-mail
Friend just have a look in the forum itself, there are many posts for ur query, you definetly get exact solution no need to wait for answers/solutions.
All the best -
Send Invoice email with pdf attachement through DI?
Hi all,
is it possible to send an Invoice email with pdf attachement through DI as it can be done through UI?
Best Regards,
VangelisHi Vangelis,
I Don't think that the DI API has that functionality (but I am not sure).
However with .Net's System.Net.Mail it should be quite easy to build.
Good luck,
Johan -
Send email with XMl attachment
Hi All,
My requrement are, to send emails to particular person "PDF" attachment and "XML" attachments.
i did pdf by using convert spool to pef and send email to that vendor.its working .
But i dnt know how to send email with XML attachment.Is there any function for convert spool to xml and email to that vendor.Please send me code ASAP.
i have to sumbit this object soon.Please help me regarding this issue.
Abhi...Hi,
Try this out.
ISR_FI_SEND_EMAIL
ISR_FI_SEND_EMAIL_NEW_USER
SLS_CUST_SEND_EMAIL_TOOL
OR
report y_cr17_mail.
data method1 like sy-ucomm.
data g_user like soudnamei1.
data g_user_data like soudatai1.
data g_owner like soud-usrnam.
data g_receipients like soos1 occurs 0 with header line.
data g_document like sood4 .
data g_header like sood2.
data g_folmam like sofm2.
data g_objcnt like soli occurs 0 with header line.
data g_objhead like soli occurs 0 with header line.
data g_objpara like selc occurs 0 with header line.
data g_objparb like soop1 occurs 0 with header line.
data g_attachments like sood5 occurs 0 with header line.
data g_references like soxrl occurs 0 with header line.
data g_authority like sofa-usracc.
data g_ref_document like sood4.
data g_new_parent like soodk.
data: begin of g_files occurs 10 ,
text(4096) type c,
end of g_files.
data : fold_number(12) type c,
fold_yr(2) type c,
fold_type(3) type c.
parameters ws_file(4096) type c default 'c:\debugger.txt'.
Can me any file fromyour pc ....either xls or word or ppt etc ...
g_user-sapname = sy-uname.
call function 'SO_USER_READ_API1'
exporting
user = g_user
PREPARE_FOR_FOLDER_ACCESS = ' '
importing
user_data = g_user_data
EXCEPTIONS
USER_NOT_EXIST = 1
PARAMETER_ERROR = 2
X_ERROR = 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.
fold_type = g_user_data-outboxfol+0(3).
fold_yr = g_user_data-outboxfol+3(2).
fold_number = g_user_data-outboxfol+5(12).
clear g_files.
refresh : g_objcnt,
g_objhead,
g_objpara,
g_objparb,
g_receipients,
g_attachments,
g_references,
g_files.
method1 = 'SAVE'.
g_document-foltp = fold_type.
g_document-folyr = fold_yr.
g_document-folno = fold_number.
g_document-objtp = g_user_data-object_typ.
*g_document-OBJYR = '27'.
*g_document-OBJNO = '000000002365'.
*g_document-OBJNAM = 'MESSAGE'.
g_document-objdes = 'sap-img.com testing by program'.
g_document-folrg = 'O'.
*g_document-okcode = 'CHNG'.
g_document-objlen = '0'.
g_document-file_ext = 'TXT'.
g_header-objdes = 'sap-img.com testing by program'.
g_header-file_ext = 'TXT'.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = sy-uname
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
FOLMEM_DATA =
RECEIVE_DATA =
File from the pc to send...
method1 = 'ATTCREATEFROMPC'.
g_files-text = ws_file.
append g_files.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
method1 = 'SEND'.
g_receipients-recnam = 'MK085'.
g_receipients-recesc = 'B'.
g_receipients-sndex = 'X'.
append g_receipients.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header.
*-- End of Program
Also check this links as well.
http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
/people/thomas.jung3/blog/2004/09/09/receiving-e-mail-and-processing-it-with-abap--version-610-and-higher
Hope this will help.
Regards -
Can´t send emails with pdf attachments - why?
Since i moved all my accounts to my new airbook (OS X 10.8.2) everything works fine BUT i am not able to send emails with pdf attachments.I have an exchange and a mac.account - but they both won`t work.
The emails stay put in the local ausgang? exit box and won`t move away unless i delete them.
i checked the accounts, the activity - all says it works fine - but it doesn`t!
Maybe in the *deep* of my mac is one thing that says no pdf - but where can i find it?
I appreciate every helpful hint :-)
greetingsit tries to send the email for about five minutes and than gives the message *server doesn't work* you want to try another? repeat? or later?
when i change the server e.g. from exchange to mac - tries again and without further notice i find the message in the outbox - even when i click that one and *send* again - nothing changes......
I already tried to name the attachments in.pdf - i also change the pdf to jpeg - nothing works - all emails i write after that go immediately to the outbox - so when i want to send messages at all i need to delete the ones with the attachment or send the other ones manually
Please notice in the activity window there is a lot of traffic :-) but it doesn`t help
i even closed all other programmes like excel,safari and stuff - but still
and i still have al lot of free GB on my airbook....
any idea???? -
I have Windows 7, Microsoft Outlook and PSE 13. I have used the "Share photos as embedded images" feature frequently, but today when I went to use it, it wasn't there, only the option to send email with files attached. How do I get back the ability to send emails with photos embedded. I like adding the frames and backgrounds and I think it's easier for recipients to look at the photos. Thanks for any suggestions of things to try.
GailI had a similar problem in that my wife's iphone 5 could not send pics with imessage. Had to set the settings to default to SMS or whatever. After laboring many hours on the web I coincidentally was on the phone with the internet people to question my internet speed. They changed the router channel, which is something that I am capable of doing myself. After that, the pics go over imessage. My own Iphone didn't have the problem. We are both latest IOS 7.0.6.
-
Workflow Step 'In Process'- Send mail with PDF attachment
Hi,
have to send mail with PDF attachment.
I have written a function module with following steps,
1. Convert SPOOL number to PDF using Function Module 'CONVERT_OTFSPOOLJOB_2_PDF'.
2. Send mail with PDF attachment using Function Module 'SO_DOCUMENT_SEND_API1'.
The Function Module is giving required output when tested and called in the report(Background Job).
When I call this Function Module from Method-> Workflow Task the Workflow steps status is 'In Process' and not ending.
Could you please help me on this??Hi shafath,
When you try to send mail, You need to call the function FP_JOB_OPEN before calling the function module to generate the pdf. ( /1B****) . Is it missing in your code? -
I am have trouble sending email with an attachment?
I am having trouble sending emails with an attachment. Does anyone have a solution to this problem?
Impossible to answer with information provided
Allan -
How do I send email with pictures attached, using PSE 9 and Windows 7 ?
How do I send email with pictures attached, using PSE 9 and Windows 7 ?
Try email attachment workflow in Organizer. http://tv.adobe.com/watch/learn-photoshop-elements-9/sharing-your-images-via-email/
Thanks
Andaleeb -
Hello,
I just upgrading to ios 8 (8.0.2) and I am now unable to send email with an attachement (photo) through activesync (zarafa).
It works fine with smtp or through activesync but without attachement.
Is there any solution?
Thx.It worked fine with the last version of iOS 7 and still works fine with outlook connected from a PC to the same activesync server.
-
External Send PO as email with PDF attachment not working
hi,
we are using ECC6, and in txn NACT, Processing routine we can use Sapscript External send > SAPFM06P > ENTRY_NEU > MEDRUCK > PDF and in MN04/5 i create Output record, and in SCOT my PO is ready for transmission from either ME21N/2 and ME9F - works well - email sent with pdf PO attached.
<b>HOWEVER,</b> we have just created a SMARTFORM PO, and with similar settings, i cannot create External send OUTPUT!!! (Output failed in ME9F/ME23N) NACT settings External Send > /SMB40/FM06P > Z_MMPO_A > PDF
In SCOT > SMTP > Internet X > Sapscript/SmartForm = PDF.
Does special code need to be entered into Smartform to generate PDF email similar to Sapscript? Any code would be appreciated.
regards AdamHi,
You need to build a code to create the Spool OTF output into PDF.
This can be done in Print program, which converts the spool into PDF & sends a mail with PDF attachment.
Please refer this sample program:
http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
Best regards,
Prashant -
Send Mail with PDF Attachment in ABAP
Hi Experts,
I have a requirement where I need to convert internal table data into PDF format and send it as an E-Mail with PDF attachment to Outlook mail using ABAP.
How do I achieve this .
Can anyone send me example code for doing this.
Thanks
Kumarhiii
check following code for PDF attachment and mail
** Check for any ATTACHMENTS...
IF d_desired_type = 'RAW'. " Set to RAW?
* PERFORM convert_to_abaplist. " YES - convert it
ENDIF. " end...
IF d_desired_type = 'ALI'. " Set to ALI?
PERFORM convert_to_alilist. " YES - convert it
ENDIF. " end...
* Check for any ATTACHMENTS...
IF NOT t_soli[] IS INITIAL. " attachment?
h_real_type = d_desired_type. " ENABLE
h_transf_type = 'X'. " Transfer type BINARY...
* Write PDF/ALI formatted data to BINARY table...
t_con_bin[] = t_soli[].
* Add Packing List (attachment) for PDF...
DESCRIBE TABLE t_con_bin LINES h_tab_cntr.
READ TABLE t_con_bin INDEX h_tab_cntr.
h_doc_data-doc_size = h_doc_data-doc_size
+ ( ( h_tab_cntr - 1 )
* 255 + STRLEN( t_con_bin ) ).
h_doc_data-obj_descr = mail_subject.
h_body_start = 1.
h_body_num = h_tab_cntr.
* Write RAW data if that's what it is (adds to TEXT)...
IF h_real_type = 'RAW'.
DESCRIBE TABLE t_con_text LINES h_body_start.
h_body_start = h_body_start + 1.
h_transf_type = space. " Transfer type TEXT...
LOOP AT t_con_bin. " Zip thru TEXT stuff
t_con_text = t_con_bin. " set TEXT table header..
APPEND t_con_text. " add to what's there!
ENDLOOP.
CLEAR: t_con_bin. " clear BINARY header..
REFRESH: t_con_bin. " reset BINARY table...
ENDIF.
CLEAR t_pak_list.
IF h_transf_type = 'X'. " Binary=PDF/ALI?
t_pak_list-transf_bin = 'X'.
t_pak_list-head_start = 1.
t_pak_list-head_num = 0.
t_pak_list-body_start = 1.
t_pak_list-body_num = h_tab_cntr.
t_pak_list-doc_type = h_real_type.
t_pak_list-obj_name = 'ATTACHMENT'.
t_pak_list-obj_descr = 'Document'(001).
t_pak_list-doc_size = ( h_tab_cntr - 1 )
* 255 + STRLEN( t_con_bin ).
ELSE.
DESCRIBE TABLE t_con_text LINES h_tab_cntr.
READ TABLE t_con_text INDEX h_tab_cntr.
t_pak_list-transf_bin = ' '. " Binary=RAW
t_pak_list-head_start = 1.
t_pak_list-head_num = 0.
t_pak_list-body_start = h_body_start.
t_pak_list-body_num = h_tab_cntr.
t_pak_list-doc_type = h_real_type.
t_pak_list-obj_name = 'ATTACHMENT'(002).
t_pak_list-obj_descr = 'Report'(003).
t_pak_list-doc_size = ( h_body_num - 1 )
* 255 + STRLEN( t_con_text ).
ENDIF.
APPEND t_pak_list.
ENDIF.
* Send the EMAIL out with SAP function...
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = h_doc_data
put_in_outbox = 'X'
* commit_work = 'X'
TABLES
packing_list = t_pak_list
contents_bin = t_con_bin
contents_txt = t_con_text
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.
IF syst-subrc NE 0.
* RAISE send_failed.
CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
EXPORTING
msg_arbgb = '00'
msg_nr = '001'
msg_ty = 'E'
msg_v1 = 'O/P Could not be issued '(001)
msg_v2 = ' Due to No Mail ID'(002)
msg_v3 = syst-msgv3
msg_v4 = syst-msgv4
EXCEPTIONS
OTHERS = 1.
* Check General incompletion status of the header
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'.
ENDIF.
ELSE.
* commit work.
ENDIF.
ENDFORM. " SEND_MAIL_FAX
*& Form convert_otf_2_pdf
* text
* --> p1 text
* <-- p2 text
FORM convert_otf_2_pdf .
DATA: "t_line LIKE tline OCCURS 0 WITH HEADER LINE,
t_objcont LIKE soli OCCURS 0 WITH HEADER LINE,
d_doc_size(12) TYPE c,
d_fle1(2) TYPE p,
d_fle2(2) TYPE p,
d_off1 TYPE p,
d_hltlines TYPE i,
d_hfeld(500) TYPE c,
w_indx LIKE sy-tabix.
CLEAR: t_line, t_objcont, d_off1.
REFRESH: t_line, t_objcont.
* Check/set DEFAULT Desired-type attachment...
IF d_desired_type IS INITIAL. " Entered Desired type?
d_desired_type = 'PDF'. " NO - default to PDF
ENDIF. "
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = d_desired_type
IMPORTING
bin_filesize = d_doc_size
TABLES
otf = t_itcoo
lines = t_line
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
IF sy-subrc > 0.
RAISE otf_convert_failed.
ENDIF.
ENDFORM. " convert_otf_2_pdf
*& Form convert_otf_2_pdf_sx
* text
* --> p1 text
* <-- p2 text
FORM convert_otf_2_pdf_sx .
DATA:
t_otf LIKE solisti1 OCCURS 0 WITH HEADER LINE,"ENABLE
t_pdf LIKE tline OCCURS 0 WITH HEADER LINE,"ENABLE
doc_size(12) TYPE n,
len_out TYPE i,
x_real LIKE soodk-objtp,
x_idx_b LIKE sy-tabix,
x_idx_e LIKE sy-tabix.
IF d_desired_type = 'PDF'.
d_desired_type = 'OTF'.
ENDIF.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
rqident = d_spool_id
desired_type = d_desired_type
IMPORTING
real_type = x_real
TABLES
buffer = t_otf
buffer_pdf = t_pdf
EXCEPTIONS
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
OTHERS = 8.
IF sy-subrc <> 0.
IF sy-subrc = 1.
RAISE invalid_spool_id.
ELSE.
RAISE otf_convert_failed.
ENDIF.
ENDIF.
* Check Desired-Type vs. Real-Type (if any)...
IF d_desired_type IS INITIAL.
IF x_real = 'OTF'.
d_desired_type = 'PDF'.
ELSE.
d_desired_type = x_real.
ENDIF.
ELSE.
IF ( d_desired_type = 'PDF' OR
d_desired_type = 'OTF' ) AND
( x_real = 'OTF' OR
x_real = 'PDF' ).
d_desired_type = 'PDF'.
ELSE.
IF d_desired_type <> x_real.
RAISE type_no_match.
ENDIF.
ENDIF.
IF ( d_desired_type = 'ALI' OR
d_desired_type = 'RAW' ) AND
x_real = 'OTF'.
RAISE type_no_match.
ENDIF.
ENDIF.
* Check if ABAP-LIST and not SapScript...
IF d_desired_type = 'ALI' OR
d_desired_type = 'RAW'.
t_soli[] = t_otf[].
EXIT.
ENDIF.
* Load OTF data gotten from spool...
LOOP AT t_otf.
t_itcoo = t_otf.
APPEND t_itcoo.
* if Vendor P/O (SapScript = Z_MEDRUCK) then
* trap INDEX for "Terms & Conditions" on BACK...
IF t_itcoo-tdprintcom = 'IN' AND
t_itcoo-tdprintpar = '01EZ_MEDRUCK BACK'.
x_idx_b = sy-tabix.
ENDIF.
IF t_itcoo-tdprintcom = 'IN' AND
t_itcoo-tdprintpar = '01EZ_MEDRUCK NEXT'.
x_idx_e = ( sy-tabix - 1 ).
ENDIF.
ENDLOOP.
* Drop from table if INDEX'S are set (see above)...
IF ( x_idx_b > 0 AND
( x_idx_e > x_idx_b ) ) .
DELETE t_itcoo FROM x_idx_b
TO x_idx_e.
ENDIF.
PERFORM convert_otf_2_pdf.
ENDFORM. " convert_otf_2_pdf_sx
*& Form CONVERSION_OF_SIZE *
* *"Converting the file to get a 255 char single line internal table *
* The PDF file that is generated out of the above function module *
* cannot be transported as it needs to be of 255 chars. Hence *
* converting the file to get a 255 char single line,internal table. *
FORM conversion_of_size .
"Declaring Local Constants............................................
CONSTANTS:
cnv_hexconst_zero TYPE x VALUE '00'.
* Internal table to hold 255 Char's Single Line. *
DATA:
lv_big_lines(268) TYPE c
OCCURS 0 WITH HEADER LINE.
*"Local Work Variables.................................................
DATA:
lfl_flag TYPE c,
lv_left_t(268) TYPE c,
lv_left_i TYPE i,
tv_left_i TYPE i,
lv_curr_i TYPE i.
FIELD-SYMBOLS: <f>.
* Get the lines into a table of 268 char as the first step to put it in
* the pdf file of 255 chars
CLEAR lfl_flag.
LOOP AT t_line.
IF lfl_flag EQ ' '.
CLEAR lv_big_lines.
ASSIGN lv_big_lines(134) TO <f>.
<f> = t_line.
lfl_flag = 'X'.
ELSE.
lv_big_lines+134 = t_line.
APPEND lv_big_lines.
CLEAR: lfl_flag.
ENDIF. " If lfl_flag = ''..
ENDLOOP. " Loop at t_pdf
IF lfl_flag EQ 'X'.
APPEND lv_big_lines.
ENDIF. " If lflf_flag eq 'X'..
* Next fill it into a 255 char table
CLEAR: lv_left_t, lv_left_i, tv_left_i.
lv_curr_i = 255.
LOOP AT lv_big_lines.
IF lv_left_i NE 0.
IF lv_curr_i NE 0.
wa_objcont(lv_left_i) = lv_left_t(lv_left_i).
wa_objcont+lv_left_i(lv_curr_i) = lv_big_lines(lv_curr_i).
ELSE.
wa_objcont = lv_left_t(lv_left_i).
ENDIF. " IF lv_curr_i NE 0
ELSE.
wa_objcont = lv_big_lines(lv_curr_i).
ENDIF. " IF lv_left_i NE 0
APPEND wa_objcont TO t_objcont.
tv_left_i = 268 - lv_curr_i.
IF tv_left_i > 255.
wa_objcont = lv_big_lines+lv_curr_i(255).
APPEND wa_objcont TO t_objcont.
lv_left_i = tv_left_i - 255.
tv_left_i = 255 + lv_curr_i.
lv_curr_i = 255 - lv_left_i.
lv_left_t = lv_big_lines+tv_left_i.
ELSE.
lv_left_t = lv_big_lines+lv_curr_i.
lv_left_i = 268 - lv_curr_i.
lv_curr_i = 255 - lv_left_i.
ENDIF. " IF tv_left_i > 255
ENDLOOP. " LOOP AT lv_big_lines.
CLEAR wa_objcont .
ASSIGN wa_objcont(lv_left_i) TO <f>.
<f> = lv_left_t(lv_left_i).
APPEND wa_objcont TO t_objcont.
h_transf_type = 'X'. " Transfer type BINARY...
IF NOT t_objcont[] IS INITIAL.
t_soli[] = t_objcont[]. " SapScript doc to Objects...
ENDIF.
regards
twinkal -
How do I add text message to this email with PDF attachment?
Good day, everyone!
Okay, we have a "z"-version of program RFFOUS_T and some of its include codes. One include code, RFFORIO6, has a form called MAIL_PDF_ADVICE. It is in this form that we are emailing a remittance advice form. The actual form is attached as a PDF file.
Unfortunately, there's no text in the body of the email -- it's just the attachment -- so the users would like us to add a couple basic lines in the body of the email that explain the attachment. I'm pretty new to using this particular FM and emailing the PDF attachment, and I've gotten stuck in my research trying to find out exactly how to do this. I'm guessing this shouldn't be all that difficult, but I'm not finding the right solution. Here's the form:
*& Form mail_pdf_advice
E-mail PDF advice
-->IT_ADVICE PDF form (output from Adobe server)
-->I_PDF_LEN length of PDF advice in bytes
FORM mail_pdf_advice USING it_advice TYPE solix_tab
i_pdf_len TYPE i.
DATA:
lt_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
l_user LIKE soextreci1-receiver,
ls_send_doc LIKE sodocchgi1,
lt_pdf_attach TYPE TABLE OF sopcklsti1 WITH HEADER LINE.
CHECK NOT finaa-intad IS INITIAL.
CHECK finaa-nacha EQ 'I'.
*--- determine E-Mail sender and recipient
IF fsabe-usrnam EQ space.
l_user = sy-uname.
ELSE.
l_user = fsabe-usrnam. "Office-User des Sachbearb.
ENDIF.
lt_receivers-receiver = finaa-intad.
lt_receivers-rec_type = 'U'. "E-mail address
APPEND lt_receivers.
ls_send_doc-obj_descr = itcpo-tdtitle.
lt_pdf_attach-transf_bin = 'X'.
lt_pdf_attach-doc_type = 'PDF'.
lt_pdf_attach-obj_langu = reguh-zspra.
lt_pdf_attach-body_start = 1.
lt_pdf_attach-doc_size = i_pdf_len.
DESCRIBE TABLE it_advice LINES lt_pdf_attach-body_num.
APPEND lt_pdf_attach.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = ls_send_doc
sender_address = l_user
TABLES
packing_list = lt_pdf_attach
contents_hex = it_advice
receivers = lt_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.
<error checking code snipped>
Does someone know how to do this? <b><REMOVED BY MODERATOR></b> Thanks so much in advance!
Dave
Message was edited by:
Alvaro Tejada GalindoHi Dave,
Table <b>contents_bin</b> is used to pass attachment file and <b>contents_txt</b> is used to pass mail body contents. You need to declare one more int table to give contents for mail body.
For reference check the code below
ut_message is for message body
and ut_attach is having attachement file.
FORM send_file_as_email_attachment TABLES ut_message
ut_attach
USING uv_email
uv_mtitle
uv_format
uv_filename
uv_attdescription
uv_sender_address
uv_sender_addres_type
CHANGING uc_error
uc_reciever.
DATA: l_error TYPE sy-subrc,
l_reciever TYPE sy-subrc,
l_mtitle LIKE sodocchgi1-obj_descr,
l_email LIKE somlreci1-receiver,
l_format TYPE so_obj_tp ,
l_attdescription TYPE so_obj_nam ,
l_attfilename TYPE so_obj_des ,
l_sender_address LIKE soextreci1-receiver,
l_sender_address_type LIKE soextreci1-adr_typ,
l_receiver LIKE sy-subrc.
DATA: lt_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
lt_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
lt_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
lt_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
lt_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
l_cnt TYPE i,
l_sent_all(1) TYPE c,
lw_doc_data LIKE sodocchgi1.
l_email = uv_email.
l_mtitle = uv_mtitle.
l_format = uv_format.
l_attdescription = uv_attdescription.
l_attfilename = uv_filename.
l_sender_address = uv_sender_address.
l_sender_address_type = uv_sender_addres_type.
Fill the document data.
lw_doc_data-doc_size = 1.
Populate the subject/generic message attributes
lw_doc_data-obj_langu = sy-langu.
lw_doc_data-obj_name = 'SAPRPT'.
lw_doc_data-obj_descr = l_mtitle.
lw_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR lw_doc_data.
READ TABLE ut_attach INDEX l_cnt.
lw_doc_data-doc_size =
( l_cnt - 1 ) * 255 + STRLEN( ut_attach ).
lw_doc_data-obj_langu = sy-langu.
lw_doc_data-obj_name = 'SAPRPT'.
lw_doc_data-obj_descr = l_mtitle.
lw_doc_data-sensitivty = 'F'.
CLEAR lt_attachment.
REFRESH lt_attachment.
lt_attachment[] = ut_attach[].
Describe the body of the message
CLEAR lt_packing_list.
REFRESH lt_packing_list.
lt_packing_list-transf_bin = space.
lt_packing_list-head_start = 1.
lt_packing_list-head_num = 0.
lt_packing_list-body_start = 1.
DESCRIBE TABLE ut_message LINES lt_packing_list-body_num.
lt_packing_list-doc_type = 'RAW'.
APPEND lt_packing_list.
Create attachment notification
lt_packing_list-transf_bin = 'X'.
lt_packing_list-head_start = 1.
lt_packing_list-head_num = 1.
lt_packing_list-body_start = 1.
DESCRIBE TABLE lt_attachment LINES lt_packing_list-body_num.
lt_packing_list-doc_type = l_format.
lt_packing_list-obj_descr = l_attdescription.
lt_packing_list-obj_name = l_attfilename.
lt_packing_list-doc_size = lt_packing_list-body_num * 255.
APPEND lt_packing_list.
Add the recipients email address
CLEAR lt_receivers.
REFRESH lt_receivers.
lt_receivers-receiver = l_email.
lt_receivers-rec_type = 'U'.
lt_receivers-com_type = 'INT'.
lt_receivers-notif_del = 'X'.
lt_receivers-notif_ndel = 'X'.
APPEND lt_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = lw_doc_data
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = l_sent_all
TABLES
packing_list = lt_packing_list
contents_bin = lt_attachment
contents_txt = ut_message
receivers = lt_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.
Message was edited by:
Amit Kumar
Maybe you are looking for
-
Getting Error while starting SOA Server OIM 11gR1
Hi, I am getting following errors while staring SOA server in OIM 11g R1, my OIM server is running fine I can login to OIM and work but SOA server is not coming up. It was working fine suddenly it started throwing these errors. I have done the whole
-
How to change default media player setting in Mountain Lion
I right click on the desired media player, then I click on "get info" and another pop up appears, but there is no "open with" selection! See pic below: I open the application folder in the Finder window, I highlight the desired media player, I go to
-
Strange ARP Problems with C170 and AsyncOS 9
after upgrading to asyncOS 9.0 (Ironport C170) we have the following problem. For better understanding a short explanation (without all network devices) The traffic flow is Lan --- Application Firewall ---Ironport During a connection between the Fir
-
Please help on this requirement .. to develop an ALV report
When there are changes in VC characteristic allowed values or in VC tables there is need to ensure that they will not affect existing orders or orders created with reference to the ones that have the corresponding value. Currently there is no report
-
How can I activate the option "lens corrections" in the Develop-mode?
Hello How can I activate the option "lens corrections" in the Develop-mode? I have lightroom 5.5. In the Develop Mode I have every option exept "lens corrections" - where is it hidden? (see picture - sorry it's in German) Thanks!