This enhancement is required to connect the Dynamic Work Centre with the standard BPEM functionality provided by SAP and/or the Assignments History feature of both the DWC and BDEx Customer-centric Hub. It is essential that this enhancement catches and maintains the underlying BWC database tables in line with updates to the EMMA Case Header fields and assignments changes otherwise the DWC and/or the Assignments History feature will become disconnected from the work routed to agents.

Since SAP has built their BPEM Solution to allow for Cases to be created manually and also in batch the additional logic required to keep the BWC tables up to date requires the following Methods to be adjusted:

CREATE_CASES – Post Exit needed to ensure a new entry is added to the main BWC Work Request Header Table /BTI/MDE_BWC_WRH for each new BPEM Case being created.
Note: When called in Batch mode this Method may also be provided Agent Assignments up front which will need to be captured in the BWC Assignments table /BTI/MDE_BWC_ASN.

CHANGE_CASE – Post Exit required to modify the existing entry in the BWC table /BTI/MDE_BWC_WRH and keep it in line with any changes made to the EMMA Case header fields. If any Agent Assignment changes have occurred these will also need to be stored in the BWC Assignments table /BTI/MDE_BWC_ASN.

CHANGE_CASE_HEADER – Post Exit required to modify the existing entry in the BWC table /BTI/MDE_BWC_WRH and keep it in line with any changes made to the EMMA Case header fields. If any Agent Assignment changes have occurred these will also need to be stored in the BWC Assignments table /BTI/MDE_BWC_ASN.

CHANGE_CASE_ACTORS – Post Exit required to capture any Agent Assignment changes and cascade them to the BWC Assignments table /BTI/MDE_BWC_ASN.

DELETE_CASES – An Overwrite Exit is required to ensure database integrity and sequencing of updates to allow for the BPEM and BWC tables to be deleted in a logical order.

Method Type Description
CHANGE_CASE PostExit Update BWC Tables with new details and possibly new Processors if required
CHANGE_CASE_HEADER PostExit Update BWC Tables with new details and possibly new Processors if required
CREATE_CASES PostExit Update BWC Tables with new details and Actors
DELETE_CASES Overwrite-Exit Delete BWC Table entries in line with updates to EMMA Tables
CHANGE_CASE_ACTORS PostExit Update BWC Assignments tables

The following sample code should be used as a guide:

CLASS lcl_zbwc_emma_dbl46 DEFINITION DEFERRED.
CLASS cl_emma_dbl46 DEFINITION LOCAL FRIENDS lcl_zbwc_emma_dbl46.
———————————————————————————————————

  • CLASS LCL_ZBWC_EMMA_DBL46 DEFINITION

———————————————————————————————————
*
———————————————————————————————————
CLASS lcl_zbwc_emma_dbl46 DEFINITION. PUBLIC SECTION. CLASS-DATA obj TYPE REF TO lcl_zbwc_emma_dbl46. “#EC NEEDED DATA core_object TYPE REF TO cl_emma_dbl46 . “#EC NEEDED INTERFACES: IPO_ZBWC_EMMA_DBL46, IOW_ZBWC_EMMA_DBL46. METHODS: constructor IMPORTING core_object TYPE REF TO cl_emma_dbl46 OPTIONAL.
ENDCLASS. “LCL_ZBWC_EMMA_DBL46 DEFINITION
———————————————————————————————————
  • CLASS LCL_ZBWC_EMMA_DBL46 IMPLEMENTATION

———————————————————————————————————
*
———————————————————————————————————
CLASS lcl_zbwc_emma_dbl46 IMPLEMENTATION. METHOD constructor. me->core_object = core_object. ENDMETHOD. “CONSTRUCTOR METHOD iow_zbwc_emma_dbl46~delete_cases. “———————————————————————————————————— *” Declaration of Overwrite-method, do not insert any comments here please! *” *“methods DELETE_CASES *” importing *” !IV_EMMARUNID type EMMA_RUNID optional *” !IV_INTNR type EMMA_INTNR optional *” exceptions *” NOT_DELETED *” NOT_FOUND . “———————————————————————————————————— DATA lt_emma_case TYPE STANDARD TABLE OF emma_case WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0. FIELD-SYMBOLS: TYPE emma_case. DATA: ls_emma_hdr TYPE emma_hdr. DATA: co_obj TYPE balobj_d VALUEEMMA’. DATA: co_subobj TYPE balsubobj VALUECASE’. DATA: lv_extnum TYPE balnrext. DATA: lt_emma_int TYPE STANDARD TABLE OF emma_int WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0. DATA: ls_emma_int TYPE emma_int. DATA: ls_bal_fil TYPE bal_s_lfil, lt_extnum TYPE bal_r_extn, ls_extnum TYPE bal_s_extn, lt_obj TYPE bal_r_obj, ls_obj TYPE bal_s_obj, lt_subobj TYPE bal_r_sub, ls_subobj TYPE bal_s_sub, lt_balhdr TYPE balhdr_t, ls_balhdr TYPE balhdr, ls_log TYPE bal_s_log, ls_data TYPE emma_case, ls_context TYPE emma_case_context, lt_loghandle TYPE bal_t_logh, lv_biw TYPE boole_d, ls_biw TYPE biw_emma_case, lt_biw TYPE TABLE OF biw_emma_case, lv_wr_key TYPE /bti/mde_de_wr_key.
  • update EMMA_HDR and EMMA_INT only as long as classic EMMA is still calling method SELECT SINGLE * FROM emma_hdr INTO ls_emma_hdr WHERE runid = iv_emmarunid.
