Skip to Content
author's profile photo Former Member
Former Member

User status using CRM_ORDER_MAINTAIN

Hi There,

I have to change user status for CRM order from my program using FM CRM_ORDER_MAINTAIN.

Can any one please tell me how should I specify parameters for this?

Regards,

Rams.

Add comment
10|10000 characters needed characters exceeded

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2006 at 05:28 AM

    I think you are having difficulty in building paramater tables to pass to CRM_ORDER_MAINTAIN.

    Check the following code and build the parameter tables lt_status & ct_input_fields.

    'E0003' is the user status corresponding to 'completed' for status profile 'CRMACTIV'

    -


    CLEAR: lt_header[].

    INSERT lv_header_guid INTO TABLE lt_header.

    CLEAR: ls_input_fields,ct_input_fields,ct_input_fields[].

    REFRESH lt_input_field_names.

    • Prepare ctinput_fields

    ls_input_field_names-fieldname = 'ACTIVATE'.

    ls_input_fields-ref_handle = '0000000000'.

    INSERT ls_input_field_names INTO TABLE lt_input_field_names.

    ls_input_fields-ref_guid = lv_header_guid.

    ls_input_fields-ref_kind = 'A'.

    ls_input_fields-objectname = 'STATUS'.

    ls_input_fields-logical_key = 'E0003CRMACTIV'.

    ls_input_fields-field_names = lt_input_field_names.

    INSERT ls_input_fields INTO TABLE ct_input_fields.

    • Prepare lt_status1

    ls_status-ref_guid = lv_header_guid. "Guid of Sales Audit

    ls_status-ref_kind = 'A'.

    ls_status-user_stat_proc = 'CRMACTIV'.

    ls_status-ref_handle = '0000000000'.

    ls_status-activate = 'X'.

    ls_status-status = 'E0003'. "Status code for Completed.

    INSERT ls_status INTO TABLE lt_status.

    CALL FUNCTION 'CRM_ORDER_MAINTAIN'

    EXPORTING

    it_status = lt_status

    CHANGING

    ct_input_fields = ct_input_fields

    EXCEPTIONS

    error_occurred = 1

    document_locked = 2

    no_change_allowed = 3

    no_authority = 4

    OTHERS = 5.

    -


    Hope this solves your problem.

    Ideally one should use BAPI_CRMACTIVITY*_CHANGEMULTI to change the status in Activity. But in case you choose to use CRM_ORDER_MAINTAIN my above code may be useful.

    best regards,

    vivek

    Reward points for helpful contributions

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 31, 2006 at 09:39 PM

    Hi,

    You have an example in include LCRM_ACTIVITY_PLAN_UIF08, line 155.

    First You have to complete the status values and then the input_field structure.

    regards,

    MAA

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 01, 2006 at 04:27 AM

    Hi,

    Use the FM CRM_STATUS_MAINTAIN_OW to change the status of your CRM order. This would be the easier way.

    If you want to use CRM_ORDER_MAINTAIN, then handle the internal table CT_ORDERADM_H and specify the MODE parameter in this internal table as B(Change mode).

    Then handle the internal IT_STATUS and specify the values for USER_STAT_PROC, STATUS, ACTIVATE, PROCESS along with REF_GUID and REF_KIND.

    Then call the FM BAPI_TRANSACTION_COMMIT to commit your work.

    Hope this helps.

    Regards,

    Karthik.

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 01, 2006 at 03:36 PM

    Hi Rams,

    <b>Refer the following code and reward points if it helps.</b>

    *&---------------------------------------------------------------------*
    *& Report  YAM_TEST_CONT_END_DATE                                      *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    *&                                                                     *
    *&                                                                     *
    *&---------------------------------------------------------------------*
    
    REPORT  yam_test_cont_end_date                  .
    
    DATA: lit_header_guid TYPE crmt_object_guid_tab,
          lit_appointment TYPE crmt_appointment_comt,
          lit_status_comt TYPE crmt_status_comt,
          wa_status_comt  LIKE LINE OF lit_status_comt.
    
    DATA : lit_ret          TYPE TABLE OF bapiret2,
           lit_obj_to_save  TYPE TABLE OF bapibus20001_guid_dis,
           lit_saved_obj    TYPE TABLE OF bapibus20001_object_id.
    
    DATA: lv_header_guid   TYPE crmt_object_guid,
          lv_item_guid     TYPE crmt_object_guid,
          lv_timestamp(15) TYPE c.
    
    DATA: lit_fname TYPE crmt_input_field_names_tab,
          wa_fname  TYPE crmt_input_field_names.
    
    DATA: lit_input TYPE crmt_input_field_tab,
          wa_input  TYPE crmt_input_field.
    
    DATA: wa_appointment      TYPE  crmt_appointment_com,
          wa_logical_date_key TYPE  crmt_date_logical_date_key.
    
    CONSTANTS: lc_end       TYPE crmt_apptype     VALUE 'CONTEND',
               lc_appt      TYPE crmt_fieldname   VALUE 'APPT_TYPE',
               lc_from      TYPE crmt_fieldname   VALUE 'TIMESTAMP_FROM',
               lc_to        TYPE crmt_fieldname   VALUE 'TIMESTAMP_TO',
               lc_obj       TYPE crmt_object_name VALUE 'APPOINTMENT',
               lc_tzone_from(13) TYPE c           VALUE 'TIMEZONE_FROM',
               lc_tzone_to(11)   TYPE c           VALUE 'TIMEZONE_TO'.
    
    PARAMETER: p_objid TYPE crmt_object_id.
    
    START-OF-SELECTION.
    
    
    * Get the HEADER GUID for the Contract Number
      SELECT SINGLE guid
        INTO lv_header_guid
        FROM crmd_orderadm_h
       WHERE object_id EQ p_objid.
    
    
      CHECK sy-subrc EQ 0.
    
    * Get the Item GUID for the HEADER GUID
      SELECT SINGLE guid
        INTO lv_item_guid
        FROM crmd_orderadm_i
       WHERE header EQ lv_header_guid.
    
      CHECK sy-subrc EQ 0.
    
      APPEND lv_header_guid TO lit_header_guid.
      APPEND lv_header_guid TO lit_obj_to_save.
    
    * Convert System date and time to timestamp
      CONCATENATE sy-datum sy-uzeit INTO lv_timestamp.
    
    * Setting Contract End Date
      MOVE: lv_item_guid          TO wa_appointment-ref_guid,
            'B'                   TO wa_appointment-ref_kind,
            'CONTEND'             TO wa_appointment-appt_type,
            lv_timestamp          TO wa_appointment-timestamp_from,
            lv_timestamp          TO wa_appointment-timestamp_to,
            sy-zonlo              TO wa_appointment-timezone_to,
            sy-zonlo              TO wa_appointment-timezone_from.
    
    * Filling the Input Fields for Appointment
      wa_fname-fieldname = lc_appt.
      INSERT wa_fname INTO TABLE lit_fname.
      CLEAR: wa_fname.
    
      wa_fname-fieldname = lc_from.
      INSERT wa_fname INTO TABLE lit_fname.
      CLEAR: wa_fname.
    
      wa_fname-fieldname = lc_to.
      INSERT wa_fname INTO TABLE lit_fname.
      CLEAR: wa_fname.
    
      wa_fname-fieldname = lc_tzone_from.
      INSERT wa_fname INTO TABLE lit_fname.
      CLEAR: wa_fname.
    
      wa_fname-fieldname = lc_tzone_to.
      INSERT wa_fname INTO TABLE lit_fname.
      CLEAR: wa_fname.
    
      wa_logical_date_key-appt_type = lc_end.
    
      MOVE: lv_item_guid          TO wa_input-ref_guid,
            'B'                   TO wa_input-ref_kind,
            lc_obj                TO wa_input-objectname,
            wa_logical_date_key   TO wa_input-logical_key,
            lit_fname             TO wa_input-field_names.
      APPEND wa_input TO lit_input.
      CLEAR: wa_input, wa_logical_date_key.
    
      APPEND wa_appointment TO lit_appointment.
    
      REFRESH: lit_fname.
      CLEAR:   wa_fname.
    
    * Fill the System Status in status table
      wa_status_comt-ref_guid       = lv_item_guid.
      wa_status_comt-ref_kind       = 'B'.
      wa_status_comt-status         = 'I1401'.
      wa_status_comt-user_stat_proc = 'ZCONTR_I'.
      wa_status_comt-activate       = 'X'.
      INSERT wa_status_comt INTO TABLE lit_status_comt.
    
      CLEAR wa_status_comt.
    
    * Fill input fields for status
      wa_fname-fieldname = 'ACTIVATE'.
      INSERT wa_fname INTO TABLE lit_fname.
      CLEAR: wa_fname.
    
      wa_input-ref_guid      = lv_item_guid.
      wa_input-ref_kind      = 'B'.
      wa_input-objectname    = 'STATUS'.
      wa_input-field_names[] = lit_fname[].
      INSERT wa_input INTO TABLE lit_input.
    
    * Fill the User Status in status table
      wa_status_comt-ref_guid       = lv_item_guid.
      wa_status_comt-ref_kind       = 'B'.
      wa_status_comt-status         = 'E0035'.
      wa_status_comt-user_stat_proc = 'ZCONTR_I'.
      wa_status_comt-activate       = 'X'.
      INSERT wa_status_comt INTO TABLE lit_status_comt.
    
      CLEAR wa_status_comt.
    
    * Fill input fields for status
    
      wa_input-ref_guid      = lv_item_guid.
      wa_input-ref_kind      = 'B'.
      wa_input-objectname    = 'STATUS'.
      wa_input-field_names[] = lit_fname[].
      INSERT wa_input INTO TABLE lit_input.
    
      CALL FUNCTION 'CRM_ORDER_MAINTAIN'
        EXPORTING
          it_appointment    = lit_appointment
          it_status         = lit_status_comt
        CHANGING
          ct_input_fields   = lit_input
        EXCEPTIONS
          error_occurred    = 1
          document_locked   = 2
          no_change_allowed = 3
          no_authority      = 4
          OTHERS            = 5.
      CHECK sy-subrc EQ 0.
    * Saving the items alone
      CALL FUNCTION 'BAPI_BUSPROCESSND_SAVE'
        TABLES
          objects_to_save = lit_obj_to_save
          saved_objects   = lit_saved_obj
          return          = lit_ret.
    
    
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
    

    • How to give points: Mark your thread as a question while creating it. In the answers you get, you can assign the points by clicking on the stars to the left.

    Add comment
    10|10000 characters needed characters exceeded