Supply Chain Management Blogs by Members
Learn about SAP SCM software from firsthand experiences of community members. Share your own post and join the conversation about supply chain management.
cancel
Showing results for 
Search instead for 
Did you mean: 
abprad
Active Participant
8,024

Introduction:


A common functionality in SAP TM can be to send the email with the attachment to a particular receiver or a set of them when an action is executed in Output Management. This can be achieved manually by adding the email id into the Communication Tab and executing the action but checking the email checkbox.

But the requirements can be like, the receiver should be auto-populated based on certain conditions and add into the receiver table in the Output Management tab whenever the action is executed.

This blog will show the steps needed to achieve this functionality.

Assuming, the reader has an idea about the PPF output functionality and SAP TM, moving forward with the explanation.

Explanation


Let us see first the problem and then proceed to the solutions.

  1. Open a Freight Order



       2. Generate an action using the Generate button under the Output Management Tab. When an action is generated, the PDF associated with the form can be displayed in the preview mode. And when you execute the Action , the PDF can be sent as an email, or printed .


      3. If you want to send an email of the PDF, you need to provide the recipient information in the recipient table under the Communication tab of the specified action. The recipient can be an email address, an SAP user, a FAX number, or a Business Partner.




 

This is the manual way to add the Email Address into the recipient and when the Action is generated, the email is sent to the added recipients here.

Now, the requirement is, whenever the action is generated, we should populate the recipients based on some logic and the recipients are prefilled so the user need not do the manual step.

Output Management in SAP TM is done using PPF (Post Processing Framework) which provides print class and print service class to add custom logic to call a custom form.

The print service class is derived from the class /BOFU/CL_PPF_SERV_FOR_BO and has a method /BOFU/IF_PPF_SERV_FOR_BO~COMPLETE_SEND which can be used to add the recipient information. Redefine this method and add the below code to create an internet address/email and add it to the recipient's table. This method has an instance of the BCS communication class which is used to send the email. We need to use this instance object and add the recipients into it.

 



"Print Service Class logic should segregate for action specific logic
CASE is_ppf_act-ppf_action .
WHEN 'ZCUSTOM_ACTION'.
** Add your custom logic to get all recipients
** Loop at your recipients and a create a recipient object for each and add to the BCS class instance
** Available in the method signature.
LOOP AT lt_rec
ASSIGNING FIELD-SYMBOL(<fs_rec>).

lv_email = <fs_rec>-e_mail.

TRY.
DATA(lo_rec) = cl_cam_address_bcs=>create_internet_address(
i_address_string = lv_email ).

CATCH cx_address_bcs.

ENDTRY.

io_send->add_recipient(
EXPORTING
i_recipient = lo_rec " Recipient of Message
).

CLEAR lo_rec.

ENDLOOP.

WHEN OTHERS.

ENDCASE.

 

Save, activate, and open the freight order and try testing.

 

Did it work? No, right, that's because there is another step to it, which is needed for this method to be executed in the framework.

 

SAP's Output Management Guide gives a BADI COMPLETE_PROC_PPF which needs to be implemented for the PPF print service class method COMPLETE_SEND to work.


Go-To Se18 - Create an implementation of the BADI COMPLETE_PROC_PPF. This BADI is a filter dependent BADI. The filter needed here is your Action profile and Action that was created for sending the PDF.


In the resultant Implementation Class of the BADI, Implement the method IF_EX_COMPLETE_PROC_PPF~COMPLETE_SEND  and add the below code. This code calls the PPF service class COMLETE_SEND method by the framework.
    DATA: lo_facade TYPE REF TO /bofu/cl_ppf_badi_facade.

lo_facade ?= /bofu/cl_ppf_badi_facade=>get_instance( ).
CALL METHOD lo_facade->if_ex_complete_proc_ppf~complete_send
EXPORTING
io_context = io_context
ip_protocol = ip_protocol
ip_no_protocol = ip_no_protocol
io_send = io_send
io_medium = io_medium
flt_val = flt_val.

 

Save , Activate, and Now Try Again.

 

The recipients are now fetched and updated in the Recipients Tables.



Conclusion:


This can be a very common requirement during the output management of SAP TM. I hope this blog helps.

 

 

 

 
9 Comments
JVasconcellos
Participant
thanks for sharing!!! Excelent.
0 Kudos
Hi Abhilash,

Great blog. Is it possible to fetch the list of recipients using BRF+ or this is the only way to do it?

Thanks
abilash_cj
Discoverer
0 Kudos
Hi Abhilash,

How to perform the document attached. In IO_SEND, providing the document but not able to view in the output. Please provide some insight into it.

 

Thanks,

Abilash
abprad
Active Participant
0 Kudos
You can use BRF+ and call the class to evaluate the BRF condition to get the recipients , it depends on your requirements
abprad
Active Participant
0 Kudos
Hello,

You can use the document create method of BCS class by passing the document type and content and try that . Should work ideally .
ananda_raghava
Newcomer
0 Kudos
Hi Abhilash.

Thanks for the blog, I want to configure similarly for Outbound delivery , i have implemented the BADI but it is not triggering and redefined the method as specified but the BADI is not triggered and i am not able to understand how the redefined class will be triggered .Any specific configuration needs to be done.

Thanks,

Raghav.
peter_naetscher
Newcomer
0 Kudos

Hi abhilash.pradhan1

Thank you for the detailed help. The automatic population of the e-mail worked like expected, but suddenly it no longer worked.

After I had debugged the method /bofu/if_ppf_serv_for_bo~complete_send, I figured out that it is not able to fill the email to the object lo_rec of the class cl_cam_address_bcs anymore. There were no changes in code in terms of the email-addresses. So the method create_internet_address does not work correctly anymore.

I have attached a screenshot of lo_rec. It shows the situation after the execution of the method create_internet_address:

Like you can see on the right side of the values of the object lo_rec, the address_string is still empty.

Have you any idea, what could be the issue?

Thank you very much,

 

Peter

former_member792703
Discoverer
0 Kudos
How Can we add an attachment? - Smart form content to be attached as PDF.
kaya_ercan
Explorer
0 Kudos

Hi,

Can someone inform me on where we can maintain the "Sender" email address? Currently, it seems like the email address of the user who triggered the "Send to Carrier" action is being used. We have the need to change this email address to the one plant wishes?

Thanks.

Kaya

Labels in this area