cancel
Showing results for 
Search instead for 
Did you mean: 

get guid using multiple line items in crm_order_maintain

0 Kudos

Hi,

how can i get the item guids using crm_order_maintain for multiple line items. when i loop item details and pass it crm_order_maintain, the guid will create only first record not all records. if i want to guid for all items records, what should i do ...

please explain 

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member190077
Participant
0 Kudos

Please try with FM!!

Place the CRM_ORDER_MAINTAIN with in the function and place the function within the LOOP ..

Discuss the results,

Best regards,

JMP.

0 Kudos

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.

former_member190077
Participant
0 Kudos

Hi Can you try from this FM "CRM_ORDER_MAINTAIN_MULTI_OW"

Hope can  help you!

Best Regard,

JMP.

praveen_kumar194
Active Contributor
0 Kudos

hi ,

when you are sending handle parameter, you need not to send guid.

if you send guid, then no need to send handle.

you can always create new guid and send it for each line item. you can google on how to create to guid in CRM.

if you are updating existing transaction, you can get line item guid in different ways. CRM_ORDER_READ would help in getting all fields.

hope this helps.

0 Kudos

Hi Praveen,

Actually my requirement is create a complaint  passing the orgman, partner, schedule_i, service_os and update item details..number_int and serial number. is there any code to create complaints, when i pass all the details in 'crm_order_maintain' serial_number is not updating.and when i pass guid to crm_order_save its getting dump.

please help .

praveen_kumar194
Active Contributor
0 Kudos

hi the best ways is

put a session break point in CRM ORDER MAINTAIN function module

go and create a complaint manually either from GUI or from WEB UI with all the fields you want to update then observer all parameters in the debugging mode.

This will give you 90% clarity on what kind of parameters you need to send. i always follow this approach.