on 03-18-2013 5:14 PM
Hi All,
Is it possible to maintain transaction history programmatic .In my requirement I created a custom program and inside the custom program ,I am using ORDER_MAINTAIN,ORDER_READ and ORDER_SAVE function module.
It is updating in web ui but it is not updating all the fields.....
Thanks In advance.
Regards
RR PRADHAN
Hello Pradhan,
Are you using custom change document? Please share the details.
Thanks,
Amit Singh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If only a few fields are not getting updated, then you need to look at how the changed document object has been defined and implemented in your scenario. The update function module generated with the object is generally called in the genil.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Parul,
Thanks for replay.
All are custom and only document no is standard one.
Below is my code.
PARAMETERS: lv_id_a TYPE crmt_object_id OBLIGATORY, lv_id_b TYPE crmt_object_id OBLIGATORY.
DATA: guids TYPE crmt_object_guid_tab,
guid_a LIKE LINE OF guids,
guid_b LIKE LINE OF guids.
* * * Read GUID for Activity A *
CALL FUNCTION 'CRM_ORDERADM_H_GUID_GET_DB'
EXPORTING
iv_object_id = lv_id_a
IMPORTING
et_guid = guids.
READ TABLE guids INTO guid_a INDEX 1.
REFRESH: guids.
* * * Read GUID for Activity B *
CALL FUNCTION 'CRM_ORDERADM_H_GUID_GET_DB'
EXPORTING
iv_object_id = lv_id_b
IMPORTING
et_guid = guids.
READ TABLE guids INTO guid_b INDEX 1.
DATA:it_activity_h TYPE crmt_activity_h_wrkt,
ls_activity_h LIKE LINE OF it_activity_h,
it_requested_objects TYPE crmt_object_name_tab,
ls_requested_objects LIKE LINE OF it_requested_objects,
it_orderadm_h TYPE crmt_orderadm_h_wrkt,
it_orderadm_c TYPE CRMT_ORDERADM_H_COMT,
ls_orderadm_h LIKE LINE OF it_orderadm_h,
it_doc_flow TYPE crmt_doc_flow_wrkt,
ls_doc_flow LIKE LINE OF it_doc_flow,
it_header_guid TYPE crmt_object_guid_tab,
ls_header_guid LIKE LINE OF it_header_guid.
* * Append GUID_A to Header GUID Table
APPEND guid_a TO it_header_guid.
* * What should we read
*ls_requested_objects = 'ACTIVITY_H'.
*APPEND ls_requested_objects TO it_requested_objects.
ls_requested_objects = 'DOC_FLOW'.
APPEND ls_requested_objects TO it_requested_objects.
* * * Read Activity A *
CALL FUNCTION 'CRM_ORDER_READ'
EXPORTING
it_header_guid = it_header_guid
it_requested_objects = it_requested_objects
IMPORTING
et_orderadm_h = it_orderadm_h
et_activity_h = it_activity_h
et_doc_flow = it_doc_flow.
*it_orderadm_c[] = it_orderadm_h[].
DATA: it_activity_h_comt TYPE crmt_activity_h_comt,
ls_activity_h_comt LIKE LINE OF it_activity_h_comt,
lt_doc_flow TYPE crmt_doc_flow_comt, ls_doc_flow_comt LIKE LINE OF lt_doc_flow,
lv_ref_guid TYPE guid_16,
lt_doc_link TYPE crmt_doc_flow_extdt,
*lt_doc_link TYPE table of crmst_docflow_btil,
ls_doc_link LIKE LINE OF lt_doc_link,
*ls_doc_link type crmst_docflow_btil,
lt_input_fields TYPE crmt_input_field_tab,
ls_input_field TYPE crmt_input_field,
ls_input_field_names TYPE crmt_input_field_names,
ls_log_handle TYPE balloghndl.
*LOOP AT it_activity_h INTO ls_activity_h.
*
* MOVE-CORRESPONDING ls_activity_h TO ls_activity_h_comt.
* APPEND ls_activity_h_comt TO it_activity_h_comt.
*
*ENDLOOP.
* * * Fill DOC_FLOW Structure *
ls_doc_link-objkey_a = guid_a.
ls_doc_link-objtype_a = 'BUS2000112'.
ls_doc_link-objkey_b = 'ZCRM_REMINDER_MAIL_01' . "'ZCR4_DSMRESDECLETTER'."guid_b.
ls_doc_link-objtype_b = 'PRINTLIST'."'BUS2000112'.
ls_doc_link-vona_kind = 'A'.
ls_doc_link-reltype = 'VONA'.
ls_doc_link-brel_kind = 'A'.
ls_doc_link-DATE = sy-datum.
*ls_doc_link-STAT = sy-status.
APPEND ls_doc_link TO lt_doc_link.
CLEAR: ls_doc_flow_comt.
ls_doc_flow_comt-ref_guid = guid_a.
ls_doc_flow_comt-ref_kind = 'A'.
ls_doc_flow_comt-doc_link[] = lt_doc_link.
APPEND ls_doc_flow_comt TO lt_doc_flow.
* * * Fill INPUT_FIELDS which indicate what Values where changed * and had to be updated *
ls_input_field_names-fieldname = 'OBJKEY_A'.
INSERT ls_input_field_names INTO TABLE ls_input_field-field_names.
ls_input_field_names-fieldname = 'OBJTYPE_A'.
INSERT ls_input_field_names INTO TABLE ls_input_field-field_names.
ls_input_field_names-fieldname = 'OBJKEY_B'.
INSERT ls_input_field_names INTO TABLE ls_input_field-field_names.
ls_input_field_names-fieldname = 'OBJTYPE_B'.
INSERT ls_input_field_names INTO TABLE ls_input_field-field_names.
ls_input_field_names-fieldname = 'VONA_KIND'.
INSERT ls_input_field_names INTO TABLE ls_input_field-field_names.
ls_input_field_names-fieldname = 'RELTYPE'.
INSERT ls_input_field_names INTO TABLE ls_input_field-field_names.
ls_input_field_names-fieldname = 'BREL_KIND'.
INSERT ls_input_field_names INTO TABLE ls_input_field-field_names.
ls_input_field_names-fieldname = 'BREL_MODE'.
INSERT ls_input_field_names INTO TABLE ls_input_field-field_names.
ls_input_field_names-fieldname = 'RELATIONID'.
INSERT ls_input_field_names INTO TABLE ls_input_field-field_names.
ls_input_field_names-fieldname = 'RELATION_HANDLE'.
INSERT ls_input_field_names INTO TABLE ls_input_field-field_names.
ls_input_field-objectname = 'DOC_FLOW'.
ls_input_field-ref_guid = guid_a.
ls_input_field-ref_kind = 'A'.
INSERT ls_input_field INTO TABLE lt_input_fields.
* * * Update Document Flow *
CALL FUNCTION 'CRM_ORDER_MAINTAIN'
CHANGING
CT_ORDERADM_H = it_orderadm_c
ct_input_fields = lt_input_fields
cv_log_handle = ls_log_handle
ct_doc_flow = lt_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.
DATA: it_saved_objects TYPE crmt_return_objects.
* * * Save Changes *
CALL FUNCTION 'CRM_ORDER_SAVE'
EXPORTING
it_objects_to_save = it_header_guid
IV_UPDATE_TASK_LOCAL = 'X'
IV_SAVE_FRAME_LOG = 'X'
IMPORTING
et_saved_objects = it_saved_objects.
IF sy-subrc = 0.
* * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DATA: lt_return TYPE TABLE OF bapiret2,
ls_return LIKE LINE OF lt_return.
* * * Commit Changes *
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = ls_return.
WRITE: / ls_return-message.
* * * Read Error Messages *
*IF NOT log_handle IS INITIAL.
* DATA: is_msg_handle TYPE balmsghndl, es_info TYPE crmt_msg_info, es_msg TYPE bal_s_msg, ev_ref_object TYPE crmt_ref_obj_text.
* is_msg_handle-log_handle = log_handle.
* CALL FUNCTION 'CRM_MESSAGES_GET_MSG_INFO'
* EXPORTING
* is_msg_handle = is_msg_handle
* iv_get_caller_name = 'X'
* IMPORTING
* es_info = es_info
* es_msg = es_msg
* ev_ref_object = ev_ref_object.
*ENDIF.
Hi Pradhan,
For updating the changes in the change history, you need to call the change history update function.
You need to find the change history document object that is being used for your object. in SCDO transaction, you will find the corresponding function module.
Invoke that FM in your code and pass the old and new value. This will write the changed values for your transaction in CDPOS and CDHDR tables. Then it should get picked when change history of your document is being populated.
The code would be something on the following lines:
******* Change Documents
CALL FUNCTION '<Change Doc Object FM>' "<Change doc Object>_WRITE_DOCUMENT'
EXPORTING
objectid = <guid>
tcode = sy-tcode
utime = sy-uzeit
udate = sy-datum
username = sy-uname
xvalye = lt_new_value
yvalue = lt_old_value
TABLES
xtable = lt_new_table
ytable = lt_old_table.
Basically, the parameters of the FM are subject to how your change document object is defined.
If you are not sure of the change doc object being used, you can check the genil class of your component. The change history would have been handled in save_objects or some other method.
Hope this helps!
Parul
Hi,
You can do it. You have to explicitly call the update function module of the change object that you are using for the transaction type and pass the old and new values.
This would write the value in CDPOS and CDHDR tables.
Then in my opinion, the current implementation of reading the transaction history should suffice to read the values.
You can check the function module you have to use by looking for your change document in transaction SCDO, or by just debugging the genil.
Hope this helps.
Regards,
Parul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
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.