前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Trigger PPF Post Processing Framework

Trigger PPF Post Processing Framework

作者头像
古道无仙
修改2021-03-11 11:41:18
6310
修改2021-03-11 11:41:18
举报
文章被收录于专栏:叕鰦座

1.0 Introduction

In SAP Transportation Management, we get many scenarios to trigger a PPF (Post Processing Framework) Action by stand alone code. Examples being; Trigger a PPF Action from a POWL (Personal Object Work list) or trigger a PPF action in TRQ (Booking Request) when a condition satisfies in TOR (Manifestation). So we need a mechanism to trigger the PPF action configured in a BO via stand alone code.

2.0 Technical Design

The following design is based on a requirement in a project where a PPF Action was triggered from a legacy system via a RFC enabled FM which is called on certain events in the system. So appropriate inputs were created considering the requirement. These inputs can be changed as per project needs.

Inputs to the FM.

a) Booking #

b) Application Name (Defaulted to ‘/SCMTMS/TRANSPORTATION ‘)

c) Context Name (Name of the Action)

d) Name of the Action Definition

e) Commit (Default = ‘X’)

The following code is written with the constraint in PPF frame work that the Schedule Condition BADI (EVAL_SCHEDCOND_PPF) will not be instantiated and hence it cannot be called as a part of frame work. So we have to do the necessary code for doing the schedule condition check and then if that passes we can call the FM to trigger the PPF. In this part of discussion we will talk about the trigger to a BADI implementation of EVAL_STARTCOND_PPF & EXEC_METHODCALL_PPF.

[adToAppearHere]

2.1 Code snippet (Where we configure EXEC_METHODCALL_PPF BADI as final method)

Step 1) Get an instance of PPF manager

代码语言:javascript
复制
TRY.

lo_manager = cl_manager_ppf=>get_instance( ).

CHECK lo_manager IS BOUND.

ENDTRY.

 

" Get persistent PPF object

lo_agent = /bofu/ca_ppf_container=>agent.

lv_bo_key = /scmtms/if_trq_c=>sc_bo_key.

lv_appl_key = ls_key-key.

 

TRY.

lo_agent->get_persistent(

EXPORTING

i_bo_key = lv_bo_key

i_db_key = ls_key-key

i_node_key = /scmtms/if_trq_c=>sc_node-root

i_ppf_profile = iv_context

RECEIVING

result = lo_ppf_container ).

 

CATCH cx_os_object_not_found.

 

" Create persistant object

TRY.

lo_agent->create_persistent(

EXPORTING

i_appl_key = lv_appl_key

i_bo_key = lv_bo_key

i_db_key = ls_key-key

i_node_key = /scmtms/if_trq_c=>sc_node-root

i_ppf_profile = iv_context

RECEIVING

result = lo_ppf_container ).

 

CATCH cx_os_object_existing .

ENDTRY.

ENDTRY.

 

 

Step 2) Create PPF context

代码语言:javascript
复制

CREATE OBJECT lo_context.

 

lo_context->name = iv_context.

lo_context->appl = lo_ppf_container.

lo_context->applctn = iv_applctn.

lo_context->applkey = lv_appl_key.

 

CLEAR lo_trigger.

 

IF lo_trigger IS INITIAL.

" Create trigger for PPF action

lo_manager->create_trigger(

EXPORTING

ip_ttype_name = iv_ttype

io_context = lo_context

RECEIVING

ro_trigger = lo_trigger

EXCEPTIONS

empty_triggertype = 1

empty_context = 2

OTHERS = 3 ).

IF sy-subrc <> 0.

RAISE error_trigger_creation.

ENDIF.

ENDIF.

 

* Set partner Independent flag as TRUE

IF lo_trigger IS NOT INITIAL.

lo_trigger->set_partindep( i_partindep = abap_true ).

ENDIF.

 

* Set application key for all triggers of the context

lo_manager->set_applkey(

EXPORTING

ip_applkey = lv_appl_key

io_context = lo_context ).

Step 3) Execute the trigger

代码语言:javascript
复制
CALL METHOD lo_trigger->execute

RECEIVING

rp_rc = ev_rc

EXCEPTIONS

empty_medium_reference = 1

empty_appl_reference = 2

locked = 3

document_is_locked = 4

inactive = 5

startcondition_not_true = 6

OTHERS = 7.

 

COMMIT WORK AND WAIT.

Commit is required to make the changes reflect in the output management tab. Please be cautious if you are writing the code in BOPF. As we need not write commit work in BOPF coding as the system commit will take care of it.

Also Read : SAP HANA from Space Level

For the complete code extract of the FM : Click Here

2.2 PPF Action for triggering Adobe / smart forms (Where we configure DOC_PERSONALIZE_BCS BADI as final method)

When we are dealing with triggering BADI Implementations for DOC_PERSONALIZE_BCSfor printing forms we need to add following lines of code to set the Medium of PPF action for Printers and Number of copies before calling Step 3 to execute the call. You can have the printer & number of copies as variable input in your FM. In this example I have hard coded for easy understanding.

代码语言:javascript
复制
**For 'External Communication' populate mandatory parameters. E.g.:

Printer and Number of copies.

IF lref_trigger IS BOUND.

CREATE OBJECT lref_bcs.

lref_medium_ppf = lref_trigger->get_medium( ).

IF lref_medium_ppf IS BOUND.

lref_bcs ?= lref_medium_ppf.

lref_bcs->print_copies = lc_copies. “001

lref_bcs->device = lc_printer. “LOCL

lref_medium_ppf = lref_bcs.

 

**Set the medium of PPF Action

CALL METHOD lref_trigger->set_medium

EXPORTING

i_medium = lref_medium_ppf.

ENDIF.

ENDIF.

This the first post on SAP TM series. Please stay tuned for more posts related to Transportation Management. In the next post, I would show how to “Execute Actions or Function Modules in locked instances mode in SAP TM“.

If you want to get such practical tweaks and tricks straight to your inbox, please SUBSCRIBE. We respect your privacy and take protecting it seriously.

If you liked this post, please hit the share buttons at the left side of your screen.

Thank you very much for your time!!

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-09-26,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 叕鰦座 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档