cancel
Showing results for 
Search instead for 
Did you mean: 

EMAIL Triggering when status changed

Former Member
0 Kudos

Hi,

Based on the requirement I have customized few actions in SDMI actions. Developer created transport request and completed task. Before trasnport to QAS he needs approval from Change Manager

To be Approved QAS

APPROVED QAS

REJECTED QAS

Status is " To be Approved" - Mail should go to the Change Manager (CM). " Rejected" is performed by CM and status changes to " rejected" these mails are tirggered.Then again developer changed status to " To be Approved " . I want to trigger same mail now to CM. This is not happening

If I set action profiles "Set Highest Number of Processed Actions" When i am in same status (To be approved or Rejected if i saved) mail is triggering it should not trigger because i was not changed status just i am saving.

I want to trigger mails every time when status changed to 'To be approved' or 'Rejected' (multiple times)

How to do this?

Could you please help me on this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Could you pleae send me coding

Thanks

Srinivas

Former Member
0 Kudos

hi Srinivas,

all the actions changing the status of the document have the following method (look for example IN_PROCESS_MJ or TO_BE_TESTED_MJ in profile SDMJ_ACTIONS)

HF_SET_STATUS of the badi EXEC_METHODCALL_PPF

by implementing your own method (once) you can send you email there

Basically a copy of CL_IM_CHM1_HF_CHECK_SET

at the beginning (data declaration) just define the variables you need for your smart form

