on 12-09-2005 9:20 AM
Hi,
Can a smartform output be sent directly as a mail into SAP inbox with out converting it into .PDF format? Help needed regarding this.
Regards,
suresh.
Hi Suresh,
Refer this SDN blog where smartform output is mailed in HTML format directly without converting in .PDF file...
/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suresh,
You need to associate the exchange server to the SAP system to send the mail outside. This is called SAPconnect. You can use transaction SCOT in R/3 system. Contact your basis team about setting up this.
Also, plz make sure that your user id has a valid email address attached to it via Transaction SU01.
Regards,
Sakthi.
Message was edited by: sakthivel s
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Here is the sample code for sending mail after converting it into PDF.
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
w_objhead TYPE soli_tab,
w_ctrlop TYPE ssfctrlop,
w_compop TYPE ssfcompop,
w_return TYPE ssfcrescl,
w_doc_chng typE sodocchgi1,
w_data TYPE sodocchgi1,
w_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_TEST2'
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.
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 PDF from 132 to 255.
LOOP AT i_tline.
Replacing space by ~
TRANSLATE i_tline USING ' ~'.
CONCATENATE w_buffer i_tline INTO w_buffer.
ENDLOOP.
Replacing ~ by space
TRANSLATE w_buffer USING '~ '.
DO.
i_record = w_buffer.
Appending 255 characters as a record
APPEND i_record.
SHIFT w_buffer LEFT BY 255 PLACES.
IF w_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Refresh: i_reclist,
i_objtxt,
i_objbin,
i_objpack.
clear w_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.
i_objtxt = 'Regards,'.
APPEND i_objtxt.
i_objtxt = 'J.Jayanthi'.
APPEND i_objtxt.
DESCRIBE TABLE i_objtxt LINES v_lines_txt.
Document information.
w_doc_chng-obj_name = 'Smartform'.
w_doc_chng-expiry_dat = sy-datum + 10.
w_doc_chng-obj_descr = 'Smart form output'.
w_doc_chng-sensitivty = 'F'. "Functional object
w_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
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 = 'xyz@yahoo.com'.
i_reclist-express = 'X'.
i_reclist-rec_type = 'U'. "Internet address
APPEND i_reclist.
Sending mail.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_chng
put_in_outbox = 'X'
TABLES
packing_list = i_objpack
object_header = w_objhead
contents_hex = 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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
Message was edited by: Jayanthi Jayaraman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
with out converting this to PDF it can be possible..
<b>SSFCONVERT_OTF_AND_MAIL</b>
for more info check this..include <b>LSTXBCOTF</b>
vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
call function 'SSFCONVERT_OTF_AND_MAIL'
exporting
mail_sender = dev_mail_sender
mail_recipient = dev_mail_recipient
mailoptions = p_param
importing
mail_ok = l_ok
office_objid = l_off_obj
msgno = l_msgno
msgid = l_msgid
msgv1 = l_msgv1
msgv2 = l_msgv2
msgv3 = l_msgv3
msgv4 = l_msgv4
tables
mail_application_object_ids = dev_mail_applobj_tab
otf = p_otfdata.
try this....
vijay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
it can be done. here's the code
report zhr_r_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 'bhaskark@intelligroup.com',
g_mail type so_name value 'madang@intelligroup.com',
g_mail TYPE ppfdmailad VALUE 'muralikri@intelligroup.com' ,
g_mail TYPE ppfdmailad VALUE 'dmkrishna76@yahoo.com' ,
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.
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.
*--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 = 'sampathc@intelligroup.com'.
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
regards
Arun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.