IF iv_intnr IS INITIAL.
  • read all intervals SELECT * INTO TABLE lt_emma_case FROM emma_case WHERE runid = iv_emmarunid. ELSE. SELECT * INTO TABLE lt_emma_case FROM emma_case WHERE runid = iv_emmarunid AND intnr = iv_intnr.
  • read only one interval ENDIF. IF sy-subrc <> 0. IF ls_emma_hdr-version < cl_emma_job=>co_version_5.
  • update EMMA_HDR and EMMA_INT only as long as classic EMMA is still calling method UPDATE emma_hdr SET emma_case = 0 cgen_status = ‘0’ WHERE runid = iv_emmarunid. UPDATE emma_int SET emma_case = 0 cgen_status = ‘0’ WHERE runid = iv_emmarunid. ENDIF. RAISE not_found. ENDIF.
  • don’t delete manual cases IF ls_emma_hdr-emma_jobrustatus = ‘4’. “cl_emma_job=>co_job_status_comp_no_del. RAISE not_deleted. ENDIF.
  • all cases need to be in status NEW or CANCELLED LOOP AT lt_emma_case ASSIGNING . CHECK -status NE cl_emma_case=>co_status_new AND -status NE cl_emma_case=>co_status_canc. RAISE not_deleted. ENDLOOP.
DELETE emma_case FROM TABLE lt_emma_case. LOOP AT lt_emma_case ASSIGNING . DELETE FROM emma_cactor WHERE casenr = -casenr. DELETE FROM emma_cmsg_link WHERE casenr = -casenr. DELETE FROM emma_cobject WHERE casenr = -casenr. DELETE FROM emma_csolp WHERE casenr = -casenr. DELETE FROM stxh WHERE tdobject = cl_emma_case=>co_text_obj AND tdname = -casenr AND tdid = cl_emma_case=>co_text_idcase. DELETE FROM stxb WHERE relid = ‘TX’ AND tdobject = cl_emma_case=>co_text_obj AND tdname = -casenr AND tdid = cl_emma_case=>co_text_idcase. DELETE FROM stxl WHERE relid = ‘TX’ AND tdobject = cl_emma_case=>co_text_obj AND tdname = -casenr AND tdid = cl_emma_case=>co_text_idcase.
  • Update the BWC tables to cancel any deleted cases. lv_wr_key = -casenr.
UPDATE /bti/mde_bwc_wrh SET status = /bti/mde_cl_bwc_wr_core=>pc_status_cancelled WHERE class = /bti/mde_cl_wr_isu_bpem=>pc_wrclass AND wr_key = lv_wr_key. DELETE FROM /bti/mde_bwc_asn WHERE class = /bti/mde_cl_wr_isu_bpem=>pc_wrclass AND wr_key = lv_wr_key. DELETE FROM /bti/mde_bwc_fwd WHERE class = /bti/mde_cl_wr_isu_bpem=>pc_wrclass AND wr_key = lv_wr_key. ENDLOOP. IF ls_emma_hdr-version < cl_emma_job=>co_version_5.
  • update EMMA_HDR and EMMA_INT only as long as classic EMMA is still calling method UPDATE emma_hdr SET emma_case = 0 cgen_status = ‘0’ WHERE runid = iv_emmarunid. UPDATE emma_int SET emma_case = 0 cgen_status = ‘0’ WHERE runid = iv_emmarunid. ENDIF.
  • check if DataSource 0FCEMMA_CASE is initialized SELECT initstate FROM roosprmsc INTO lv_biw WHERE oltpsource = cl_emma_case=>co_datasource AND initstate = cl_emma_case=>co_true. EXIT. ENDSELECT. IF lv_biw = cl_emma_case=>co_true. “DataSource initialized
  • add delete records to delta table LOOP AT lt_emma_case ASSIGNING . -changed_date = sy-datum. -changed_time = sy-uzeit. -changed_by = sy-uname.
  • fill deltaqueue table for BW MOVE-CORRESPONDING TO ls_biw.
  • add business process area IF NOT -bpcode IS INITIAL. SELECT SINGLE bparea FROM emma_bpc INTO ls_biw-bparea WHERE bpcode = -bpcode. ENDIF.
  • draw new GUID CALL FUNCTIONGUID_CREATE’ IMPORTING ev_guid_16 = ls_biw-delta.
  • mark case as deleted ls_biw-updmode = ‘D’. APPEND ls_biw TO lt_biw. ENDLOOP.
  • insert BW delta records INSERT biw_emma_case FROM TABLE lt_biw. ENDIF.
