SAP Knowledge Base Article - Public

3346277 - SAP S/4HANA Cloud Public Edition output control - BAdI: Addition of Email Recipients for Purchase Orders Output messages

Symptom

The Output Parameter Determination (OPD) for Purchase Orders is currently being configured. The requirement is to have multiple email addresses (including TO, CC, and BCC) determined and returned for the Email output channel.

 

"Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental."  

Environment

SAP S/4HANA Cloud Public Edition

Resolution

Since SAP S/4HANA Cloud 2308 release will be possible to have multiple email address using Custom Logic to determine them.

There is a new BADI with this purpose, the BAdI will be called as part of the output parameter determination runtime, so once for each output item with channel EMAIL.

 follow bellow all the detailed steps about how to configure in OPD App, and how to enable the BADI and what sample code can be used as a proposal.

Steps for Output Parameter Determination App:

1.In OPD, select Determination step as Email Recipient.

2.Add new line

 

3.Under Email Address column, select option as Select Expression

4.Under search Criteria provide value for

Application Name = OPD_APOC_SYSTEM 

Expression Type = Constant      

And click on search button

5.Select object Add email recipients from custom logic

6.Activate OPD changes

With the above configuration the BADI will be called, 

Follow below steps for implementing BADI :

1.Open Application Custom Logic

2.Click on create Button

Step 1: Business Context: Output Request Item and select checkbox for extension point

Step 2: Click on Step 2 button and maintain filter value

Click on save

3. Provide implementation description and Implementation ID

Click on Review and then Create button

 

4.Publish

  

5.Write logic to get output to PO creator and click on Save and Publish button:

*This method can be used to add email recipients to the current output item during output parameter determination.
*To call this BADI method for purchase order output, maintained filter value for the
*application object type (OUTPUTCONTROLAPPLOBJECTTYPE) as "PURCHASE_ORDER"
*To send copy email to purchase order creator, we are providing below sample implemetation logic

    DATA: ls_additional_email_recipient LIKE LINE OF additionalemailrecipients.
*Using CDS view I_PURCHASEORDERAPI01, getting LV_PURCHASER by passing value of PURCHASERORDER as OUTPUTCONTROLAPPLICATIONOBJECT.
    SELECT SINGLE createdbyuser FROM i_purchaseorderapi01 WITH PRIVILEGED ACCESS
                                                       WHERE purchaseorder = @outputcontrolapplicationobject INTO @DATA(lv_purchaser).
*Check if Purchaser id is determined
    IF lv_purchaser IS NOT INITIAL.
*Based on purchaser id, fetching purchaser details such as indicator which say whether user is technical user or not and email address.

      SELECT SINGLE istechnicaluser, \_addrcurdefaultemailaddress-emailaddress FROM i_user WHERE userid = @lv_purchaser
                                                                          INTO @DATA(lv_user_details) PRIVILEGED ACCESS.

*Check below condition before assigning email address as addintionalemailrecipients
*   1. If user is technical user, don't send email output
*   2. If email address is not determined, then will not assign recipient details
      IF lv_user_details-emailaddress IS NOT INITIAL AND lv_user_details-istechnicaluser IS INITIAL.
        ls_additional_email_recipient-outputrequestitememailrole = 'CC'.
        ls_additional_email_recipient-outputrequestitememailaddress = lv_user_details-emailaddress.
        APPEND ls_additional_email_recipient TO additionalemailrecipients.

 

 

See Also

3331087 - Sample implementations of custom logic: Addition of Email Recipients - SAP S/4HANA Cloud

Keywords

email output Purchase order, CC email, custom, Recipients, Badi, S4_PC,  2308, Output control, Multiple email address, OPD, Output Parameter determination , KBA , MM-FIO-PUR-PO-OM-2CL , Purchase Order Output Management (Public Cloud) , MM-FIO-PUR-PO-OM , Purchase Order Output Management , How To

Product

SAP S/4HANA Cloud 2308

Attachments

Pasted image.png
Pasted image.png