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.

SAP COMMUNITY NETWORK © 2010 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com 1

............com 2 .............com | UAC ...sdn..............boc........................................................................ 7 Related Content ...................... 8 Disclaimer and Liability Notice ..... 9 SAP COMMUNITY NETWORK © 2010 SAP AG SDN ........................... 3 Step-by-Step Solution ....................ABAP Code .......................bpx........................................................................sap.............................................com | BOC .................. 3 ABAP Code (Email Function Module) .......................................................................sap......................................................uac............................................com | BPX ..........sap.Email Recipients (Specific Format) – SAP BW Process Chain Table of Contents Scenario .sap.................................................................................................................................................................... 3 Process Chain.............................................................................................................................................

com | UAC . Step-by-Step Solution Solution is explained in two steps: ICM Setup and SAP Connect: Confirm the SMTP activation alongwith the setting in SCOT. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .uac.Email Recipients (Specific Format) – SAP BW Process Chain Scenario Send specific format email using process chain.boc.com | BPX .sap.sap.com | BOC .sdn. SAPConnect All of the SAPConnect monitoring and configuration can be reached from one transaction called SCOT.ABAP Code .sap. 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.bpx.sap.com 3 . ABAP Code (Email Function Module): Use of the FM ‘SO_NEW_DOCUMENT_SEND_API1’ to send email. Values are retrieved from DSO and then a formatted email to be sent to specific Email-IDs.

Date etc and also should be formatted as the requirement. LOOP AT t_phsdrbse INTO wa_phsdrbse. t_mail_content-line.sap. t_mail_content-line = text-012. CONCATENATE 'Customer' ':' wa_phsdrbse-customer INTO APPEND t_mail_content. APPEND t_mail_content. * Chain ID IF wa_phsdrbse-/bic/zcustchid IS NOT INITIAL. * Retrieve data from Rebate Selection Screen DSO SELECT * FROM /bic/aphsdrbse00 INTO TABLE t_phsdrbse.Email Recipients (Specific Format) – SAP BW Process Chain ABAP Code: Step1: Retrieve the details from DSO PHSDRBSE. * Rebate BI-BO Validation CONCATENATE text-001 '(' sy-datum+6(2) '-' sy-datum+4(2) '-' sydatum+0(4) ')' INTO t_mail_header-obj_descr.sap.com | BOC .com | UAC .sap.boc. APPEND t_mail_content.sdn. CONCATENATE ' ' ' APPEND t_mail_content. * Customer IF wa_phsdrbse-customer IS NOT INITIAL.uac. ENDIF.ABAP Code .bpx. ' INTO t_mail_content-line. CONCATENATE 'Chain ID' ':' wa_phsdrbse-/bic/zcustchid INTO t_mail_content- SAP COMMUNITY NETWORK © 2010 SAP AG SDN . ' INTO t_mail_content-line. * Validation successfully done for following: t_mail_content-line = text-002. CONCATENATE ' ' ' APPEND t_mail_content.sap.com | BPX . whose details have to be sent: Email to be sent which contains details about the Chain ID .com 4 . IF sy-subrc EQ 0.