IF iv_intnr IS INITIAL. UPDATE emma_hdr SET emma_case = 0 cgen_status = 0 WHERE runid = iv_emmarunid. ENDIF.
  • try to find the existing action log for the cases
  • build ranges EXTERNAL_NUMBER CLEAR ls_extnum. ls_extnum-sign = ‘I’. ls_extnum-option = ‘EQ’. ls_extnum-low = iv_emmarunid. APPEND ls_extnum TO lt_extnum.
  • build ranges OBJECT CLEAR ls_obj. ls_obj-sign = ‘I’. ls_obj-option = ‘EQ’. ls_obj-low = co_obj. APPEND ls_obj TO lt_obj.
  • build ranges SUBOBJECT CLEAR ls_subobj. ls_subobj-sign = ‘I’. ls_subobj-option = ‘EQ’. ls_subobj-low = co_subobj. APPEND ls_subobj TO lt_subobj.
  • build filter structure CLEAR ls_bal_fil. ls_bal_fil-extnumber = lt_extnum. ls_bal_fil-object = lt_obj. ls_bal_fil-subobject = lt_subobj.
CALL FUNCTIONBAL_DB_SEARCH’ EXPORTING i_s_log_filter = ls_bal_fil IMPORTING e_t_log_header = lt_balhdr EXCEPTIONS log_not_found = 1 no_filter_criteria = 2 OTHERS = 3. CHECK sy-subrc = 0. CALL FUNCTIONBAL_DB_DELETE’ EXPORTING i_t_logs_to_delete = lt_balhdr EXCEPTIONS no_logs_specified = 1 OTHERS = 2. ENDMETHOD. “IOW_ZBWC_EMMA_DBL46~DELETE_CASES METHOD ipo_zbwc_emma_dbl46~create_cases. “———————————————————————————————————— *” Declaration of POST-method, do not insert any comments here please! *” *“methods CREATE_CASES *” changing *” !CT_CASES type EMMA_CL_CASE_T *” !EV_CASECNT type I *” !EV_OBJCNT type I *” !EV_ACTCNT type I *” !EV_MSGCNT type I *” !EV_SOLPCNT type I *” exceptions *” NO_CASES_CREATED *” ERROR_DRAWING_NEW_CASE_NUMBER *” ERROR_SAVING_TEXT . “———————————————————————————————————— DATA: lr_db TYPE REF TO /bti/mde_cl_bwc_db, lr_case TYPE REF TO cl_emma_case, ls_data TYPE emma_case, lt_act TYPE tswhactor, lr_wr TYPE REF TO /bti/mde_cl_bwc_wr_core. FIELD-SYMBOLS: TYPE REF TO cl_emma_case. CREATE OBJECT lr_db. LOOP AT ct_cases ASSIGNING . ls_data = ->get_data( ). lr_case = core_object->read_case_detail( ls_data-casenr ). ls_data = lr_case->get_data( ). lt_act = lr_case->get_actors( ). CALL METHOD lr_db->load_from_bpem EXPORTING is_case = ls_data it_actors = lt_act RECEIVING rr_bwc_wr = lr_wr. CALL METHOD lr_db->update_db EXPORTING ir_wr = lr_wr EXCEPTIONS update_header_failed = 1 update_assignments_failed = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. CLEAR: ls_data, lt_act[]. ENDLOOP. ENDMETHOD. “IPO_ZBWC_EMMA_DBL46~CREATE_CASES METHOD ipo_zbwc_emma_dbl46~change_case_header. “———————————————————————————————————— *” Declaration of POST-method, do not insert any comments here please! *” *“methods CHANGE_CASE_HEADER *” importing *” !IS_DBCASE type EMMA_CASE *” !IV_WRITE_CDOC type XFELD *” changing *” !CS_CASE type EMMA_CASE *” exceptions *” UPDATE_FAILED . “———————————————————————————————————— DATA: lr_db TYPE REF TO /bti/mde_cl_bwc_db, ls_bwc_wrh TYPE /bti/mde_bwc_wrh, lt_proclog TYPE /bti/mde_tt_bwc_proclog, lr_wr TYPE REF TO /bti/mde_cl_bwc_wr_core, lt_actors TYPE tswhactor.
  • Retrieve the latest case actors SELECT * FROM emma_cactor INTO CORRESPONDING FIELDS OF TABLE lt_actors WHERE casenr = cs_case-casenr.
  • Update the BWC tables CREATE OBJECT lr_db.
