Send reports as email attachment
Hi,
In the APEX application, I have a page that has filters on top and few reports generated based on the given filter values. I have a email button that when pressed, send the whole page as an email attachment. I cannot use PDF. Is it possible to send the page with few reports as email attachment?
Thanks
saru
When you send as an e-mail, do you mean the html produced report or some sort output file? You could send it as an excel produced output.
Why can't you use a PDF option in this case?
Thank you,
Tony Miller
Webster, TX
Similar Messages
-
How to convert sap script to pdf and send it as email attachment
hi,
my requirement is to convert a standard sales order form to pdf and send it as email attachment. get me some sample code for the same
thanks in advanceHi
See this sample code and after that use the fun module to send the mail
SO_NEW_DOCUMENT_ATT_SEND_API1
REPORT zzz_jaytest .
Types Declaration
TYPES : BEGIN OF ty_pa0001,
pernr TYPE pa0001-pernr,
bukrs TYPE pa0001-bukrs,
werks TYPE pa0001-werks,
END OF ty_pa0001.
Internal Table Declaration
DATA : i_pa0001 TYPE STANDARD TABLE OF ty_pa0001, "For pa0001 Details
i_otf TYPE STANDARD TABLE OF itcoo, "For OTF data
i_content_txt TYPE soli_tab, "Content
i_content_bin TYPE solix_tab, "Content
i_objhead TYPE soli_tab,
Work Area Declaration
w_pa0001 TYPE ty_pa0001, "For pa0001 Details
w_res TYPE itcpp, "SAPscript output
"parameters
w_otf TYPE itcoo, "For OTF
w_pdf TYPE solisti1, "For PDF
w_transfer_bin TYPE sx_boolean, "Content
w_options TYPE itcpo, "SAPscript output
"interface
Variable Declaration
v_len_in TYPE so_obj_len,
v_size TYPE i.
Constants Declaration
CONSTANTS : c_x TYPE c VALUE 'X', "X
c_locl(4) TYPE c VALUE 'LOCL', "Local Printer
c_otf TYPE sx_format VALUE 'OTF', "OTF
c_pdf TYPE sx_format VALUE 'PDF', "PDF
c_printer TYPE sx_devtype VALUE 'PRINTER', "PRINTER
c_bin TYPE char10 VALUE 'BIN', "BIN
c_name TYPE string VALUE 'C:\ZZZ_JAYTEST.PDF',"Downloading
"File Name
c_form(11) TYPE c VALUE 'ZZZ_JAYTEST'. "Form Name
START-OF-SELECTION.
Selecting the records from pa0001
SELECT pernr bukrs werks FROM pa0001
INTO TABLE i_pa0001 UP TO 10 ROWS.
Setting the options
w_options-tdcopies = 1 ."Number of copies
w_options-tdnoprev = c_x."No print preview
w_options-tdgetotf = c_x."Return of OTF table
w_options-tddest = c_locl."Spool: Output device
Opening the form
CALL FUNCTION 'OPEN_FORM'
EXPORTING
form = c_form
device = c_printer
language = sy-langu
OPTIONS = w_options
IMPORTING
RESULT = w_res.
LOOP AT i_pa0001 INTO w_pa0001.
Writting into the form
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'MAIN'
window = 'MAIN'.
ENDLOOP.
Closing the form
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = w_res
TABLES
otfdata = i_otf
EXCEPTIONS
unopened = 1
bad_pageformat_for_print = 2
send_error = 3
spool_error = 4
codepage = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Converting OTF data to single line
LOOP AT i_otf INTO w_otf.
CONCATENATE w_otf-tdprintcom w_otf-tdprintpar
INTO w_pdf.
APPEND w_pdf TO i_content_txt.
ENDLOOP.
Converting to PDF Format
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
format_src = c_otf
format_dst = c_pdf
devtype = c_printer
CHANGING
transfer_bin = w_transfer_bin
content_txt = i_content_txt
content_bin = i_content_bin
objhead = i_objhead
len = v_len_in
EXCEPTIONS
err_conv_failed = 1
OTHERS = 2.
v_size = v_len_in.
Downloading the PDF File
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = v_size
filename = c_name
filetype = c_bin
TABLES
data_tab = i_content_bin.
If you r using this function module check it once....
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.
or u can use the standard program RSTXPDFT4 to download the script into PDF format onto a particular location
follow this link for sample program.
http://searchsap.techtarget.com/tip/0,289483,sid21_gci1121833,00.html
check...
How to send smart form via email
/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp
Regards
Anji -
Preview 6.0, no send file as email attachment?
Does anyone know where they put the send file command? I need to email pdfs from Preview all the time.
There used to be a "send file as email attachment" command under the edit menu. It's gone. Anyone have any suggestions?Handsomfreddy wrote:
Sorry, I dont understand what you are referring to. Can you calify please "undo the changes."
Thanks,
Andy
Didn't you just post this (below)
Handsomfreddy wrote:
Very bizarrely Parallels had changed this Mail Preference to some weird Windows program [Disk Clean up or something equally random] thus preventing me from emailing anything from any program.
That's the change I am referring to. -
Send report as email thru bursting
I am trying to send report by email thru bursting. My query follows:
SELECT CLIENT_ID AS KEY
,'afsrep' AS TEMPLATE
,'RTF' AS TEMPLATE_FORMAT
,'en-US' AS LOCALE
,'EXCEL' AS OUTPUT_FORMAT
,'FILE' AS DEL_CHANNEL
'[email protected]' PARAMETER1, '[email protected]' PARAMETER2, '[email protected]' PARAMETER3, 'TEST' PARAMETER4,
'BODY TESET' PARAMETER5, 'true' PARAMETER6, '[email protected]' PARAMETER7
from Client_contacts
When we burst the report is opening in the desktop but NOT SENDING EMAIL.
Can someone help me.
Edited by: user10711255 on Jun 11, 2009 3:36 AMhave you configured the address for the email server you will be snding through. its in the delivery setup in administration.
-
Send page by email attaching to Lotus as a link instead of a pdf attachment
Acrobat reader in internet explorer - Send page by email attaching to Lotus as a link instead of a pdf attachment any ideas? was working fine yesterday. Ive reset the Internet explorer settings , cleared cashe, was gonna try to reinstall next
I don't think that Adobe Reader is involved in any of this; it looks like a purely IE functionality.
-
Send reports by eMail without .BIAR
Hi,
Can i send reports by email for deployment on another CMC without using .BIAR file? The reports are created in Webi Rich client. The universe and associated DB already exist at the destination location. I am relatively new to BO.
Thanks...Technicaly - yes you can, but in that destination environment you will have to open thise reports using Webi Rich Client, re-point them to the proper universes and then export them to repository.
The Proper , Recomended and Supported method is to use Life Cycle Manager or BIAR file funxctionality for this operation. -
Send file as email attachment not working
any help would be greatly appreciated...
When I click "send file as email attachment" it will open outlook with the PDF attached but when I click send on the email, the email closes like it is sent but never actually gets sent (nothing in sent items and recipient never gets the email)
Adobe Acrobat 11 Pro (Creative Cloud Suite installed)
Outlook 2013Hi sandyw26405588,
Could you please try sending PDF as email attachment via another email apart from Outlook.
Are you able to send the file successfully?
Also, go under 'Help> Check for Updates' and ensure if you are using the latest version of Acrobat XI i.e. 11.0.10
Have you tried sending any other PDF via Outlook?
Let me know.
Regards,
Anubha -
Sending report as an attachment to an email
Hi,
I need to send a report as an attachment via email using xml publisher. I created data definition, templates and could run a report. I do not know where to add the coding for sending the email? I found the following coding in developer guide:
<?xml version="1.0" encoding="UTF-8"?>
<xapi:requestset xmlns:xapi="http://xmlns.oracle.com/oxp/xapi">
<xapi:request select="/DATA/DEPTS/DEPT/EMPLOYEES/EMPLOYEE"> <! - Burst
on employee element - >
<xapi:delivery>
<xapi:email server="my.smtp.server" port="25"
from=" email@removed " reply-to ="">
<xapi:message id="123" to="${EMAIL}"
<! - Set the id for the delivery method - ><! - Use the employees
EMAIL element to email the document to
the employee - >cc="${ADMIN_EMAIL}"
<! - Use the ADMIN_EMAIL parameter to CC the document
to the administrator - > attachment="true" subject="Employee
Details for ${ENAME}">
Mr. ${ENAME}, Please review the attached document</xapi:message><! -
Embed the employees name into the email message - >
</xapi:email>
</xapi:delivery>
<xapi:document output-type="pdf" delivery="123"><!Specify the
delivery method id to be used - >
<xapi:template type="rtf"
location="\usr\empDet.rtf"></xapi:template>
</xapi:document>
</xapi:request>
</xapi:requestset>
Should this needs to be added to the data template file (xml file which will attached in the data definition screen) or in the template .rtf file?
Any help on this appreciated.
Thanks
ValliHi,
I need to send a report as an attachment via email using xml publisher. I created data definition, templates and could run a report. I do not know where to add the coding for sending the email? I found the following coding in developer guide:
<?xml version="1.0" encoding="UTF-8"?>
<xapi:requestset xmlns:xapi="http://xmlns.oracle.com/oxp/xapi">
<xapi:request select="/DATA/DEPTS/DEPT/EMPLOYEES/EMPLOYEE"> <! - Burst
on employee element - >
<xapi:delivery>
<xapi:email server="my.smtp.server" port="25"
from=" email@removed " reply-to ="">
<xapi:message id="123" to="${EMAIL}"
<! - Set the id for the delivery method - ><! - Use the employees
EMAIL element to email the document to
the employee - >cc="${ADMIN_EMAIL}"
<! - Use the ADMIN_EMAIL parameter to CC the document
to the administrator - > attachment="true" subject="Employee
Details for ${ENAME}">
Mr. ${ENAME}, Please review the attached document</xapi:message><! -
Embed the employees name into the email message - >
</xapi:email>
</xapi:delivery>
<xapi:document output-type="pdf" delivery="123"><!Specify the
delivery method id to be used - >
<xapi:template type="rtf"
location="\usr\empDet.rtf"></xapi:template>
</xapi:document>
</xapi:request>
</xapi:requestset>
Should this needs to be added to the data template file (xml file which will attached in the data definition screen) or in the template .rtf file?
Any help on this appreciated.
Thanks
Valli -
Convert SMARTFORM report to PDF and send as an email attachment
Hi
I am using the CONVERT_OTF function module to convert a SMARTFORM report in the "spool" to a PDF file. When I use the DOWNLOAD function module, the resulting file can be opened in acrobat.
I would like to email the report in PDF format as an attachment. I am using the function module SO_NEW_DOCUMENT_ATT_SEND_API1 to create an attachment however the attached file is not being created correctly and When try to open, it gives 'File is damaged and could not be repaired' error message. I believe that somehow I am not using the SO_NEW_DOCUMENT_ATT_SEND_API1 function module correctly.
Please help me to correct this
Thanks
Rohitha
see my code below,
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 132 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
REFRESH: I_RECLIST,
I_OBJTXT,
I_OBJBIN,
I_OBJPACK.
CLEAR WA_OBJHEAD.
I_OBJBIN[] = I_RECORD[].
I_OBJTXT = '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_to_PDF'.
WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
WA_DOC_CHNG-OBJ_DESCR = 'Smartform to PDF'.
WA_DOC_CHNG-SENSITIVTY = 'F'.
WA_DOC_CHNG-DOC_SIZE = STRLEN( I_OBJTXT ) + ( ( V_LINES_TXT - 1 ) * 255 ) .
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.
I_OBJPACK-TRANSF_BIN = 'X'.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 1.
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 = 'ATTACHMENT'.
I_OBJPACK-OBJ_DESCR = 'test'.
APPEND I_OBJPACK.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = 'my email address u2019.
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 ', SY-SUBRC.
ELSE.
WRITE:/ 'Mail sent'.
ENDIF.Hi rohitha.wijewardena ,
Please find the below code which i followed and succeed ,
CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
EXPORTING
pi_nast = nast
pi_country = lv_dlv-land
pi_addr_key = lv_addr_key
pi_repid = sy-repid
pi_screen = lc_x
IMPORTING
pe_returncode = gv_retcode
pe_itcpo = lv_itcpo
pe_device = lv_device
pe_recipient = lv_recipient
pe_sender = lv_sender.
IF gv_retcode = 0.
*moving the data to composer and control parameters for output
MOVE-CORRESPONDING lv_itcpo TO lv_composer_param.
lv_control_param-device = lv_device.
lv_control_param-no_dialog = lc_x.
lv_control_param-preview = lc_x.
lv_control_param-getotf = lv_itcpo-tdgetotf.
lv_control_param-langu = nast-spras.
lv_composer_param-tdnoprint = space.
ENDIF.
*Getting the Smartform Function module using Standard Function module
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lv_formname "Smartform Name
IMPORTING
fm_name = lv_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3
IF sy-subrc <> 0.
gv_retcode = sy-subrc.
PERFORM protocol_update.
PERFORM add_smfrm_prot.
ENDIF.
**Smartform function module to get the output
CALL FUNCTION lv_fm_name
EXPORTING
control_parameters = lv_control_param
mail_recipient = lv_recipient
mail_sender = lv_sender
output_options = lv_composer_param
user_settings = ' '
is_bil_invoice = lv_bil_invoice
gt_header = gt_header
IMPORTING
job_output_info = gv_job_output
TABLES
gt_item = gt_item
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
IF sy-subrc <> 0.
gv_retcode = sy-subrc.
PERFORM protocol_update.
PERFORM add_smfrm_prot.
ENDIF.
IF nast-nacha = lc_mail.
gt_otfdata[] = gv_job_output-otfdata[].
* Converting Smartform to PDF *
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = lc_pdf
max_linewidth = 10
IMPORTING
bin_filesize = gv_binfilesize
bin_file = gv_pdf_xstring
TABLES
otf = gt_otfdata[]
lines = gt_pdftab[]
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.
* Sending PDF to Email using Class *
IF NOT lv_email IS INITIAL .
TRY.
gv_send_request = cl_bcs=>create_persistent( ).
gv_pdf_content = cl_document_bcs=>xstring_to_solix( gv_pdf_xstring ).
gv_document = cl_document_bcs=>create_document(
i_type = lc_pdf
i_hex = gv_pdf_content
i_length = gv_pdf_size
i_subject = lc_subject ). "Subject for Email
gv_send_request->set_document( gv_document ).
gv_recipient = cl_cam_address_bcs=>create_internet_address( lv_email ).
gv_send_request->add_recipient( gv_recipient ).
gv_sent_to_all = gv_send_request->send( i_with_error_screen = lc_x ).
COMMIT WORK.
IF gv_sent_to_all IS INITIAL.
MESSAGE i500(sbcoms) WITH lv_email.
ELSE.
MESSAGE s022(so).
ENDIF.
CATCH cx_bcs INTO gv_bcs_exception.
MESSAGE i865(so) WITH gv_bcs_exception->error_type.
ENDTRY.
ENDIF. -
Convert SAP spoolOR list to excel and send as an email attachment
Hello All Masterminds ,
Iu2019ve developed a utility, in which users has to maintain one u201CZu201D view where they can give any report name, type of attachment (PDF, XLS, TXT) and sender email addresses.u201DNote: thing to remember here is Iu2019m creating XLS,TXT,PDF format dynamicallyu201D
It is working fine for PDF. Iu2019m submitting the program and creating spool and converting it to PDF and sending to their emails as an attachment. It looks fantastic. When Iu2019m doing the same thing for XLS it is showing messy output, I tried many functions and search lots of unanswered, unfinished SDN posts. I almost tried every single clue given in these posts but no luck. Email part is working fine using classes ( l_document = cl_document_bcs=>create_document , l_document->add_attachment , l_send_request->set_document( l_document ).,cl_sapuser_bcs=>create( l_uname ).,l_send_request->add_recipient, l_send_request->set_send_immediately( '' ). ) .
My real deal is to create a beautiful XLS out put. I also tried FMs LIST_FROM_MEMORY and LIST_TO_ASCI but no-luck. I thought instead of spool if I use u201CSubmit EXPORTING LIST TO MEMORY u201C option may be It works but BIG NO
Iu2019m sure some genius out there has done something like his , I ain`t genius that is why I am stuck Please guys throw me some bones . As I said, I am able to do most of the things. I need some magic code /answer which turns my messy, ugly unformatted excel sheet attachment to beautiful u201Cpiece of art u201CExcel output.
Here are the FMs I tried so far with different combinations.
CALL FUNCTION 'LIST_FROM_MEMORY'
CALL FUNCTION 'LIST_TO_ASCI'
CALL FUNCTION 'GUI_DOWNLOAD'
CALL FUNCTION 'RSPO_DOWNLOAD_SPOOLJOB'
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
CALL FUNCTION 'CONVERT_OTF'
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
And logic like to get rid of things getting in Asci tables
cl_abap_char_utilities=>newline.
cl_abap_char_utilities=>horizontal_tab
cl_abap_char_utilities=>VERTICAL_TAB
cl_abap_char_utilities=>cr_lf
FIELD-SYMBOLS: <lfs_table>, " Internal table structure
<lfs_con>. " Field Content
DATA: l_text TYPE char1024. " Text content for mail attachment
DATA: l_con(50) TYPE c. " Field Content in character format
Columns to be tab delimeted
LOOP AT FINAL ASSIGNING <lfs_table>.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <lfs_table>
TO <lfs_con>.
IF sy-subrc NE 0.
CONCATENATE c_cr l_text INTO l_text.
APPEND l_text TO i_attach.
EXIT.
ELSE.
CLEAR: l_con.
MOVE <lfs_con> TO l_con.
CONDENSE l_con.
IF sy-index = 1.
CLEAR: l_text.
MOVE l_con TO l_text.
ELSE.
CONCATENATE l_text l_con INTO l_text
SEPARATED BY c_tab.
ENDIF.
ENDIF.
ENDDO.
ENDLOOP.
Posts : https://forums.sdn.sap.com/click.jspa?searchID=14756211&messageID=4401940
https://forums.sdn.sap.com/click.jspa?searchID=14756211&messageID=4796657
https://forums.sdn.sap.com/search.jspa?threadID=&q=convertspoolintoexcelformatforsendingmail&objID=c42&dateRange=all&numResults=30&rankBy=10001
Will appreciate your help and time.
Thanks,
Saquib KhanHi,
i send excel-att like this.
REPORT Z_EMAIL_CL_BCS MESSAGE-ID ZZ.
More examples here BCS_EXAMPLE_* with se38
DATA: SEND_REQUEST TYPE REF TO CL_BCS.
DATA: SUBJECT TYPE SO_OBJ_DES.
DATA: ATT_TYPE TYPE SOODK-OBJTP.
DATA: IT_TEXT TYPE BCSY_TEXT.
DATA: WA_TEXT LIKE SOLI.
DATA: IT_BIN TYPE SOLIX_TAB.
DATA: WA_BIN TYPE SOLIX.
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: BCS_EXCEPTION TYPE REF TO CX_BCS.
DATA: SENT_TO_ALL TYPE OS_BOOLEAN.
Bytes der Datei
DATA: IT_LENGHT TYPE SO_OBJ_LEN.
DATA: N10(10) TYPE N.
CONSTANTS: CON_NEWL TYPE ABAP_CHAR1 VALUE CL_ABAP_CHAR_UTILITIES=>NEWLINE,
CON_TAB TYPE ABAP_CHAR1 VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
CONSTANTS: CON_NEWL TYPE X VALUE '0D', "OK for non Unicode
CON_TAB TYPE X VALUE '09'. "OK for non Unicode
START-OF-SELECTION.
PERFORM MAIN.
END-OF-SELECTION.
FORM MAIN.
TRY.
-------- create persistent send request ------------------------
SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
PERFORM HEAD_CONT.
PERFORM XLS_ATT.
add document to send request
CALL METHOD SEND_REQUEST->SET_DOCUMENT( DOCUMENT ).
--------- set sender -------------------------------------------
SENDER = CL_SAPUSER_BCS=>CREATE( SY-UNAME ).
CALL METHOD SEND_REQUEST->SET_SENDER
EXPORTING
I_SENDER = SENDER.
--------- set recipent -----------------------------------------
RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
'the email adress' ).
add recipient with its respective attributes to send request
CALL METHOD SEND_REQUEST->ADD_RECIPIENT
EXPORTING
I_RECIPIENT = RECIPIENT
I_EXPRESS = 'X'.
RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
'the email adress 2' ).
add recipient with its respective attributes to send request
CALL METHOD SEND_REQUEST->ADD_RECIPIENT
EXPORTING
I_RECIPIENT = RECIPIENT
I_EXPRESS = 'X'.
---------- send document ---------------------------------------
CALL METHOD SEND_REQUEST->SEND(
EXPORTING
I_WITH_ERROR_SCREEN = 'X'
RECEIVING
RESULT = SENT_TO_ALL ).
COMMIT WORK.
CATCH CX_BCS INTO BCS_EXCEPTION.
WRITE: 'Fehler aufgetreten.'(001).
WRITE: 'Fehlertyp:'(002), BCS_EXCEPTION->ERROR_TYPE.
EXIT.
ENDTRY.
ENDFORM. "main
FORM HEAD_CONT.
CLEAR: IT_TEXT[], WA_TEXT, SUBJECT.
ATT_TYPE = 'RAW'.
CONCATENATE 'Betreffzeile am' SY-DATUM 'um' SY-UZEIT
INTO SUBJECT SEPARATED BY SPACE.
WA_TEXT = 'Hello!'.
APPEND WA_TEXT TO IT_TEXT.
WA_TEXT = 'dieses ist eine Testmail'.
APPEND WA_TEXT TO IT_TEXT.
WA_TEXT = 'Gruß'.
APPEND WA_TEXT TO IT_TEXT.
DESCRIBE TABLE IT_TEXT LINES N10.
N10 = ( N10 - 1 ) * 255 + STRLEN( WA_TEXT ).
IT_LENGHT = N10.
DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = ATT_TYPE
I_TEXT = IT_TEXT
I_LENGTH = IT_LENGHT
I_SUBJECT = SUBJECT ).
ENDFORM. "HEAD_CONT
FORM XLS_ATT.
DATA: BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MATKL LIKE MARA-MATKL,
BRGEW LIKE MARA-BRGEW,
END OF ITAB.
DATA: BRGEW(18).
CLEAR: IT_BIN[], WA_BIN, SUBJECT.
SELECT MATNR MTART MATKL BRGEW INTO TABLE ITAB FROM MARA UP TO 10 ROWS.
CONCATENATE 'Material' CON_TAB
'Materialart' CON_TAB
'Warengruppe' CON_TAB
'Bruttogewicht' CON_NEWL
INTO WA_BIN.
APPEND WA_BIN TO IT_BIN.
LOOP AT ITAB.
WRITE ITAB-BRGEW TO BRGEW.
CONCATENATE ITAB-MATNR CON_TAB
ITAB-MTART CON_TAB
ITAB-MATKL CON_TAB
BRGEW CON_NEWL
INTO WA_BIN.
APPEND WA_BIN TO IT_BIN.
ENDLOOP.
ATT_TYPE = 'XLS'.
SUBJECT = 'My XLS attachment'.
DESCRIBE TABLE IT_BIN LINES N10.
N10 = ( N10 - 1 ) * 255 + STRLEN( WA_BIN ).
IT_LENGHT = N10.
CALL METHOD DOCUMENT->ADD_ATTACHMENT
EXPORTING
I_ATTACHMENT_TYPE = ATT_TYPE
I_ATT_CONTENT_HEX = IT_BIN
I_ATTACHMENT_SIZE = IT_LENGHT
I_ATTACHMENT_SUBJECT = SUBJECT.
ENDFORM. "XLS_ATT
Perhaps it helps.
regards, Dieter -
Sending excel as email attachment
Hi All,
I am getting truncated with the header only upto 255 char length , and the field contents are ok more than 255 length it s taking.
I am using it_attach type standard table of solisti1 with header line.
the report code is given below
**& Report ZPBILL_INT1 **
REPORT zpbill_int1 .
*Declaration of type-pools.
TYPE-POOLS slis.
D A T A **
TABLES: zbill_inphdr,
zbill_inpdtl.
TYPES: BEGIN OF t_zbill_ipdtl,
cusnr TYPE zbill_inpdtl-cusnr,
svsnr TYPE zbill_inpdtl-svsnr,
revnr TYPE zbill_inpdtl-revnr,
sysnr TYPE zbill_inpdtl-sysnr,
sdate TYPE zbill_inpdtl-sdate,
filnm TYPE zbill_inpdtl-filnm,
zlsch TYPE zbill_inpdtl-zlsch,
clrfe TYPE zbill_inpdtl-clrfe,
revds TYPE zbill_inpdtl-revds,
prind TYPE zbill_inpdtl-prind,
svsds TYPE zbill_inpdtl-svsds,
quant TYPE zbill_inpdtl-quant,
adate TYPE zbill_inpdtl-adate,
trdat TYPE zbill_inpdtl-trdat,
mdate TYPE zbill_inpdtl-mdate,
trdval type zbill_inpdtl-trdval,*
exrate TYPE zbill_inpdtl-exrate,
birate TYPE zbill_inpdtl-birate,
cusds1 TYPE zbill_inpdtl-cusds1,
cusds2 TYPE zbill_inpdtl-cusds2,
cusstr TYPE zbill_inpdtl-cusstr,
cuspc TYPE zbill_inpdtl-cuspc,
cuscity TYPE zbill_inpdtl-cuscity,
cusctry TYPE zbill_inpdtl-cusctry ,
rect TYPE zbill_inpdtl-rect,
invno TYPE zbill_inpdtl-invno,
ldate TYPE zbill_inpdtl-ldate,
conty TYPE zbill_inpdtl-conty,
edate TYPE zbill_inpdtl-edate,
custa TYPE zbill_inpdtl-custa,
currc TYPE zbill_inpdtl-currc,
warrt TYPE zbill_inpdtl-warrt,
indrp TYPE zbill_inpdtl-indrp,
textc TYPE zbill_inpdtl-textc,
gstr TYPE zbill_inpdtl-gstr,
clrds TYPE zbill_inpdtl-clrds,
commty TYPE zbill_inpdtl-commty,
commyr TYPE zbill_inpdtl-commyr,
commmt TYPE zbill_inpdtl-commmt,
commop TYPE zbill_inpdtl-commop,
eposdoc TYPE zbill_inpdtl-eposdoc,
custp TYPE zbill_inpdtl-custp,
END OF t_zbill_ipdtl.
DATA: it_zbill TYPE STANDARD TABLE OF t_zbill_ipdtl
INITIAL SIZE 0.
ALV Data declaration.*
DATA : v_repid LIKE sy-repid.
ALV Function Module Variables*
DATA: gs_layout TYPE slis_layout_alv,
g_exit_caused_by_caller,
gs_exit_caused_by_user TYPE slis_exit_by_user.
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv,
gs_print TYPE slis_print_alv,
gt_events TYPE slis_t_event,
gt_list_top_of_page TYPE slis_t_listheader,
g_status_set TYPE slis_formname VALUE 'PF_STATUS_SET',
g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
g_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',
g_top_of_list TYPE slis_formname VALUE 'TOP_OF_LIST',
g_end_of_list TYPE slis_formname VALUE 'END_OF_LIST',
g_variant LIKE disvariant,
g_save(1) TYPE c,
g_tabname_header TYPE slis_tabname,
g_tabname_item TYPE slis_tabname,
g_exit(1) TYPE c,
gx_variant LIKE disvariant.
DATA : gr_layout_bck TYPE slis_layout_alv.
DATA : wa_zbill TYPE t_zbill_ipdtl.
*Email related declarations
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
*DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
*WITH HEADER LINE.
DATA: it_attach TYPE STANDARD TABLE OF SOMLRECI1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
*t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
*DATA IT_HEADER TYPE STANDARD TABLE OF SOLIX INITIAL SIZE 0 WITH
*HEADER LINE.
*data : begin of it_header occurs 0,
header(1023) type C,*
end of it_header.*
S E L E C T I O N S **
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
SELECT-OPTIONS: s_cusnr FOR zbill_inpdtl-cusnr,
s_svsnr FOR zbill_inpdtl-svsnr,
s_revnr FOR zbill_inpdtl-revnr,
s_sysnr FOR zbill_inpdtl-sysnr,
s_sdate FOR zbill_inpdtl-sdate,
s_filnm FOR zbill_inpdtl-filnm,
s_prind for zbill_inpdtl-prind.
PARAMETERS: p_test AS CHECKBOX,
p_email AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b01.
*PARAMETERS: p_email TYPE somlreci1-receiver
Initialization **
INITIALIZATION.
v_repid = sy-repid.
start-of-selection **
START-OF-SELECTION.
PERFORM data_retrieval.
IF p_test = '' AND P_EMAIL = ''.
MESSAGE S038(ZMBILLING).
ELSEIF P_TEST = 'X'.
display the data in the form of ALV*
PERFORM display_data.
ELSEIF P_EMAIL = 'X'.
*Populate table with detaisl to be entered into .xls file
PERFORM build_xls_data_table.
*Populate message body text
PERFORM populate_email_message_body.
*Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
TABLES it_message it_attach USING p_email
'Billing Details list'
'XLS'
'filename'
CHANGING gd_error
gd_reciever.
*Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM initiate_mail_execute_program.
ENDIF.
*& Form data_retrieval
text*
FORM data_retrieval.
SELECT revnr sysnr sdate filnm cusnr
svsnr zlsch clrfe revds prind svsds
quant adate trdat mdate exrate
birate cusds1 cusds2 cusstr
cuspc cuscity cusctry rect
invno ldate conty edate custa
currc warrt indrp textc
gstr clrds commty commyr commmt
commop eposdoc custp
INTO CORRESPONDING FIELDS OF TABLE it_zbill FROM zbill_inpdtl
WHERE cusnr IN s_cusnr
AND svsnr IN s_svsnr
AND revnr IN s_revnr
AND sysnr IN s_sysnr
AND sdate IN s_sdate
AND filnm IN s_filnm
and prind in s_prind.
ENDFORM. " DATA_RETRIEVAL
**& Form build_xls_data_table
text*
FORM build_xls_data_table.
DATA: ld_store(50) TYPE c. "Leading zeros
DATA: wa_zbill-quant(20),
wa_zbill-custa(20),
wa_zbill-gstr(20).
wa_zbill-mxamt(20).*
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
CLASS cl_abap_char_utilities DEFINITION LOAD.
CONSTANTS:
con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
CONCATENATE 'Customer code' 'Service Number' 'Revenue Type' 'Source
System Code' 'Date Source' 'File Name' 'Payment Code' 'Single Char Flag'
'Revenue Description' 'Processing Indicator' 'Service Description'
'Order Quantity' 'Date of Adustment' 'Trade Date' 'Mos Date'
'ExchangeRate' 'Billing Rate' 'Customer Name1' 'Customer name2'
'Customer adress' 'Customer postalcode' 'Customer city'
'Customer country' 'Billing amt without GST' 'GST Payable'
'Receipt number' 'Invoice Number' 'Listing Period'
'Contract Type' 'Entry date' 'Custody Code' 'Currency Code'
'Name of Warrant' 'Rights issue' 'No Of copies'
'GST Rate' 'Clearing Fee' 'Commodity type'
'Commodity year' 'Commodity month' 'Commodity Option Tpye'
'Quantity Transacted' 'Amendment Quantity' 'EPOS DOC type'
'Customer Type'
INTO IT_ATTACH SEPARATED BY con_tab.
CONCATENATE con_cret IT_ATTACH INTO IT_ATTACH.
*CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
LOOP AT it_zbill INTO wa_zbill.
CONCATENATE wa_zbill-cusnr wa_zbill-svsnr wa_zbill-revnr
wa_zbill-sysnr wa_zbill-sdate wa_zbill-filnm wa_zbill-zlsch
wa_zbill-clrfe wa_zbill-revds wa_zbill-prind wa_zbill-svsds
wa_zbill-quant wa_zbill-adate wa_zbill-trdat wa_zbill-mdate
wa_zbill-exrate wa_zbill-birate wa_zbill-cusds1 wa_zbill-cusds2
wa_zbill-cusstr wa_zbill-cuspc wa_zbill-cuscity wa_zbill-cusctry
wa_zbill-rect wa_zbill-invno wa_zbill-ldate wa_zbill-conty
wa_zbill-edate wa_zbill-custa wa_zbill-currc wa_zbill-warrt
wa_zbill-indrp wa_zbill-textc wa_zbill-gstr wa_zbill-clrds
wa_zbill-commty wa_zbill-commyr wa_zbill-commmt wa_zbill-commop
wa_zbill-eposdoc wa_zbill-custp
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
it_header = it_attach .*
*append it_header.
APPEND it_attach.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
***& Form SEND_FILE_AS_EMAIL_ATTACHMENT
FORM send_file_as_email_attachment TABLES pit_message
pit_attach
USING p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
CHANGING p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
*ld_sender_address = SY-UNAME.
ld_sender_address_type = 'SMTP'.*
*fill the document data.
w_doc_data-doc_size = 1.
*populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
*Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
*( w_cnt - 1 ) * 255 + STRLEN( it_attach ).*
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-OBJ_NAME = ld_attfilename.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment = it_attach.
t_attachment[] = it_attach[] .
t_attachment = it_header.*
t_attachment[] = it_header[] .*
*Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
*CREATE attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
*t_packing_list-doc_size = t_packing_list-body_num * 255.*
APPEND t_packing_list.
*Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.*
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
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.
*Populate zerror return code
ld_error = sy-subrc.
*Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM. "build_xls_data_table
regards
subbaHi ,
i'm saying check the field doc_size, umcomment it .change 255--->1025 .
w_doc_data-doc_size =
**( w_cnt - 1 ) * 255 + STRLEN( it_attach ).**
**t_packing_list-doc_size = t_packing_list-body_num * 255.**
for more details , check the documentation.
regards
Prabhu -
Send report Via Email in HTML format
hi,
i am using forms 6.0
I want to send my report Via Email to an email address in HTML Farmat.i want to set destination property at run time retriving from database. (mean without giving any runtime parameter manually)Plz tell me how i can do that i am working in windows environment.
Waiting 4 ur reply.
Thanx in advance.
Zahid Raj.Zahid,
reports6i sends mails where the Report itself is attached as a file in the format you specified. The support for sending a report as part of the HTML mail body is provided in Reports9i.
Frank -
Send report via email as xls file.
Hello from Spain,
Sorry if this is not the correct forum. It's both a forms and reports question, but I think it fits better in the reports forum. I have queried into the forums for similar questions and found some threads without any replies around this same issue. I wish I am lucky today.
I have developed some web forms which generate pdf and txt reports. The latter ones make use of desformat=delimiteddata when calling the reports. They run fine. I have also developed one form which suscribes those reports to email addresses. To do so, I am setting those email addresses in the DESNAME reports parameter and setting DESTYPE parameter as MAIL. They arrive as an attachment with pdf or txt extensions.
Now, I am required to deliver those reports as xls files. I have been reading that desformat=spreadsheet would allow me to do so (as well as formatting the reports and make them look "cuter" than by using just delimiteddata), but have been unable to do it so far. When setting desformat=spreadsheet, reports are sent via email as html attachments, and when they are opened they look awful. Is there any way I can do this? It shouldn't be a too big deal, but I feel completely unable.
Thank you,
Fernando G.Hi,
Please check the following forum thread that may help --> Re: Generate report in Excel and send to user via email.
Thanks, RZ -
Classic report as email attachment
Hi,
Is there any way to send the classic report as an email attachment in xls format.
Regards,
SasiHi,
No, you cant to it for classical report. Convert it as an interactive report and check the email option under download section.
Regards,
Natarajan -
CiscoWorks: How to receive reports in email attachment?
Hi,
Please guide me that how I can get scheduled reports in Campus Manager in email attachment.
I am unable to receive email for the schedule reports saying error says that unable to connect the smtp on port 25.
In the location CS->Server->System Preferences Enable E-mail Attachment (Checked)
I am using;
RME: 4.3.0
CM:5.2.1
Thankstry to telnet on the port 25 of the SMTP server and see if you can.
also you can check the anti-virus and the firewall if it's blocking the connection.
else you can see the sniffer trace output while the LMs try to send the E-mail
hope this helps
Maybe you are looking for
-
Hi, After installation of EhP4 and BP for MSS 1.41 the application Team Calendar does not work anymore and there is an error. Team Calendar has not come with the latest packages, but there must be some components that cause the error. When I preview
-
Quad PPC won't boot--near wit's end
I have a fun little mystery on my hands. At work, we have a Quad-Core PPC (I don't remember which flavor it is, but it's about 2 years old or so now, I believe) which stopped booting up. Here's the skinny: I sat down to the computer (which is barely
-
Is it normal to black out for 3 seconds on wake from sleep?
When my MBP wakes from sleep (usually from opening the lid), the wake from sleep sequences is pretty mystifying. At first I see my desktop screen, but then it goes black for 2 or 3 seconds, and then I can see my desktop screen again and start using t
-
Is there a way on CONVERSION to create a sales order with a scheduled ship date in the past?
Is there a way on CONVERSION to create a sales order with a scheduled ship date in the past? Customer wants to maintain the original scheduled ship date on converted ordered, but the scheduled dates is defaulting to sysdate for past due shipments on
-
I am using accordion menus in my site( DWCS3) and have links in the content panel area. I would just like the the corresponding panel to stay open when clicking on the links contained within the content. Does anyone know how to achieve this? Thanks m