rename the parameter in your own parameter name (xxxx is our company name for exampleà

in the line

WHEN 'HF_SET_STATUS" rename into WHEN 'ZxxxxSET_STATUS '

Just before the line Write success notice into text body insert the code that will send the smartform there (The logic of the smartform construction is defined in the smartform itself, I can send you also some sample)

There are different ways to do this in object programming (and I am not sure the implementation the programmer did was the best ) but this one is working


*put here the mail generation
               LOOP AT lt_container INTO ls_container
               WHERE element EQ 'SMARTFORM'.

               ENDLOOP.
               IF sy-subrc EQ 0.
                lv_smart_form = ls_container-value.
               else.
                lv_smart_form = 'Z_CRM_xxxx_GENERIC_MAIL'.
               endif.
               lwa_control_parameters-device = 'MAIL'.
               lwa_control_parameters-no_dialog = 'X'.
               lwa_output_options-tdarmod = 1.
               lwa_output_options-tdtitle = lv_smart_form.

               CALL METHOD ZCL_xxxx_CRM_SEND_MAILS=>CRM_HTML_SMART_FORM
                 EXPORTING
*                is_archive_index        = archive_index
                    is_control_parameters   = lwa_control_parameters
                    is_output_options       = lwa_output_options
                    io_appl_object          = io_appl_object "io_appl_ref
                    ip_smart_form           = lv_smart_form
*                    io_partner              = partner
*                    ip_user_settings        = user_settings
*                    is_mail_recipient       = mail_recipient-recipient
*                    is_mail_sender          = mail_sender
*                    ip_application_log      = l_protocol_handle
                 IMPORTING es_document_output_info = lwa_document_output_info
                    es_job_output_info      = lwa_job_output_info
                    es_job_output_options   = lwa_job_output_options
                    et_error_tab            = lit_error_tab
                 CHANGING  ct_archive_index_tab    = lit_archive_index_tab
                .
              ENDIF.
            ENDIF.

I am not a programmer but this should make sense to a "real" programmer

In the above code we copied the class CL_DOC_PROCESSING_CRM_ORDER (transaction SE24) into the the class ZCL_xxxx_CRM_SEND_MAILS

I hope you it helps

best regards Xavier

Former Member
0 Kudos

Hi Xavier,

I tried to implement your solution in our System:


                ...
 
                LOOP AT lt_container INTO ls_container
                WHERE element EQ 'SMARTFORM'.
 
                ENDLOOP.
                IF sy-subrc EQ 0.
                  lv_smart_form = ls_container-value.
                else.
                  lv_smart_form = 'Z_CRM_SIDB_GENERIC_MAIL'.
                endif.
                lwa_control_parameters-device = 'MAIL'.
                lwa_control_parameters-no_dialog = 'X'.
                lwa_output_options-tdarmod = 1.
                lwa_output_options-tdtitle = lv_smart_form.
 
                CALL METHOD ZCL_SIDB_CRM_SEND_MAILS=>CRM_ORDER_EXEC_SMART_FORM
                  EXPORTING
*               IS_ARCHIVE_INDEX        =
*               IS_ARCHIVE_PARAMETERS   =
                    IS_CONTROL_PARAMETERS   = lwa_control_parameters
                    IS_OUTPUT_OPTIONS       = lwa_output_options
                    IO_APPL_OBJECT          = io_appl_object
                    IP_SMART_FORM           = lv_smart_form
*               IS_MAIL_APPL_OBJ        =
*               IS_MAIL_RECIPIENT       =
*               IS_MAIL_SENDER          =
*               IO_PARTNER              =
*               IP_USER_SETTINGS        =
*               IP_APPLICATION_LOG      =
                  IMPORTING
                    ES_DOCUMENT_OUTPUT_INFO = lwa_document_output_info
                    ES_JOB_OUTPUT_INFO      = lwa_job_output_info
                    ES_JOB_OUTPUT_OPTIONS   = lwa_job_output_options
                    ET_ERROR_TAB            = lit_error_tab
                  CHANGING
                    CT_ARCHIVE_INDEX_TAB    = lit_archive_index_tab
                  .
*
                 ...

Unfortunately no mail is produced. The Problem seems to be, that no sender and recipient information is transfered to the method CRM_ORDER_EXEC_SMART_FORM. I have an idea how to create a sender but no idea how to read the partner determination for the action and then derive the recipient.

Can you help?

I guess, you do this things in your method CRM_HTML_SMART_FORM.

Best regards,

Peter

Former Member
0 Kudos

hi Peter,

you are totally correct (I am not a programmer and I called mine for this info)

This is done in the method CRM_HTML_SMART_FORM of your new class

Please find some piece of code that might help you


* read partners
*read message partner
*get used partnersets of document
  CALL FUNCTION 'CRM_GET_ALL_LINKS'
    EXPORTING
      iv_guid_hi     = LV_OBJECT_GUID
      iv_objname_hi  = gc_object_name-orderadm_h
      iv_objname_set = gc_object_name-partner
    IMPORTING
      et_link        = lt_link
    EXCEPTIONS
      OTHERS         = 0.

  DELETE lt_link
    WHERE objname_set NE gc_object_name-partner.

  read table lt_link into lv_link index 1.


*read the new partners of document

  lwa_ref_object-guid  = LV_OBJECT_GUID.
  INSERT lwa_ref_object INTO TABLE lit_ref_objects.

  CALL FUNCTION 'CRM_PARTNER_READ_MULTI_OB'
    EXPORTING
      it_ref_objects  = lit_ref_objects
    IMPORTING
      et_external_wrk = lit_partners_sorted
      ET_WRK    = lit_PARTNERs_WRKT
      ET_PARTNER_COM = lit_PARTNERs_COMT

      .

  lit_partners_std = lit_partners_sorted.
*not the same key
  sort lit_partners_std by partner_fct.
  lit_partners = lit_partners_std.

And also here how to read the email


*read smtp address for each recipient
    select ADDRNUMBER PERSNUMBER SMTP_ADDR
           into table lit_smtps
           from adr6
           for all entries in lit_receivers
           where ADDRNUMBER = lit_receivers-ADDR_nr
             and PERSNUMBER = lit_receivers-addr_np

I hope it helps

br Xavier

Former Member
0 Kudos

Hi Xavier,

thank you for the quick answer. It was very helpful and our solution works now.

Best regards,

Peter

Edited by: Peter Klatthaar on May 8, 2009 11:03 AM

Former Member
0 Kudos

I have implemented your solution

lv_smart_form = 'Z_CHARM_EMAIL'.

lwa_control_parameters-device = 'MAIL'.

lwa_control_parameters-no_dialog = 'X'.

lwa_output_options-tdarmod = 1.

lwa_output_options-tdtitle = lv_smart_form.

Former Member
0 Kudos

I have tried your solution

lv_smart_form = 'Z_CHARM_EMAIL'.

lwa_control_parameters-device = 'MAIL'.

lwa_control_parameters-no_dialog = 'X'.

lwa_output_options-tdarmod = 1.

lwa_output_options-tdtitle = lv_smart_form.

CALL METHOD ZCL_DOC_PROCESSING_CRM_ORDER=>CRM_ORDER_EXEC_SMART_FORM

EXPORTING

  • IS_ARCHIVE_INDEX =

  • IS_ARCHIVE_PARAMETERS =

IS_CONTROL_PARAMETERS = lwa_control_parameters

IS_OUTPUT_OPTIONS = lwa_output_options

IO_APPL_OBJECT = io_appl_object

IP_SMART_FORM = lv_smart_form

  • IS_MAIL_APPL_OBJ =

  • IS_MAIL_RECIPIENT =

  • IS_MAIL_SENDER =

  • IO_PARTNER =

  • IP_USER_SETTINGS =

  • IP_APPLICATION_LOG =

IMPORTING

ES_DOCUMENT_OUTPUT_INFO = lw_doc_info

ES_JOB_OUTPUT_INFO = lw_job_info

ES_JOB_OUTPUT_OPTIONS = lw_job_opt

ET_ERROR_TAB = lit_error_tab

CHANGING

CT_ARCHIVE_INDEX_TAB = lit_archive_index_tab .

But no mail is produced.Problem seems to be no sender and recipient information is transfered to the method CRM_ORDER_EXEC_SMART_FORM.Can you give me idea how to create sender and derive the reciepent information

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi xavier,

Thanks its woking

Srinivas

Former Member
0 Kudos

hello,

We have implemented the same in our company and it is working fine but with another solution.

The mechanism is different in CHARM and support-desk.

In support desk you can easily capture status changes because the user is doing it himself

In CHARM the actions are changing the status, not the user directly. The capture of the status change is happening before the actions. Thus when an action will trigger a status change it is too late to capture the status change and trigger the email.

That means that we need to trigger the mail sending by actions and not by status changes.

When you do this you don't send an email each time a SDMJ is in a specific status

If needed I can send you the coding principle. I don't know if I can disclose this development like this

I hope you understand the difference between the solutions

best regards

Xavier