Problem: you want to get the definition of the Appointment in CRM document. It might be either Date or Duration. You also want to get the name of the Rule for one of the dates.
Solution: What you need to do is simply call two Function Modules and your task will be complete.
First, you need to get name of the Date Profile associated with the header/item of the document. For this you can use FM CRM_DATES_PROFILENAME_GET_OW. Below is an example for item Appointments:
INCLUDE: crm_direct. DATA: lv_item_guid TYPE crmt_object_guid, lv_profile_name type timecont. CALL FUNCTION 'CRM_DATES_PROFILENAME_GET_OW' EXPORTING iv_ref_guid = lv_item_guid iv_ref_kind = gc_object_kind-orderadm_i IMPORTING ev_profile_name = lv_profile_name EXCEPTIONS error_occurred = 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.
INCLUDE: crm_direct. DATA: lv_item_guid TYPE crmt_object_guid, lv_profile_name type timecont. CALL FUNCTION 'CRM_DATES_PROFILENAME_GET_OW' EXPORTING iv_ref_guid = lv_item_guid iv_ref_kind = gc_object_kind-orderadm_i IMPORTING ev_profile_name = lv_profile_name EXCEPTIONS error_occurred = 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.
When you already have the name of the Date Profile all is left to do is to get its definition. This can be done using FM CRM_DATES_PROFILE_SELECT_CB like so:
DATA: lt_profile_dates TYPE crmt_dates_prf, lt_profile_durations TYPE timetpfdu. * get date profile items' definitions CALL FUNCTION 'CRM_DATES_PROFILE_SELECT_CB' EXPORTING iv_profile_name = lv_profile_name IMPORTING et_profile = lt_profile_dates et_duration = lt_profile_durations.
DATA: lt_profile_dates TYPE crmt_dates_prf, lt_profile_durations TYPE timetpfdu. * get date profile items' definitions CALL FUNCTION 'CRM_DATES_PROFILE_SELECT_CB' EXPORTING iv_profile_name = lv_profile_name IMPORTING et_profile = lt_profile_dates et_duration = lt_profile_durations.
In the LT_PROFILE_DATES and LT_PROFILE_DURATIONS you have all the Dates and Durations associated with the Date Profile from the given document item. Now, you can proceed with further logic of your report/BADI/etc.
Komentowanie jest zakończone.