Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

We all use E-mail notifications in Solman, but not always all standard features satisfy our requirements. This blog will explain how you can make own Schedule/Start condition checks via PPF BADI for sending Emails.

Schedule condition - EVAL_SCHEDCOND_PPF

Start condition - EVAL_STARTCOND_PPF - this will be covered here

* Note EXEC_METHODCALL_PPF - is available also, but this type BADI will cost you more coding

          CONTAINER_PPF - only works if you use BOR objects, possible in ITSM but not for Charm ( requires BOR objects skills ).

Example Scenario: Normal Change send email to Developer when Developer Changed.

Steps:

  1. Create Implementation for EVAL_STARTCOND_PPF with
    filter
  2. Create Action with Rule Type Conditions Using Business
    AddIn (BAdI)
  3. Choose start condition filter created in point 1
  4. Define parameter PARTNER_CHANGE
  5. Fill implementation with logic
  6. See results


1. Okay let's start create Implementation for EVAL_STARTCOND_PPF with filter Z*

Launch SE18 choose BADI Name and enter EVAL_STARTCOND_PPF

Choose Filter Value - Create

Give name to Implementation f.e. ZBD_SOLE002_PPF  and filter = ZPARTNER CHANGED and hit confirm

Save changes and activate BADI ( Coding will be covered in next steps )

Ok now we are ready to see this in PPF conditions.

2.Create Action with Rule Type Conditions Using Business AddIn (BAdI)


Tcode SPPFCADM, choose CRM_ORDER and hit Define Action Profiles and Actions

Choose Action profile in our example its a ZMMJ_ACTIONS copied from standard SMMJ, double click Action Definition

Create New action f.e. ZMMJ_MAIL_DEV_CHNGE:

Mark - Scheduled Automatically

Processing when saving document

No restrictions

Partner-Dependent

Rule Type - Conditions Using Business AddIn

Merging and technology look at pic below:

In processing Types you may use standard Email notifications / Class, but in my example Custom used

3.Choose start condition filter created in point 1

Tcode SPPFDETCRM, Application CRM_ORDER, Action Profile ZMMJ_ACTIONS and Mode = Change

Add  ZMMJ_MAIL_DEV_CHNGE and choose Start conditions - find your Z* condition

4.Define parameter PARTNER_CHANGE

Now we need to add Parameter

Initial Value SMCD0001 - Developer

Save all

5.Fill implementation with logic

The final step is coding, its very simple so don't worry much about it

Find you Implementation by same method described in first step use Overview section.

*Note there two FM's used CRM_PARTNER_READ_OW - give all information from buffer and CRM_PARTNER_READ_DB - what is in Database

  Simply compare values


  DATA: lr_crm_order        TYPE REF TO cl_doc_crm_order,
        ls_object          TYPE sibflporb,
        lv_partner_fct     TYPE crmt_partner_fct,
        lv_item_guid        TYPE crmt_object_guid,
        lv_guid            TYPE crmt_object_guid,
        lv_guid_db         TYPE crmt_object_guid,
        lt_partner_db      TYPE crmt_partner_db_tab,
        ls_partner_wrk     TYPE crmt_partner_external_wrk
       .
  ep_rc = 1.
  lr_crm_order  ?= io_context->appl.
  IF lr_crm_order->get_crm_obj_kind( ) = 'A'.
    lv_guid  = lr_crm_order->get_crm_obj_guid( ).
  ELSEIF lr_crm_order->get_crm_obj_kind( ) = 'B'.
    lv_item_guid  = lr_crm_order->get_crm_obj_guid( ).
    CALL FUNCTION 'CRM_ORDERADM_I_READ_OW'
      EXPORTING
        iv_guid        = lv_item_guid
      IMPORTING
        ev_header_guid = lv_guid
      EXCEPTIONS
        item_not_found = 1
        OTHERS         = 2.
  ENDIF.
  CHECK NOT lv_guid IS INITIAL.
  CASE flt_val.
    WHEN 'ZPARTNER CHANGED'.
      CHECK ii_container IS NOT INITIAL.
      CALL METHOD ii_container->get_value
        EXPORTING
          element_name = 'PARTNER_CHANGE'
        IMPORTING
          data         = lv_partner_fct.
      CHECK lv_partner_fct IS NOT INITIAL.
      SELECT SINGLE guid FROM crmd_orderadm_h INTO lv_guid_db WHERE  guid = lv_guid .
*        Read Main Partner from Buffer
      CALL FUNCTION 'CRM_PARTNER_READ_OW'
        EXPORTING
          iv_ref_guid          = lv_guid
          iv_ref_kind          = 'A'
          iv_partner_fct       = lv_partner_fct
          iv_mainpartner_only  = 'X'
        IMPORTING
          es_partner_wrk       = ls_partner_wrk
        EXCEPTIONS
          error_occurred       = 1
          parameter_error      = 2
          entry_does_not_exist = 3
          OTHERS               = 4.
      IF sy-subrc <> 0.
        "Issue with Buffer
      ENDIF.
*        Read Partners from Database
      CALL FUNCTION 'CRM_PARTNER_READ_DB'
        EXPORTING
          iv_ref_guid                   = lv_guid
          iv_ref_kind                   = 'A'
        IMPORTING
          et_partner_db                 = lt_partner_db
*         ET_ATTRIBUTES_DB              =
*         ET_CUST_ATTRIBUTES_DB         =
*         ET_CUST_RELATIONS_DB          =
        EXCEPTIONS
          entry_does_not_exist          = 1
          record_not_found              = 2
          at_least_one_record_not_found = 3
          parameter_error               = 4
          OTHERS                        = 5.
      IF sy-subrc <> 0.
        "Issue with Buffer
      ENDIF.
** Compare Partners from Buffer and DB
      READ TABLE lt_partner_db WITH KEY partner_no = ls_partner_wrk-bp_partner_guid partner_fct = lv_partner_fct TRANSPORTING NO FIELDS.
      IF sy-subrc = 0.
        ep_rc = 4.
      ELSE.
        ep_rc = 0.
      ENDIF.
    WHEN OTHERS.
  ENDCASE.




6.See results

Okay we done, don't forget to activate BADI.

Launch SM_CRM find or create new Normal Change, after this try to change Developer.

Each time you change it email will go to New Developer when saving document.

p.s. for the EVAL_SCHEDCOND_PPF methodology is same.

Have fun using it :wink:

6 Comments
Labels in this area