REPORT zhtml_report.
*----------------------------------------------------------*
*Description: this report will creates an output in email
* in HTML format
*----------------------------------------------------------*
DATA: it_maildata TYPE sodocchgi1 OCCURS 10 WITH HEADER LINE ,
it_mailtext LIKE solisti1 OCCURS 10 WITH HEADER LINE,
it_mailrecep LIKE somlrec90 OCCURS 10 WITH HEADER LINE,
it_listtable TYPE abaplist OCCURS 10 WITH HEADER LINE,
it_htmldata TYPE w3html OCCURS 10 WITH HEADER LINE,
it_ascidatatab TYPE char255 OCCURS 10 WITH HEADER LINE.
START-OF-SELECTION.
*----------------------------------------------------------*
**before submitting the report first create a test program for
**displaying the output in html program .copy and paste the
**below report
*report ztest_submit.
*start-of-selection.
*do 10 times.
*write:/ 'this is the test report for html output in email'.
*enddo.
*----------------------------------------------------------*
SUBMIT ztest_submit
EXPORTING LIST TO MEMORY AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = it_listtable
EXCEPTIONS
not_found = 1
OTHERS = 2.
CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
TABLES
html = it_htmldata
listobject = it_listtable.
CLEAR: it_maildata,
it_mailtext,
it_mailrecep.
REFRESH: it_mailtext,
it_mailrecep.
it_maildata-obj_name = 'TEST'.
it_maildata-obj_descr = 'Test Subject'.
LOOP AT it_htmldata.
it_mailtext = it_htmldata.
APPEND it_mailtext.
ENDLOOP.
it_mailrecep-receiver = 'venkatntw@gmail.com'.
it_mailrecep-rec_type = 'U'.
APPEND it_mailrecep.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = it_maildata
document_type = 'HTM'
put_in_outbox = 'X'
TABLES
object_header = it_mailtext
object_content = it_mailtext
receivers = it_mailrecep
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 NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
COMMIT WORK.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
Here you can find examples and sample programs related to ABAP Report Programs, ALV Grid/List Programs, BDC, HR ABAP, Function Modules, BAPIs, BADIs, Smartforms, SapScripts, etc.
Venkateswararao,
ReplyDeleteI used to use the method you describe on this blog.
Then:
I started using a function module that Thomas Jung shared with the community in his blog.
http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/789
We have been using this FM successfully for five years. Now today, intermittently the FM is abending at the line "raise exception bcs_exception.". The FM is executed inside of a method called by a foreground task of a workflow. We are on basis 620 and applications 4.7.
Almost every time this function module completes successfully, 99.999 % success rate. Occasionally it abends on the RAISE statement.
This FM is called successfully by other methods called by a foreground task of a workflow. The FM is also called by many reports. I just successfully ran a report that uses this FM.
This is the logic of the FM.
See the blog on SDN for coding specifics.
try.
* Create persistent send request
* Now we are ready to create the e-mail content itself.
* Add document to send request
* Get sender object
* Add sender
* Following the sender, we can add our recipients to the e-mail.
* Set that you don't need a Return Status E-mail
* set send immediately flag
* Send document
call method send_request->send( ).
commit work.
catch cx_bcs into bcs_exception.
raise exception bcs_exception. " <<<<<
*
endtry.
********************************
Run time error log text follows
********************************
The exception 'CX_SEND_REQ_BCS' was raised but was not caught at any stage in the call hierarchy.
Any ideas what the problem is or how to correct it?
Thanks
Bruce