‎2011 Jan 17 12:56 PM
Hi ,
I am using the FM 'SO_NEW_DOCUMENT_SEND_API1' for sending data in an internal table as an email . I am wondering whether it will be possible to to send it in the table format with the field names intact. Currently i am able to send the mail but without the table field names . Please help
Regards,
Tashi
‎2011 Jan 17 3:46 PM
Yes, certainly, but you didn't mention whether it's an attachment or in the body and what type of data it is. You'd be far better off using CL_BCS and sending the data as an attachment (whatever format it is), but you can also send it in the body if that's what you're doing - use HTML and the table tags for that.
‎2011 Jan 19 6:24 AM
i would want the data to come in the mail body . can u please give a sample code on how to use the HTML table to display the internal table data in tabular fashion.
Thanks
Tashi
‎2011 Jan 19 6:40 AM
hi ,
This is for Column heading ....
it_fcat-coltext = 'Tot Pln'.
append it_fcat.
it_fcat-coltext = 'Tot Act'.
append it_fcat.
it_fcat-coltext = 'Plan Diff'.
append it_fcat.
it_fcat-coltext = 'Contri Pln'.
append it_fcat.
it_fcat-coltext = 'Contri Act'.
append it_fcat.
it_fcat-coltext = 'Contri Diff'.
append it_fcat.
it_fcat-coltext = 'REMARKS'.
append it_fcat.
it_fcat-coltext = 'Plant'.
APPEND it_fcat.
*
data : v_sub(50) type c .
data : c_color type w3fields-fg_color .
data : l type w3fields-lnr .
describe table it_mailvar_blank lines l .
loop at it_fcat.
w_head-text = it_fcat-coltext.
clear c_color .
*-Populate the Column Headings
call function 'WWW_ITAB_TO_HTML_HEADERS'
exporting
field_nr = sy-tabix
text = w_head-text
fgcolor = 'black'
bgcolor = 'Lightblue'
size = '3'
text_length = 'S'
justified = 'CENTER'
tables
header = t_header.
-populate column properties
call function 'WWW_ITAB_TO_HTML_LAYOUT'
exporting
field_nr = sy-tabix
line_nr = l
fgcolor = c_color
size = '3'
font = '14'
justified = 'CENTER'
tables
fields = t_fields.
endloop.
concatenate 'For Date : ' so_date3(8) ' ' 'For Line : ' so_line3(18) 'For Plan :' v_sub into wa_header-text .
wa_header-font = 'Arial'.
wa_header-size = '3'.
call function 'WWW_ITAB_TO_HTML'
exporting
TABLE_ATTRIBUTES = 'BORDER=1'
table_header = wa_header
all_fields = 'X'
tables
html = lt_html
fields = t_fields
row_header = t_header
itable = it_mailvar_blank . "it_maildisp .Regards
Deepak.
‎2011 Jan 20 10:07 AM
Hi,
I want the ouput to come on a mail body ....
Hi Deepak,
I assume the code u mentioned will give the output in HTML format but i want the output to come in a mail with proper format ..
‎2011 Jan 17 4:33 PM
Here is sample code of how to do it.
http://wiki.sdn.sap.com/wiki/display/Snippets/HowtosendInternalTabletoE_Mail+address
‎2011 Jan 19 6:49 AM
hello gurus,
please check this below program.
TABLES : ADR6.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : SPOOLNO TYPE TSP01-RQIDENT OBLIGATORY.
SELECT-OPTIONS : MAILS FOR ADR6-SMTP_ADDR DEFAULT 'xyz.com' OBLIGATORY NO INTERVALS.
SELECTION-SCREEN END OF BLOCK B1.
DATA SEND_REQUEST TYPE REF TO CL_BCS.
DATA DOCUMENT TYPE REF TO CL_DOCUMENT_BCS.
DATA RECIPIENT TYPE REF TO IF_RECIPIENT_BCS.
DATA BCS_EXCEPTION TYPE REF TO CX_BCS.
DATA SENT_TO_ALL TYPE OS_BOOLEAN.
DATA PDF_SIZE TYPE SO_OBJ_LEN.
DATA PDF_CONTENT TYPE SOLIX_TAB.
DATA PDF_XSTRING TYPE XSTRING.
DATA MAILTO TYPE AD_SMTPADR.
START-OF-SELECTION.
PERFORM CREATE_PDF.
PERFORM SEND.
&----
*& Form send
&----
FORM SEND.
TRY.
-------- create persistent send request ------------------------
SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
-------- create and set document -------------------------------
PDF_CONTENT = CL_DOCUMENT_BCS=>XSTRING_TO_SOLIX( PDF_XSTRING ).
DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = 'PDF'
I_HEX = PDF_CONTENT
I_LENGTH = PDF_SIZE
I_SUBJECT = 'sending pdf as email' ). "#EC NOTEXT
add document object to send request
SEND_REQUEST->SET_DOCUMENT( DOCUMENT ).
LOOP AT MAILS. " for sending multiple mails we can use this logic
MAILTO = MAILS-LOW.
--------- add recipient (e-mail address) -----------------------
create recipient object
RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( MAILTO ).
add recipient object to send request
SEND_REQUEST->ADD_RECIPIENT( RECIPIENT ).
ENDLOOP.
---------- send document ---------------------------------------
SENT_TO_ALL = SEND_REQUEST->SEND( I_WITH_ERROR_SCREEN = 'X' ).
COMMIT WORK.
IF SENT_TO_ALL IS INITIAL.
MESSAGE I500(SBCOMS) WITH MAILTO.
ELSE.
MESSAGE S022(SO).
ENDIF.
------------ exception handling ----------------------------------
replace this rudimentary exception handling with your own one !!!
CATCH CX_BCS INTO BCS_EXCEPTION.
MESSAGE I865(SO) WITH BCS_EXCEPTION->ERROR_TYPE.
ENDTRY.
ENDFORM. "send
&----
*& Form create_pdf
&----
Create PDF Content
1) get attributes of spool request
2) convert spool request to PDF dependent on document type
----
FORM CREATE_PDF.
DATA RQ TYPE TSP01.
DATA BIN_SIZE TYPE I.
DATA DUMMY TYPE TABLE OF RSPOATTR.
------------ get attributes of spool request ---------------------
CALL FUNCTION 'RSPO_GET_ATTRIBUTES_SPOOLJOB'
EXPORTING
RQIDENT = SPOOLNO
IMPORTING
RQ = RQ
TABLES
ATTRIBUTES = DUMMY
EXCEPTIONS
NO_SUCH_JOB = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE E126(PO) WITH SPOOLNO.
ENDIF.
--- convert spool request into PDF, dependent on document type ---
IF RQ-RQDOCTYPE = 'OTF' OR RQ-RQDOCTYPE = 'SMART'.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = SPOOLNO
NO_DIALOG = 'X'
PDF_DESTINATION = 'X'
NO_BACKGROUND = 'X'
IMPORTING
PDF_BYTECOUNT = BIN_SIZE
BIN_FILE = PDF_XSTRING
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DSTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12.
IF SY-SUBRC <> 0.
MESSAGE E712(PO) WITH SY-SUBRC 'CONVERT_OTFSPOOLJOB_2_PDF'.
ENDIF.
ELSEIF RQ-RQDOCTYPE = 'LIST'.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = SPOOLNO
NO_DIALOG = 'X'
PDF_DESTINATION = 'X'
NO_BACKGROUND = 'X'
IMPORTING
PDF_BYTECOUNT = BIN_SIZE
BIN_FILE = PDF_XSTRING
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DESTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12.
IF SY-SUBRC <> 0.
MESSAGE E712(PO) WITH SY-SUBRC 'CONVERT_ABAPSPOOLJOB_2_PDF'.
ENDIF.
ELSE.
MESSAGE E789(PO) WITH RQ-RQDOCTYPE.
ENDIF.
PDF_SIZE = BIN_SIZE.
ENDFORM. "create_pdf
‎2011 Jan 20 1:56 PM
Hi,
refer to the code:
LOOP AT so_malid.
wa_receivers-receiver = so_malid-low.
wa_receivers-rec_id = so_malid-low.
wa_receivers-rec_type = 'U'.
wa_receivers-com_type = 'INT'.
wa_receivers-notif_del = 'X'.
wa_receivers-notif_ndel = 'X'.
APPEND wa_receivers TO gi_receivers.
CLEAR wa_receivers.
ENDLOOP.
to create table in the mail body use HTML.
DATA: lv_tab_lines TYPE i VALUE 255.
CLEAR gi_packing_list.
REFRESH gi_packing_list.
wa_packing_list-transf_bin = space.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 0.
wa_packing_list-body_start = 1.
DESCRIBE TABLE gi_messages LINES lv_tab_lines.
READ TABLE gi_messages INDEX lv_tab_lines INTO wa_message.
wa_doc_data-doc_size = ( lv_tab_lines - 1 ) * 255 + STRLEN( wa_message ).
APPEND wa_message TO gi_messages.
DESCRIBE TABLE gi_messages LINES wa_packing_list-body_num.
wa_packing_list-doc_type = 'HTM'.
wa_packing_list-doc_size = lv_tab_lines * 255.
APPEND wa_packing_list TO gi_packing_list.
CLEAR wa_packing_list.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = wa_doc_data
sender_address = gc_sender_address
sender_address_type = gc_sender_address_type
commit_work = 'X'
TABLES
packing_list = gi_packing_list
contents_txt = gi_messages
receivers = gi_receivers.
Regards,
Rajesh Kumar