cancel
Showing results for 
Search instead for 
Did you mean: 

Urgent: Change custom conditions on item level

Former Member
0 Kudos

Hi experts,

could you please tell me how you resolve this issue, its very urgent? I´m facing the promblem that my condition type doesn´t get changed! I want only to change KBETR at item level. After CRM_ORDER_SAVE is called I can see, that order got saved, but nothing happens

Please help me out! I think there is not a lot which has to be change. Here is my Coding:

parameters: lv_head type crmt_object_guid default '...'.

parameters: lv_item type crmt_object_guid default '...'.
parameters: lv_kbetr type prct_cond_rate default '12'.

insert lv_head into table lt_guid.
insert lv_item into table lt_item.

call function 'CRM_ORDER_READ'
   exporting
     it_header_guid                    = lt_guid
     it_item_guid                      = lt_item
   importing
     et_pridoc                         = lt_pridoc
     et_pricing_i                      = lt_pricing_i
* CHANGING
*   CV_LOG_HANDLE                     =
  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.

if sy-subrc <> 0 and lt_pridoc is not initial.
   write: / 'ERROR'.
   exit.
endif.

read table lt_pridoc index 1 into ls_pridoc.
if sy-subrc <> 0.
   write: / 'ERROR'.
   exit.
endif.

read table ls_pridoc-pric_cond into ls_cond with key kschl = 'Z002'.
if sy-subrc <> 0.
   write: / 'ERROR'.
   exit.
endif.

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

ls_input_fn-fieldname = 'WAERS'.
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 = 'ACTIVATE'.
*insert ls_input_fn into table ls_input-field_names.

insert ls_input into table lt_input.

ls_pricom-ref_guid   = lv_head.
ls_pricom-ref_kind   = 'B'.
ls_pricom-pric_cond[] = ls_pridoc-pric_cond[].

move-corresponding ls_cond to ls_cond_chg.
ls_cond_chg-waers = 'EUR'.
ls_cond_chg-kbetr = lv_kbetr.
insert ls_cond_chg into table ls_pricom-cond_change.

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.
else.
   rollback work.
endif.



Best Regards

Tanja

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member196467
Active Contributor
0 Kudos

Hi Tanja,

I am probably not the right person for code but please review below listed former threads which should be helpful:

http://forums.sdn.sap.com/thread.jspa?threadID=661004

http://forums.sdn.sap.com/thread.jspa?threadID=596313

http://forums.sdn.sap.com/thread.jspa?threadID=186588

Best regards - Christophe