Hi Jose,
thanks for replay, once I get orderadm_h-guid from crm_order_maintain and pass it to loop orderadm_i-header = lv_guid endloop.Get item guid using crm_order_maintain and pass this header guid (lv_guid) in crm_order_save .. in debuging when execute the crm_order_save it displaying error message .
call function 'CRM_ORDER_MAINTAIN'
exporting
it_orgman = lt_orgman
it_partner = lt_partner
it_service_os = lt_service_os
changing
ct_orderadm_h = lt_orderadm_h
ct_input_fields = lt_input_fields
exceptions
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
others = 5.
read table lt_orderadm_h into ls_orderadm_h index 1.
lv_guid = ls_orderadm_h-guid.
loop at lt_items into ls_items.
if lv_prod is not initial.
lv_handle = lv_handle + 1.
ls_orderadm_i-guid = lv_guid1.
ls_orderadm_i-header = lv_guid.
ls_orderadm_i- header_handle = lv_handle.
ls_orderadm_i-handle = lv_handle.
ls_orderadm_i-mode = 'B'.
ls_orderadm_i-ordered_prod = lv_prod.
ls_orderadm_i-/rcrm/f005v = ls_article_details-serial_no.
ls_orderadm_i-number_int = ls_article_details-number_int.
insert ls_orderadm_i into table lt_orderadm_i.
ls_input_fields-ref_guid = lv_guid1.
ls_input_fields- ref_handle = lv_handle.
ls_input_fields-ref_kind = 'B'.
ls_input_fields-objectname = 'ORDERADM_I'.
ls_field_names-fieldname = 'MODE'.
insert ls_field_names into table lt_field_names.
clear ls_field_names.
ls_field_names-fieldname = 'ORDER_PROD'.
insert ls_field_names into table lt_field_names.
clear ls_field_names.
ls_input_fields-field_names = lt_field_names.
insert ls_input_fields into table lt_input_fields.
clear: ls_input_fields, lt_field_names, ls_field_names.
endif.
ls_schedlin_i-ref_guid = lv_guid1.
ls_schedlin_i-ref_handle = lv_handle.
ls_schedlines-quantity = lv_quantity.
ls_schedlines-logical_key = lv_guid1.
insert ls_schedlines into table lt_schedlines.
ls_schedlin_i-schedlines = lt_schedlines.
insert ls_schedlin_i into table lt_schedlin_i.
ls_input_fields-ref_guid = lv_guid1.
ls_input_fields-ref_handle = lv_handle.
ls_input_fields-ref_kind = 'B'.
ls_input_fields-objectname = 'SCHEDLIN'.
ls_input_fields-logical_key = lv_guid1.
ls_field_names-fieldname = 'LOGICAL_KEY'.
insert ls_field_names into table lt_field_names.
clear ls_field_names.
ls_field_names-fieldname = 'QUANTITY'.
insert ls_field_names into table lt_field_names.
clear ls_field_names.
ls_input_fields-field_names = lt_field_names.
insert ls_input_fields into table lt_input_fields.
clear: ls_input_fields, lt_field_names, ls_field_names.
call function 'CRM_ORDER_MAINTAIN'
exporting
it_schedlin_i = lt_schedlin_i
changing
ct_orderadm_i = lt_orderadm_i
ct_input_fields = lt_input_fields
exceptions
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
others = 5.
endloop.
INSERT lv_guid INTO TABLE lt_obj_guid_tab.
call function 'CRM_ORDER_SAVE'
exporting
it_objects_to_save = lt_obj_guid_tab
iv_no_bdoc_send = ' '
importing
et_saved_objects = lt_saved_objects
exceptions
document_not_saved = 1
others = 2.
if sy-subrc = 0.
call function 'BAPI_TRANSACTION_COMMIT'.
if lt_saved_objects is not initial.
clear: ls_saved_objects.
read table lt_saved_objects into ls_saved_objects with key guid = ls_orderadm_h-guid.
if sy-subrc = 0.
iv_order_no = ls_saved_objects-object_id.
endif.
endif.