CALL METHOD lr_db->load_from_bpem EXPORTING is_case = cs_case is_dbcase = is_dbcase it_actors = lt_actors RECEIVING rr_bwc_wr = lr_wr. ls_bwc_wrh = lr_wr->get_header( ). IF NOT cs_case-currproc IS INITIAL AND NOT cs_case-currproc EQ is_dbcase-currproc. lt_proclog = lr_wr->get_processor_log( ). ENDIF. CALL METHOD lr_db->update_header EXPORTING is_header = ls_bwc_wrh it_processors = lt_proclog EXCEPTIONS update_failed = 1 OTHERS = 2. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDMETHOD. “IPO_ZBWC_EMMA_DBL46~CHANGE_CASE_HEADER METHOD ipo_zbwc_emma_dbl46~change_case. “———————————————————————————————————— *” Declaration of POST-method, do not insert any comments here please! *” *“methods CHANGE_CASE *” importing *” !IR_CASE type ref to CL_EMMA_CASE *” !IR_DBCASE type ref to CL_EMMA_CASE *” exceptions *” ERROR_INSERTING_OBJECTS *” ERROR_UPDATING_CASE *” ERROR_SAVING_TEXT . “———————————————————————————————————— DATA: lr_case TYPE REF TO cl_emma_case, ls_data TYPE emma_case, ls_dbdata TYPE emma_case, lt_act TYPE tswhactor, lr_db TYPE REF TO /bti/mde_cl_bwc_db, lr_wr TYPE REF TO /bti/mde_cl_bwc_wr_core. ls_data = ir_case->get_data( ).
  • Need most up to date version of case, so retrieve from db instead of using ir_case lr_case = core_object->read_case_detail( ls_data-casenr ). ls_data = lr_case->get_data( ).
ls_dbdata = ir_dbcase->get_data( ). lt_act = lr_case->get_actors( ).
  • Use this data to update BWC tables CREATE OBJECT lr_db. CALL METHOD lr_db->load_from_bpem EXPORTING is_case = ls_data is_dbcase = ls_dbdata it_actors = lt_act RECEIVING rr_bwc_wr = lr_wr.
CALL METHOD lr_db->update_db EXPORTING ir_wr = lr_wr EXCEPTIONS update_header_failed = 1 update_assignments_failed = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. ENDMETHOD. “IPO_ZBWC_EMMA_DBL46~CHANGE_CASE METHOD IPO_ZBWC_EMMA_DBL46~CHANGE_CASE_ACTORS. “———————————————————————————————————— *” Declaration of POST-method, do not insert any comments here please! *” *“methods CHANGE_CASE_ACTORS *” importing *” !IR_CASE type ref to CL_EMMA_CASE *” !IT_ACTORS type TSWHACTOR *” exceptions *” ERROR_UPDATING_ACTORS . “———————————————————————————————————— DATA: lr_case TYPE REF TO cl_emma_case, ls_data TYPE emma_case, ls_dbdata TYPE emma_case, lt_act TYPE tswhactor, lr_db TYPE REF TO /bti/mde_cl_bwc_db, lr_wr TYPE REF TO /bti/mde_cl_bwc_wr_core. ls_data = ir_case->get_data( ).
  • Need most up to date version of case, so retrieve from db instead of using ir_case lr_case = core_object->read_case_detail( ls_data-casenr ). ls_data = lr_case->get_data( ). lt_act = lr_case->get_actors( ).
  • Use this data to update BWC tables CREATE OBJECT lr_db. CALL METHOD lr_db->load_from_bpem EXPORTING is_case = ls_data it_actors = lt_act RECEIVING rr_bwc_wr = lr_wr.
CALL METHOD lr_db->update_db EXPORTING ir_wr = lr_wr EXCEPTIONS update_header_failed = 1 update_assignments_failed = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.

ENDMETHOD.
ENDCLASS.

Feedback

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Post your comment on this topic.

Post Comment