cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to create item condition records using program-CRM

Former Member
0 Kudos

Dear Experts,

In my Z program am trying to create the Service Contract with condition record for the line item. For getting this, am using 'CRM_ORDER_MAINTAIN' with the input of it_pridoc. But its not creating the condition record for the line item. Hope i missed somthing in my program. Pl find my program bellow, Guide  me.

    ls_pridoc_com-ref_kind = 'B'.
    ls_pridoc_com-ref_handle = '0000000001'.
    ls_cond-kschl = '0PSV'.
    ls_cond-kbetr = '10000'.
    ls_cond-KPEIN = '1'.                     

    ls_cond-waers = 'INR'.
    INSERT ls_cond INTO TABLE ls_pridoc_com-cond_add.
    INSERT ls_pridoc_com INTO TABLE gt_pridoc_com.

    ls_crmt_input_field-ref_handle = '0000000001'.
    ls_crmt_input_field-ref_guid = lv_guid.
    ls_crmt_input_field-ref_kind = 'B'.
    ls_crmt_input_field-objectname = 'PRIDOC'.

    INSERT ls_input_field_names INTO TABLE ls_crmt_input_field-field_names.
    INSERT ls_crmt_input_field  INTO TABLE  it_crmt_input_field_tab.

   CALL FUNCTION 'CRM_ORDER_MAINTAIN'
      EXPORTING
        it_sales             = ls_ordermaintain_if-sales
        it_pridoc             = gt_pridoc_com
        it_schedlin_i        = ls_ordermaintain_if-schedlin_i
        it_partner             = it_crmt_partner_comt            

        it_orgman             = gt_orgman
        it_ordprp_objl_i_d  = it_ordprp_objl_i_d
        it_pricing              = it_pricing
*       it_appointment     = gt_appointment
      CHANGING
        ct_orderadm_h      = ls_ordermaintain_if-orderadm_h
        ct_orderadm_i      = ls_ordermaintain_if-orderadm_i
        ct_input_fields    = it_crmt_input_field_tab          

        cv_log_handle      = gv_log_handle
      EXCEPTIONS
        error_occurred     = 1
        document_locked    = 2
        no_change_allowed  = 3
        no_authority       = 4
        OTHERS             = 5.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.


    ls_bad_orderadm_h-orderadm_h_guid = lv_guid.

    INSERT ls_bad_orderadm_h-orderadm_h_guid INTO TABLE lt_objects_to_save.


    CALL FUNCTION 'CRM_ORDER_SAVE'
      EXPORTING
        it_objects_to_save   = lt_objects_to_save
        iv_update_task_local = ''
        iv_save_frame_log    = 'X'
      IMPORTING
        et_saved_objects     = lt_saved_objects
        et_exception         = lt_exception
      CHANGING
        cv_log_handle        = lv_loghandle
      EXCEPTIONS
        document_not_saved   = 1
        OTHERS               = 2.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Dear Experts,

Thanks for your suggestion, actually am creating the contract using my coding, now i have a task that in my excel sheet am having the customer & product. I want to generate 1 contract for one customer, but he having multiple line items, so i need to add all the items and call the crm_order_maintain, one by one customer it should work like this.

How to make the code or how to validate this.

Suggestion please, my excel looks like below,

Sold-to-partyProduct IdQuantitystart dateend date
30002012GARBADAX112/12/201311/12/2014
30002012PARBAHAX1012/12/201311/12/2014
30002012SLANDRAX1212/10/201311/10/2014
65002014CLAXXAX131/02/201311/12/2014
65002014ZORAXHAX1017/12/201311/12/2014
39002018MKARAXHAX1911/10/201311/10/2014
Former Member
0 Kudos

Anandhan,

Check your code.

s_crmt_input_field-ref_handle = '0000000001'.

This ref handle should be the handle of item. And in item's ref_handle, you need to pass handle of header. 

Also if you are using handles, there is no need of guid. Also check whether you passed the field names correctly or not.


See SAP delivered program - CRM_TEST_ORDER_MAINTAIN to see how to use CRM_ORDER_MAINTAIN to create order.


And yes, once you crack it, your requirement can be handled with this code.


Regards

Niraj

Former Member
0 Kudos

I want to add the condition type 0PSV and Z007 using abap report, this abap report used for creating new Service Contract. Any Suggestion.

VishnAndr
Active Contributor
0 Kudos

Hello,

probably you should refer to item guid and not to the header guid (as you do using lv_guid) during pricing maintenance.