In tcode SWO1 we can find for example business object BUS1178 has defined several events.
When you create a new product and save it from WebClient UI, this BOR type will be raised in the following callstack:
COM_PR_CHBADI_RAISE_WF_EVENT will call SWE_EVENT_CREATE_IN_UPD_TASK in update task.
In update task execution, BOR event will be raised by SWE_EVENT_CREATE. The guid of created product is available in variable objkey.
So how to react to this BOR event published by function module SWE_EVENT_CREATE? tcode SWE2, just create a new entry for this BOR event:
Maintain a function module as event listener:
As I would like to send a mail to my inbox every time a new product is created, so I implement the following source code:
FUNCTION z_jerry_prod_create_via_event.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(EVENT) LIKE SWETYPECOU-EVENT
*" VALUE(RECTYPE) LIKE SWETYPECOU-RECTYPE
*" VALUE(OBJTYPE) LIKE SWETYPECOU-OBJTYPE
*" VALUE(OBJKEY) LIKE SWEINSTCOU-OBJKEY
*" VALUE(EXCEPTIONS_ALLOWED) LIKE SWEFLAGS-EXC_OK DEFAULT SPACE
*" EXPORTING
*" VALUE(REC_ID) LIKE SWELOG-RECID
*" TABLES
*" EVENT_CONTAINER STRUCTURE SWCONT
*" EXCEPTIONS
*" READ_FAILED
*" CREATE_FAILED
*"----------------------------------------------------------------------
DATA: lo_recipient TYPE REF TO cl_cam_address_bcs.
DATA: lt_body TYPE bcsy_text,
lv_prod_id TYPE comm_product-product_id,
lt_send_to TYPE string_table.
APPEND 'XXXX@sap.com' TO lt_send_to.
data(ls_line) = value SOLI( line = `It's important to realize that using the in-development REPL, Project Kulla, is not for the faint of heart. Kulla, aka JShell, isn't part of the JDK 9 preview bundle at the time of writing` ).
APPEND ls_line TO lt_body.
SELECT SINGLE product_id INTO lv_prod_id FROM comm_product where product_guid = objkey.
IF sy-subrc = 0.
ls_line-line = '*'.
APPEND ls_line TO lt_body.
ls_line-line = | Created Product ID: { lv_prod_id }|.
APPEND ls_line TO lt_body.
ENDIF.
TRY.
DATA(lo_send_request) = cl_bcs=>create_persistent( ).
DATA: lv_len TYPE so_obj_len VALUE 0.
LOOP AT lt_body ASSIGNING FIELD-SYMBOL(<line>).
lv_len = lv_len + strlen( <line> ).
ENDLOOP.
DATA(lo_document) = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = lt_body
i_length = lv_len
i_subject = CONV #( 'Java9 is coming!' ) ).
lo_send_request->set_document( lo_document ).
DATA(lo_sender) = cl_cam_address_bcs=>create_internet_address( 'XXXX@sap.com' ).
lo_send_request->set_sender( lo_sender ).
LOOP AT lt_send_to ASSIGNING FIELD-SYMBOL(<lv_send_to>).
lo_recipient = cl_cam_address_bcs=>create_internet_address( CONV #( <lv_send_to> ) ).
lo_send_request->set_send_immediately( i_send_immediately = 'X' ).
lo_send_request->add_recipient( i_recipient = lo_recipient i_express = 'X' ).
ENDLOOP.
lo_send_request->send( i_with_error_screen = 'X' ).
COMMIT WORK AND WAIT.
CATCH cx_bcs INTO DATA(lo_bcs_exception).
DATA(lv_message) = lo_bcs_exception->get_text( ).
WRITE:/ lv_message.
RETURN.
ENDTRY.
ENDFUNCTION.
After that I create a new product and save it:
Then I will receive a mail in my inbox immediately:
How to debug the event listener
If you set a breakpoint within the event listener function module it will never get triggered, as it is called via transaction RFC as default maintained in tcode SWE2. If you write an “ASSERT 1 = 0” in it, you can observe that it is executed with user WF-BATCH which is not a dialog user so you cannot debug directly.
The solution for debug is rather simple, before the event is really raised, set the value of me->m_process_mode to “D” ( debug mode ) in method below:
After that your listener function module will be executed via normal way instead of tRFC, you can then now directly click F5 to debug into the function module.
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
相关推荐
Bor开发工具Bor开发工具Bor开发工具Bor开发工具Bor开发工具
2.BAPIs 实现了BOR中业务对象的方法 3.BAPIs 通过RFC-enable的功能模块实现。 4.用户可以自行开发新的BAPI以满足业务需求。 5.BAPI是sap提供的基于业务对象的函数,它处理的对象是r/3的业务相关business object, ...
20210617-华西证券-科大讯飞-002230-千亿营收,2Bor2C?.pdf
bor,Day(植树节).doc
BOR引擎(BORE)是《随机性》(http://www.bookofrandom.co.uk/)的源代码,它允许任何人以与《随机性》相似的格式创建网站。
枳BOR基因家族的克隆与缺硼胁迫下的表达分析,颜廷帅,罗庆,为了揭示柑橘砧木枳[Poncirus trifoliata (L.) Raf.]BOR基因家族各成员与硼运输的关系,本实验克隆获得枳BOR基因家族成员进行生物信息学分析�
具有gui界面的pls的toolbox for matlab
在PIC系列单片机中,有许多型号内部就集成了这项功能(BOR)电路,如PIC16F87X。因此,对于PIC单片机的开发者来说,就可以免用外加专用集成电路,降低了成本,简化了电路。 掉电锁定复位时序如图1所示,图中均...
颞bor
用于画空间旋转动态图形,包括圆、圆环、椭圆、正方体、圆台,圆锥等等,空间动态生成,效果明显。
该研究比较了两个地点(雅温得和Ntui)因稻bore引起的影响。 它还显示了喀麦隆南部(桑乔,恩多普,汤加,埃博洛瓦,巴戈姆,雅温得和恩图伊)非洲稻Gall(AfRGM)生物型的多样性。 Ntui播种的非洲新稻(NERICA)3、...
BaB2S4: Das erste nicht-oxidische Chalkogenoborat mit trigonal-planar und tetraedrisch koordiniertem Bor BaB2S4: Das erste nicht-oxidische Chalkogenoborat mit trigonal-planar und tetraedrisch ...
data server join server fully source webzen
该状态位在复位后仍然有效,并允许程序检测到问题并执行其他恢复或记录事件。 如果BOR被禁用会怎样?一般情况下,其表现为电源电压稳定下降。至于原因,可能是电源老化或电池放电。 如上图所示,V1是正常电源...
触发事件(计数器启动、停止、初始化或通过内部/外部触发计数) 输入捕捉 输出比较匹配 关断输入 一路高速异步收发器UART - 支持异步全双工收发 - 支持8 位/9位数据格式 - 约定数据从最低位...
BoR:在启用RDMA的网络中迈向高性能许可的区块链
Bor- und Stickstoffeinbau: AIIIBV -Mischkristallbildung bei der metallorganischen Gasphasenepitaxie auf (001) GaAs Substraten Kurzvorträge Bor- und Stickstoffeinbau: AIIIBV- Mischkristallbildung ...
Synthese, Röntgenstrukturanalyse und Multikern-NMR-spektroskopische Untersuchung einiger intramolekular stickstoffstabilisierter Bor-, Aluminium- und Galliumorganyle Synthese, RoÈ ...
本文实例讲述了jQuery实现鼠标移入移出事件切换功能。分享给大家供大家参考,具体如下: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> [removed][removed] <style> #...
B2Si2O6 - ein amorphes anorganisches Netzwerk mit Si-Si-Bindungen B2Si2O6 ± ein amorphes anorganisches Netzwerk mit ... Durch die Umsetzung von Si2Cl6 mit Bor- saÈure in abs. Dioxan gelang die Darst