cancel
Showing results for 
Search instead for 
Did you mean: 

ORDER_SAVE BADI not allowing changes in 'Complete' Status

Former Member
0 Kudos
786

Hello All,

We have implemented ORDER_SAVE so that when a user changes the activity user status under some circumstances we add a new appointment(date) to the activity (using CRM_ORDER_MAINTAIN) . This works except when the new user status is Complete ('FINI'). In that case although the BADI is processed the activity is not updated. I guess this is because you cannot change an activity that has status complete. Does anyone know any way around this?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Idan,

Try using BADI CRM_ORDER_STATUS, method AFTER_CHANGE.

Let me know if this works.

Regards,

Chandrika

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Sergio,

Is it possible to implement CRM_ORDER_STATUS BADI without filter?

We need to activate the implementation for all statuses and not for a specific status.

Former Member
0 Kudos

Hi Idan,

We had a similar issue. If you still havent solved it, heres what we did:

Using SE18, create an implementation of CRM_ORDER_STATUS, say ZCRM_COMPLETE_DATE. The in the 'Attribites' tab of ZCRM_COMPLETE_DATE assign the corresponding 'Complete' status as a filter. Within the BEFORE_CHANGE method (NOT AFTER_INPUT) do something similar to:


CHECK: is_status_wrk-CHECK_ONLY     = c_false.

*  Get All Dates
  CALL FUNCTION 'CRM_DATES_READ_SINGLE_OW'
         EXPORTING                                       
       iv_ref_guid                = ip_ref_guid      
       iv_ref_kind                = ip_ref_kind      
*   IS_LOGICAL_DATE_KEY        =                     
     IMPORTING                                       
       es_date_wrk                = ws_crm_wrk       
       et_date_wrk                = wt_crm_wrk       
     EXCEPTIONS                                      
       link_does_not_exist        = 1                
       entry_does_not_exist       = 2                
       OTHERS                     = 3.               
  IF sy-subrc <> 0.                                  
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO  
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.  
  ENDIF.                                             
 
* Pick out the date we need

  READ TABLE wt_crm_wrk INTO ws_crm_wrk          
            WITH KEY appt_type =   ZCOMPLETE. 
 
  ...

* Fill lt_appointment and lt_input_fields as necessary. 
  move-corresponding ws_crm_wrk to st_appointment.  
st_appointment-REF_GUID = ip_ref_guid.            
st_appointment-ref_kind = ip_ref_kind.            
st_appointment-mode     = ' '.     
* fill the rest of the structure as needed               
APPEND st_appointment TO lt_appointment.          
                                                  
st_field_name-FIELDNAME = 'DOMINANT'.             
APPEND st_field_name TO lt_field_names.           
st_field_name-FIELDNAME = 'DURATION'.             
APPEND st_field_name TO lt_field_names.           
st_field_name-FIELDNAME = 'RULE_NAME'.            
APPEND st_field_name TO lt_field_names.           
st_field_name-FIELDNAME = 'SHOW_LOCAL'.           
APPEND st_field_name TO lt_field_names.           
st_field_name-FIELDNAME = 'TIMESTAMP_FROM'.       
APPEND st_field_name TO lt_field_names.           
st_field_name-FIELDNAME = 'TIMEZONE_FROM'.        
APPEND st_field_name TO lt_field_names.           
st_field_name-FIELDNAME = 'TIME_UNIT'.            
APPEND st_field_name TO lt_field_names.           

 st_input_fields-ref_guid      = ip_ref_guid.    
 st_input_fields-ref_kind      = ip_ref_kind.    
 st_input_fields-objectname    = 'APPOINTMENT'.  
 st_input_fields-logical_key   = ZCOMPLETE.   
 st_input_fields-field_names   = lt_field_names. 
 APPEND st_input_fields TO lt_input_fields.      


* Because at this stage we are within a CRM_ORDER_MAINTAIN call, 
*   use CRM_APPT_MAINTAIN_MULTI_OW to set appointments.

  CALL FUNCTION 'CRM_APPT_MAINTAIN_MULTI_OW'
     EXPORTING
       iv_ref_guid                  = ip_ref_guid 
       iv_ref_kind                  = ip_ref_kind 
       it_appointment_com           = lt_appointment
     changing
       ct_input_fields              = lt_input_fields
    EXCEPTIONS
      PRECONDITION_VIOLATION       = 1
      INVARIANT_VIOLATION          = 2
      OTHERS                       = 3
             .
   IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   ENDIF.
  

