Quantcast
Channel: SCN : Unanswered Discussions - SAP Solution Manager
Viewing all articles
Browse latest Browse all 5299

Unable to update message processor field via crm_order_maintain

$
0
0

We have a requirement to programmatically change/insert the “Message Processor” field on a Solman Incident. Our system is SAP Solman 7.0

I am using CRM_ORDER_MAINTAIN function module for this purpose. Unfortunately, the message processor field is not getting updated. I am not getting any errors or exceptions. I am herewith attaching the code I have written to change the message processor on the incident.

Kindly suggest what changes I need to make to ensure the processor field is successfully updated.

 

Code:

 

REPORT  Z_TEST.
Tables: crmd_orderadm_h.
DATA: lv_header_guid    TYPE crmt_object_guid,
       IT_HEADER_GUID   
type CRMT_OBJECT_GUID_TAB,
       IT_ORDERADM_H    
type CRMT_ORDERADM_H_WRKT,
       it_partner       
type CRMT_PARTNER_EXTERNAL_WRKT,
       wa_orderadm_h    
type CRMT_ORDERADM_H_WRK,
       wa_partner       
type CRMT_PARTNER_EXTERNAL_WRK,
       ls_partner
type CRMT_PARTNER_COM,
       lt_partner
type CRMT_PARTNER_COMT,
       ls_input_field
type CRMT_INPUT_FIELD,
       lt_input_field
type CRMT_INPUT_FIELD_TAB,
       ls_fieldname
type CRMT_INPUT_FIELD_NAMES,
       ls_object_to_save
type CRMT_OBJECT_GUID,
       lt_object_to_save
type CRMT_OBJECT_GUID_TAB,
       lt_saved_objects
type CRMT_RETURN_OBJECTS,
       lt_objects_not_saved
type CRMT_OBJECT_GUID_TAB,
       lt_exceptions
type CRMT_EXCEPTION_T.
DATA lt_guidlist TYPE crmt_object_guid_tab.
SELECTION-SCREEN BEGIN OF BLOCK transaction WITH FRAME TITLE text-001.
select-options s_idnum for crmd_orderadm_h-object_id.PARAMETERS: p_procsr TYPE CRMT_PARTNER_NO.
SELECTION-SCREEN END OF BLOCK transaction.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
 
EXPORTING
   
INPUT         = p_procsr
IMPORTING
  
OUTPUT        = p_procsr
          .

SELECT guid INTO TABLE lt_guidlist
                   
FROM crmd_orderadm_h WHERE process_type = 'SLFN' AND object_id in s_idnum.
if sy-subrc is initial.

 
loop at lt_guidlist into lv_header_guid.
insert lv_header_guid into it_header_guid index 1.
* Fetch the details from the incident
 
CALL FUNCTION 'CRM_ORDER_READ'
  
EXPORTING
     IT_HEADER_GUID                   
= it_header_guid
    
IMPORTING*   ET_ORDERADM_H                     = IT_ORDERADM_H
     ET_PARTNER                       
= it_partner
  
EXCEPTIONS
     DOCUMENT_NOT_FOUND               
= 1
     ERROR_OCCURRED                   
= 2
     DOCUMENT_LOCKED                  
= 3
     NO_CHANGE_AUTHORITY              
= 4
     NO_DISPLAY_AUTHORITY             
= 5
     NO_CHANGE_ALLOWED                
= 6
    
OTHERS                            = 7.
* Get existing processor information from incident and populate* new processor details into lt_partner itab
 
read table it_partner
   
into wa_partner with key REF_PARTNER_FCT = 'SLFN0004'.

 
if sy-subrc is initial.
   
CLEAR: ls_partner, ls_input_field.

    ls_partner
-ref_kind     = wa_partner-ref_kind.
    ls_partner
-ref_handle   = wa_partner-ref_handle.
    ls_partner
-ref_guid     = wa_partner-ref_guid.
    ls_partner
-ref_partner_handle = wa_partner-ref_partner_handle.
    ls_partner
-ref_partner_fct = wa_partner-ref_partner_fct.
    ls_partner
-ref_PARTNER_NO = wa_partner-ref_PARTNER_NO.
    ls_partner
-ref_display_type = wa_partner-ref_display_type.
    ls_partner
-ref_no_type      = wa_partner-ref_no_type.
    ls_partner
-kind_of_entry = 'C'.
    ls_partner
-PARTNER_NO = p_procsr.
    ls_partner
-display_type = 'BP'.
    ls_partner
-no_type      = 'BP'.
    ls_partner
-mainpartner  = 'X'.

   
INSERT ls_partner INTO TABLE lt_partner.

   
CLEAR: ls_input_field.
    ls_input_field
-ref_handle  = wa_partner-ref_handle.
    ls_input_field
-ref_guid    = wa_partner-ref_guid.
    ls_input_field
-ref_kind    = wa_partner-ref_kind.
    ls_input_field
-objectname  = 'PARTNER'.
* Build logical key
    ls_input_field
-logical_key = ls_partner-ref_partner_handle.
    ls_input_field
-logical_key+4 = ls_partner-ref_partner_fct.
    ls_input_field
-logical_key+12 = ls_partner-partner_no.
    ls_input_field
-logical_key+32 = ls_partner-display_type.
    ls_input_field
-logical_key+34 = ls_partner-no_type.
* Populate the fields to be updated
   
CLEAR: ls_fieldname.
    ls_fieldname
-fieldname = 'DISPLAY_TYPE'.
   
APPEND ls_fieldname TO ls_input_field-field_names.
    ls_fieldname
-fieldname = 'KIND_OF_ENTRY'.
   
APPEND ls_fieldname TO ls_input_field-field_names.
    ls_fieldname
-fieldname = 'NO_TYPE'.
   
APPEND ls_fieldname TO ls_input_field-field_names.
    ls_fieldname
-fieldname = 'PARTNER_NO'.
   
APPEND ls_fieldname TO ls_input_field-field_names.


   
INSERT ls_input_field INTO TABLE lt_input_field.
***** Change the processor ****
   
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
     
EXPORTING
        it_partner       
= lt_partner
     
IMPORTING
        et_exception     
= lt_exceptions
     
CHANGING
        ct_input_fields  
= lt_input_field
     
EXCEPTIONS
        error_occurred   
= 1
        document_locked  
= 2
        no_change_allowed
= 3
        no_authority     
= 4
       
OTHERS            = 5.
*** Save the Incident after updating new processor ***
   
clear ls_object_to_save.
   
refresh lt_object_to_save.
    ls_object_to_save
= lv_header_guid.
   
append ls_object_to_save TO lt_object_to_save.
   
CALL FUNCTION 'CRM_ORDER_SAVE'
     
EXPORTING
        it_objects_to_save  
= lt_object_to_save
     
IMPORTING
        et_saved_objects    
= lt_saved_objects
        et_exception        
= lt_exceptions
        et_objects_not_saved
= lt_objects_not_saved
     
EXCEPTIONS
        document_not_saved  
= 1
       
OTHERS               = 2.

   
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

 
else.

   
write: 'Invalid Processor. Please check input value.' .
   
exit.

 
endif.endloop.

Write: 'Message Processor successfully updated'.
ELSE.
 
Write: 'There are no records corresponding to given message number. Please check input'.ENDIF.

 

Best Regards,

JDas


Viewing all articles
Browse latest Browse all 5299

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>