ABAP Code - Email Recipients (Specific Format) - SAP BW Process Chain
ABAP Code - Email Recipients (Specific Format) - SAP BW Process Chain
ABAP Code - Email Recipients (Specific Format) - SAP BW Process Chain
Applies to:
This article is applicable to all the SAP BI consultants who are accustomed with SAP ABAP skills. For more information, visit the EDW homepage.
Summary
This document specifies the detailed understanding of sending specific format emails using process chain. Author: Suraj Tigga
Company: Capgemini Consulting India Pvt. Ltd. Created on: 8 July 2010
Author Bio
Suraj Tigga is a Senior SAP BI / ABAP consultant at Capgemini Consulting, India. Suraj joined Capgemini Consulting in 2008 and has worked on multiple SAP BI implementation and support projects.
Table of Contents
Scenario ....................................................................................................................................................... 3 Step-by-Step Solution ................................................................................................................................ 3
ABAP Code (Email Function Module) .......................................................................................................................... 3 Process Chain.............................................................................................................................................................. 7
Scenario
Send specific format email using process chain. Values are retrieved from DSO and then a formatted email to be sent to specific Email-IDs. Step-by-Step Solution Solution is explained in two steps:
ICM Setup and SAP Connect: Confirm the SMTP activation alongwith the setting in SCOT. ABAP Code (Email Function Module): Use of the FM SO_NEW_DOCUMENT_SEND_API1 to send email. Process Chain: Schedule the process chain to send email
ABAP Code (Email Function Module)
Maintain the Email IDs in custom table to whom the mail to be sent:
ICM setup and SAP Connect: Go to transaction SICF and verify the SMTP node is activated properly.
SAPConnect All of the SAPConnect monitoring and configuration can be reached from one transaction called SCOT.
ABAP Code: Step1: Retrieve the details from DSO PHSDRBSE, whose details have to be sent:
Email to be sent which contains details about the Chain ID , Date etc and also should be formatted as the requirement.
* Retrieve data from Rebate Selection Screen DSO
SELECT * FROM /bic/aphsdrbse00 INTO TABLE t_phsdrbse. IF sy-subrc EQ 0.
* Customer
IF wa_phsdrbse-customer IS NOT INITIAL. CONCATENATE 'Customer' ':' wa_phsdrbse-customer INTO APPEND t_mail_content. ENDIF. t_mail_content-line.
* Chain ID
IF wa_phsdrbse-/bic/zcustchid IS NOT INITIAL. CONCATENATE 'Chain ID' ':' wa_phsdrbse-/bic/zcustchid INTO t_mail_content-
* National Grp
IF wa_phsdrbse-/bic/zcnltgpc IS NOT INITIAL. CONCATENATE 'National Group' ':' wa_phsdrbse/bic/zcnltgpc INTO t_mail_content-line. APPEND t_mail_content. ENDIF.
* Rebate ID
CONCATENATE 'Rebate ID' ':' wa_phsdrbse-/bic/zreb_id INTO APPEND t_mail_content. t_mail_content-line.
* From Date
CONCATENATE 'Date From' ':' wa_phsdrbse-/bic/phrbfr INTO APPEND t_mail_content. t_mail_content-line.
* To date
CONCATENATE 'Date From' ':' wa_phsdrbse-/bic/phrbto INTO APPEND t_mail_content. ENDLOOP. CONCATENATE '******************************' ' APPEND t_mail_content. t_mail_content-line.
* Query : ZPHSDRBMP1_COMPARE_BI_BO
CONCATENATE text-005 ' ' INTO t_mail_content-line. APPEND t_mail_content.
* WAD: ZWT_PHSDRBMP1_COMPARE_BI_BO
CONCATENATE text-006 ' ' INTO t_mail_content-line. APPEND t_mail_content. CONCATENATE '******************************' ' APPEND t_mail_content. ' INTO t_mail_content-line.
* Portal Link
CONCATENATE 'http://essbwpapp01.mckesson.com:59000/irj/' ' ' INTO t_mail_content-line. APPEND t_mail_content. CONCATENATE ' ' ' APPEND t_mail_content. ' INTO t_mail_content-line.
CONCATENATE text-013 ' ' INTO t_mail_content-line. APPEND t_mail_content. CONCATENATE text-010 ' ' INTO t_mail_content-line.
APPEND t_mail_content. CONCATENATE text-011 ' ' INTO t_mail_content-line. APPEND t_mail_content. CONCATENATE ' ' ' APPEND t_mail_content. CONCATENATE ' ' ' APPEND t_mail_content. ' INTO t_mail_content-line.
CONCATENATE text-008 ' ' INTO t_mail_content-line. APPEND t_mail_content. CONCATENATE text-009 ' ' INTO t_mail_content-line. APPEND t_mail_content. ENDIF.
Step 2: Call the Function Module SO_NEW_DOCUMENT_SEND_API1 which sent the email
* Send email (Notify the Users about the successful validation) CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1' EXPORTING document_data = t_mail_header document_type = 'RAW' put_in_outbox = 'X' commit_work = 'X' TABLES object_content = t_mail_content 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.
Create a process chain which contains the ABAP Code, which sents email to specific Email IDs:
Email Notification
Related Content
For more information, visit the EDW homepage.