* Portal Link CONCATENATE 'http://essbwpapp01. APPEND t_mail_content. APPEND t_mail_content. * Rebate ID CONCATENATE 'Rebate ID' ':' wa_phsdrbse-/bic/zreb_id INTO APPEND t_mail_content.com | BOC . APPEND t_mail_content. CONCATENATE text-013 ' ' INTO t_mail_content-line.sap.com | BPX .bpx.ABAP Code . ENDIF.sap. t_mail_content-line. * National Grp IF wa_phsdrbse-/bic/zcnltgpc IS NOT INITIAL. CONCATENATE 'National Group' ':' wa_phsdrbse/bic/zcnltgpc INTO t_mail_content-line.uac.mckesson. CONCATENATE '******************************' ' APPEND t_mail_content. ENDLOOP. CONCATENATE ' ' ' APPEND t_mail_content. APPEND t_mail_content. * Web Template Execution CONCATENATE text-007 ' ' INTO t_mail_content-line. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sap.com:59000/irj/' ' ' INTO t_mail_content-line.sap.boc. * To date CONCATENATE 'Date From' ':' wa_phsdrbse-/bic/phrbto INTO APPEND t_mail_content. APPEND t_mail_content. * WAD: ZWT_PHSDRBMP1_COMPARE_BI_BO CONCATENATE text-006 ' ' INTO t_mail_content-line. CONCATENATE 'National Sub Group' ':' wa_phsdrbse/bic/zcntlsgpc INTO t_mail_content-line. APPEND t_mail_content. ' INTO t_mail_content-line. * From Date CONCATENATE 'Date From' ':' wa_phsdrbse-/bic/phrbfr INTO APPEND t_mail_content.com | UAC . CONCATENATE text-010 ' ' INTO t_mail_content-line. ' INTO t_mail_content-line. * National Sub Grp IF wa_phsdrbse-/bic/zcntlsgpc IS NOT INITIAL. * Kindly execute either of them to validate: CONCATENATE text-004 ' ' INTO t_mail_content-line. ' INTO t_mail_content-line. t_mail_content-line. ENDIF. APPEND t_mail_content.Email Recipients (Specific Format) – SAP BW Process Chain line. ENDIF. * Query : ZPHSDRBMP1_COMPARE_BI_BO CONCATENATE text-005 ' ' INTO t_mail_content-line. t_mail_content-line. APPEND t_mail_content.com 5 . APPEND t_mail_content.sdn. CONCATENATE '******************************' ' APPEND t_mail_content.

uac. ' INTO t_mail_content-line.sap. ' INTO t_mail_content-line.com | BPX .sap.com 6 . Step 1: Retrieve the email IDs as maintained in custom table YBBWT_REB_EMAIL * Retreive Email Address SELECT * FROM ybbwt_reb_email INTO TABLE t_ybbwt_reb_email.sap.bpx. APPEND t_mail_content. t_receivers-rec_type = 'U'. CONCATENATE ' ' ' APPEND t_mail_content. SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sdn. APPEND t_receivers.sap. ENDIF. CONCATENATE text-008 ' ' INTO t_mail_content-line. t_receivers-receiver = wa_ybbwt_reb_email-address. LOOP AT t_ybbwt_reb_email INTO wa_ybbwt_reb_email. CONCATENATE text-011 ' ' INTO t_mail_content-line.com | UAC . APPEND t_mail_content. CONCATENATE text-009 ' ' INTO t_mail_content-line. CONCATENATE ' ' ' APPEND t_mail_content.ABAP Code .Email Recipients (Specific Format) – SAP BW Process Chain APPEND t_mail_content. t_receivers-com_type = 'INT'. ENDIF.boc. 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. APPEND t_mail_content.com | BOC . ENDLOOP. IF sy-subrc EQ 0.

bpx.com | UAC .com | BOC .ABAP Code .com 7 .sap. which sents email to specific Email IDs: Execute the Process Chain Email Notification SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sap.sdn.boc.uac.com | BPX .Email Recipients (Specific Format) – SAP BW Process Chain Step3: Check the email in Inbox Process Chain Create a process chain which contains the ABAP Code.sap.sap.

Email Recipients (Specific Format) – SAP BW Process Chain Related Content For more information.sap.com | BOC .sap.sap.com | BPX .sap.com | UAC . SAP COMMUNITY NETWORK © 2010 SAP AG SDN .sdn.boc.bpx. visit the EDW homepage.ABAP Code .uac.com 8 .

SAP COMMUNITY NETWORK © 2010 SAP AG SDN .com | BPX .sdn.sap. including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP.com 9 . SAP responsible or liable with respect to the content of this document.uac. Changes made based on this information are not supported and can be overwritten during an upgrade.Email Recipients (Specific Format) – SAP BW Process Chain Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP.bpx.com | BOC .com | UAC . SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample. SAP will not be held liable for any damages caused by using or misusing the information. or seek to hold.ABAP Code . code or methods suggested in this document.sap.sap. and anyone using these methods does so at his/her own risk. You agree that you will not hold.boc.sap.

Sign up to vote on this title
UsefulNot useful