on 10-16-2008 11:18 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.