on 08-23-2020 7:28 PM
Hi Everybody,
I have to change start date of contract, which every tables contain this data field in CRM? (I know two tables in which is necessary to change value of this data fields: in table SCAPPTSEG is field TST_FROM and in table
CRMD_ISUEXTA4 is field A4CONTSTART).
Which FM is necessary use to change start date of contract in all tables? Is that possible with FM CRM_ORDER_MAINTAIN if I know GUID item and how can I do that?
Thaks for your answers.
Thank you for your answers, I had to use FM CRM_APPT_BUILD_INPUT_FIELDS and it works.
MOVE-CORRESPONDING ls_appointment TO ls_logical_date_key.
CALL FUNCTION 'CRM_APPT_BUILD_INPUT_FIELDS'
EXPORTING
iv_ref_handle = '0'
iv_ref_guid = ls_appointment-ref_guid
iv_ref_kind = ls_appointment-ref_kind
is_logical_key = ls_logical_date_key
IMPORTING
es_input_fields = ls_input_fields.
INSERT ls_input_fields INTO TABLE lt_input_fields.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
it_appointment = lt_appointment
IMPORTING
et_exception = lt_exception
CHANGING
ct_input_fields = lt_input_fields
EXCEPTIONS
error_occurred = 1
document_locked = 2
no_change_allowed = 3
no_authority = 4
OTHERS = 5.
INSERT ls_output_ele-header INTO TABLE lt_objects_to_save.
CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
it_objects_to_save = lt_objects_to_save
IMPORTING
et_saved_objects = lt_saved_objects
et_exception = lt_exception
et_objects_not_saved = lt_objects_not_saved
EXCEPTIONS
document_not_saved = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT."MESSAGE 'Error' TYPE 'E'.
ELSE.
CALL FUNCTION 'BUPA_BADI_AND_UPDATE_SERVICE'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nela,
Yes, the contract GUID should be used in CRM_ORDER_MAINTAIN to do the trick or in other FMs like CRM_APPT_MAINTAIN_MULTI_OW (alternative).
In CRM_ORDER_MAINTAN, the main data you need to change is IT_APPOINTMENT internal table with your contract dates info and the CT_INPUT_FIELDS parameter referring the field names of IT_APPOINTMENT that you're changing.
After you perform the change in memory, you also have to use CRM_ORDER_SAVE if you wish to commit the changes.
See if that helps you a little more. There's a lot of examples of CRM_ORDER_MAINTAIN usage in the community. Also, in this wiki, you can see an example of an alternative approach.
Kind regards,
Garcia
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bruno,
thank you for your answer. I tried it and it seems like working (no error or exception) but if I use GUID item for this FMs I see no change in system.
What's wrong with my code?
TYPES: BEGIN OF t_output_ele,
object_id TYPE crmd_orderadm_h-object_id,
a4contstart TYPE crmd_isuexta4-a4contstart,
guid TYPE crmd_orderadm_i-guid,
END OF t_output_ele.
DATA: lt_output_ele TYPE STANDARD TABLE OF t_output_ele,
ls_output_ele TYPE t_output_ele.
*---------------------------------------------------------------------*
* Form change_data_ele
*---------------------------------------------------------------------*
FORM change_data_ele.
DATA: lt_appointment TYPE crmt_appointment_comt,
ls_appointment TYPE crmt_appointment_com,
time_stamp TYPE timestamp, "string,
time_from TYPE sy-timlo,
lt_guid TYPE crmt_object_guid_tab,
lt_saved_objects TYPE crmt_return_objects,
ls_saved_objects LIKE LINE OF lt_saved_objects,
lt_objects_not_saved TYPE crmt_object_guid_tab,
lt_input_fields TYPE crmt_input_field_tab,
ls_input_field LIKE LINE OF lt_input_fields,
ls_field_name TYPE crmt_input_field_names,
lt_exception TYPE crmt_exception_t.
" Změna dat v systému
LOOP AT lt_output_ele INTO ls_output_ele WHERE zprava IS INITIAL.
REFRESH: lt_set_data, lt_appointment, lt_exception, lt_input_fields, lt_guid, lt_saved_objects, lt_objects_not_saved.
ls_appointment-ref_guid = ls_output_ele-guid.
* ls_appointment-ref_handle = '0000000000'.
ls_appointment-ref_kind = 'B'. "'A' header, 'B' item
ls_appointment-appt_type = 'CONTSTART'.
CONVERT DATE ls_output_ele-a4contstart TIME time_from INTO TIME STAMP time_stamp TIME ZONE 'CET'.
ls_appointment-timestamp_from = time_stamp.
APPEND ls_appointment TO lt_appointment.
ls_input_field-ref_guid = ls_output_ele-guid.
* ls_input_field-ref_handle = '0000000000'.
ls_input_field-ref_kind = 'B'. "'A' header, 'B' item
ls_input_field-objectname = 'APPOINTMENT'.
ls_input_field-logical_key = 'CONTSTART'.
ls_field_name-fieldname = 'TIMESTAMP_FROM'.
INSERT ls_field_name INTO TABLE ls_input_field-field_names.
INSERT ls_input_field INTO TABLE lt_input_fields.
INSERT ls_output_ele-guid INTO TABLE lt_guid.
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
EXPORTING
it_appointment = lt_appointment
IMPORTING
et_exception = lt_exception
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.
MESSAGE 'CHYBA' TYPE 'E'.
ENDIF.
CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
it_objects_to_save = lt_guid
iv_update_task_local = 'X'
* IV_SAVE_FRAME_LOG = FALSE
* IV_NO_BDOC_SEND = FALSE
* IT_ACTIVE_SWITCH =
IMPORTING
et_saved_objects = lt_saved_objects
et_exception = lt_exception
et_objects_not_saved = lt_objects_not_saved
* CHANGING
* CV_LOG_HANDLE =
* CT_NOCHECK_BEFORE_SAVE =
EXCEPTIONS
document_not_saved = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT."MESSAGE 'Error' TYPE 'E'.
ELSE.
CALL FUNCTION 'BUPA_BADI_AND_UPDATE_SERVICE'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
* COMMIT WORK.
ENDLOOP.
ENDFORM. "change_data_ele
nella17, when you are in Trx. CRMD_ORDER, change the value manually, have a breakpoint in Fuba CRM_ORDER_MAINTAIN and see what the standard does different than you.
Hi Nela,
It could be that LT_INPUT_FIELDS needs more fields to be updated like APPT_TYPE or TIMEZONE_FROM.
But the best is to follow Michael's suggestion, that way you'll know how what the function module is expecting to fulfil your change.
Kind regards,
Garcia
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.