Skip to Content

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

ppf 1.JPG

Choose Filter Value – Create

ppf 2.png

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

ppf 3.JPG

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

ppf 4.JPG

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

ppf 5.JPG

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:

ppf 6.JPG

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

ppf 7.JPG

3.Choose start condition filter created in point 1

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

ppf 8.JPG

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

ppf 9.JPG

4.Define parameter PARTNER_CHANGE

Now we need to add Parameter

ppf 10.JPG

Initial Value SMCD0001 – Developer

ppf 11.JPG

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 😉

To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

  1. S1nth Reddy P

    Thanks for the wonderful post,

    could you please guide me using EVAL_SCHEDCOND_PPF badi how to send SMS to a customer when the status changed(for email you have used smart form mail for SMS which option to be used and also please suggest the classes and methods required)

    (0) 
    1. Daniyar Kulmanov Post author

      Hi Reddy, Thank you for nice reply. First to which type of transaction you want this? incidents or Charm documents. Second if you want this to be triggered when status is changed use EVAL_STARTCOND_PPF there is already condition delivired by standard AI_STATUS_CHANGED Define Parameter in start condition Element          STATUS_CHANGE Name              STATUS_CHANGE Short Descript.  STATUS_CHANGE ABAP Dict. Data Type Type Name  FLAG Third and last about SMS check this threads http://scn.sap.com/thread/1405093 http://sappandit.wordpress.com/2009/05/03/sms-setting-in-sap-scot-configuration-for-sms/ BR Dan

      (0) 
  2. Peter Weigel

    Hi Daniyar,


    there are three SAP standard solutions to enhance PPF Action conditions. Using BADI CONTAINER PPF is one of them. Using BADI EVAL_SCHEDCOND_PPF or EVAL_STARTCOND_PPF is another solution.


    However, the most simplest solution is to enhance the BOR object providing context sensitive attributes which can be combined and evalutated. In most cases the enhancement can be done without development. In my opinion this solution is the most consultant friendly one.


    Because I could not find any guide explaining this solution in a good  and development free manner, I created an own one. Please be free to use it too.


    http://www.hybrid-eichhoernchen.de/ppf-action-condition-enhancement/


    Kind regards,
    Peter

    (0) 

Leave a Reply