cancel
Showing results for 
Search instead for 
Did you mean: 

BAdi ORDER_SAVE

Former Member
0 Kudos

Hi Experts,

During save of a transaction(Ticket), i need to trace/determine which fields' value has been changed because i need to perform checking on those fields before the actual SAVE of the transaction.

So i will make use of BAdi ORDER_SAVE because it will be triggered during SAVE. So my problem would be how can i trace the fields change? For eg, an update occurs for field Description. And i need to grab the field name. Is there any FMs that i can use?

Please comment.

Thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Guys,

This is to update you that i got my prob solved. I'm using FM CRM_ORDER_READ to read the screen's value and FM CRM_ORDERADM_H_READ_DB to read table's value. From there i performed the value comparison accordingly.

Thanks.

Former Member
0 Kudos

Write the code ORDER_SAVE badi call the function module

CRM_ORDER_READ passing header or line iteam GUID as per the business requiremnet.it will get all the details from the memory.

Again call this FM CRM_ORDER_READ by giving transaction number which is earlier created.

Check both data now u will get to know which field is changed.

I don't know exact FM...i told alternative method.

Regards,

Shiv

Former Member
0 Kudos

Hi Shiv,

Thanks for your reply.

From what i understand from your post. At first, i have to read the value from buffer via FM CRM_ORDER_READ by passing in the GUID.

Secondly, i have to use back the same FM to read the value that previously created by passing in the Transaction number (that is service ticket number for my case). Since the import parameter IT_HEADER_GUID is only accepting GUID but not the transaction number. So, i would need your help again on how to achieve the second read from the FM.

Please comment.

Thanks in advance.

0 Kudos

1. If you have the service ticket number get the object guid using the FM CRM_HEADER_OBJ_ID_GET_GUID.

2. Perform CRM_ORDER_READ to get the values from the buffer

3. Perform the second read later but do mark the importing parameter IV_ONLY_CHANGED_OBJ as 'X'

4. Compare the results!

OR

In case you already know the field names, use the FM CRM_ORDER_COMPARE_BUFFER (havent quite used it so dont know if it works)

Former Member
0 Kudos

Hi Krish,

Thank you very much for the reply. However i have tried on the both methods that you mentioned, and I'm facing problems as follow:

Method 1

Call FM CRM_ORDER_READ for the first time, get result A. And then call FM CRM_ORDER_READ again for second time with additional 'X' passed to parameter IV_ONLY_CHANGED_OBJ, get result B.

Problem: Result A and result B both having the same value, that is the changed value from screen.

Please comment what actually went wrong with my code and below are my code:

  CALL FUNCTION 'CRM_ORDER_READ'
    EXPORTING
      IT_HEADER_GUID                = L_HEADER1
    IMPORTING
      ET_APPOINTMENT               = L_APPOIN1.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CALL FUNCTION 'CRM_ORDER_READ'
    EXPORTING
      IT_HEADER_GUID                = L_HEADER1
      IV_ONLY_CHANGED_OBJ    = 'X'
    IMPORTING
      ET_APPOINTMENT               = L_APPOIN2.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

L_APPOIN1 is Result A, while L_APPOIN2 is Result B. Both of them carrying the same value(on screen value).

Method B

I can not get any info from CT_INPUT_FIELDS by indicating which field value has been changed. Below are my code and please comment if anything went wrong:


  CALL FUNCTION 'CRM_ORDER_READ'
    EXPORTING
      IT_HEADER_GUID                 = L_HEADER1
    IMPORTING
      ET_ORDERADM_H                = I_ORDERADM_H
      ET_APPOINTMENT                = L_APPOIN1
    CHANGING
      CV_LOG_HANDLE                 = V_BALLOGHNDL.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

** prepare I_ORDERADM_H_COM
  LOOP AT I_ORDERADM_H INTO K_ORDERADM_H.
    MOVE-CORRESPONDING K_ORDERADM_H TO K_ORDERADM_H_COM.
    APPEND K_ORDERADM_H_COM TO I_ORDERADM_H_COM.
  ENDLOOP.

** prepare I_INPUT_FIELDS
  K_SUBFIELD-FIELDNAME = 'ZCTS_0000001'.
  APPEND K_SUBFIELD TO L_SUBFIELD.

  K_FIELD-REF_GUID = IV_GUID.
  K_FIELD-REF_KIND = 'A'.
  K_FIELD-OBJECTNAME = 'APPOINTMENT'.
  K_FIELD-FIELD_NAMES = L_SUBFIELD.
  APPEND K_FIELD TO I_INPUT_FIELDS.

** prepare L_APPOINT
  K_APPOINT-REF_GUID = IV_GUID.
  K_APPOINT-REF_KIND = 'A'.
  K_APPOINT-APPT_TYPE = 'ZCTS_0000001'.
  APPEND K_APPOINT TO L_APPOINT.

  CALL FUNCTION 'CRM_ORDER_COMPARE_BUFFER'
    EXPORTING
      IT_APPOINTMENT              = L_APPOINT
      IT_ORDERADM_H               = I_ORDERADM_H_COM
      IT_ORDERADM_I               = I_ORDERADM_I 	 "object having dummy  value
      IT_PARTNER_ATTRIBUTES       = I_PARTNER_ATTRIBUTES "object having  dummy value
    CHANGING
      CT_INPUT_FIELDS             = I_INPUT_FIELDS
   EXCEPTIONS
     ERROR_OCCURRED              = 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.

Please help the above scenarios, your opinions are highly appreciated.

*full points are guaranteed.

Former Member
0 Kudos

This solution is not what you require.

But I used event architecture in my case.

use t-cd:crmv_event and implement call back function module.

You can catch what data is changed in some events.

if you don't understand that architecture, please tell me.

Yohei

Former Member
0 Kudos

Hi Yohei,

Thanks for your reply, however i have not have much idea on how to use TCode CRMV_EVENT. Would you like to explain briefly on how to implement the call back function module for my case?

Thanks in advance.