Skip to Content
avatar image
Former Member

Functional Module used to update quantity field for a sales order

Hi All,

I have a requirement in which ,i would like to update quantity field for a sale order.Is there any standard functional modules available in SAP-CRM.I know CRM_ORDER_MAINTAINCE,i didn't know ,how to use it exactly.Could some one please help me out in this regard.

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 16, 2008 at 11:23 AM

    Hi,

    use CRM_ORDER_MAINTAIN. Here's a sample:

    **********     HEADER     **********************************************
      ls_order_com-handle = '0000000001'.
      ls_order_com-mode = 'B'.   "change
    *** fill rest of ls_order_com with data from CRMD_ORDERADM_H
      APPEND ls_order_com TO lt_orderadm_h.
    
      CLEAR: ls_input_fields, ls_fields.
      ls_input_fields-ref_handle = '0000000001'.
      ls_input_fields-objectname = 'ORDERADM_H'.
    
      ls_fields-fieldname = 'MODE'.
      INSERT ls_fields INTO TABLE ls_input_fields-field_names.
      INSERT ls_input_fields INTO TABLE lt_input_fields.
    
    *** item
        ls_order_i-handle = lv_handle_pos.
        ls_order_i-header_handle = '0000000001'.
        ls_order_i-mode = 'B'.
    *** fill rest of ls_order_i with data from CRMD_ORDERADM_I
        APPEND ls_order_i TO lt_orderadm_i.
    
        CLEAR: ls_input_fields, ls_fields.
        ls_input_fields-ref_handle = lv_handle_pos.
        ls_input_fields-objectname = 'ORDERADM_I'.
        ls_input_fields-logical_key  = lv_handle_pos.
    
        ls_fields-fieldname = 'ORDERED_PROD'.
        INSERT ls_fields INTO TABLE ls_input_fields-field_names.
        ls_fields-fieldname = 'MODE'.
        INSERT ls_fields INTO TABLE ls_input_fields-field_names.
        INSERT ls_input_fields INTO TABLE lt_input_fields.
    
    ** change quantity
        CLEAR ls_schedlin_i.
        ls_schedlin_i-ref_handle = lv_handle_pos.
        ls_schedlin_i-ref_guid = lv_item_guid.
        ls_schedlines-quantity = '10'.    "<-- add your quantity
        ls_schedlines-handle = '0000000001'.
        ls_schedlines-logical_key = lv_handle_pos.
        INSERT ls_schedlines INTO TABLE ls_schedlin_i-schedlines.
        INSERT ls_schedlin_i INTO TABLE lt_schedlin_i.
    
        CLEAR: ls_input_fields, ls_fields.
        ls_input_fields-ref_handle = lv_handle_pos.
        ls_input_fields-ref_kind = 'B'.
        ls_input_fields-objectname = 'SCHEDLIN'.
        ls_input_fields-logical_key  = lv_handle_pos.
    
        ls_fields-fieldname = 'QUANTITY'.
        INSERT ls_fields INTO TABLE ls_input_fields-field_names.
        ls_fields-fieldname = 'LOGICAL_KEY'.
        INSERT ls_fields INTO TABLE ls_input_fields-field_names.
        INSERT ls_input_fields INTO TABLE lt_input_fields.
    
    ** unit
        ls_product_i-ref_handle = lv_handle_pos.
        ls_product_i-process_qty_unit = 'XX'.
        INSERT ls_product_i INTO TABLE lt_product_i.
    
        CLEAR: ls_input_fields, ls_fields.
        ls_input_fields-ref_handle = lv_handle_pos.
        ls_input_fields-ref_kind = 'B'.
        ls_input_fields-objectname = 'PRODUCT_I'.
        ls_input_fields-logical_key  = lv_handle_pos.
    
        ls_fields-fieldname = 'PROCESS_QTY_UNIT'.
        INSERT ls_fields INTO TABLE ls_input_fields-field_names.
        INSERT ls_input_fields INTO TABLE lt_input_fields.
    
    **********     WRITE CHANGES TO BUFFER     *****************************
      CALL FUNCTION 'CRM_ORDER_MAINTAIN'
        EXPORTING
          it_schedlin_i     = lt_schedlin_i
          it_product_i      = lt_product_i
        IMPORTING
          et_exception      = lt_exception
        CHANGING
          ct_orderadm_h     = lt_orderadm_h
          ct_orderadm_i     = lt_orderadm_i
          ct_input_fields   = lt_input_fields
        EXCEPTIONS
          error_occurred    = 1
          document_locked   = 2
          no_change_allowed = 3
          no_authority      = 4
          OTHERS            = 5.
    
      READ TABLE lt_orderadm_h INTO ls_order_com INDEX 1.
    
    **********     SAVE ORDER     ******************************************
      APPEND ls_order_com-guid TO lt_objects_to_save.
    
    * save order
      CALL FUNCTION 'CRM_ORDER_SAVE'
        EXPORTING
          it_objects_to_save   = lt_objects_to_save
        IMPORTING
          et_saved_objects     = lt_saved_objects
          et_exception         = lt_exception
          et_objects_not_saved = lt_objects_not_saved
        EXCEPTIONS
          document_not_saved   = 1
          OTHERS               = 2.

    Hope, this helps.

    Regards,

    Claudia

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 29, 2008 at 01:50 PM

    Hi Claudia,

    I am also working on the same kind of Enhancement , Can you please let me know what value lv_handle_pos will contain.

    Thanks a lot for your input.

    Lakshmi.

    Add comment
    10|10000 characters needed characters exceeded