2020 May 21 10:52 AM
Hello Abapers
My requirement is to send the notification with the HTML layout in SAP inbox and external Email. I am using the FM SO_NEW_DOCUMENT_SEND_API1 and its working fine but the HTML layout is not working.
I did the 2 steps
1) I created the text by SO10 and write the html logic there and I am calling it through READ_TEXT
2) Then moving the contents into body OBJECT_CONTENT and sending it by document type HTM
But its not working can anybody explain me what step I am doing wrong or missing
Thanks
Hello Abapers
My requirement is to send the notification with the HTML layout in SAP inbox and external Email. I am using the FM SO_NEW_DOCUMENT_SEND_API1 and its working fine but the HTML layout is not working.
I did the 2 steps
1) I created the text by SO10 and write the html logic there and I am calling it through READ_TEXT
2) Then moving the contents into body OBJECT_CONTENT and sending it by document type HTM
But its not working can anybody explain me what step I am doing wrong or missing
Thanks
2020 May 21 11:59 AM
Hi aizysyed
I know this isn't for SO_NEW_DOCUMENT_SEND_API1, but maybe you can rewrite your code to use the CL_CRM_EMAIL_DATA class? In my opinion it's much more developer friendly.
DATA:
lv_html TYPE string,
ls_recipient TYPE crms_email_recipient.
DATA(lo_email) = NEW cl_crm_email_data( ).
CALL METHOD cl_crm_email_utility_base=>get_body_part_from_editor
IMPORTING
et_mime_data = lo_email->body
CHANGING
cv_html = lv_html
EXCEPTIONS
input_error = 1
OTHERS = 2.
lo_email->subject = |My first HTML email, yay!|.
lo_email->from-name = 'My name'.
lo_email->from-address = '<[email protected]>'.
ls_recipient-name = 'Your name'.
ls_recipient-address = '[email protected]'.
APPEND ls_recipient TO lo_email->to.
TRY.
DATA(lo_send_request) = cl_crm_email_utility_base=>cre_send_req_from_mail_data( lo_email ).
" N = never, E = on error
lo_send_request->set_status_attributes( i_requested_status = 'N' ).
lo_send_request->set_send_immediately( abap_true ).
DATA(lv_result) = lo_send_request->send( ).
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
CATCH cx_send_req_bcs INTO DATA(lx_bcs).
" handle the exception
CATCH cx_crm_email INTO DATA(lx_crm).
" handle the exception
ENDTRY.
Regards,
Mateusz2020 May 22 5:14 AM
You dont specify how you "move the contents", but I assume, that you simply insert the lines from READ_TEXT, which are "SAP-Script Text Rows" with Format and Content of TDSTXLLINE having CHAR 132, into the "SAP-Office Rows" with only Content SO_TEXT255 having CHAR 255.
But instead, you could/should transform the SAP-Script into SAP-Office format correctly. I do this by moving SAP-Script into string first, and then from string into SAP-Office.
" 1) READ TEXT in SAP-Script Format
DATA lt_lines TYPE TABLE OF tline. " table of struc TLINE with TDFORMAT and TDLINE having CHAR 132
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = your_id " e.g. 'ST'
language = your_language " e.g. 'E'
name = your_text_name
object = your_object " e.g. 'TEXT'
TABLES
lines = lt_lines. " output in SAP-Script
* 2) Convert SAP-Script to String
DATA lo_text_assist TYPE REF TO /plmu/cl_ltx_assist.
DATA lv_string TYPE string.
CREATE OBJECT lo_text_assist.
CALL METHOD lo_text_assist->convert_itf_to_string(
EXPORTING it_lines = lt_lines
IMPORTING ev_ltx_content = lv_string ).
* 3) Convert String to SAP-Office
DATA lt_content TYPE SOLI_TAB. " table of struc SOLI with LINE TYPE SO_TEXT255 having CHAR 255
lt_content = cl_document_bcs=>string_to_soli( lv_string ).
* 4) Use the SAP-Office data for the object content
DATA lt_mail_content TYPE TABLE OF SOLISTI1. " same struc as soli_tab, just different 'table type'
INSERT LINES OF lt_content INTO TABLE lt_mail_content.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
" ...
IMPORTING
" ...
TABLES
object_content = lt_mail_content
" ...
EXCEPTIONS
" ...
PS: Instead of using the FM, you can also use class CL_BCS to create and send the mail and class CL_DOCUMENT_BCS to create content.
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |