Skip to Content
0
Former Member
Nov 16, 2014 at 12:38 PM

How to add / Change pricing condition for item in SAP CRM

1171 Views

Hi Experts,

I am facing problem in adding pricing condition at item level. Tried all the ways to add. gone through previous threads but no help.

I have used the CRM_ORDER_MAINTAIN.. The transaction is saved but the pricing condition is not added to the item.

The pricing condition manual entries option is "Not possible to process manually". Is this condition possible to add through CRM_ORDER_MAINTAIN?

Below is the code. Please let me know what i'm missing.

ls_cond_add-KSCHL = 'ZP30'.
*ls_cond_add-WAERS = '%'.
ls_cond_add-KBETR = lv_kbetr.
*ls_cond_add-KPEIN = ''.
*ls_cond_add-KMEIN = ''.
*ls_cond_add-KBETR_INITIAL = ''.
ls_cond_add-KWERT = lv_kbetr.
*ls_cond_add-KWERT_INITIAL = 'X'.
ls_cond_add-KRECH = 'B'.
*ls_cond_add-KWAEH = ''.
ls_cond_add-KNUMH = lv_item.
*ls_cond_add-KOTABNR = ''.
ls_cond_add-KAWRT = lv_kbe_B.
*ls_cond_add-KAWRT_INITIAL = 'X'.
*ls_cond_add-KRUEK = ''.

APPEND ls_cond_add to lt_cond_add.
CLEAR ls_cond_Add.

ls_pricom-ref_guid = lv_item.
ls_pricom-ref_KIND = 'B'.
*ls_pricom-PRICING_PROCEDURE = 'ZBRPRD'.
ls_pricom-cond_Add[] = lt_cond_add.

ls_input-ref_guid = lv_item.
ls_input-ref_kind = 'B'.
ls_input-objectname = 'PRIDOC'.


ls_input_fn-fieldname = 'REF_GUID'.
INSERT ls_input_fn INTO TABLE ls_input-field_names.
ls_input_fn-fieldname = 'REF_KIND'.
INSERT ls_input_fn INTO TABLE ls_input-field_names.
*ls_input_fn-fieldname = 'REF_KIND'.
*INSERT ls_input_fn INTO TABLE ls_input-field_names.

ls_input_fn-fieldname = 'KRECH'.
INSERT ls_input_fn INTO TABLE ls_input-field_names.
ls_input_fn-fieldname = 'KNUMH'.
INSERT ls_input_fn INTO TABLE ls_input-field_names.
ls_input_fn-fieldname = 'KSCHL'.
INSERT ls_input_fn INTO TABLE ls_input-field_names.
ls_input_fn-fieldname = 'KBETR'.
INSERT ls_input_fn INTO TABLE ls_input-field_names.
ls_input_fn-fieldname = 'KAWRT'.
INSERT ls_input_fn INTO TABLE ls_input-field_names.

ls_input_fn-fieldname = 'KWERT'.
INSERT ls_input_fn INTO TABLE ls_input-field_names.
INSERT ls_input INTO TABLE lt_input.

APPEND ls_pricom TO lt_pricom.

CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
it_pridoc = lt_pricom
CHANGING
* ct_orderadm_h = lt_header
ct_input_fields = lt_input
EXCEPTIONS
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
OTHERS = 5.

IF sy-subrc <> 0.
EXIT.
ENDIF.

CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
it_objects_to_save = lt_guid
IMPORTING
et_saved_objects = lt_saved
* ET_EXCEPTION =
* ET_OBJECTS_NOT_SAVED =
EXCEPTIONS
document_not_saved = 1
OTHERS = 2.

IF sy-subrc EQ 0.
* COMMIT WORK AND WAIT.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
.


ELSE.
ROLLBACK WORK.
ENDIF.