Adding message to document

Problem: You want to add a message to the CRM document from a custom report.

Solution: There is a standard FM available for this purpose. The use of it is quite simple.

  DATA: lv_dummy type string,
        lv_handle TYPE balmsghndl.
 
  MESSAGE w028(CRM_ACTIVITY_I) WITH 'test product' into lv_dummy.
  CALL FUNCTION 'CRM_MESSAGE_COLLECT'
    EXPORTING
     iv_caller_name   = 'ORDERADM_H'
     iv_ref_object    = '4CD6FB52061A00E3E10080000AC90570'
     iv_ref_kind      = 'A'
     iv_external_call = 'X'
  IMPORTING
    es_msg_handle     = lv_handle.
  DATA: lv_dummy type string,
        lv_handle TYPE balmsghndl.

  MESSAGE w028(CRM_ACTIVITY_I) WITH 'test product' into lv_dummy.
  CALL FUNCTION 'CRM_MESSAGE_COLLECT'
    EXPORTING
     iv_caller_name   = 'ORDERADM_H'
     iv_ref_object    = '4CD6FB52061A00E3E10080000AC90570'
     iv_ref_kind      = 'A'
     iv_external_call = 'X'
  IMPORTING
    es_msg_handle     = lv_handle.

If message is being added in the User-Exit or BADI, in the middle of process of document creation, nothing else is needed. Even more – log should not be saved as it will be overwritten.

If message is being added from an external report, message log needs to be saved, using below code:

  CALL METHOD cl_log_ppf=>save_log
    EXPORTING
      ip_loghandle = lv_handle-log_handle.
  CALL METHOD cl_log_ppf=>save_log
    EXPORTING
      ip_loghandle = lv_handle-log_handle.

Komentowanie jest zakończone.