Convert ABAP Report to HTML & Send External Email Attachment
Hi,
I have a requirement described as below. A report is scheduled to run in the background creates a spool, to be converted to HTML format and send to Third Parties (External Email ID's) via Email. Please let me know whether the requirement is not clear. Can you please suggest me a suitable SAP Solution for this requirement?
Thanks,
Kannan.SA
Hi,
See below simple report to convert the internal table data to a HTML format data and stores in a internal table and then pass that internal table as an attachment to the external email using function module SO_NEW_DOCUMENT_ATT_SEND_API1.
You need for create a spool also.
REPORT Z_HTML .
include <icon>.
types: begin of msg,
type like icon-id,
text(140) type c,
end of msg.
constants: gc_marked type c value 'X',
gc_ok like icon-id value '@5B@'.
data:
gt_msg type standard table of msg,
gs_msg like line of gt_msg,
gv_msg(138) type c,
*-- html
html_container type ref to cl_gui_custom_container,
html_control type ref to cl_gui_html_viewer,
my_row_header like w3head occurs 10 with header line,
my_fields like w3fields occurs 10 with header line,
my_header like w3head,
my_html type standard table of w3html ,
ok_code like sy-ucomm.
Start of Selection *
start-of-selection.
clear gv_msg.
gv_msg = 'MESSAGES for HTML'.
do 3 times.
perform message using gc_ok gv_msg .
enddo.
End of Selection *
end-of-selection.
set screen 0100.
*& Form message
form message using p_type
p_text.
clear gs_msg.
gs_msg-type = p_type.
gs_msg-text = p_text.
append gs_msg to gt_msg.
endform. " MESSAGE
*& Module STATUS_0100 OUTPUT
module status_0100 output.
perform convert_itab_html.
set titlebar '100' .
set pf-status 'MAIN100'.
create object html_container
exporting
container_name = 'CONTAINER'.
create object html_control
exporting
parent = html_container
saphtmlp = gc_marked .
data: assigned_url type url.
call method html_control->load_data
EXPORTING
URL = url
TYPE = 'text'
SUBTYPE = 'html'
SIZE = 0
ENCODING =
CHARSET =
importing
assigned_url = assigned_url
changing
data_table = my_html
EXCEPTIONS
DP_INVALID_PARAMETER = 1
DP_ERROR_GENERAL = 2
CNTL_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.
call method html_control->show_url
exporting
url = assigned_url
FRAME =
IN_PLACE = ' X'
EXCEPTIONS
CNTL_ERROR = 1
CNHT_ERROR_NOT_ALLOWED = 2
CNHT_ERROR_PARAMETER = 3
DP_ERROR_GENERAL = 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.
endmodule. " STATUS_0100 OUTPUT
*& Module exit INPUT
module exit input.
leave program.
endmodule. " exit INPUT
*& Module user_command_0100 INPUT
text
module user_command_0100 input.
case ok_code.
when 'EXIT' or 'BACK'.
leave program.
when others.
call method cl_gui_cfw=>dispatch.
endcase.
endmodule. " user_command_0100 INPUT
*& Form convert_itab_html
form convert_itab_html.
data: lv_tabix like sy-tabix.
*-- table header
call function 'WWW_ITAB_TO_HTML_HEADERS'
exporting
field_nr = 1
text = 'Type'
fgcolor = 'navy'
bgcolor = 'red'
font = 'Arial'
tables
header = my_row_header.
call function 'WWW_ITAB_TO_HTML_HEADERS'
exporting
field_nr = 2
text = 'Message'
fgcolor = 'navy'
bgcolor = 'red'
font = 'Arial'
tables
header = my_row_header.
*-- table rows
clear lv_tabix.
loop at gt_msg into gs_msg.
lv_tabix = sy-tabix.
call function 'WWW_ITAB_TO_HTML_LAYOUT'
exporting
field_nr = 1
line_nr = lv_tabix
icon = gc_marked
tables
fields = my_fields.
call function 'WWW_ITAB_TO_HTML_LAYOUT'
exporting
field_nr = 2
line_nr = lv_tabix
fgcolor = 'red'
bgcolor = 'black'
font = 'Arial'
size = '2'
tables
fields = my_fields.
endloop.
*-- header
move 'Messages during program run' to my_header-text.
move 'Arial' to my_header-font.
move '2' to my_header-size.
move 'Centered' to my_header-just.
move 'red' to my_header-bg_color.
move 'blue' to my_header-fg_color.
refresh my_html.
call function 'WWW_ITAB_TO_HTML'
exporting
table_header = my_header
all_fields = ' '
tables
html = my_html
fields = my_fields
row_header = my_row_header
itable = gt_msg.
endform. "convert_itab_html
Similar Messages
-
Convert spool to PDF and send as email attachment
When i try to convert SAP spool to PDF and send it as email attachment, size of PDF document becomes large as compared to size of the PDF cocument i download using the same spool.
I am using following FMs.
CONVERT_ABAPSPOOLJOB_2_PDF to convert spool to PDF
and
SO_NEW_DOCUMENT_ATT_SEND_API1 to send email with attchment.
some times size of attchment exceeds 2MB and email results in error in SAP connect (SOST).
Any idea on how to compress the PDF attchment??
ThanksHi Venkat,
Can you plesae assist me.
I have a requirement to convert spool to pdf
send an email to users
issue is that attachement is big cant go through
I have used compress, but when I open the pdf file error that file was not correclty decoded
please assist, anyone -
Sending Report as HTML via external email.
I have a report on Apex 4.0.2 and was wondering if it is possible to get the report values as HTML so that I can send them using an email function I have in separate packages?
I just send the username, recipients and the HTML to this function and it generates the email along with the ones I generate from all other screens.Just to clarify, I have a process that is called on submit.
At the moment it emails fine with data from the apex page, but is there way to include a html version of the page without creating it myself?
the function is called like this:
Email(pEmailName => lvEmailName,
pSubject => lvSubject,
pTextMsg => lvText,
pHTMLMsg => lvHtml);
and I want to pass the data as html to pHTMLMsg. -
Converting Smartform to PDF and send as email attachment
Hi
I want to send the Smartform to mail as PDF attachment.
I found the program in code gallery., it name was 'ZTEST_NREDDY_PDF_MAIL' .
I used this program and it send the Smartform to mail as PDF attachment but when open the pdf file it gave me error.
error : 'An unrecognized token Qq was found'.
Please help me out.
Thanks
AninaHi,
Following is the code logic:
Tables for OTF to PDF Conversion
DATA: g_t_docs TYPE STANDARD TABLE OF docs, " Table for Stored Document
g_t_lines TYPE STANDARD TABLE OF tline. " Table for Text lines
Objects to send mail.
DATA: g_t_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE, " SAPoffice: Description of Imported Object Components
g_t_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
g_t_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
g_t_contout LIKE solisti1 OCCURS 0 WITH HEADER LINE,
g_t_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE. " SAPoffice: Structure of the API Recipient List
Addresses (Business Address Services)
DATA: g_t_adrc LIKE adrc OCCURS 0,
g_t_adrc2 LIKE adrc OCCURS 0,
g_t_adrc3 LIKE adrc OCCURS 0,
g_t_adrc_wa TYPE adrc,
g_t_adrc2_wa TYPE adrc,
g_t_adrc3_wa TYPE adrc.
Sales Document: Partner
DATA: g_t_vbpa_wa TYPE vbpa.
E-Mail Addresses (Business Address Services)
DATA: g_t_adr6 LIKE adr6 OCCURS 0,
g_t_adr6_2 LIKE adr6 OCCURS 0,
g_t_adr6_wa TYPE adr6,
g_t_adr6_2_wa TYPE adr6.
DATA:
Work Area declarations
g_wa_objhead TYPE soli_tab, " Work Area for Objcont and Objhead as Table Type
g_wa_doc_chng TYPE sodocchgi1, " Work Area - Data of an object which can be changed
Variables declarations
g_lines_txt TYPE i,
g_lines_bin TYPE i,
g_email_id(40) VALUE '', " E-mail Address
PDF related data declarations
g_wa_job_output_info TYPE ssfcrescl, " Smart Forms: Return value at end of form printing
g_wa_control_parameters TYPE ssfctrlop,"#EC NEEDED " Smart Forms: Control structure
g_name TYPE string,
g_path TYPE string,
g_fullpath TYPE string,
g_filename TYPE string,
g_filter TYPE string,
g_bin_filesize TYPE i,
g_uact TYPE i,
g_guiobj TYPE REF TO cl_gui_frontend_services.
PERFORM f0100_download_pdf.
PERFORM f200_convert_to_pdf.
PERFORM f300_attach_and_mail_pdf.
*& Form f0100_download_pdf
To Download the PDF Format of SmartForm on
Presentation Server
FORM f0100_download_pdf. "#EC CALLED
Downloading PDF File
CREATE OBJECT g_guiobj.
CALL METHOD g_guiobj->file_save_dialog
EXPORTING
default_extension = 'pdf'
default_file_name = g_name
file_filter = g_filter
CHANGING
filename = g_name
path = g_path
fullpath = g_fullpath
user_action = g_uact.
IF g_uact = g_guiobj->action_cancel.
EXIT.
ENDIF.
MOVE g_fullpath TO g_filename.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = g_bin_filesize
filename = g_filename
filetype = 'BIN'
TABLES
data_tab = g_t_lines.
ENDFORM. "f0100_download_pdf
*& Form f0200_convert_to_pdf
To convert the SmartForm to PDF format
FORM f0200_convert_to_pdf . "#EC CALLED
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = g_bin_filesize
TABLES
otf = g_wa_job_output_info-otfdata
doctab_archive = g_t_docs
lines = g_t_lines.
CONCATENATE text-001 g_sales_order_no '.pdf' INTO g_name.
ENDFORM. " f0200_convert_to_pdf
*& Form f0300_attach_and_mail_pdf
To E-Mail the PDF form as an Attachment
FORM f0300_attach_and_mail_pdf . "#EC CALLED
Attachment
REFRESH: g_t_reclist,
g_t_objtxt,
g_t_objbin,
g_t_objpack.
CLEAR g_wa_objhead.
Create Message Body Title and Description
g_t_objtxt = g_name.
APPEND g_t_objtxt.
DESCRIBE TABLE g_t_objtxt LINES g_lines_txt.
READ TABLE g_t_objtxt INDEX g_lines_txt.
g_wa_doc_chng-obj_name = g_name.
g_wa_doc_chng-expiry_dat = sy-datum + 10.
g_wa_doc_chng-obj_descr = g_name.
g_wa_doc_chng-sensitivty = 'F'.
g_wa_doc_chng-doc_size = g_lines_txt * 255.
Main Text
CLEAR g_t_objpack-transf_bin.
g_t_objpack-head_start = 1.
g_t_objpack-head_num = 0.
g_t_objpack-body_start = 1.
g_t_objpack-body_num = g_lines_txt.
g_t_objpack-doc_type = 'RAW'.
APPEND g_t_objpack.
Attachment (PDF-Attachment)
g_t_objpack-transf_bin = 'X'.
g_t_objpack-head_start = 1.
g_t_objpack-head_num = 0.
g_t_objpack-body_start = 1.
Convert TLINE to SOLISTI1
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_src = 134
line_width_dst = 255
TABLES
content_in = g_t_lines
content_out = g_t_contout
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 s000(0k) WITH text-002.
EXIT.
ENDIF.
Create Message Attachment
APPEND LINES OF g_t_contout[] TO g_t_objbin[].
DESCRIBE TABLE g_t_objbin LINES g_lines_bin.
READ TABLE g_t_objbin INDEX g_lines_bin.
g_t_objpack-doc_size = g_lines_bin * 255 .
g_t_objpack-body_num = g_lines_bin.
g_t_objpack-doc_type = 'PDF'.
g_t_objpack-obj_name = text-003.
g_t_objpack-obj_descr = text-004.
APPEND g_t_objpack.
CLEAR g_t_reclist.
g_t_reclist-receiver = g_email_id.
g_t_reclist-rec_type = 'U'.
APPEND g_t_reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = g_wa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = g_t_objpack
object_header = g_wa_objhead
contents_bin = g_t_objbin
contents_txt = g_t_objtxt
receivers = g_t_reclist.
ENDFORM. " f0300_attach_and_mail_pdf -
To send external email from ABAP
How to send external email from ABAP Program and what are the settings to be done for the same ?
Please check..
Sending External email through SAP
What is the FM for sending the external email through SAP by attaching layout set to it?
These are the FM for sending external email :-
SO_DOCUMENT_SEND_API1
SAPoffice: Send new document with attachments via RFC
SO_NEW_DOCUMENT_ATT_SEND_API1
(In 4.6C only, You can go to SE37 and click the documentation on how to use it. A sample program is provided there.)
SAPoffice: Send new document with attachments via RFC
Note : If you are using FM SO_NEW_DOCUMENT_ATT_SEND_API1 then Export Parameter DOCUMENT_DATA-OBJ_DESCR contains the Subject.
SO_NEW_DOCUMENT_SEND_API1
SAPoffice: Send new document
How to send a report to an external mail-id?
Try this sample code :-
REPORT ZREPORT_TO_EMAIL NO STANDARD PAGE HEADING LINE-SIZE 200.
DATA : BEGIN OF ITAB OCCURS 0,
PERNR LIKE PA0001-PERNR,
ENAME LIKE PA0001-ENAME,
END OF ITAB.
DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE,
receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,
packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,
listobject LIKE abaplist OCCURS 10,
compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,
w_object_hd_change LIKE sood1,
compressed_size LIKE sy-index.
START-OF-SELECTION.
SELECT PERNR ENAME
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM PA0001
WHERE PERNR < 50.
LOOP AT ITAB.
WRITE :/02 SY-VLINE , ITAB-PERNR, 15 SY-VLINE , ITAB-ENAME, 50
SY-VLINE.
ENDLOOP.
Receivers
receiver_list-recextnam = '[email protected]'. "-->
EMAIL ADDRESS
RECEIVER_list-RECESC = 'E'. "<-
RECEIVER_list-SNDART = 'INT'."<-
RECEIVER_list-SNDPRI = '1'."<-
APPEND receiver_list.
General data
w_object_hd_change-objla = sy-langu.
w_object_hd_change-objnam = 'Object name'.
w_object_hd_change-objsns = 'P'.
Mail subject
w_object_hd_change-objdes = 'Message subject'.
Mail body
APPEND 'Message content' TO message_content.
Attachment
CALL FUNCTION 'SAVE_LIST'
EXPORTING
list_index = '0'
TABLES
listobject = listobject.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
compressed_size = compressed_size
TABLES
in = listobject
out = compressed_attachment.
DESCRIBE TABLE compressed_attachment.
CLEAR packing_list.
packing_list-transf_bin = 'X'.
packing_list-head_start = 0.
packing_list-head_num = 0.
packing_list-body_start = 1.
packing_list-body_num = sy-tfill.
packing_list-objtp = 'ALI'.
packing_list-objnam = 'Object name'.
packing_list-objdes = 'Attachment description'.
packing_list-objlen = compressed_size.
APPEND packing_list.
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
object_hd_change = w_object_hd_change
object_type = 'RAW'
owner = sy-uname
TABLES
objcont = message_content
receivers = receiver_list
packing_list = packing_list
att_cont = compressed_attachment. -
I use FM SO_OBJECT_SEND to send external email in my Z program but the output always in attachment format, depend on the format i specified (pdf,htm,txt,xls). I want the output to be in standard email body. How to do it?
Hi,
Can you please send your code or check if you are passing att_cont parameter in your function module. I would suggest you to use SO_NEW_DOCUMENT_SEND_API1 function module to send mail.
Also find the code below for your reference.
REPORT z_test_email_sending.
DATA: t_reclist TYPE TABLE OF somlreci1,
wa_receiver LIKE LINE OF t_reclist,
objcont TYPE TABLE OF solisti1,
subject TYPE TABLE OF solisti1,
objline TYPE solisti1,
w_line_count TYPE i,
doc_chng TYPE sodocchgi1,
offset type i.
CONSTANTS c_sep TYPE c VALUE '|'.
DATA : BEGIN OF mail_line OCCURS 0,
sep0,
model_year(6),
sep1,
mf(4),
sep2,
type(5),
sep3,
variant(14),
sep4,
kitype(5),
sep5,
option(8),
sep6,
color(8),
sep7,
uph(11),
sep8,
struc_week(10),
sep9,
END OF mail_line.
*construct the message and the e-mail
wa_receiver-receiver = receivers mail id.
* Email Subject
doc_chng-obj_name = 'test mail'.
MOVE 'Cost Error from SAP' TO doc_chng-obj_descr.
doc_chng-obj_langu = sy-langu.
* doc_chng-SENSITIVTY = 'P'.
* Email body
CLEAR objline.
CONCATENATE 'This is an automatically generated email'
'Please do not reply to this email.'
INTO objline SEPARATED BY space.
APPEND objline TO objcont.
CLEAR objline.
APPEND objline TO objcont.
CONCATENATE 'Cost errors in SAP as on' sy-datum INTO
objline SEPARATED BY space.
APPEND objline TO objcont.
CLEAR objline.
CLEAR objline.
APPEND objline TO objcont.
* horizontal line at beginning of records
DO 80 TIMES.
IF sy-index = 1.
* objline+sy-index(1) = ' '.
continue.
ELSE.
offset = sy-index - 1.
objline+offset(1) = '-'.
ENDIF.
ENDDO.
clear offset.
APPEND objline TO objcont.
CLEAR objline.
mail_line-sep0 = c_sep.
mail_line-model_year = 'Model Yr'.
mail_line-sep1 = c_sep.
mail_line-mf = 'Mf'.
mail_line-sep2 = c_sep.
mail_line-type = 'Type'.
mail_line-sep3 = c_sep.
mail_line-variant = 'Variant'.
mail_line-sep4 = c_sep.
mail_line-kitype = 'Ki-type'.
mail_line-sep5 = c_sep.
mail_line-option = 'Option'.
mail_line-sep6 = c_sep.
mail_line-color = 'Color'.
mail_line-sep7 = c_sep.
mail_line-uph = 'Upholstery'.
mail_line-sep8 = c_sep.
mail_line-struc_week = 'Str_week'.
mail_line-sep9 = c_sep.
MOVE mail_line TO objline.
APPEND objline TO objcont.
CLEAR mail_line.
CLEAR objline.
* horizontal line at beginning of records
*horizontal line at beginning of records
DO 80 TIMES.
IF sy-index = 1.
* objline+sy-index(1) = ' '.
continue.
ELSE.
offset = sy-index - 1.
objline+offset(1) = '-'.
ENDIF.
ENDDO.
clear offset.
APPEND objline TO objcont.CLEAR objline.
DO 5 TIMES.
mail_line-sep0 = c_sep.
mail_line-model_year = 'xxxx'.
mail_line-sep1 = c_sep.
mail_line-mf = 'xxx'.
mail_line-sep2 = c_sep.
mail_line-type = 'xxx'.
mail_line-sep3 = c_sep.
mail_line-variant = 'xxxx xxxxx'.
mail_line-sep4 = c_sep.
mail_line-kitype = 'xxx'.
mail_line-sep5 = c_sep.
mail_line-option = 'xxxxxx'.
mail_line-sep6 = c_sep.
mail_line-color = 'xxxxxx'.
mail_line-sep7 = c_sep.
mail_line-uph = 'xxxxxx'.
mail_line-sep8 = c_sep.
mail_line-struc_week = 'xxxxxx'.
mail_line-sep9 = c_sep.
MOVE mail_line TO objline.
APPEND objline TO objcont.
ENDDO.
CLEAR objline.
*horizontal line at beginning of records
DO 80 TIMES.
IF sy-index = 1.
* objline+sy-index(1) = ' '.
continue.
ELSE.
offset = sy-index - 1.
objline+offset(1) = '-'.
ENDIF.
ENDDO.
clear offset.
APPEND objline TO objcont.
CLEAR objline.
wa_receiver-rec_type = 'U'.
wa_receiver-com_type = 'INT'.
APPEND wa_receiver TO t_reclist.
* size
DESCRIBE TABLE objcont LINES w_line_count.
READ TABLE objcont INDEX w_line_count INTO objline.
doc_chng-doc_size = ( w_line_count - 1 ) * 255 +
STRLEN( objline ).
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = doc_chng
document_type = 'RAW'
* put_in_outbox = ' '
commit_work = 'X'
TABLES
* object_header = subject
object_content = objcont
receivers = t_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 9.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
KR Jaideep, -
Please help in senplease help in smartform send external email send.
hii all,
pleaseeeeeeeee help in sending external email in smartform print program.
i need for RLB_INVOICE order confirmation to send thru email.
what to code in ZRLN_INVOICE . i copied RLB_INVOICE in zprog.
so what rthe changes i need to code in driver program?
pleaseeeeeeee help with sample coding..Here is the code to send the Smartform to mail as PDF attachment.
*& Report ZTEST_PDF_MAIL
REPORT ZTEST_PDF_MAIL.
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 = 'ZTEST'
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.
ENDIF.
LOOP AT I_TLINE.
TRANSLATE I_TLINE USING '~'.
CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING '~'.
DO.
I_RECORD = WA_BUFFER.
APPEND I_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Attachment
REFRESH: I_RECLIST,
I_OBJTXT,
I_OBJBIN,
I_OBJPACK.
CLEAR WA_OBJHEAD.
I_OBJBIN[] = I_RECORD[].
Create Message Body Title and Description
I_OBJTXT = 'test with pdf-Attachment!'.
APPEND I_OBJTXT.
DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
READ TABLE I_OBJTXT INDEX V_LINES_TXT.
WA_DOC_CHNG-OBJ_NAME = 'smartform'.
WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
WA_DOC_CHNG-SENSITIVTY = 'F'.
WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
Main Text
CLEAR I_OBJPACK-TRANSF_BIN.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
I_OBJPACK-BODY_NUM = V_LINES_TXT.
I_OBJPACK-DOC_TYPE = 'RAW'.
APPEND I_OBJPACK.
Attachment (pdf-Attachment)
I_OBJPACK-TRANSF_BIN = 'X'.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
READ TABLE I_OBJBIN INDEX V_LINES_BIN.
I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
I_OBJPACK-BODY_NUM = V_LINES_BIN.
I_OBJPACK-DOC_TYPE = 'PDF'.
I_OBJPACK-OBJ_NAME = 'smart'.
I_OBJPACK-OBJ_DESCR = 'test'.
APPEND I_OBJPACK.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = '[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'
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.
If you want to send some text as Body of the Mail then follow this once
when u r callin the FM'SO_NEW_DOCUMENT_ATT_SEND_API1'.. points to remember
1.u have to pass the body of content in table CONTENTS_TXT(ia m using I_OBJBIN) (each line a record) then. suppose i have appended 11 records to the table CONTENTS_TXT .
2.PACKING_LIST(iam usign I_OBJPACK) table u ahve to append a redord as follows
I_OBJPACK-TRANSF_BIN = ' '.
I_OBJPACK-HEAD_START = 000000000000001.
I_OBJPACK-HEAD_NUM = 000000000000001.
I_OBJPACK-BODY_START = 000000000000002
I_OBJPACK-BODY_NUM = 000000000000010.
I_OBJPACK-DOC_TYPE = 'RAW'.
append I_OBJPACK-.
by the above code system treat the first line in table I_OBJBIN as header and the 2nd line to 10 lines tread as body.
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.
regards,
srinivas -
Sending external email via SAPCONNECT
Hi all,
I want to know how to send external email through sap.
Thanks in advance,
Manosh.HI,
Try this code:
*& Report ZSENDEMAIL *
*& Example of sending external email via SAPCONNECT *
REPORT zsendemail .
PARAMETERS: psubject(40) type c default 'Hello',
p_email(40) type c default '[email protected]' .
data: 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,
gd_cnt type i,
gd_sent_all(1) type c,
gd_doc_data like sodocchgi1,
gd_error type sy-subrc.
data: it_message type standard table of SOLISTI1 initial size 0
with header line.
*START-OF-SELECTION.
START-OF-SELECTION.
Perform populate_message_table.
*Send email message, although is not sent from SAP until mail send
*program has been executed(rsconn01)
PERFORM send_email_message.
*Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.
*& Form POPULATE_MESSAGE_TABLE
Adds text to email text table
form populate_message_table.
Append 'Email line 1' to it_message.
Append 'Email line 2' to it_message.
Append 'Email line 3' to it_message.
Append 'Email line 4' to it_message.
endform. " POPULATE_MESSAGE_TABLE
*& Form SEND_EMAIL_MESSAGE
Send email message
form send_email_message.
Fill the document data.
gd_doc_data-doc_size = 1.
Populate the subject/generic message attributes
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SAPRPT'.
gd_doc_data-obj_descr = psubject.
gd_doc_data-sensitivty = 'F'.
Describe the body of the message
clear it_packing_list.
refresh it_packing_list.
it_packing_list-transf_bin = space.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
describe table it_message lines it_packing_list-body_num.
it_packing_list-doc_type = 'RAW'.
append it_packing_list.
Add the recipients email address
clear it_receivers.
refresh it_receivers.
it_receivers-receiver = p_email.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
it_receivers-notif_del = 'X'.
it_receivers-notif_ndel = 'X'.
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'
importing
sent_to_all = gd_sent_all
tables
packing_list = it_packing_list
contents_txt = it_message
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.
Store function module return code
gd_error = sy-subrc.
Get it_receivers return code
loop at it_receivers.
endloop.
endform. " SEND_EMAIL_MESSAGE
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
form initiate_mail_execute_program.
wait up to 2 seconds.
if gd_error eq 0.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
endif.
endform. " INITIATE_MAIL_EXECUTE_PROGRAM
Reward points if found helpful....
Cheers,
Chandra Sekhar. -
Sending external email from SAP with following requirements...
Hi All,
I need to send external emails from SAP by meeting following requirements.
1) With subject line more than 100 characters.
2) No attachments, only body which has specific format (blueprint/layout) and would be amended often, hence code shouldn't be touched during amendments.
3) Should be able to know the success/failure of mail sending at program level.Hi,
The code below demonstrates how to send an email to an external email address
*& Report ZSENDEMAIL *
*& Example of sending external email via SAPCONNECT *
REPORT zsendemail .
PARAMETERS: psubject(40) type c default 'Hello',
p_email(40) type c default '[email protected]' .
data: 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,
gd_cnt type i,
gd_sent_all(1) type c,
gd_doc_data like sodocchgi1,
gd_error type sy-subrc.
data: it_message type standard table of SOLISTI1 initial size 0
with header line.
*START-OF-SELECTION.
START-OF-SELECTION.
Perform populate_message_table.
*Send email message, although is not sent from SAP until mail send
*program has been executed(rsconn01)
PERFORM send_email_message.
*Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.
*& Form POPULATE_MESSAGE_TABLE
Adds text to email text table
form populate_message_table.
Append 'Email line 1' to it_message.
Append 'Email line 2' to it_message.
Append 'Email line 3' to it_message.
Append 'Email line 4' to it_message.
endform. " POPULATE_MESSAGE_TABLE
*& Form SEND_EMAIL_MESSAGE
Send email message
form send_email_message.
Fill the document data.
gd_doc_data-doc_size = 1.
Populate the subject/generic message attributes
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_name = 'SAPRPT'.
gd_doc_data-obj_descr = psubject.
gd_doc_data-sensitivty = 'F'.
Describe the body of the message
clear it_packing_list.
refresh it_packing_list.
it_packing_list-transf_bin = space.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
describe table it_message lines it_packing_list-body_num.
it_packing_list-doc_type = 'RAW'.
append it_packing_list.
Add the recipients email address
clear it_receivers.
refresh it_receivers.
it_receivers-receiver = p_email.
it_receivers-rec_type = 'U'.
it_receivers-com_type = 'INT'.
it_receivers-notif_del = 'X'.
it_receivers-notif_ndel = 'X'.
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'
importing
sent_to_all = gd_sent_all
tables
packing_list = it_packing_list
contents_txt = it_message
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.
Store function module return code
gd_error = sy-subrc.
Get it_receivers return code
loop at it_receivers.
endloop.
endform. " SEND_EMAIL_MESSAGE
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
form initiate_mail_execute_program.
wait up to 2 seconds.
if gd_error eq 0.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
endif.
endform. " INITIATE_MAIL_EXECUTE_PROGRAM
Hope this helps.
Reward if helpful.
Regards,
Sipra -
Need to send external email with attachment for workflow 20000075
Hello Everyone,
I am new to W/F, I Need to send external email with attachment for PO Release W/F 20000075. Currently Work item is being sent to SAP inbox of required user based on PO Release strategy configuration in SPRO. I tried to create Send mail step after PO release event but I am not sure how to arrive at Recipient type in send mail step(the mail should be sent to person in the release strategy). Everything looks fine all I need to do is to send external email with attachment instead of sending work item into SAP inbox.
Your help will be highly appreciated.
Thanks.You can use extended notifications to send an e-mail message with a link to the workitem. Search for extended notifications in SDN.
Regards,
Martin -
Convert abap reports into crystal reports
Hi,
We are trying to convert abap reports into crystal reports.We could convert these reports into XML files
Now we want to create utility which will automate the conversion of XML files into RPT files of crystal reports.Later on we can refresh the data in reports by changing the datasource location.
Can you please guide us whether it is possible and if yes how should we go about it?
regards,
shitalHi, i suggest, 2 technies to do this, the first one, you can use,
CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
EXPORTING
APPLICATION = 'C:\Program Files\crystalreports.exe'
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
BAD_PARAMETER = 3
FILE_NOT_FOUND = 4
PATH_NOT_FOUND = 5
FILE_EXTENSION_UNKNOWN = 6
ERROR_EXECUTE_FAILED = 7
SYNCHRONOUS_FAILED = 8
NOT_SUPPORTED_BY_GUI = 9
OTHERS = 10.
where, exe file could be, a crviewer.exe, and, use a parameters ( on exe ) to indicate rpt file, or, define of standar mode, a generic name and put, xml file generated via abap, on a repository, this way, rpt file, when launched, displaying file.
the second choice, could be, go SM69, click create. enter a command name 'ZCREXE', enter the path and the exe file name in operating system command field. You can call this exe from ABAP using SXPG_COMMAND_EXECUTE.
i hope so that my answers help you.
greetings. -
Disallow sending External email
Hi, how to configure Exchange 2013 to disallow certain users to send external email
Hi,
As what DareDevil57 mentioned above, we can create a transport rule to meet this requirement.
Here is an article about transport rule for your reference.
Transport Rules:
http://social.technet.microsoft.com/Forums/en-US/dedce6eb-f4b9-42be-b732-dba691b6c284/disallow-sending-external-email?forum=exchangesvradmin
Hope this helps.
Best regards,
Belinda
Belinda Ma
TechNet Community Support -
Scheduling a Report to Deliver As an Email Attachment
Hi,
I want to schedule a Report to Deliver As an Email Attachment. But I am getting the below error.
oracle.apps.xdo.service.delivery.DeliveryException: oracle.apps.xdo.delivery.DeliveryException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset
at oracle.apps.xdo.service.delivery.impl.DeliveryServiceImpl.deliverToEmail(DeliveryServiceImpl.java:235)
at oracle.apps.xdo.servlet.scheduler.XDOJob.deliver(XDOJob.java:1215)
at oracle.apps.xdo.servlet.scheduler.XDOJob.execute(XDOJob.java:493)
at org.quartz.core.JobRunShell.run(JobRunShell.java:195)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
In the below link its given to setup the email server (ArGoSoft Mail Server Freeware)
http://www.oracle.com/technology/obe/obe_bi/bipub/advance/advance.htm
But I did not do the steps mentioned in the above link. Since I have email server configured on my system.
I am using the proper Host name and Port. Can you please suggest why I am getting this error.
Thanks,
ShivaNot really the best way to go. You'll waste a lot of time and it may not work for your receiver. Most email hosts have file size limits that make emailing video files a problem. Better choice is upload you video to YouTube or some other file sharing site then email a link.
-
Error 829 in SOST tcode while sending an email attachment ??
Hi..
I am using the function module "SO_NEW_DOCUMENT_ATT_SEND_API1" to send an email attachment.
The program is getting executed successfully but when i see in SOST transaction, i am getting an error message.
Error number is 829 and it says " Internal error: SO_OBJECT_MIME_GET Exception: 2 "...
How do i resolve this error ....??Hi,
Please check this links will help you.
Error in SOST transaction for Mail Triggered from SAP
Re: need help in implementing a note -
How to send external email of a Purchase Order
Hello,
I have to send an external email (pdf attachment) of a Purchase Order.
I use the standard sap program: /SMB40/FM06P and the smartform: /SMB40/MMPO_L.
Within transaction NACE I used the following entries:
Medium: 5 (External Send), Program: /SMB40/FM06P, Form routine: ENTRY NEU and Smartform: /SMB40/MMPO_L.
After running transaction ME22n (messages: External Send) I got the following error-messages in processing log:
- Please maintain an output device in your user master data.
- Archiving format not equal to PDF.
Please, can someone help me to solve this problem.
Regards,
Rajeshhi
U need to write the code to convert the smartform to PDF using FM Convert_otf and also for sending mail
The standard program has to be copied to Z and write ur code..to perform u requirements
Check the below links
SO_NEW_DOCUMENT_ATT_SEND_API1
http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8cd6adbb-0301-0010-39ba-938c601d5db9
Email Invoices to customer as a PDF attachment
surya
Maybe you are looking for
-
Federation Service with External Organization is not working
Hi, Exchange 2010 is running in present environment and recently I have introduced Exchange 2013. There is federation Enabled at Exchange 2010 end with External Exchange organization. When we migrated users from E2k10 to E2k13 Free /Busy sync has sto
-
In Windows 7, I really like the easy access to Windows XP Mode that enabled me to have full compatibility to my older hardware scanner and its software (which I still use today). Similarly, I love my Z30 Blackberry phone which allows me to run Andro
-
Size/color of error message
Hello All, Is it possible to change the default size and color of the WebDynpro error/warning messages? Can we somehow change the icon, displayed next to the error/warning mesages? Thanks, Asheesh
-
My ipod deleted my rented movie!!
i purchased my movie on itunes and i watched it on my ipod for about 2 minutes. then the next time i synced my ipod it was deleted from both my library and ipod. (note: my itouch is a 1st gen and this happened) i dont care if i get the movie back im
-
Unexpectedly quit while quiting
Hi Can anyone help? For a couple of weeks now I have been finding that when I quit an application I will receive the "application enexpectedley quit" dialogue box. It doesn't always happen but often enough. Is there something I can do to my system th