cancel
Showing results for 
Search instead for 
Did you mean: 

copy the order reason from one transaction to another

Former Member
0 Kudos

Hi Experts,

When a service ticket is created from interaction record as a follow up document, I need to copy reason field. I tried using CRM_COPY_BADI. But SUBJECT method of this BADI is not getting triggered. I also tried to use CRM_ORDER_MAINTAIN in ORDERADM_H method of badi, but to use this FM I am not able to get necessary data(use of FM CRM_ORDER_READ to get this data doesn't serve the purpose as it doesn't return any data related to subject profile).

Any help in this regard will be highly appreciated.

Regards,

Vimal

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

I had the same issue, need to copy Reason code from source transaction to follow-up transaction and solved my problem by using IF_EX_CRM_COPY_BADI~ACTIVITY_H the following code.

*&*****************************************************************

*& Tauqir Ahmad Malik

*& Copy Order Reason from source to target transaction

*&*****************************************************************

    DATA: ls_srv_osset_com    TYPE crmt_srv_osset_com2,

          lt_srv_subject_com  TYPE crmt_srv_subject_comt,

          ls_target_osset     TYPE crmt_srv_osset_com1,

          lt_target_osset     TYPE crmt_srv_osset_comt1,

          ls_target_os        TYPE crmt_srv_osset_com.

    FIELD-SYMBOLS <ls_subject> TYPE crmt_srv_subject_com.

**  Read Source OSSET to get subject data

    CALL FUNCTION 'CRM_SERVICE_OS_GET_DATA'

      EXPORTING

        iv_profile_type    = 'F'

        iv_ref_guid        = is_ref_orderadm_h-guid

        iv_ref_kind        = 'A'

      IMPORTING

        es_srv_osset_com   = ls_srv_osset_com

        et_srv_subject_com = lt_srv_subject_com

      EXCEPTIONS

        error_occured      = 1

        invalid_guid       = 2

        invalid_profile    = 3.

    READ TABLE lt_srv_subject_com ASSIGNING <ls_subject> INDEX 1.

    CHECK sy-subrc = 0.

    CLEAR: <ls_subject>-ref_handle,

           <ls_subject>-ref_handle_h,

           <ls_subject>-ref_guid,

           <ls_subject>-ref_guid_h.

**  Replace only GUID and Mode, reset data will be copied

    <ls_subject>-ref_guid =  is_orderadm_h-guid.

    <ls_subject>-mode     = 'A'.

    ls_target_osset-subject         = lt_srv_subject_com.

    ls_target_osset-subject_profile = ls_srv_osset_com-subject_profile.

    ls_target_osset-profile_type    = ls_srv_osset_com-profile_type.

    APPEND ls_target_osset TO lt_target_osset.

    ls_target_os-osset    = lt_target_osset.

    ls_target_os-ref_guid = is_orderadm_h-guid.

    ls_target_os-ref_kind = 'A'.

** maintain reference object + subject

    CALL FUNCTION 'CRM_SERVICE_OS_MAINTAIN_OW'

      EXPORTING

        is_srv_osset_com     = ls_target_os

        iv_external_call     = 'X'

      CHANGING

        ct_input_field_names = ct_inputs_field_names

      EXCEPTIONS

        error_occurred       = 1

        OTHERS               = 2.

As this message is old and you might have solved your issue but I am posting so any one in future can get help from this.

Regards,

Tauqir

robert_kunstelj
Active Contributor
0 Kudos

Take guid of order. Now through CRMD_LINK and CRMD_SRV_OSSET reach table CRMD_SRV_SUBJECT and there you will get order reason. And if you want to read the text, just read table QPCT too.

Regards.

Former Member
0 Kudos

The data will not be availaible in the table as order has not been saved till this point.

robert_kunstelj
Active Contributor
0 Kudos

If I understand you correctly you want to copy reason from preceeding document to the follow up document. So in this case preceeding document is already saved (and data should be in the able) otherwise you can't create follow up. And also in the follow up document the guid is already available at runtime.

Former Member
0 Kudos

Used below code in method IF_EX_CRM_COPY_BADI~ORDERADM_H of BADI to solve the problem

wa_subject-ref_handle = 1.

wa_subject-katalogart = 'A1'.

wa_subject-codegruppe = 'ZAPLCS2'.

wa_subject-code = 'Y04'.

wa_subject-mode = 'A'.

APPEND wa_subject TO lt_subject.

wa_osset-subject = lt_subject.

wa_osset-subject_profile = 'ZAPLST'.

wa_osset-profile_type = 'F'.

APPEND wa_osset TO lt_osset.

wa_service_os_com-osset = lt_osset.

wa_service_os_com-ref_guid = cs_orderadm_h-guid.

wa_service_os_com-ref_kind = 'A'.

wa_field_names-fieldname = 'CONC_KEY'.

APPEND wa_field_names TO lt_field_names.

  • maintain reference object + subject

CALL FUNCTION 'CRM_SERVICE_OS_MAINTAIN_OW'

EXPORTING

is_srv_osset_com = wa_service_os_com

iv_external_call = 'X'

CHANGING

ct_input_field_names = lt_field_names

EXCEPTIONS

error_occurred = 1

OTHERS = 2.

Former Member
0 Kudos

hi, I remeber there is a table CRMD_Subject, which store the subject information of CRM document.

And you can check the program CRM_ORDER_READ in se38, the subject can be read and display in the result list.

Former Member
0 Kudos

As mentioned earlier when we call CRM_ORDER_READ from BADI, it doesn't return any data related to subject profile