Emailing outputs to partners is a standard out-of-the-box feature in SAP Output Control. This blog explains enhancement options available in case you want to control various aspects of email (subject, recipient, sender etc) before its sent.
Before we begin I am assuming that you are using output control (NACE) in purchasing application, specifically, you are using program SAPFM06P (or a copy of) as your processing program. This processing program supports a number of standard output types NEU (Purchase order) , LPET (SchedAgrmtSchedLine), LPH1 (ForecastDlv schedule) , LPH2 (ForecastDlv schedule) , LPJ1 (JIT Delivery Sched.), LPJ2 (JIT Delivery Sched).
Before you think of enhancing the email first make sure you can send output as email i.e. generate output with transmission medium 5 – External Send. If this is not working then there are few things it worth checking.
Prerequisite
1. Check if ‘5 External send’ medium is specified in Processing routine under output type.
2. Check communication strategy specified in the output type.
If comm strategy is not specified then you can create one under SPRO path SAP NetWeaver->Application Server->Basis Services->Message Control->Determine Communication Strategy. Define a comm strategy with communication type ‘INT Email’.
3. Check email address is specified in Business Partner, it would be a supplier in case of Purchasing.
Enhance using BADI
Once you have standard email functionality working through output control you can go ahead and implement BADI BADI_MM_PO_OC_EMAIL.
After BADI implementation, you would be able to write code in methods CHANGE_SENDER, CHANGE_RECIPIENTS, CHANGE_SUBJECT and CHANGE_BODY to enhance email before it sent out.
Debugging
Put a breakpoint in program SAPFM06P subroutine ADOBE_PRINT_OUTPUT (assuming you are using adode form). Code to call BADI is in this routine so you should be able to see what’s happening with BADI call.
Also make sure when you add output type to document (purchase order, outline agreement etc.) using Dispatch time as ‘1 – Send with periodically scheduled job’ in the Further data section. Then use program RSNAST00 to issue your output. Execution should then stop at the breakpoint.
BADI_MM_PO_OC_EMAIL works only with adode forms. not with smartforms
Really helpful