cancel
Showing results for 
Search instead for 
Did you mean: 

CRM: Creating a new Condition within Copy Control

Former Member
0 Kudos

Hi SAP Experts,

we are facing the following challenge within CRM copy control:

Task:

- Creating/adding a new manual Z* condition during the copy from service contract into pl service order.

Done:

- Create copy control BADI and implement the methode orderadm_i (see below)

System Behavior

- Copy control creates new z* condition but in error status and without conditon value

The following Badi code seems to be incorrect. Unfortunately we could not use CRM_OrderMaintain, because the Badi is called within CRM_OrderMaintain. So we implement FM 'CRM_PRIDOC_MAINTAIN_MUL_OW', to avoid recursive execution of CRM_OrderMaintain.

Perhaps you have face a similar problem and give me hint.

Thanks in advance for your help.

Ole

CODE:

**Preparing add Condition from the preceeding Doc

LOOP AT lt_pridoc_s INTO ls_pridoc_s.

MOVE-CORRESPONDING ls_pridoc_s TO ls_pridoc_t.

**Read Condition from source

lt_p_cond = ls_pridoc_t-pric_cond.

LOOP AT lt_p_cond INTO ls_p_cond where KSCHL = 'ZCUS'.

MOVE-CORRESPONDING ls_p_cond TO ls_add_con.

  • ls_add_con-WAERS = currency

  • ls_add_con-KBETR = netto value

ls_add_con-KPEIN = 1.

ls_add_con-KMEIN = 'PU'.

APPEND ls_add_con TO lt_add_con .

ENDLOOP.

ls_PRidoc_t-ref_kind = 'A'.

ls_pridoc_t-ref_guid = cs_orderadm_i-guid.

ls_pridoc_t-cond_add = lt_add_con.

ls_pridoc_t-ref_handle = cs_orderadm_i-handle.

REFRESH ls_pridoc_t-pric_cond.

  • ls_PRidoc_t-PRICING_PROCEDURE =

ls_PRidoc_t-PRICING_TYPE = 'B'.

*A Copy price components and redetermine scales

*B Carry out new pricing

*C Copy manual pricing elements and redetermine the others

*D Copy pricing elements unchanged

*E Adopt price components and fix values

*F Copy pricing elements, turn value and fix

*G Copy pricing elements unchanged and redetermine taxes

APPEND ls_pridoc_t TO lt_pridoc_t.

ENDLOOP.

**Target Item Guid

REFRESH Lt_guid_pr.

Ls_guid_pr-guid = cs_orderadm_i-guid.

Ls_guid_pr-ITEM_MAINTAIN = cs_orderadm_i-NUMBER_INT.

Ls_guid_pr-Handle = cs_orderadm_i-handle.

APPEND Ls_guid_pr TO Lt_guid_pr.

CALL FUNCTION 'CRM_PRIDOC_MAINTAIN_MUL_OW'

EXPORTING

it_trusted_items = Lt_guid_pr

it_pridoc = lt_pridoc_t

EXCEPTIONS

error_occurred = 1

OTHERS = 2.

Edited by: Ole Sylvester on Apr 3, 2009 10:50 AM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Sorry, it's post double.

Edited by: deripmav on Nov 13, 2009 9:52 AM

Former Member
0 Kudos

Hi, we met the same problem. we done it with event.

First, we define a new event with Execute time 50(End of Document Processing) and Event Name AFTER_CREATE_WITH_REFERENCE.

And the event major doing is copy and change the condition value, the code block is following:


  ls_cond_change-waers = 'USD'.
  ls_cond_change-stunr = '012'.
  ls_cond_change-zaehk = '001'.
  ls_cond_change-kbetr = '1351'.
  INSERT ls_cond_change INTO TABLE lt_cond_change.

  READ TABLE lt_orderadm_i INTO ls_orderadm_i INDEX 2.

  ls_new_pridoc-ref_guid    = ls_orderadm_i-guid.
  ls_new_pridoc-cond_change = lt_cond_change.
  INSERT ls_new_pridoc INTO TABLE lt_new_pridoc.

  ls_input_field-ref_guid   = ls_orderadm_i-guid.
  ls_input_field-ref_kind   = 'B'.
  ls_input_field-objectname = 'PRIDOC'.

  ls_field_names-fieldname  = 'KBETR'.
  INSERT ls_field_names INTO TABLE ls_input_field-field_names.
  INSERT ls_field_names INTO TABLE lt_field_names.
  INSERT ls_input_field INTO TABLE lt_input_field.

  ls_guid_handle-guid = ls_orderadm_i-guid.
  INSERT ls_guid_handle INTO TABLE lt_guid_handle.

  CALL FUNCTION 'CRM_PRIDOC_MAINTAIN_MUL_OW'
    EXPORTING
      it_trusted_items       = lt_guid_handle
      it_pridoc              = lt_new_pridoc
    EXCEPTIONS
      error_occurred         = 1
      OTHERS                 = 2
            .

Hope it's useful.