Hope this helps your cause 😛

Former Member
0 Kudos

Hi Gun,

As I explained above, we want to disable fields for user input in status 'Complete'. However, we also want to update automatically a Z date (appointment) field when setting 'Complete' status.

We have tried to achieve it by using ORDER_SAVE BADI, but it didn't work because the order is already in COMPLETE status (with FINI status profile), and therefore order updates cannot be made.

Hope I cleared out your confusion..

Former Member
0 Kudos

Any suggestion?

Former Member
0 Kudos

Hi Idan,

One option would be to set up an intermediate status say for example 'ZCMP' (User process complete) and let the user use this for their process complete step. And in the order save BADI check for this status and set the appointment date and change user status to complete automatically.

Hope this helps!

Chandrika

Former Member
0 Kudos

Thanks for reply.

This is very interesting suggestion (We would try it soon).

However, Do you have any idea how to find out what is the status transaction of specific status ('FINI' in case of completed status, for example)? or to check if input is disabled?

Former Member
0 Kudos

Hi Idan,

Use BS33 to see what all status influences a particular business process (for example - double clicking on FINI shows you that system status I1005(completed) sets this process.

To see if the document is locked you could use the fieldcheck BADI CRM_ORDER_FIELDCHECK method FIELDCHECK. Here you can check the table CT_INPUT_FIELD_NAMES-CHANGEABLE='A' for FIELDNAME = your field.

Hope this helps!

Chandrika

Former Member
0 Kudos

Hi, sorry for the late response, but we have been investigating the issue again.

We hoped for a better solution, but we chose to use the BADI ORDER_SAVE and change the status to 'OPEN' when it is 'COMPLETE' (using CRM_ORDER_CHANGE_STATUS FM) before updating the order.

However, we have not been able to find out the attributes of the status transaction (FINI, in this case).

Does anyone know how to find if the user status set order as read-only (does enable any change of order fields)?

P.S.

We have not been able to activate an event (We try activating PARTNER AFTER_CHANGE Event). Is there any special action to perform (except linking the event to FM)?

Former Member
0 Kudos

Hi Idan,

I try to response to your case, but I am bit confused by

the previous (first question) and your last question.

Do you mean you like to change some fields while the

user status has set to COMPLETED (FINI) ?

If my understanding is correct, have you try to change

the configuration in user status? I mean, for user

status COMPLETED, do not set the business transaction to

FINI. Try to set it to other Business transaction such as

INPR or OPEN.

This means, everytime user status in document change into

COMPLETED, the system status will be still OPEN or In

Process (mean, you also can edited some fields).

This depends on the business practise you try to achive.

By the workaround mentioned above, your user status

COMPLETED may has bias meaning (since you still can change

other fields).

Hope this helps.

Cheers,

Gun.

Former Member
0 Kudos

Thanks for you reply, but it does not work.

This badi does not enable to change activity fields (using CRM_ORDER_MAINTAIN FM) when the status is 'completed'.

Does anyone know how to update activity fields on order save when status is changed to 'completed'?

Former Member
0 Kudos

Hi Idan,

Try using the following function call. This should set back the status to what you want.

CALL FUNCTION 'CRM_ORDER_CHANGE_STATUS'

EXPORTING

IV_REF_GUID = IV_GUID

  • Code for completed status should be in LC_Completed

IV_STATUS = LC_COMPLETED

IV_ACTIVATE = 'X'

EXCEPTIONS

PARAMETER_ERROR = 1

NOT_ALLOWED = 2

ERROR_OCCURRED = 3

OTHERS = 4.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Former Member
0 Kudos

Hi ,

You can define your own CRM order event ,such as 'BEFORE_SAVE' using the tcode 'CRMV_EVENT' .

You can add your own function module which could have

fm 'CRM_ORDER_MAINTAIN' . Hope this can help you .

Former Member
0 Kudos

Hi Idan,

If you haven't solved this already, try using the BADI I mentioned earlier and instead of CRM_ORDER_MAINTAIN, use function 'CRM_STATUS_CHANGE_INTERN_OW'

Example:

  • set header status to complete

lt_stat_wrk-stat = 'I1005'.

append lt_stat_wrk to lt_stat.

call function 'CRM_STATUS_CHANGE_INTERN_OW'

exporting

  • CHECK_ONLY = ' '

objnr = is_ref_orderadm_h-guid

iv_ref_kind = 'A'

  • IV_OBJECT_TYPE =

iv_no_1o_maintain = 'X'.

Hope this helps!

Chandrika