Error in crm_order_maintain.
Hi All,
I want to create Service Contract with Perticular Product here i am getting someProblem when adding Product line item in it when i am submitting correct item Category then system is giving me mail with i am giving you code.
Update was terminated
System ID.... TCD
Client....... 110
User..... IBMABAP_
Transaction.. SE38
Update key... 4B46FA07D7B80092E10080000A600525
Generated.... 09.01.2010, 10:24:15
Completed.... 09.01.2010, 10:24:15
Error Info... ABAP/4 processor: SAPSQLARRAY_INSERT_DUPREC_
here i am giving you my code.
REPORT ytest10.
DATA: lv_header_guid TYPE guid_32,
ls_orderadm_h TYPE TABLE OF bapibus20001_header_ins WITH HEADER LINE,
ls_input_fields TYPE TABLE OF bapibus20001_input_fields WITH HEADER LINE,
lt_created_process TYPE TABLE OF bapibus20001_header_ins WITH HEADER LINE,
lt_return TYPE TABLE OF bapiret2 WITH HEADER LINE ,
lt_objects_to_save TYPE TABLE OF bapibus20001_guid_dis WITH HEADER LINE,
lt_saved_objects TYPE TABLE OF bapibus20001_object_id WITH HEADER LINE,
lt_log TYPE bapibus20001_control-log_handle,
ls_objects_to_save TYPE bapibus20001_guid_dis,
lt_orgman TYPE TABLE OF bapibus20001_orgman_ins WITH HEADER LINE,
lt_partner TYPE TABLE OF bapibus20001_partner_ins WITH HEADER LINE,
lt_service TYPE TABLE OF bapibus20001_service_os_ins WITH HEADER LINE,
ls_item TYPE TABLE OF BAPIBUS20001_ITEM WITH HEADER LINE .
DATA: t_CRMM_BUT_CUSTNO TYPE TABLE OF CRMM_BUT_CUSTNO WITH HEADER LINE,
t_CRMM_BUT_FRG0081 TYPE TABLE OF CRMM_BUT_FRG0081 WITH HEADER LINE,
t_adrc TYPE TABLE OF adrc WITH HEADER LINE,
t_zzcomplaintroute TYPE TABLE OF zzcomplaintroute WITH HEADER LINE,
it_STATUS TYPE TABLE OF BAPIBUS20001_STATUS_INS WITH HEADER LINE,
IT_PRICING TYPE TABLE OF BAPIBUS20001_PRICING WITH HEADER LINE,
IT_PRODUCT TYPE TABLE OF BAPIBUS20001_PRODUCT WITH HEADER LINE,
IT_PRODUCT_ITEM TYPE TABLE OF BAPIBUS20001_PRODUCTS WITH HEADER LINE.
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_32 = lv_header_guid.
*CONCATENATE text-d01 is_import-complt_id i
*INTO ls_orderadm_h-description SEPARATED BY space.
PERFORM orderadm_h.
*PERFORM item.
PERFORM orgman.
PERFORM partner.
*PERFORM lt_service.
PERFORM status.
PERFORM pricing.
*PERFORM PRODUCT_LIST.
*PERFORM PRODUCT_ITEM.
CLEAR: lt_created_process, lt_return.
DATA : gv_exit TYPE REF TO if_ex_crm_serviceprod_badi,
ev_product_id TYPE comt_product_id VALUE '4AE694A1BAF800B8E10080000A600525',
lt_schedlin_i TYPE crmt_schedlin_i_comt,
lv_schedlin_i TYPE crmt_schedlin_i_com,
lt_schedlin TYPE crmt_schedlin_extdt,
lv_schedlin TYPE crmt_schedlin_extd,
lt_header_guids TYPE crmt_object_guid_tab,
lt_req_obj TYPE crmt_object_name_tab,
lt_appointment_wrk TYPE crmt_appointment_wrkt,
lv_appointment_wrk TYPE crmt_appointment_wrk,
lt_product_i TYPE crmt_product_i_comt,
lv_product_i TYPE crmt_product_i_com,
ls_schedlines TYPE TABLE OF crmt_schedlin_extdt,
wa_schedlines TYPE crmt_schedlin_extd,
ls_orderadm_i TYPE crmt_orderadm_i_com,
lt_orderadm_i TYPE crmt_orderadm_i_comt,
ls_field_names TYPE crmt_input_field_names,
lt_input_fields1 TYPE crmt_input_field_tab,
ls_input_fields1 TYPE crmt_input_field,
lt_orderadm_h1 TYPE crmt_orderadm_h_comt,
ls_orderadm_h1 TYPE crmt_orderadm_h_com.
lv_schedlin-quantity = '1.000'.
INSERT lv_schedlin INTO TABLE lt_schedlin.
lv_schedlin_i-schedlines = lt_schedlin.
lv_schedlin_i-ref_handle = '0000000001'.
INSERT lv_schedlin_i INTO TABLE lt_schedlin_i.
ls_input_fields1-ref_handle = '0000000001'.
ls_input_fields1-ref_kind = 'B'.
ls_input_fields1-objectname = 'SCHEDLIN'.
ls_field_names-fieldname = 'LOGICAL_KEY'.
APPEND ls_field_names TO ls_input_fields1-field_names.
ls_field_names-fieldname = 'QUANTITY'.
APPEND ls_field_names TO ls_input_fields1-field_names.
INSERT ls_input_fields1 INTO TABLE lt_input_fields1.
WAIT UP TO 1 SECONDS.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
it_product_i = lt_product_i
it_schedlin_i = lt_schedlin_i
CHANGING
ct_orderadm_i = lt_orderadm_i
ct_orderadm_h = lt_orderadm_h1
ct_input_fields = lt_input_fields1
EXCEPTIONS
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
OTHERS = 5.
Similar Messages
-
Error calling CRM_ORDER_MAINTAIN twice
Hello experts,
i am facing following problem; i made a Fm in which i call CRM_ORDER_MAINTAIN and CRM_ORDER_SAVE, the first call from product 'A' from BADI works fine but the second call in same sesion (SAME HEADER GUID) gives an error;
EXCEPTIONS no_change_allowed is thrown.
Do i need to release the order after SAVE or ..??
Grtz Richard
CLEAR w_customer_i_maintain.
w_customer_i_maintain-ref_handle = 1.
w_customer_i_maintain-ref_guid = iv_item_guid. "ls_orderadm_i-guid.
w_customer_i_maintain-mode = 'A'. "create mode
CASE iv_fieldname.
WHEN 'ZZPOLICY_NUM'.
w_customer_i_maintain-zzpolicy_num = iv_value.
WHEN 'ZZSAVING_ACNT'.
w_customer_i_maintain-zzsaving_acnt = iv_value.
ENDCASE.
APPEND w_customer_i_maintain TO it_customer_i_maintain.
CLEAR: w_input_fields, w_field_names.
w_input_fields-ref_handle = 1.
w_input_fields-ref_guid = iv_item_guid. "ls_orderadm_i-guid.
w_input_fields-ref_kind = 'D'.
w_input_fields-objectname = 'CUSTOMER_I'.
w_field_names-fieldname = iv_fieldname.
INSERT w_field_names INTO TABLE w_input_fields-field_names.
w_field_names-fieldname = 'MODE'.
INSERT w_field_names INTO TABLE w_input_fields-field_names.
w_field_names-fieldname = 'REF_GUID'.
INSERT w_field_names INTO TABLE w_input_fields-field_names.
INSERT w_input_fields INTO TABLE it_input_fields.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
it_customer_i = it_customer_i_maintain
CHANGING
ct_input_fields = it_input_fields
EXCEPTIONS
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
OTHERS = 5.
IF sy-subrc = 0.
INSERT iv_head_guid INTO TABLE et_objects_to_save.
INSERT iv_item_guid INTO TABLE et_objects_to_save.
CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
it_objects_to_save = et_objects_to_save
IMPORTING
et_saved_objects = it_saved_objects
CHANGING
cv_log_handle = cv_log_handle
EXCEPTIONS
document_not_saved = 1
OTHERS = 2.Solved by adding two FM calls:
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
CALL FUNCTION 'CRM_ORDER_INITIALIZE'
EXPORTING
it_guids_to_init = et_objects_to_save
iv_keep_lock = ''. -
Error Occured in CRM_ORDER_MAINTAIN . Kindly help asap.
I have written folowing code but exception occurs in changing parameter lt_exception of FM maintain.What can be the possible error.
msg no - 0004
REPORT ZTEST_PROGRAM.
*Internal tables
Data : lt_partner TYPE crmt_partner_comt,
lt_sales TYPE crmt_sales_comt,
lt_orgman TYPE crmt_orgman_comt,
lt_status TYPE crmt_status_comt,
lt_customer_h TYPE CRMT_SERVICE_H_COMT,
lt_input_field TYPE crmt_input_field_names_tab,
lt_exception TYPE crmt_exception_t,
lt_crm_save TYPE crmt_object_guid_tab,
lt_orderadm_h TYPE crmt_orderadm_h_comt,
lt_saved_objects TYPE crmt_return_objects,
lt_objects_not_saved TYPE CRMT_OBJECT_GUID_TAB,
lt_input TYPE crmt_input_field_tab.
*Structures
Data : ls_partner TYPE crmt_partner_com,
ls_sales TYPE crmt_sales_com,
ls_orgman TYPE crmt_orgman_com,
ls_status TYPE crmt_status_com,
ls_input TYPE crmt_input_field,
ls_input_field TYPE crmt_input_field_names,
ls_crm_save TYPE crmt_object_guid,
ls_saved_objects LIKE LINE OF lt_saved_objects,
ls_orderadm_h TYPE crmt_orderadm_h_com,
ls_customer_h TYPE CRMT_SERVICE_H_COM.
*Variables
Data : lv_guid TYPE guid_16,
lv_timezone TYPE timezone,
lv_timestamp TYPE timestamp,
lv_log_handle TYPE balloghndl.
GET GUID
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_16 = lv_guid.
Filling status data
CLEAR ls_status.
ls_status-ref_guid = lv_guid.
ls_status-ref_kind = 'A'.
ls_status-status = 'E0003'.
ls_status-user_stat_proc = 'CRMORDER'.
ls_status-activate = 'X'.
APPEND ls_status TO lt_status.
Filling the partner data
CLEAR ls_partner.
ls_partner-ref_guid = lv_guid.
ls_partner-ref_kind = 'A'.
ls_partner-ref_partner_handle = '0001'.
ls_partner-kind_of_entry = 'C'.
ls_partner-partner_fct = '00000001'. " Sold to Party
ls_partner-partner_no = '190'.
ls_partner-display_type = 'BP'.
ls_partner-no_type = 'BP'.
INSERT ls_partner INTO TABLE lt_partner.
Input Fields for Partner Data that are to be changed
CLEAR ls_input.
ls_input-ref_guid = lv_guid.
ls_input-ref_kind = 'A'.
ls_input-logical_key = '0001'.
ls_input-objectname = 'PARTNER'.
ls_input_field-fieldname = 'DISPLAY_TYPE'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'KIND_OF_ENTRY'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'NO_TYPE'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'PARTNER_FCT'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'PARTNER_NO'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input-field_names[] = lt_input_field[].
INSERT ls_input INTO TABLE lt_input.
Prepare Organisation Data
Clear ls_orgman.
ls_orgman-ref_guid = lv_guid.
ls_orgman-ref_kind = 'A'.
ls_orgman-sales_group_ori = 'A'.
ls_orgman-sales_orgr_ori = 'A'.
ls_orgman-division_ori = 'A'.
ls_orgman-dis_channel_ori = 'A'.
APPEND ls_orgman TO lt_orgman.
Input Fields for Organization Data that are to be changed
ls_input-ref_guid = lv_guid.
ls_input-ref_kind = 'A'.
ls_input-objectname = 'ORGMAN'.
ls_input_field-fieldname = 'SALES_GROUP_ORI'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'SALES_ORGR_ORI'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'DIVISION_ORI'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input-field_names[] = lt_input_field[]. " Contains all fields to updatd
INSERT ls_input INTO TABLE lt_input.
CLEAR: ls_input, ls_input_field.
REFRESH lt_input_field.
EXTERNAL REFERENCE DATA And Requested Delivery Date Data
ls_sales-ref_guid = lv_guid.
ls_sales-po_number_sold = 'A'. " PO Reference
ls_sales-ref_kind = 'A'.
Get the user Time Zone
CALL FUNCTION 'TZON_GET_USER_TIMEZONE'
EXPORTING
if_username = sy-uname
IMPORTING
ef_timezone = lv_timezone
EXCEPTIONS
no_timezone_customizing = 1
no_valid_user = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Convert Requested delivery date into Timestamp
CALL FUNCTION 'BBP_PD_CONVERT_DATETIME_TO_TS'
EXPORTING
iv_date = sy-datum
iv_time = sy-uzeit
iv_time_zone = lv_timezone
IMPORTING
ev_timestamp = lv_timestamp
EV_TIMESTAMPL =
EXCEPTIONS
convert_error = 1
OTHERS = 2
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_sales-req_dlv_date = lv_timestamp. " Requested delivery date time stamp
ls_sales-req_timezone = lv_timezone. " User timezone
ls_sales-po_date_sold = sy-datum.
APPEND ls_sales TO lt_sales.
Input fields for Sales Data that are to be changed
CLEAR: ls_input, ls_input_field.
REFRESH lt_input_field.
ls_input-ref_guid = lv_guid.
ls_input-ref_kind = 'A'.
ls_input-objectname = 'SALES'.
ls_input_field-fieldname = 'PO_NUMBER_SOLD'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'REQ_DLV_DATE'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input-field_names[] = lt_input_field[]. "Contains all fields to updatd
INSERT ls_input INTO TABLE lt_input.
Prepare Data for Orderadm_h
CLEAR ls_orderadm_h.
CLEAR: ls_input, ls_input_field.
REFRESH lt_input_field.
ls_orderadm_h-guid = lv_guid.
ls_orderadm_h-process_type = 'ZEDL'.
ls_orderadm_h-description = 'ACB'. " Order Description
ls_orderadm_h-posting_date = sy-datum.
ls_orderadm_h-descr_language = 'EN'.
ls_orderadm_h-template_type = 'D'.
ls_orderadm_h-mode = 'A'.
APPEND ls_orderadm_h TO lt_orderadm_h.
CLEAR ls_input.
ls_input-ref_guid = lv_guid.
ls_input-ref_kind = 'A'.
ls_input-objectname = 'ORDERADM_H'.
ls_input_field-fieldname = 'MODE'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'DESCRIPTION'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'PROCESS_TYPE'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input-field_names[] = lt_input_field[]. "Contains all fields to updatd
INSERT ls_input INTO TABLE lt_input.
CLEAR: ls_input, ls_input_field.
REFRESH lt_input_field.
Prepare Data for customer_h
ls_customer_h-ref_guid = lv_guid.
Ls_customer_h-mode = 'A'.
*Ls_customer_h-customer_ext = 'b'.
APPEND ls_customer_h to lt_customer_h.
Call bapi to create and update order
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
IT_OPPORT_H =
IT_LEAD_H =
IT_ACTIVITY_H =
IT_LAWREF_H =
IT_SALES = lt_sales
IT_PRICING =
IT_PRICING_I =
IT_PRIDOC =
IT_ORGMAN = lt_orgman
IT_SHIPPING =
IT_ACTIVITY_I =
IT_PRODUCT_I =
IT_BATCH =
IT_FINPROD_I =
IT_STRUCT_I =
IT_CONFIG =
IT_PAYPLAN =
IT_PAYPLAN_D =
IT_CUSTOMER_H =
IT_CUSTOMER_I =
IT_SERVICE_H =
IT_SERVICE_I =
IT_SERVICE_ASSIGN =
IT_QUALIF =
IT_APPOINTMENT =
IT_TEXT =
IT_SCHEDLIN_I =
IT_PARTNER = lt_partner
IT_SERVICE_OS =
IT_REFOBJ =
IT_SUBJECT =
IT_CANCEL =
IT_CANCEL_IR =
IT_CANCEL_DATES =
IT_STATUS = lt_status
IT_BILLPLAN =
IT_BILLING =
IT_ORDPRP_I =
IT_ORDPRP_I_D =
IT_ORDPRP_OBJL_I_D =
IT_CUMULATED_I =
IT_SERVICEPLAN_I =
IT_SERVICEPLAN_IE =
IT_PRICE_AGREEMENTS_BBP =
IT_PRICE_AGREEMENTS_CRM =
IT_CONFIG_FILTER =
IT_AC_ASSIGN =
IT_SURVEY =
IT_EXTENSION =
IT_ACTIVE_SWITCH =
IT_UBB_CTR_I =
IT_UBB_CR_I =
IT_UBB_VOL_I =
IT_APO_I =
IT_CHNGPROC_I =
IT_EXT_REF =
IT_DOC_FLOW_PNT =
IT_CHNGPROC_H =
IT_FUND_H =
IT_CLA_H =
IT_SRV_REQ_H =
IT_APPROVAL =
IMPORTING
ET_EXCEPTION = lt_exception
CHANGING
CT_ORDERADM_H = lt_orderadm_h
CT_ORDERADM_I =
CT_INPUT_FIELDS = lt_input
CV_LOG_HANDLE = lv_log_handle
CT_PARTNER_ATTRIBUTES =
CT_DOC_FLOW =
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_crm_save = lv_guid.
INSERT ls_crm_save INTO TABLE lt_crm_save.
Saving the Order which is created by above function module
CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
it_objects_to_save = lt_crm_save
IMPORTING
et_saved_objects = lt_saved_objects
et_exception = lt_exception " Receiving objects that can be saved
et_objects_not_saved = lt_objects_not_saved
EXCEPTIONS
document_not_saved = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
write 'hello1'.
ENDIF.
Commit the save
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
write 'hello2'.
ENDIF.
Check Created order
READ TABLE lt_saved_objects INTO ls_saved_objects INDEX 1.
READ TABLE lt_objects_not_saved INTO ls_saved_objects INDEX 1.
write : lv_guid,ls_saved_objects-GUID,ls_saved_objects-OBJECT_ID.I have written folowing code but exception occurs in changing parameter lt_exception of FM maintain.What can be the possible error.
msg no - 0004
REPORT ZTEST_PROGRAM.
*Internal tables
Data : lt_partner TYPE crmt_partner_comt,
lt_sales TYPE crmt_sales_comt,
lt_orgman TYPE crmt_orgman_comt,
lt_status TYPE crmt_status_comt,
lt_customer_h TYPE CRMT_SERVICE_H_COMT,
lt_input_field TYPE crmt_input_field_names_tab,
lt_exception TYPE crmt_exception_t,
lt_crm_save TYPE crmt_object_guid_tab,
lt_orderadm_h TYPE crmt_orderadm_h_comt,
lt_saved_objects TYPE crmt_return_objects,
lt_objects_not_saved TYPE CRMT_OBJECT_GUID_TAB,
lt_input TYPE crmt_input_field_tab.
*Structures
Data : ls_partner TYPE crmt_partner_com,
ls_sales TYPE crmt_sales_com,
ls_orgman TYPE crmt_orgman_com,
ls_status TYPE crmt_status_com,
ls_input TYPE crmt_input_field,
ls_input_field TYPE crmt_input_field_names,
ls_crm_save TYPE crmt_object_guid,
ls_saved_objects LIKE LINE OF lt_saved_objects,
ls_orderadm_h TYPE crmt_orderadm_h_com,
ls_customer_h TYPE CRMT_SERVICE_H_COM.
*Variables
Data : lv_guid TYPE guid_16,
lv_timezone TYPE timezone,
lv_timestamp TYPE timestamp,
lv_log_handle TYPE balloghndl.
GET GUID
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_16 = lv_guid.
Filling status data
CLEAR ls_status.
ls_status-ref_guid = lv_guid.
ls_status-ref_kind = 'A'.
ls_status-status = 'E0003'.
ls_status-user_stat_proc = 'CRMORDER'.
ls_status-activate = 'X'.
APPEND ls_status TO lt_status.
Filling the partner data
CLEAR ls_partner.
ls_partner-ref_guid = lv_guid.
ls_partner-ref_kind = 'A'.
ls_partner-ref_partner_handle = '0001'.
ls_partner-kind_of_entry = 'C'.
ls_partner-partner_fct = '00000001'. " Sold to Party
ls_partner-partner_no = '190'.
ls_partner-display_type = 'BP'.
ls_partner-no_type = 'BP'.
INSERT ls_partner INTO TABLE lt_partner.
Input Fields for Partner Data that are to be changed
CLEAR ls_input.
ls_input-ref_guid = lv_guid.
ls_input-ref_kind = 'A'.
ls_input-logical_key = '0001'.
ls_input-objectname = 'PARTNER'.
ls_input_field-fieldname = 'DISPLAY_TYPE'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'KIND_OF_ENTRY'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'NO_TYPE'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'PARTNER_FCT'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'PARTNER_NO'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input-field_names[] = lt_input_field[].
INSERT ls_input INTO TABLE lt_input.
Prepare Organisation Data
Clear ls_orgman.
ls_orgman-ref_guid = lv_guid.
ls_orgman-ref_kind = 'A'.
ls_orgman-sales_group_ori = 'A'.
ls_orgman-sales_orgr_ori = 'A'.
ls_orgman-division_ori = 'A'.
ls_orgman-dis_channel_ori = 'A'.
APPEND ls_orgman TO lt_orgman.
Input Fields for Organization Data that are to be changed
ls_input-ref_guid = lv_guid.
ls_input-ref_kind = 'A'.
ls_input-objectname = 'ORGMAN'.
ls_input_field-fieldname = 'SALES_GROUP_ORI'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'SALES_ORGR_ORI'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'DIVISION_ORI'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input-field_names[] = lt_input_field[]. " Contains all fields to updatd
INSERT ls_input INTO TABLE lt_input.
CLEAR: ls_input, ls_input_field.
REFRESH lt_input_field.
EXTERNAL REFERENCE DATA And Requested Delivery Date Data
ls_sales-ref_guid = lv_guid.
ls_sales-po_number_sold = 'A'. " PO Reference
ls_sales-ref_kind = 'A'.
Get the user Time Zone
CALL FUNCTION 'TZON_GET_USER_TIMEZONE'
EXPORTING
if_username = sy-uname
IMPORTING
ef_timezone = lv_timezone
EXCEPTIONS
no_timezone_customizing = 1
no_valid_user = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Convert Requested delivery date into Timestamp
CALL FUNCTION 'BBP_PD_CONVERT_DATETIME_TO_TS'
EXPORTING
iv_date = sy-datum
iv_time = sy-uzeit
iv_time_zone = lv_timezone
IMPORTING
ev_timestamp = lv_timestamp
EV_TIMESTAMPL =
EXCEPTIONS
convert_error = 1
OTHERS = 2
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_sales-req_dlv_date = lv_timestamp. " Requested delivery date time stamp
ls_sales-req_timezone = lv_timezone. " User timezone
ls_sales-po_date_sold = sy-datum.
APPEND ls_sales TO lt_sales.
Input fields for Sales Data that are to be changed
CLEAR: ls_input, ls_input_field.
REFRESH lt_input_field.
ls_input-ref_guid = lv_guid.
ls_input-ref_kind = 'A'.
ls_input-objectname = 'SALES'.
ls_input_field-fieldname = 'PO_NUMBER_SOLD'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'REQ_DLV_DATE'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input-field_names[] = lt_input_field[]. "Contains all fields to updatd
INSERT ls_input INTO TABLE lt_input.
Prepare Data for Orderadm_h
CLEAR ls_orderadm_h.
CLEAR: ls_input, ls_input_field.
REFRESH lt_input_field.
ls_orderadm_h-guid = lv_guid.
ls_orderadm_h-process_type = 'ZEDL'.
ls_orderadm_h-description = 'ACB'. " Order Description
ls_orderadm_h-posting_date = sy-datum.
ls_orderadm_h-descr_language = 'EN'.
ls_orderadm_h-template_type = 'D'.
ls_orderadm_h-mode = 'A'.
APPEND ls_orderadm_h TO lt_orderadm_h.
CLEAR ls_input.
ls_input-ref_guid = lv_guid.
ls_input-ref_kind = 'A'.
ls_input-objectname = 'ORDERADM_H'.
ls_input_field-fieldname = 'MODE'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'DESCRIPTION'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input_field-fieldname = 'PROCESS_TYPE'.
INSERT ls_input_field INTO TABLE lt_input_field.
ls_input-field_names[] = lt_input_field[]. "Contains all fields to updatd
INSERT ls_input INTO TABLE lt_input.
CLEAR: ls_input, ls_input_field.
REFRESH lt_input_field.
Prepare Data for customer_h
ls_customer_h-ref_guid = lv_guid.
Ls_customer_h-mode = 'A'.
*Ls_customer_h-customer_ext = 'b'.
APPEND ls_customer_h to lt_customer_h.
Call bapi to create and update order
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
IT_OPPORT_H =
IT_LEAD_H =
IT_ACTIVITY_H =
IT_LAWREF_H =
IT_SALES = lt_sales
IT_PRICING =
IT_PRICING_I =
IT_PRIDOC =
IT_ORGMAN = lt_orgman
IT_SHIPPING =
IT_ACTIVITY_I =
IT_PRODUCT_I =
IT_BATCH =
IT_FINPROD_I =
IT_STRUCT_I =
IT_CONFIG =
IT_PAYPLAN =
IT_PAYPLAN_D =
IT_CUSTOMER_H =
IT_CUSTOMER_I =
IT_SERVICE_H =
IT_SERVICE_I =
IT_SERVICE_ASSIGN =
IT_QUALIF =
IT_APPOINTMENT =
IT_TEXT =
IT_SCHEDLIN_I =
IT_PARTNER = lt_partner
IT_SERVICE_OS =
IT_REFOBJ =
IT_SUBJECT =
IT_CANCEL =
IT_CANCEL_IR =
IT_CANCEL_DATES =
IT_STATUS = lt_status
IT_BILLPLAN =
IT_BILLING =
IT_ORDPRP_I =
IT_ORDPRP_I_D =
IT_ORDPRP_OBJL_I_D =
IT_CUMULATED_I =
IT_SERVICEPLAN_I =
IT_SERVICEPLAN_IE =
IT_PRICE_AGREEMENTS_BBP =
IT_PRICE_AGREEMENTS_CRM =
IT_CONFIG_FILTER =
IT_AC_ASSIGN =
IT_SURVEY =
IT_EXTENSION =
IT_ACTIVE_SWITCH =
IT_UBB_CTR_I =
IT_UBB_CR_I =
IT_UBB_VOL_I =
IT_APO_I =
IT_CHNGPROC_I =
IT_EXT_REF =
IT_DOC_FLOW_PNT =
IT_CHNGPROC_H =
IT_FUND_H =
IT_CLA_H =
IT_SRV_REQ_H =
IT_APPROVAL =
IMPORTING
ET_EXCEPTION = lt_exception
CHANGING
CT_ORDERADM_H = lt_orderadm_h
CT_ORDERADM_I =
CT_INPUT_FIELDS = lt_input
CV_LOG_HANDLE = lv_log_handle
CT_PARTNER_ATTRIBUTES =
CT_DOC_FLOW =
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_crm_save = lv_guid.
INSERT ls_crm_save INTO TABLE lt_crm_save.
Saving the Order which is created by above function module
CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
it_objects_to_save = lt_crm_save
IMPORTING
et_saved_objects = lt_saved_objects
et_exception = lt_exception " Receiving objects that can be saved
et_objects_not_saved = lt_objects_not_saved
EXCEPTIONS
document_not_saved = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
write 'hello1'.
ENDIF.
Commit the save
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
write 'hello2'.
ENDIF.
Check Created order
READ TABLE lt_saved_objects INTO ls_saved_objects INDEX 1.
READ TABLE lt_objects_not_saved INTO ls_saved_objects INDEX 1.
write : lv_guid,ls_saved_objects-GUID,ls_saved_objects-OBJECT_ID. -
CRM Pricing error after 5000 seconds with CRM_ORDER_MAINTAIN in background
Hi,
This is Rajender. I am using function module CRM_ORDER_MAINTAIN to create sales order. I am facing a error while creating sales order from text file. while uploading 15000 records it is taking more than 5000 seconds. But after 5000 seconds the background job gets cancelled raising the error "Error occurred when processing Java programs".
Can anybody please tell me why the error is coming.
I am using the following sequence to create sales order.
CRM_ORDER_MAINTAIN - To create sales order header
CRM_ORDER_MAINTAIN - To create Item - Product, quantity, partner, manual price.
CRM_ORDER_SAVE
CRM_ORDER_INITIALIZE
Thanks & Regards,
Rajender Naik.Hi Rajender,
Try using the FM CRMXIF_ORDER_SAVE which is more of like an interface FM and its better to use this FM for interfaces/data loading. We had issues with using crm_order_maintain FM and had to replace with this one.
Refer to this below link on how to use this FM for a specific scenario-
http://www.divulgesap.com/blog.php?p=MTEy
Hope it helps.
Cheers,
Ravikiran -
'CRM_ORDER_MAINTAIN' error messages
HI guys,
I am using BAPI 'CRM_ORDER_MAINTAIN' to create FS Quotation, but i want to get error message before SAVE, Bapi only return exceptions table and CV_LOG_HANDLE. How can I get details of errors generated in the process of creation?
Thanks ind advance,
Regards.
Marisol
Edited by: Marisol on May 3, 2011 4:22 PMHi Marisol,
Not sure how you are using it - but CRM_ORDER_MAINTAIN returns exception names. Please use pattern button to get the complete code (or CONTROL + F6)
* EXCEPTIONS
* ERROR_OCCURRED = 1
* DOCUMENT_LOCKED = 2
* NO_CHANGE_ALLOWED = 3
* NO_AUTHORITY = 4
* OTHERS = 5
Also, you are right BAPI would return exception table - but CRM_ORDER_MAINTAIN is just an FM and not bapi.
Also, further I am sure you are calling CRM_ORDER_SAVE and 'BAPI_TRANSACTION_COMMIT' after this .
CV_LOG_HANDLE is for application log - you can use FM BAL_LOG_CREATE to create it and BAL_LOG_HDR_READ to read what it contains.
I hope it helps.
Thanks,
Rohit -
'CRM_ORDER_MAINTAIN' getting errors
HI guys,
I am using BAPI 'CRM_ORDER_MAINTAIN' to create FS Quotation, but i want to get error message before SAVE, Bapi only return exceptions table and CV_LOG_HANDLE. How can I get details of errors generated in the process of creation?
Thanks ind advance,
Regards.
Marisol
Edited by: Marisol on May 3, 2011 4:23 PMHi Darren,
Have you use function crm_order_maintain before?
Because it is quiet complicated that you have to prepare
each of group tables (Orgman, Partner, Order_h, Order_I etc...) depending upon your requirement.
For the error, can you more specific on the error.
At which step this error occurr?
Yes you can create Activity using this function module.
The only thing you need to do is to fit necessary parameters (tables) to this function (which are some quiet
trick and complex).
Rgds,
Gun. -
Change Pricing Condition for an item with CRM_ORDER_MAINTAIN
Hi community,
I try to change an existing condition with the function module crm_order_maintain.
Everything looks fine, no error no dump, but no success
The condition stays the same!
Can anybody find a solution for this?
Heres my report so far:
*& Report ZTEST_PRICING2
REPORT ztest_pricing2.
DATA: lt_guid TYPE crmt_object_guid_tab,
lt_item TYPE crmt_object_guid_tab,
lt_saved TYPE crmt_return_objects,
lt_pridoc TYPE crmt_pric_cond_t,
ls_pridoc TYPE crmt_pric_cond,
lt_pricom TYPE crmt_pridoc_comt,
ls_pricom TYPE crmt_pridoc_com,
lt_header TYPE crmt_orderadm_h_comt,
lt_input TYPE crmt_input_field_tab,
ls_input TYPE crmt_input_field,
ls_input_fn TYPE CRMT_INPUT_FIELD_NAMES,
ls_cond_chg TYPE prct_cond_external_change,
ls_cond TYPE PRCT_COND_DU,
lt_pricing_i TYPE CRMT_PRICING_I_WRKT.
PARAMETERS: lv_head TYPE crmt_object_guid DEFAULT 'C4C61C4E35DDF306E10000000A024089'.
PARAMETERS: lv_item TYPE crmt_object_guid DEFAULT '09C71C4E35DDF306E10000000A024089'.
PARAMETERS: lv_kbetr TYPE prct_cond_rate DEFAULT '100'.
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
* IV_MODE =
* IV_ONLY_SPEC_ITEMS =
* IT_REQUESTED_OBJECTS =
* IV_NO_AUTH_CHECK =
* IT_ITEM_USAGE_RANGE =
* IV_SUBITEM_DEPTH = -1
* IT_OBJECT_FILTER =
* IV_ONLY_CHANGED_OBJ = FALSE
* IV_STATUS_H_CHECK_RELEVANCE = FALSE
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 = 'PB00'.
IF sy-subrc <> 0.
WRITE: / 'ERROR'.
EXIT.
ENDIF.
ls_input-ref_guid = lv_head.
ls_input-ref_kind = 'A'.
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.
INSERT ls_input INTO TABLE lt_input.
ls_pricom-ref_guid = lv_head.
ls_pricom-ref_kind = 'A'.
*ls_pricom-PRICING_TYPE = 'B'.
*ls_pricom-pricing_procedure = 'ZZMTA'.
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.
regards
MarkusHello Jordi,
The example below is whereby i was trying to copy all the pricing condition on one document to another and deleting what's not present on the source document.
You can used this piece of code to adapt your requirement.
CALL FUNCTION 'ZCRC_FM_COPY_PRICE_COND_ALL'
EXPORTING
id_object_guid_src = <fs_el_con_guid>
id_object_guid_dest = <fs_el_so_guid>
id_commit = abap_false
EXCEPTIONS
not_allowed = 1
error_occured = 2
OTHERS = 3.
PERFORM f_recup_donnees USING id_object_guid_src
id_object_guid_dest.
PERFORM f_modif_condition_prix USING id_object_guid_src
id_object_guid_dest.
PERFORM f_header_copy_pricing using id_object_guid_src
id_object_guid_dest.
FORM f_recup_donnees USING pd_object_guid_src TYPE crmt_object_guid
pd_object_guid_dest TYPE crmt_object_guid.
DATA:
lt_header_guid TYPE crmt_object_guid_tab.
INSERT pd_object_guid_src INTO TABLE lt_header_guid.
INSERT pd_object_guid_dest INTO TABLE lt_header_guid.
CLEAR: gt_orderadm_i, gt_doc_flow.
CALL FUNCTION 'CRM_ORDER_READ'
EXPORTING
it_header_guid = lt_header_guid
IMPORTING
et_doc_flow = gt_doc_flow
et_orderadm_i = gt_orderadm_i
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 NE 0.
RAISE error_occured.
ENDIF.
" F_RECUP_DONNEES
FORM f_modif_condition_prix USING pd_guid_src TYPE crmt_object_guid
pd_guid_dest TYPE crmt_object_guid.
DATA : ld_pd_handle_src TYPE prct_handle,
ld_pd_handle_dest TYPE prct_handle,
lt_komv_print_src TYPE prct_cond_print_t,
lt_komv_print_dest TYPE prct_cond_print_t,
ls_komv_print_dest LIKE LINE OF lt_komv_print_dest,
ls_komv_print_src LIKE LINE OF lt_komv_print_src,
lt_cond_chg TYPE prct_cond_print_t,
lt_cond_chg_insert TYPE prct_cond_print_t,
ls_cond_chg TYPE prct_cond_print,
ls_cond_chg_tmp TYPE prct_cond_print,
ls_input_fields TYPE crmt_input_field,
lt_input_fields TYPE crmt_input_field_tab.
DATA : bal_log TYPE balloghndl,
lt_item_ret TYPE prct_item_ret_t,
lt_cond_ret TYPE prct_cond_print_t,
ld_data_changed TYPE xfeld,
gv_decimal TYPE usdefaults-dcpfm,
ld_lines TYPE i,
ld_ajout_cond TYPE abap_bool.
FIELD-SYMBOLS : <fs_orderadm_i_dest> TYPE crmt_orderadm_i_wrk,
<fs_orderadm_i_src> TYPE crmt_orderadm_i_wrk,
<fs_cond_chg> TYPE prct_cond_print,
<fs_cond_chg_insert> TYPE prct_cond_print.
* Début Ajout CD1K904313-001.
DATA: ld_guid_src TYPE crmt_object_guid.
FIELD-SYMBOLS: <fs_doc_flow> TYPE crmt_doc_flow_wrk.
* Début Ajout CD1K904313-001.
* Verrouillage des documents source et destinataire
PERFORM f_lock_document USING pd_guid_src.
PERFORM f_lock_document USING pd_guid_dest.
*Récupérer le pricing handle des documents
* Document source
CALL FUNCTION 'CRM_PRIDOC_GET_HANDLE_OW'
EXPORTING
iv_header_guid = pd_guid_src
IMPORTING
ev_pd_handle = ld_pd_handle_src
EXCEPTIONS
error_occurred = 1
handle_determination_error = 2
orgdata_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
RETURN.
ENDIF.
* Document destinataire
CALL FUNCTION 'CRM_PRIDOC_GET_HANDLE_OW'
EXPORTING
iv_header_guid = pd_guid_dest
IMPORTING
ev_pd_handle = ld_pd_handle_dest
EXCEPTIONS
error_occurred = 1
handle_determination_error = 2
orgdata_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
RETURN.
ENDIF.
* A ne pas traiter les postes de type ZPDF
DELETE gt_orderadm_i WHERE itm_type = 'ZPDF'.
LOOP AT gt_orderadm_i ASSIGNING <fs_orderadm_i_dest> WHERE header = pd_guid_dest.
REFRESH : lt_komv_print_src,
lt_komv_print_dest,
lt_cond_chg,
lt_cond_chg_insert.
* Début Modif CD1K904313-001.
* Récupérer le guid de l'item liée au item destinataire.
READ TABLE gt_doc_flow ASSIGNING <fs_doc_flow> WITH KEY objkey_b = <fs_orderadm_i_dest>-guid.
CHECK sy-subrc EQ 0.
ld_guid_src = <fs_doc_flow>-objkey_a.
* READ TABLE gt_orderadm_i ASSIGNING <fs_orderadm_i_src> WITH KEY header = pd_guid_src
* number_int = <fs_orderadm_i_dest>-number_int.
* Fin Modif CD1K904313-001.
* Récupérer les pricing document
IF sy-subrc EQ 0.
* Document source
CALL FUNCTION 'PRC_PD_ITEM_SHOW'
EXPORTING
iv_pd_handle = ld_pd_handle_src
* iv_item_no = <fs_orderadm_i_src>-guid "Supression CD1K904313-001
iv_item_no = ld_guid_src "Addition CD1K904313-001
IMPORTING
et_komv_print = lt_komv_print_src
EXCEPTIONS
non_existing_handle = 1
non_existing_item = 2
ipc_error = 3
OTHERS = 4.
ENDIF.
* Document destinataire
CALL FUNCTION 'PRC_PD_ITEM_SHOW'
EXPORTING
iv_pd_handle = ld_pd_handle_dest
iv_item_no = <fs_orderadm_i_dest>-guid
IMPORTING
et_komv_print = lt_komv_print_dest
EXCEPTIONS
non_existing_handle = 1
non_existing_item = 2
ipc_error = 3
OTHERS = 4.
* Modification et Suppression des conditions de prix
LOOP AT lt_komv_print_dest INTO ls_komv_print_dest .
CLEAR: ls_cond_chg,
ls_komv_print_src.
MOVE-CORRESPONDING ls_komv_print_dest TO ls_cond_chg.
* Rechercher la condition sur le document source
READ TABLE lt_komv_print_src INTO ls_komv_print_src WITH KEY kschl = ls_komv_print_dest-kschl
zaehk = ls_komv_print_dest-zaehk. "CD1K904313
IF sy-subrc EQ 0.
ls_cond_chg-kbetr_prt = ls_komv_print_src-kbetr_prt.
ls_cond_chg-kwert = ls_komv_print_src-kwert.
ls_cond_chg-kinak = ls_komv_print_src-kinak.
ELSEIF ls_cond_chg-kschl IS NOT INITIAL.
CLEAR ls_cond_chg.
CONTINUE.
ENDIF.
* Format décimal
CASE gv_decimal.
WHEN space. "format N.NNN,NN
REPLACE ALL OCCURRENCES OF '.' IN ls_cond_chg-kbetr_prt WITH ','.
WHEN 'Y'. "format N NNN NNN,NN
REPLACE ALL OCCURRENCES OF '.' IN ls_cond_chg-kbetr_prt WITH ','.
ENDCASE.
INSERT ls_cond_chg INTO TABLE lt_cond_chg.
CLEAR ls_cond_chg.
ENDLOOP.
* Ajout des conditions de prix
LOOP AT lt_komv_print_src INTO ls_komv_print_src WHERE kschl IS NOT INITIAL.
CLEAR: ls_cond_chg, ld_lines, ls_komv_print_dest, ls_cond_chg_tmp, ld_ajout_cond.
* Vérifier la présence de la condition sur le document destinataire
READ TABLE lt_komv_print_dest INTO ls_komv_print_dest WITH KEY kschl = ls_komv_print_src-kschl
zaehk = ls_komv_print_src-zaehk. "CD1K904313.
IF sy-subrc EQ 0.
CLEAR: ls_cond_chg, ls_komv_print_dest.
CONTINUE.
ELSE.
DESCRIBE TABLE lt_cond_chg LINES ld_lines.
READ TABLE lt_cond_chg INTO ls_cond_chg_tmp INDEX ld_lines.
IF sy-subrc EQ 0.
ld_ajout_cond = abap_true.
MOVE-CORRESPONDING ls_komv_print_src TO ls_cond_chg.
ls_cond_chg-knumv = ls_cond_chg_tmp-knumv.
ls_cond_chg-kposn = ls_cond_chg_tmp-kposn.
ls_cond_chg-stunr = ls_cond_chg_tmp-stunr + 10.
ELSE.
CLEAR: ls_cond_chg, ld_lines, ls_komv_print_dest, ls_cond_chg_tmp.
CONTINUE.
ENDIF.
ENDIF.
* Format décimal
CASE gv_decimal.
WHEN space. "format N.NNN,NN
REPLACE ALL OCCURRENCES OF '.' IN ls_cond_chg-kbetr_prt WITH ','.
WHEN 'Y'. "format N NNN NNN,NN
REPLACE ALL OCCURRENCES OF '.' IN ls_cond_chg-kbetr_prt WITH ','.
ENDCASE.
* Récupérer les nouvelles conditions qui seront ajouté au document destinataire
IF ld_ajout_cond EQ abap_true.
INSERT ls_cond_chg INTO TABLE lt_cond_chg_insert.
ENDIF.
INSERT ls_cond_chg INTO TABLE lt_cond_chg.
CLEAR ls_cond_chg.
ENDLOOP.
CALL FUNCTION 'PRC_INT_ITEM_INPUT'
EXPORTING
iv_pd_handle = ld_pd_handle_dest
iv_item_no = <fs_orderadm_i_dest>-guid
it_cond_prt = lt_cond_chg
iv_bal_log = bal_log
iv_req_ret = abap_true
iv_req_cond_prt = abap_true
IMPORTING
et_item_ret = lt_item_ret
et_cond_prt = lt_cond_ret
ev_data_changed = ld_data_changed
EXCEPTIONS
non_existing_handle = 1
non_existing_item = 2
ipc_error = 3.
IF sy-subrc = 0.
* En cas d'ajout de nouvelles conditions de prix, appeler le MF PRC_INT_ITEM_INPUT
* avec les montants
IF lt_cond_chg_insert IS NOT INITIAL.
REFRESH lt_cond_chg[].
lt_cond_chg[] = lt_cond_ret[].
LOOP AT lt_cond_chg_insert ASSIGNING <fs_cond_chg_insert>.
READ TABLE lt_cond_chg ASSIGNING <fs_cond_chg> WITH KEY kschl = <fs_cond_chg_insert>-kschl.
IF sy-subrc EQ 0.
<fs_cond_chg>-kwert = <fs_cond_chg_insert>-kwert.
<fs_cond_chg>-kbetr_prt = <fs_cond_chg_insert>-kbetr_prt.
ENDIF.
ENDLOOP.
REFRESH lt_cond_ret[].
CALL FUNCTION 'PRC_INT_ITEM_INPUT'
EXPORTING
iv_pd_handle = ld_pd_handle_dest
iv_item_no = <fs_orderadm_i_dest>-guid
it_cond_prt = lt_cond_chg
iv_bal_log = bal_log
iv_req_ret = abap_true
iv_req_cond_prt = abap_true
IMPORTING
et_item_ret = lt_item_ret
et_cond_prt = lt_cond_ret
ev_data_changed = ld_data_changed
EXCEPTIONS
non_existing_handle = 1
non_existing_item = 2
ipc_error = 3.
ENDIF.
* Publish event afin de sauvegarder les conditions de prix
CALL FUNCTION 'CRM_EVENT_PUBLISH_OW'
EXPORTING
iv_obj_name = 'PRIDOC'
iv_guid_hi = pd_guid_dest
iv_kind_hi = 'A'
iv_event = 'SAVE'
EXCEPTIONS
OTHERS = 1.
* As no order_maintain will follow implicitly and therefore no
* exec times for the events will be set, call CRM_ORDER_MAINTAIN
* without any parameters
* Then the exec time 'end of document' will be set and with the
* group logic also all exec times before
* But at least one object is needed in input_fields
* --> use PRIDOC
ls_input_fields-ref_guid = <fs_orderadm_i_dest>-guid.
ls_input_fields-ref_kind = 'B'.
ls_input_fields-objectname = 'PRIDOC'.
INSERT ls_input_fields INTO TABLE lt_input_fields.
CLEAR ls_input_fields.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
CHANGING
ct_input_fields = lt_input_fields
EXCEPTIONS
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
OTHERS = 5.
ENDIF.
ENDLOOP.
" F_MODIF_CONDITION_PRIX
*& Form F_LOCK_DOCUMENT
* Verrouillage d'un document
FORM f_lock_document USING pd_guid TYPE crmt_object_guid.
CONSTANTS : lc_orderadm_h TYPE crmt_object_name VALUE 'ORDERADM_H',
lc_orderadm_i TYPE crmt_object_name VALUE 'ORDERADM_I'.
DATA: lv_process_mode TYPE crmt_mode,
lv_order_initialized TYPE crmt_boolean,
lv_process_type TYPE crmt_process_type,
lv_already_locked TYPE abap_bool.
DATA: ls_admin_ui_status TYPE crmt_admin_ui_status,
ls_item_usage_range TYPE crmt_item_usage_range.
DATA: lt_objects_to_read TYPE crmt_object_guid_tab,
lt_requested_objects TYPE crmt_object_name_tab,
lt_item_usage_range TYPE crmt_item_usage_range_tab,
lt_locked_contract TYPE crmt_object_guid_tab.
INSERT pd_guid INTO TABLE lt_objects_to_read.
INSERT lc_orderadm_h INTO TABLE lt_requested_objects.
INSERT lc_orderadm_i INTO TABLE lt_requested_objects.
ls_item_usage_range-sign = 'E'.
ls_item_usage_range-value = '02'.
INSERT ls_item_usage_range INTO TABLE lt_item_usage_range.
* LAM: Financing Options should be viewed in a separate screen:
ls_item_usage_range-sign = 'E'.
ls_item_usage_range-value = '05'. "Financing options
INSERT ls_item_usage_range INTO TABLE lt_item_usage_range.
*-> read document in change mode
CALL FUNCTION 'CRM_ORDER_READ'
EXPORTING
it_header_guid = lt_objects_to_read
iv_mode = 'B'
it_requested_objects = lt_requested_objects
it_item_usage_range = lt_item_usage_range
EXCEPTIONS
document_not_found = 1
error_occurred = 2
document_locked = 3
no_change_authority = 4
no_display_authority = 5
OTHERS = 6.
PERFORM enqueue_order IN PROGRAM saplcrm_order_ow IF FOUND
USING pd_guid
abap_false
abap_false
abap_false
CHANGING sy-subrc
lv_already_locked
lt_locked_contract.
" F_LOCK_DOCUMENT
* Fin Ajout CD1K904074-001
FORM f_header_copy_pricing USING pd_guid_src
pd_guid_dest.
DATA : ld_pd_handle_src TYPE prct_handle,
ld_pd_handle_dest TYPE prct_handle,
lt_komv_print_src TYPE prct_cond_print_t,
lt_komv_print_dest TYPE prct_cond_print_t,
ls_komv_print_dest LIKE LINE OF lt_komv_print_dest,
ls_komv_print_src LIKE LINE OF lt_komv_print_src,
lt_cond_chg TYPE prct_cond_print_t,
ls_cond_chg TYPE prct_cond_print,
ls_input_fields TYPE crmt_input_field,
lt_input_fields TYPE crmt_input_field_tab.
DATA : bal_log TYPE balloghndl,
lt_cond_ret TYPE prct_cond_print_t,
ld_data_changed TYPE xfeld,
gv_decimal TYPE usdefaults-dcpfm.
* Verrouillage des documents source et destinataire
PERFORM f_lock_document USING pd_guid_src.
PERFORM f_lock_document USING pd_guid_dest.
* Récupérer le pricing handle des documents
* Document source
CALL FUNCTION 'CRM_PRIDOC_GET_HANDLE_OW'
EXPORTING
iv_header_guid = pd_guid_src
IMPORTING
ev_pd_handle = ld_pd_handle_src
EXCEPTIONS
error_occurred = 1
handle_determination_error = 2
orgdata_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
RETURN.
ENDIF.
* Document destinataire
CALL FUNCTION 'CRM_PRIDOC_GET_HANDLE_OW'
EXPORTING
iv_header_guid = pd_guid_dest
IMPORTING
ev_pd_handle = ld_pd_handle_dest
EXCEPTIONS
error_occurred = 1
handle_determination_error = 2
orgdata_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
RETURN.
ENDIF.
* * Récupérer les pricing document
* Document Source
CALL FUNCTION 'PRC_PD_HEAD_SHOW'
EXPORTING
iv_pd_handle = ld_pd_handle_src
IMPORTING
et_komv_print = lt_komv_print_src
EXCEPTIONS
non_existing_handle = 1
ipc_error = 2
OTHERS = 3.
CHECK sy-subrc EQ 0.
* Document Destinataire
CALL FUNCTION 'PRC_PD_HEAD_SHOW'
EXPORTING
iv_pd_handle = ld_pd_handle_dest
IMPORTING
et_komv_print = lt_komv_print_dest
EXCEPTIONS
non_existing_handle = 1
ipc_error = 2
OTHERS = 3.
CHECK sy-subrc EQ 0.
* * Modification et Suppression des conditions de prix
LOOP AT lt_komv_print_src INTO ls_komv_print_src .
CLEAR: ls_cond_chg,
ls_komv_print_dest.
MOVE-CORRESPONDING ls_komv_print_src TO ls_cond_chg.
* Rechercher la condition sur le document source
READ TABLE lt_komv_print_dest INTO ls_komv_print_dest WITH KEY kschl = ls_komv_print_src-kschl
zaehk = ls_komv_print_src-zaehk.
IF sy-subrc EQ 0.
IF ls_komv_print_src-kbetr NE ls_komv_print_dest-kbetr.
ls_cond_chg-kbetr_prt = ls_komv_print_src-kbetr_prt.
ls_cond_chg-kwert = ls_komv_print_src-kwert.
ls_cond_chg-kinak = ls_komv_print_src-kinak.
CASE gv_decimal.
WHEN space. "format N.NNN,NN
REPLACE ALL OCCURRENCES OF '.' IN ls_cond_chg-kbetr_prt WITH ','.
WHEN 'Y'. "format N NNN NNN,NN
REPLACE ALL OCCURRENCES OF '.' IN ls_cond_chg-kbetr_prt WITH ','.
ENDCASE.
ENDIF.
ENDIF.
CLEAR ls_cond_chg-krech.
INSERT ls_cond_chg INTO TABLE lt_cond_chg.
CLEAR ls_cond_chg.
ENDLOOP.
CALL FUNCTION 'PRC_INT_HEAD_INPUT'
EXPORTING
iv_pd_handle = ld_pd_handle_dest
iv_bal_log = bal_log
it_cond_prt = lt_cond_chg
iv_req_ret = abap_true
iv_req_cond_prt = abap_true
IMPORTING
et_cond_prt = lt_cond_ret
ev_data_changed = ld_data_changed
EXCEPTIONS
non_existing_handle = 1
ipc_error = 2
not_allowed = 3
OTHERS = 4.
CHECK sy-subrc EQ 0.
* * Publish event afin de sauvegarder les conditions de prix
CALL FUNCTION 'CRM_EVENT_PUBLISH_OW'
EXPORTING
iv_obj_name = 'PRIDOC'
iv_guid_hi = pd_guid_dest
iv_kind_hi = 'A'
iv_event = 'SAVE'
EXCEPTIONS
OTHERS = 1.
* As no order_maintain will follow implicitly and therefore no
* exec times for the events will be set, call CRM_ORDER_MAINTAIN
* without any parameters
* Then the exec time 'end of document' will be set and with the
* group logic also all exec times before
* But at least one object is needed in input_fields
* --> use PRIDOC
ls_input_fields-ref_guid = pd_guid_dest.
ls_input_fields-ref_kind = 'A'.
ls_input_fields-objectname = 'PRIDOC'.
INSERT ls_input_fields INTO TABLE lt_input_fields.
CLEAR ls_input_fields.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
CHANGING
ct_input_fields = lt_input_fields
EXCEPTIONS
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
OTHERS = 5.
ENDFORM.
FORM f_header_copy_pricing USING pd_guid_src
pd_guid_dest.
DATA : ld_pd_handle_src TYPE prct_handle,
ld_pd_handle_dest TYPE prct_handle,
lt_komv_print_src TYPE prct_cond_print_t,
lt_komv_print_dest TYPE prct_cond_print_t,
ls_komv_print_dest LIKE LINE OF lt_komv_print_dest,
ls_komv_print_src LIKE LINE OF lt_komv_print_src,
lt_cond_chg TYPE prct_cond_print_t,
ls_cond_chg TYPE prct_cond_print,
ls_input_fields TYPE crmt_input_field,
lt_input_fields TYPE crmt_input_field_tab.
DATA : bal_log TYPE balloghndl,
lt_cond_ret TYPE prct_cond_print_t,
ld_data_changed TYPE xfeld,
gv_decimal TYPE usdefaults-dcpfm.
PERFORM f_lock_document USING pd_guid_src.
PERFORM f_lock_document USING pd_guid_dest.
* Récupérer le pricing handle des documents
* Document source
CALL FUNCTION 'CRM_PRIDOC_GET_HANDLE_OW'
EXPORTING
iv_header_guid = pd_guid_src
IMPORTING
ev_pd_handle = ld_pd_handle_src
EXCEPTIONS
error_occurred = 1
handle_determination_error = 2
orgdata_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
RETURN.
ENDIF.
* Document destinataire
CALL FUNCTION 'CRM_PRIDOC_GET_HANDLE_OW'
EXPORTING
iv_header_guid = pd_guid_dest
IMPORTING
ev_pd_handle = ld_pd_handle_dest
EXCEPTIONS
error_occurred = 1
handle_determination_error = 2
orgdata_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
RETURN.
ENDIF.
* * Récupérer les pricing document
* Document Source
CALL FUNCTION 'PRC_PD_HEAD_SHOW'
EXPORTING
iv_pd_handle = ld_pd_handle_src
IMPORTING
et_komv_print = lt_komv_print_src
EXCEPTIONS
non_existing_handle = 1
ipc_error = 2
OTHERS = 3.
CHECK sy-subrc EQ 0.
* Document Destinataire
CALL FUNCTION 'PRC_PD_HEAD_SHOW'
EXPORTING
iv_pd_handle = ld_pd_handle_dest
IMPORTING
et_komv_print = lt_komv_print_dest
EXCEPTIONS
non_existing_handle = 1
ipc_error = 2
OTHERS = 3.
CHECK sy-subrc EQ 0.
* * Modification et Suppression des conditions de prix
LOOP AT lt_komv_print_src INTO ls_komv_print_src .
CLEAR: ls_cond_chg,
ls_komv_print_dest.
MOVE-CORRESPONDING ls_komv_print_src TO ls_cond_chg.
* Rechercher la condition sur le document source
READ TABLE lt_komv_print_dest INTO ls_komv_print_dest WITH KEY kschl = ls_komv_print_src-kschl
zaehk = ls_komv_print_src-zaehk.
IF sy-subrc EQ 0.
IF ls_komv_print_src-kbetr NE ls_komv_print_dest-kbetr.
ls_cond_chg-kbetr_prt = ls_komv_print_src-kbetr_prt.
ls_cond_chg-kwert = ls_komv_print_src-kwert.
ls_cond_chg-kinak = ls_komv_print_src-kinak.
CASE gv_decimal.
WHEN space. "format N.NNN,NN
REPLACE ALL OCCURRENCES OF '.' IN ls_cond_chg-kbetr_prt WITH ','.
WHEN 'Y'. "format N NNN NNN,NN
REPLACE ALL OCCURRENCES OF '.' IN ls_cond_chg-kbetr_prt WITH ','.
ENDCASE.
ENDIF.
ENDIF.
CLEAR ls_cond_chg-krech.
INSERT ls_cond_chg INTO TABLE lt_cond_chg.
CLEAR ls_cond_chg.
ENDLOOP.
CALL FUNCTION 'PRC_INT_HEAD_INPUT'
EXPORTING
iv_pd_handle = ld_pd_handle_dest
iv_bal_log = bal_log
it_cond_prt = lt_cond_chg
iv_req_ret = abap_true
iv_req_cond_prt = abap_true
IMPORTING
et_cond_prt = lt_cond_ret
ev_data_changed = ld_data_changed
EXCEPTIONS
non_existing_handle = 1
ipc_error = 2
not_allowed = 3
OTHERS = 4.
CHECK sy-subrc EQ 0.
CALL FUNCTION 'CRM_EVENT_PUBLISH_OW'
EXPORTING
iv_obj_name = 'PRIDOC'
iv_guid_hi = pd_guid_dest
iv_kind_hi = 'A'
iv_event = 'SAVE'
EXCEPTIONS
OTHERS = 1.
ls_input_fields-ref_guid = pd_guid_dest.
ls_input_fields-ref_kind = 'A'.
ls_input_fields-objectname = 'PRIDOC'.
INSERT ls_input_fields INTO TABLE lt_input_fields.
CLEAR ls_input_fields.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
CHANGING
ct_input_fields = lt_input_fields
EXCEPTIONS
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
OTHERS = 5. -
Ibase and configuration error while creating a Service Contract
Hi,
I am creating a Service Contract programatically and not manually through the T-code CRMD_ORDER.
I am using the Function module CRMXIF_ORDER_SAVE for the same as the FM BAPI_BUSPROCESSND_CREATEMULTI and CRM_ORDER_MAINTAIN did not work for me because of the number of parameters that needs to be passed for creating the Service contract.
The Service contract does get created but there are errors corresponding to the Point of delivery and configuration missing.
The error corresponding to the point of delivery says "IS-U:allocate a point of delivery to the item" even though I am passing the values in the REF_OBJECTS field of the CRMXIF_BUSTRANS_ITEM structure.
Structure for the same is :
ls_objects_i-TYPE_REF_OBJ = 'B'.
ls_objects_i-object_task = 'I'.
ls_objects_i-PRODUCT_GUID = lv_product_guid.
ls_objects_i-PRODUCT_ID = p_product_id.
ls_objects_i-IBASE_COMP_GUID = ls_output-IBASE_GUID.
ls_objects_i-IB_INSTANCE = 1582.
ls_objects_i-IB_COMP_VALID = '20070926093651'.
ls_objects_i-SERIAL_NUMBER = '0102 46CC9C278B92025BE10000000AD5920E'.
append ls_objects_i to lt_objects_i.
p_ls_item-REF_OBJECT-data = lt_objects_i.
p_ls_item-REF_OBJECT-datax = 'X'.
Similarly,the error for the configuration says "Configuration for the item missing" and here again I am passing the values in the CONFIGURATION structure.
Structure for this is :
p_ls_item-configuration-data-consist = 'T'.
p_ls_item-configuration-data-kbname = 32.
p_ls_item-configuration-data-kbvers = '0.0'.
p_ls_item-configuration-data-kbprofile = 'E_H_B'.
p_ls_item-configuration-data-complete = 'T'.
p_ls_item-configuration-data-spras = 'E'.
p_ls_item-configuration-data-cfginfo = 'VCOND=VARIANT_CONDITION_KEY'
ls_cuins-OBJ_TYPE = 'SERV'.
ls_cuins-class_type = 300.
ls_cuins-obj_key = 'E_H_B'.
ls_cuins-obj_txt = 'E_H_B'.
ls_cuins-QUANTITY = '1.0'.
ls_cuins-COMPLETE = 'T'.
ls_cuins-CONSIST = 'T'.
append ls_cuins to lt_cuins.
ls_config_i-instance = lt_cuins.
p_ls_item-configuration-data = ls_config_i.
p_ls_item-configuration-datax = 'X'.
clear ls_config_i.
ls_cuval-charc = 'DISCOUNT_EUR'.
ls_cuval-charc_txt = 'DISCOUNT_EUR'.
ls_cuval-value = '0.0'.
ls_cuval-value_txt
append ls_cuval to lt_cuval.
ls_instance-value = lt_cuval.
insert ls_instance into table lt_instance.
ls_config_i-instance = lt_instance.
p_ls_item-configuration-data = ls_config_i.
p_ls_item-configuration-datax = 'X'.
clear ls_config_i.
Kindly help if anyone has worked on this.......
Regards,
Puneet Jhari.Hi,
I am creating a Service Contract programatically and not manually through the T-code CRMD_ORDER.
I am using the Function module CRMXIF_ORDER_SAVE for the same as the FM BAPI_BUSPROCESSND_CREATEMULTI and CRM_ORDER_MAINTAIN did not work for me because of the number of parameters that needs to be passed for creating the Service contract.
The Service contract does get created but there are errors corresponding to the Point of delivery and configuration missing.
The error corresponding to the point of delivery says "IS-U:allocate a point of delivery to the item" even though I am passing the values in the REF_OBJECTS field of the CRMXIF_BUSTRANS_ITEM structure.
Structure for the same is :
ls_objects_i-TYPE_REF_OBJ = 'B'.
ls_objects_i-object_task = 'I'.
ls_objects_i-PRODUCT_GUID = lv_product_guid.
ls_objects_i-PRODUCT_ID = p_product_id.
ls_objects_i-IBASE_COMP_GUID = ls_output-IBASE_GUID.
ls_objects_i-IB_INSTANCE = 1582.
ls_objects_i-IB_COMP_VALID = '20070926093651'.
ls_objects_i-SERIAL_NUMBER = '0102 46CC9C278B92025BE10000000AD5920E'.
append ls_objects_i to lt_objects_i.
p_ls_item-REF_OBJECT-data = lt_objects_i.
p_ls_item-REF_OBJECT-datax = 'X'.
Similarly,the error for the configuration says "Configuration for the item missing" and here again I am passing the values in the CONFIGURATION structure.
Structure for this is :
p_ls_item-configuration-data-consist = 'T'.
p_ls_item-configuration-data-kbname = 32.
p_ls_item-configuration-data-kbvers = '0.0'.
p_ls_item-configuration-data-kbprofile = 'E_H_B'.
p_ls_item-configuration-data-complete = 'T'.
p_ls_item-configuration-data-spras = 'E'.
p_ls_item-configuration-data-cfginfo = 'VCOND=VARIANT_CONDITION_KEY'
ls_cuins-OBJ_TYPE = 'SERV'.
ls_cuins-class_type = 300.
ls_cuins-obj_key = 'E_H_B'.
ls_cuins-obj_txt = 'E_H_B'.
ls_cuins-QUANTITY = '1.0'.
ls_cuins-COMPLETE = 'T'.
ls_cuins-CONSIST = 'T'.
append ls_cuins to lt_cuins.
ls_config_i-instance = lt_cuins.
p_ls_item-configuration-data = ls_config_i.
p_ls_item-configuration-datax = 'X'.
clear ls_config_i.
ls_cuval-charc = 'DISCOUNT_EUR'.
ls_cuval-charc_txt = 'DISCOUNT_EUR'.
ls_cuval-value = '0.0'.
ls_cuval-value_txt
append ls_cuval to lt_cuval.
ls_instance-value = lt_cuval.
insert ls_instance into table lt_instance.
ls_config_i-instance = lt_instance.
p_ls_item-configuration-data = ls_config_i.
p_ls_item-configuration-datax = 'X'.
clear ls_config_i.
Kindly help if anyone has worked on this.......
Regards,
Puneet Jhari. -
Error while creating return order(Complaint) in IC web client
Hi SAP Experts,
I am getting following Error while creating return order(Complaint) in IC web client.
Error when processing your request
What has happened?
The URL http://sapcrd.comfort.com:8000/sap/bc/bsp/sap/crm_ic/default_delta.do was not called due to an error.
Note
The following error text was processed in the system CRD : Exception condition "NON_EXISTING_HANDLE" raised.
The error occurred on the application server sapcrd_CRD_00 and in the work process 2 .
The termination type was: RABAX_STATE
The ABAP call stack was:
Function: PRC_PD_HEAD_ADD_COND of program SAPLPRC_PRICING_API
Function: CRM_PRIDOC_UPDATE_EC of program SAPLCRM_PRIDOC_COM_EC
Form: EXECUTE_CALLBACKS_PLANNED of program SAPLCRM_EVENT_OW
Function: CRM_EVENT_SET_EXETIME_OW of program SAPLCRM_EVENT_OW
Function: CRM_ORDER_COMPLETE_SINGLE_OW of program SAPLCRM_ORDER_OW
Function: CRM_ORDER_MAINTAIN_SINGLE_OW of program SAPLCRM_ORDER_OW
Function: CRM_ORDER_MAINTAIN_MULTI_OW of program SAPLCRM_ORDER_OW
Function: CRM_ORDER_MAINTAIN of program SAPLCRM_ORDER_API
Method: IF_EX_ORDER_SAVE~PREPARE of program ZCL_IM_PRICE_ADJUSTMENT=======CP
Method: IF_EX_ORDER_SAVE~PREPARE of program CL_EX_ORDER_SAVE==============CP
What can I do?
If the termination type was RABAX_STATE, then you can find more information on the cause of the termination in the system CRD in transaction ST22.
If the termination type was ABORT_MESSAGE_STATE, then you can find more information on the cause of the termination on the application server sapcrd_CRD_00 in transaction SM21.
If the termination type was ERROR_MESSAGE_STATE, then you can search for more information in the trace file for the work process 2 in transaction ST11 on the application server sapcrd_CRD_00 . In some situations, you may also need to analyze the trace files of other work processes.
If you do not yet have a user ID, contact your system administrator.
Error code: ICF-IE-http -c: 330 -u: VORUSX -l: E -s: CRD -i: sapcrd_CRD_00 -w: 2 -d: 20080324 -t: 021723 -v: RABAX_STATE -e: RAISE_EXCEPTION
HTTP 500 - Internal Server Error
Your SAP Internet Communication Framework Team
Maximum points will be awarded for useful information.
Thanks,
RonyHi,
I notice there is a Z class being called.
Method: IF_EX_ORDER_SAVE~PREPARE of program ZCL_IM_PRICE_ADJUSTMENT=======CP
You should check this customized class.
Cheers,
cady. -
Run time error while closing the CRM Order using BAPI
Hi Experts,
Need your invaluable suggestions here.Apologies for the lengthy mail, intention is to give clear idea of the issue.
I am facing an issue while closing the CRM orders. According to our business process, when an issue is solved we will keep the order in resolved status only. We will not directly close the order from the CRM tool, instead we have created a custom program for the same purpose.
For the custom program we will give input as the order number and execute it, this will close the order.
Here close the order means assigning it to Close status as well assign the reason code.
We have created some reason codes for closed status.
So when the program is run the Order moves from resolved status to closed status along with reason code.
But of late we are facing some problems with this program, it is giving run time error for some CRM orders.
Run time error message : The ABAP/4 Open SQL array insert results in duplicate database records.
The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught in procedure "CRM_SERVICE_OS_UPD_OST_DU" "(FUNCTION)", nor was it propagated by a RAISING clause.
Please find my code which have used in the custom program
Closing the resolved SOs in the system
CALL FUNCTION 'CRM_STATUS_CHANGE_EXTERN_OW'
EXPORTING
objnr = iv_guid
user_status = lc_status_closed
EXCEPTIONS
object_not_found = 1
status_inconsistent = 2
status_not_allowed = 3
OTHERS = 4.
IF sy-subrc <> 0.
WRITE : 'Error at maintaining status'.
ENDIF.
Set reason code
build lt_subject
ls_subject-ref_guid = iv_guid.
ls_subject-katalogart = 'A2'.
ls_subject-codegruppe = 'ZR000003'.
ls_subject-code = 'ZR33'. " Reason code
ls_subject-mode = 'A'.
APPEND ls_subject TO lt_subject.
build lt_ossset
ls_osset-ref_guid = iv_guid.
ls_osset-subject_profile = 'ZREASON03'.
ls_osset-profile_type = 'G'.
ls_osset-subject = lt_subject.
APPEND ls_osset TO lt_osset.
build lt_service_os
ls_service_os-ref_guid = iv_guid.
ls_service_os-ref_kind = 'A'.
ls_service_os-osset = lt_osset.
APPEND ls_service_os TO lt_service_os.
build lt_input_fields
REFRESH: lt_input_fields, lt_field_names.
CLEAR : ls_input_fields, ls_field_names.
ls_field_names-fieldname = 'CODE'.
APPEND ls_field_names TO lt_field_names.
ls_field_names-fieldname = 'CODEGRUPPE'.
APPEND ls_field_names TO lt_field_names.
ls_field_names-fieldname = 'KATALOGART'.
APPEND ls_field_names TO lt_field_names.
ls_field_names-fieldname = 'SERVICE_PROFILE'.
APPEND ls_field_names TO lt_field_names.
ls_input_fields-ref_guid = iv_guid.
ls_input_fields-ref_kind = 'A'.
ls_input_fields-objectname = 'SERVICE_OS'.
ls_input_fields-field_names = lt_field_names.
APPEND ls_input_fields TO lt_input_fields.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
it_service_os = lt_service_os
CHANGING
ct_input_fields = lt_input_fields
EXCEPTIONS
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
OTHERS = 5.
IF sy-subrc <> 0.
WRITE : 'Error at maintaining reason'.
ENDIF.
CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
it_objects_to_save = lt_header_guid
iv_update_task_local = lv_update_task_local
IMPORTING
et_saved_objects = lt_saved_objects
EXCEPTIONS
document_not_saved = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE : 'Error at saving'.
ELSE.
WRITE : 'Successfully Closed'.
COMMIT WORK AND WAIT.
ENDIF.
Run time error is coming at COMMIT WORK AND WAIT statement.
Please let me know any corrections are required in the above program.
When I analyzed the run time error I have found that it trying to insert the record in CRMD_SRV_OSSET for that CRM order, but already one record is present in the table for the same CRM order number.
For most of the CRM orders there is no entry in this table so they are closing successfully but for a few orders for which there is an entry we are getting the above run time error.
There is nothing wrong with the orders which have an entry already in the table CRMD_SRV_OSSET, I need to close these kind of orders with out run time error.
Kindly provide your feedback.Hi Dinakar,
You posted this in APO PPDS forum. This question should go to PP forum where someone could answer it.
Please close this thread and open a new thread in PP forum so that you could get help quickly from the relevant experts.
Regards - Pawan -
Problem in CRM_ORDER_MAINTAIN for updating amount in line items
Hi abapers,
I have a scenario as follows: i want to update amount for line items in a transaction. i use the bapi crm_order_maintain followed by CRM_ORDER_SAVE and bapi transaction _commit . The problem is i loop the itab by passing the trnstn id , prdct code and new amount.
i applied the logic as given by rita tan (thread no 4)
link:[Re: Update Pricing Document with CRM_ORDER_MAINTAIN]
as per the logic i delete the existing value and insert the new amount . this works fine in the first loop and in second loop it deletes the existing record but does not insert the new value . It doesn't even give error too. what may be the problem.
here's a snapshot of the code i have written:
loop at itab.
SELECT SINGLE * FROM CRMD_ORDERADM_H
WHERE OBJECT_ID = WA_ZCMR_UPDATE-Z_OBJECTID
AND PROCESS_TYPE = P_TYPE.
SELECT SINGLE * FROM CRMD_ORDERADM_I
WHERE HEADER = CRMD_ORDERADM_H-GUID
AND ORDERED_PROD = WA_ZCMR_UPDATE-PRODUCT_CODE.
SELECT SINGLE * FROM CRMD_LINK
WHERE GUID_HI = CRMD_ORDERADM_H-GUID
AND OBJTYPE_SET = '18'.
SELECT * FROM PRCD_COND
INTO CORRESPONDING FIELDS OF TABLE IT_PRCD_COND
WHERE KNUMV = CRMD_LINK-GUID_SET
AND KPOSN = CRMD_ORDERADM_I-GUID
AND KSCHL = 'ZR12'.
READ TABLE IT_PRCD_COND
INTO WA_PRCD_COND INDEX 1.
DELETE FROM PRCD_COND
WHERE KNUMV = WA_PRCD_COND-KNUMV
AND KPOSN = WA_PRCD_COND-KPOSN
AND KSCHL = 'ZR12'.
COMMIT WORK.
WA_PRIDOC-REF_HANDLE = '0000000001'.
WA_PRIDOC-REF_GUID = CRMD_ORDERADM_I-GUID.
WA_PRIDOC-REF_KIND = 'B' .
WA_COND_ADD-KSCHL = 'ZR12'.
WA_COND_ADD-KBETR = WA_ZCMR_UPDATE-NET_VALUE.
WA_COND_ADD-KPEIN = '1'.
WA_COND_ADD-WAERS = 'INR'.
INSERT WA_COND_ADD INTO TABLE IT_COND_ADD.
CLEAR WA_COND_ADD.
WA_PRIDOC-COND_ADD = IT_COND_ADD.
CLEAR IT_COND_ADD[].
INSERT WA_PRIDOC INTO TABLE IT_PRIDOC .
CLEAR WA_PRIDOC .
WA_CT_INPUT_FIELDS1-REF_HANDLE = '0000000001'.
WA_CT_INPUT_FIELDS1-REF_GUID = CRMD_ORDERADM_I-GUID.
WA_CT_INPUT_FIELDS1-REF_KIND = 'B' .
WA_CT_INPUT_FIELDS1-OBJECTNAME = 'PRIDOC'.
INSERT WA_CT_INPUT_FIELDS1 INTO TABLE IT_CT_INPUT_FIELDS1.
CLEAR WA_CT_INPUT_FIELDS1.
AT END OF Z_OBJECTID.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
IT_PRIDOC = IT_PRIDOC
CHANGING
CT_INPUT_FIELDS = IT_CT_INPUT_FIELDS1
EXCEPTIONS
ERROR_OCCURRED = 1
DOCUMENT_LOCKED = 2
NO_CHANGE_ALLOWED = 3
NO_AUTHORITY = 4
OTHERS = 5.
CALL FUNCTION 'CRM_ORDER_SAVE'
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
endat.
endloop.
Please help out.
Regards,
Navin
Edited by: navin.c on Jan 7, 2010 10:09 AMCheck the link below. This should help
Re: Change Order Quantity in CRM Sales Order -
CRM_ORDER_MAINTAIN - in order_save BADI
Hi Experts,
I want to update my order. I have to add the account assignment group to my service order when the order is saved. How do I pass this value in the badi order_save. I want to use the function module crm_order_maintain. Can anyone please suggest how do I go about it.
Warm Regards,
AbdullahHi Experts,
This is how I code after I use CRM_ORDER_READ in the badi method change_before_update.
select single *
from zco003
into wa_zco003
where service_org_shor = v_sorg and
process_type = v_process_type.
if sy-subrc = 0.
iw_ac_assign-ref_guid = iv_guid.
iw_ac_assign-ref_kind = 'A'.
iw_ac_assign-ac_object_type = '01'.
iw_ac_assign-ac_assignment = wa_zco003-aufnr.
iw_ac_assign-ac_percentage = '0.00'.
iw_ac_assign-mode = 'C'.
append iw_ac_assign to it_ac_assign.
cw_orderadm_h-guid = iv_guid.
append cw_orderadm_h to ct_orderadm_h.
cw_input_fields-ref_guid = iv_guid.
cw_input_fields-ref_kind = 'A'.
cw_input_fields-objectname = 'AC_ASSIGN'.
cw_field_name-fieldname = 'AC_ASSIGNMENT'.
cw_field_name-changeable = 'X'.
append cw_field_name to ct_field_name.
cw_field_name-fieldname = 'AC_OBJECT_TYPE'.
cw_field_name-changeable = 'X'.
append cw_field_name to ct_field_name.
cw_field_name-fieldname = 'AC_PERCENTAGE'.
cw_field_name-changeable = 'X'.
append cw_field_name to ct_field_name.
cw_field_name-fieldname = 'AC_TYPE_T'.
cw_field_name-changeable = 'X'.
append cw_field_name to ct_field_name.
cw_field_name-fieldname = 'MODE'.
cw_field_name-changeable = 'X'.
append cw_field_name to ct_field_name.
cw_input_fields-field_names[] = ct_field_name[].
append cw_input_fields to ct_input_fields.
loop at et_orderadm_i into ew_orderadm_i.
clear cw_input_fields.
cw_input_fields-ref_guid = ew_orderadm_i-guid.
cw_input_fields-ref_kind = 'B'.
cw_input_fields-objectname = 'AC_ASSIGN'.
append cw_input_fields to ct_input_fields.
endloop.
clear cw_input_fields.
cw_input_fields-ref_guid = iv_guid.
cw_input_fields-ref_kind = 'A'.
cw_input_fields-objectname = 'ORDERADM_H'.
append cw_input_fields to ct_input_fields.
loop at et_orderadm_i into ew_orderadm_i.
cw_orderadm_i-guid = ew_orderadm_i-guid.
append cw_orderadm_i to ct_orderadm_i.
clear cw_orderadm_i.
endloop.
loop at et_orderadm_i into ew_orderadm_i.
clear cw_input_fields.
cw_input_fields-ref_guid = ew_orderadm_i-guid.
cw_input_fields-ref_kind = 'B'.
cw_input_fields-objectname = 'ORDERADM_I'.
append cw_input_fields to ct_input_fields.
endloop.
call function 'CRM_ORDER_MAINTAIN'
exporting
it_ac_assign = it_ac_assign
importing
et_exception = et_exception
changing
* ct_orderadm_h = ct_orderadm_h
* ct_orderadm_i = ct_orderadm_i
ct_input_fields = ct_input_fields
cv_log_handle = cv_log_handle
* ct_partner_attributes =
* ct_doc_flow =
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.
message 'error in updating' type 'e'.
endif.
Can anyone please suggest what am I doing wrong
Regards,
Abdullah -
CRM_ORDER_MAINTAIN not updating the item level field
Hi All,
My requirement is to update a field called "CSC Code" in line item of sales order. hence for this case i am using "CRM_ORDER_MAINTAIN" inside the "ORDER_SAVE" BADI. I am passing the ref guid, ref type, object name ,Logical Key and field name in the CHANGING parametrs CT_INPUT_FIELDS. I am passing the internal table containing the ref guid,ref type, partner fct ,partnerno to the internal table IT_PARTNER.
The FM gets executed without any error and the internal table IT_PARTNER is filled with the new CSC code but on checking in the sales order after saving the field is blank.
I have tried using wait up to 2 seconds. Even then it didn't work.
Can some one help me?
Thanks.Could you please let me know how was it fixed... I have a similar kind of requirement
Edited by: rakesh chaitanya makkapati on Apr 7, 2010 4:49 PM -
No Partner details in new order : CRM_ORDER_MAINTAIN
Hi .....
I am trying to create new order in which i am getting error related to partner data though i am passing al the data into the CRM_ORDER_MAINTAIN function.
I am not able to figure out what is the problem.
Following is my code part ->
READ TABLE lt_src_partner_or INTO ls_src_partner_or
WITH KEY ref_guid = lv_guid_h
partner_fct = '00000004'.
if sy-subrc eq 0.
wa_partner-ref_guid = lv_guid_h."gs_sel_cont-guid_b.
wa_partner-ref_handle ='0000000000'.
wa_partner-ref_kind = ls_src_partner_or-ref_kind. "'A' .
wa_partner-ref_partner_handle = ls_src_partner_or-ref_partner_handle."'0000'.
wa_partner-ref_partner_fct = ls_src_partner_or-ref_partner_fct. "'00000003' .
wa_partner-ref_partner_no = ls_src_partner_or-ref_partner_no. "100040 " THIS IS THE OLD value
wa_partner-ref_no_type = ls_src_partner_or-ref_no_type.
wa_partner-ref_display_type = ls_src_partner_or-ref_display_type.
wa_partner-partner_guid = ls_src_partner_or-partner_guid .
wa_partner-kind_of_entry = ls_src_partner_or-kind_of_entry. " 'C'
wa_partner-partner_fct = ls_src_partner_or-partner_fct. " 00000003 "new value
wa_partner-partner_no = ls_src_partner_or-partner_no."'92921'p_tbill. " 0000100007 " THIS IS THE NEW VALUE
wa_partner-display_type = ls_src_partner_or-display_type. " BP
wa_partner-no_type = ls_src_partner_or-no_type . " BP
wa_partner-mainpartner = ls_src_partner_or-mainpartner. " 'X'
wa_partner-relation_partner = ls_src_partner_or-relation_partner. " '00000000000000000000000000000000'
wa_partner-addr_nr = ls_src_partner_or-addr_nr . " '0000010673'
wa_partner-addr_np = ls_src_partner_or-addr_np . " ''
wa_partner-addr_type = ls_src_partner_or-addr_type." '1'.
append ls_tb_partner_om to lt_tb_partner_om.
INSERT wa_partner INTO TABLE it_partner.
endif.
clear : wa_partner, ls_src_partner_or.
* populate field_names
REFRESH lt_field_names.
ls_field_names-fieldname = 'DISPLAY_TYPE'.
append ls_FIELD_NAMES to lt_FIELD_NAMES.
INSERT ls_field_names INTO TABLE lt_field_names ."lt_field_names.
ls_field_names-fieldname = 'KIND_OF_ENTRY'.
append ls_FIELD_NAMES to lt_FIELD_NAMES.
INSERT ls_field_names INTO TABLE lt_field_names ."lt_field_names.
ls_field_names-fieldname = 'NO_TYPE'.
append ls_FIELD_NAMES to lt_FIELD_NAMES.
INSERT ls_field_names INTO TABLE lt_field_names."lt_field_names.
ls_field_names-fieldname = 'PARTNER_NO'.
append ls_FIELD_NAMES to lt_FIELD_NAMES.
INSERT ls_field_names INTO TABLE lt_field_names."lt_field_names.
ls_field_names-fieldname = 'PARTNER_FCT'.
append ls_FIELD_NAMES to lt_FIELD_NAMES.
INSERT ls_field_names INTO TABLE lt_field_names."lt_field_names.
ls_field_names-fieldname = 'REF_PARTNER_NO'.
append ls_FIELD_NAMES to lt_FIELD_NAMES.
INSERT ls_field_names INTO TABLE lt_field_names."lt_field_names.
ls_field_names-fieldname = 'REF_PARTNER_FCT'.
append ls_FIELD_NAMES to lt_FIELD_NAMES.
INSERT ls_field_names INTO TABLE lt_field_names."lt_field_names.
build input fields
ls_input_fields-ref_handle = '0000000000'.
ls_input_fields-ref_guid = lv_guid_h . "4733030909B64D4D92A959BA5334B6F8.
ls_input_fields-ref_kind = 'A' .
ls_input_fields-objectname = 'PARTNER' .
old partner number needs to be passed here
CONCATENATE '000000000014' ls_src_partner_or-ref_partner_no ' BPBP' INTO ls_input_fields-logical_key. "=. "000000000003100040 BPBP
ls_input_fields-field_names = lt_field_names."lt_field_names.
INSERT ls_input_fields INTO TABLE ct_input_fields.
CONCATENATE '000000000002' ls_src_partner_or-ref_partner_no ' BPBP' INTO ls_input_fields-logical_key. "=. "000000000003100040 BPBP
ls_input_fields-field_names = lt_field_names."lt_field_names.
Set the first line for 000000000003
append ls_INPUT_FIELDS to lt_INPUT_FIELDS.
INSERT ls_input_fields INTO TABLE ct_input_fields."lt_input_fields.
CONCATENATE '000000000003' ls_src_partner_or-ref_partner_no ' BPBP' INTO ls_input_fields-logical_key. "=. "000000000003100040 BPBP
ls_input_fields-field_names = lt_field_names."lt_field_names.
Set the first line for 000000000003
append ls_INPUT_FIELDS to lt_INPUT_FIELDS.
INSERT ls_input_fields INTO TABLE ct_input_fields."lt_input_fields.
set the second line for 000000000004 - the only difference is the logical_key
CONCATENATE '000000000004' ls_src_partner_or-ref_partner_no ' BPBP' INTO ls_input_fields-logical_key. "=. "000000000004100040 BPBP
ls_input_fields-field_names = lt_field_names.
INSERT ls_input_fields INTO TABLE ct_input_fields.
Please tell me where i am wrong ???
Do i need to include some more fields in input parameters of crm_order_maintain function ?
please help me experts .
Thanks and regards
Edited by: Shoaibmemon on Jun 27, 2011 2:42 PMHi,
U need to execute a BAPI for customer master change. This needs to be checked whether we can call the BAPI through the exit u mentioned or even on Save.
Regards,
Deepak -
Usage of CRM_ORDER_MAINTAIN SAP Help Link and Suggestions Required
This is regarding CRM_ORDER_MAINTAIN fm
Currently we are using function module crm_order_maintain outside Loop i.e calling once for all the contracts as sap crm performance standard ,
Is there any standard documentation where we can find that states CRM_ORDER_MAINTAIN should be only used outside loop,
As some are telling us to use in Loop Endloop because of timeout error in background job with contract having 180 line items,Which i feel that this create unneccessary load on execution (Not Recommendable)
Please share any comments and suggestion this and also provide me the SAP Help Link on thisHi,
for example to you, look for FM CRM_LRP_APPOINTMENTS_GET_DIAG which using CRM_ORDER_MAINTAIN and parameter it_appointment.
Hope this helps.
Regards, Kostya Khveshchenik
Maybe you are looking for
-
How to create centered pop up window
How do you get a pop up window to appear at the center of a screen? I did it in the past on go live using an action form a 3rd party. I don't see any placement options on the pop up window behavior. thx
-
Create Blank Signature Field in Acrobat 9
Looks stupid, but I don't find the way to create blank signature fields in Acrobat 9 pro, I need it to pass the file on so that Reader users can sign it. To sign and then delete the signature (leaving the blank signature field) is not a valid alterna
-
Dynamic text don't show some characters
hi guys, i'm with a problem.. i have a dynamic text in my flash and it's reading vars from a txt file, but it does not read some portuguese character as ç Ç or accents such as ã â Ã Â... i tried to embendding theses characters on my dynamic text, cho
-
ell application "iTunes" activate reveal playlist "iTunes DJ" end tell tell application "System Events" to tell front window of application process "iTunes" if value of pop up button 1 is not "1 Morning List" then
-
Time Capsule initial back-up error
The back-up was not performed because an error occurred while copying files to the back up disk. What are the solutions to the above error message? Disk Utility verifies the time capsule disc as okay, I have no external devices attached -- and am usi