cancel
Showing results for 
Search instead for 
Did you mean: 

CRM Contract Cancel Bapi/Method

NU
Explorer
0 Kudos
379

Dear Experts,

I'm trying to cancel a contract through a specific z button in view BT126H_APPT/ApptOVViewset. I've created the button and created the event that is already called.

The question is regarding the cancel process. I was going to use the following class CL_CRM_IU_PR_CNTR_END_HD, but indeed in method start it should pass a context of type IF_CRM_IU_PROCES_CTXT that i'm unable to get it.

I believe that the process cancelation should be called by a process, maybe by the process manager, but how can i do this?

Can you help me how can i get this context or use a BAPI, i saw BAPI_BUSPROCESSND_CREATEMULTI. Is this possible through this BAPI?

Thanks.

View Entire Topic
ceedee666
Active Contributor
0 Kudos

Hi Nazir,

as you are enhancing component BT126H_APPT the first question is what type of contract do you want to cancel? Is it really a utilities contract? The reason I'm asking this is, that the class CL_CRM_IU...HD is specific for ending (not canceling) utilities contracts. If you have any other contract type at hand this class will therefor not be useful.

Christian

NU
Explorer
0 Kudos

Hi Christian,

Indeed it is a utilities contract so i believe that it should be used this class. How can i start the process?

Thanks.

ceedee666
Active Contributor
0 Kudos

Hi Nazir,

using the process framework outside the standard components for the handling of utilities contracts (e.g. IUICCON) is a little tricky. Therefore, I wanted to make sure you indeed need to use this class. I wanted to write a blog on how to do this for quite some time. So maybe your question will be the trigger to finally do it .

If you want to see how the SAP standard uses the process classes see component IUICCON. What you need to do in you case is the following:

1. Instantiate the process manager using the contract item or header and a process profile

    proc_mgr = cl_crm_iu_process_mgr=>get_instance ( item_guid  = item_guid

                                                                                 profile_id = 'DEFAULT' ).

2. Check if the process category (in the example below 'IUMO', the category id for the process CONTRACT_START_CANCEL in the DEFAULT process profile) you want to execute is executable

     is_executable = proc_mgr->is_executable( category_id = 'IUMO' ).

3. Execute the process. This will execute the process class that is customized for the process profile and category_id and return the BOL objects that need to be saved.

     proc_mgr->start(

        EXPORTING

          category_id          = 'IUMO'

        IMPORTING

          objects_to_be_saved  = objects_to_be_saved ).

Afterwards you need to save the BOL objects using the BOL transactions.

Best,

Christian

NU
Explorer
0 Kudos

Hi Christian,

Thank you for your reply.

I'm implementing with the above methods but when the start method is executed is not returning any objects to save. Inside the debug it gives an error when check:

* check repository

   try.

       success = me->execute_checks(

                   execution_time = if_crm_iu_process_check=>co_exec_time_start

                   validation     = if_crm_iu_process_check=>co_validation_before

                   assignment     = if_crm_iu_process_check=>co_assignment_head

                   context        = context

                   log_access     = context->log_access ).

This is what i'm doing:

      lr_proc_mgr = cl_crm_iu_process_mgr=>get_instance( item_guid  = ls_items-guid "Item of the contract

                                                       profile_id = 'DEFAULT' ).

DATA: lv_is_executable TYPE abap_bool.

       lv_is_executable = lr_proc_mgr->is_executable( category_id = zcl_cx_contracts_utility=>gc_contract_category )."IUMO

       DATA: lr_objects_save TYPE REF TO if_bol_bo_col.

       CHECK lv_is_executable = abap_true.

       lr_proc_mgr->start(

             EXPORTING

               category_id          = zcl_cx_contracts_utility=>gc_contract_category "IUMO

             IMPORTING

               objects_to_be_saved  = lr_objects_save ).

What is wrong or what is missing?

Anther issue if i need to change the dates that the cancel should apply how can that be changed?

Thank you.

ceedee666
Active Contributor
0 Kudos

Hi Nazir,

unless you already implemented checks using the new utilities check framework, the error in

me->execute_checks

should be no problem. AFAIK there is an exception raised if no checks are defined. Instead, please check if an error occurs in the different methods of class CL_CRM_IU_PR_CNTR_END_HD and CL_CRM_IU_PR_CNTR_END.


To change the date simply set the date ISURQCONTEND on the contract item after the creation of the process manager.


Christian

NU
Explorer
0 Kudos

Thank you Christian,

With your input it was possible to execute the process.

It is possible to retrieve the error messages with cl_crm_isu_order_check=>message_read with FM  CRM_MESSAGES_GET_MSG_INFO.

The start and end process methods should be called.

Thanks.