cancel
Showing results for 
Search instead for 
Did you mean: 

Change Status of Preceding document

Former Member
0 Kudos

Hi Experts,

Can it be possible to change Status of Preceding document using Action Profile,

in Action Defination (Process Type) i can see the Method SET_DOCUMENT_STATUS will it be useful,

Please suggest in details.

Thanks in Advance,

Dipesh.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Method SET_DOCUMENT_STATUS is used to set the status of the current document.

When do you want to set the status of the preceding document ?

Regards,

Madhu

Former Member
0 Kudos

Hi Madhu,

In my scenario i m trying to set the status of preceding document for e.g.I want set the Status of Lead which is preceding document for Opportunity, can it be achived using SET_DOCUMENT_STATUS method

or we can put transaction type of Lead in initial value.

Please Suggest.

Thanks,

Dipesh.

Former Member
0 Kudos

Dipesh,

I think you can change the status of preceding document using ORDER_SAVE badi.. Read the guid of the preceding document from doc-flow and use FM CRM_STATUS_CHANGE_EXTERN to change the status..

Hope it meets ur requirement...

Thanks,

RR

Former Member
0 Kudos

Thanks RR,

For quick reply i know i can achive this by using Badis but i m looking for the functional aspect rather than Abap, any suggesion.

Thanks,

Dipesh

Former Member
0 Kudos

Hi Dipen,

I dont find any standard method which updates the preceding document status.

I had worked on scenario where we have changed service order status upon service confirmation status gets completed

I have used a Zmethod to achieve this. Find the below code which i used. Hope it may be useful to you to create Zmethod.

method IF_EX_EXEC_METHODCALL_PPF~EXECUTE .

data: lv_guid_ref       type crmt_object_guid,

      lc_action_execute type ref to cl_action_execute,

      doc_info          type CRMT_DOC_FLOW_WRKT,

      doc_links         type line of CRMT_DOC_FLOW_WRKT,

      header_guid       type CRMT_OBJECT_GUID,

      object_no         type CRM_JSTO-OBJNR,

      order_items       type CRMT_ORDERADM_I_DU_TAB,

      order_item        type line of CRMT_ORDERADM_I_DU_TAB.

* get the object GUID for processing

  create object lc_action_execute.

  call method lc_action_execute->get_ref_object

    exporting

      io_appl_object = io_appl_object

      ip_action      = ip_action

      ii_container   = ii_container

    importing

      ev_guid_ref    = lv_guid_ref.

* If the GUID is not present then get the information from the object

* layer

  if lv_guid_ref is initial.

   CALL FUNCTION 'CRM_INTLAY_GET_HEADER_GUID'

     IMPORTING

       EV_HEADER_GUID       = lv_guid_ref

             .

  endif.

* check the GUID before processing

  check not lv_guid_ref is initial.

* Read the document flow to retrieve the service order number

  CALL FUNCTION 'CRM_DOC_FLOW_READ_OB'

    EXPORTING

      IV_HEADER_GUID        = lv_guid_ref

    IMPORTING

      ET_DOC_FLOW_WRK       = doc_info

            .

*  CALL FUNCTION 'CRM_DOC_FLOW_READ_DB'

*    EXPORTING

*      IV_HEADER_GUID       = lv_guid_ref

*    IMPORTING

*      ET_DOC_LINKS         = doc_info.

* determine if this service confirmation has a service order

  describe table doc_info lines sy-tabix.

  check sy-tabix gt 0.

  read table doc_info into doc_links with key objtype_a = 'BUS2000116'.

* set the user status to Complete upon save of the

* service confirmation

  move doc_links-objkey_a to header_guid.

*  call function 'CRM_STATUS_BUFFER_REFRESH'.

* Lock the service order

   call function 'CRM_ORDER_ENQUEUE'

   exporting

     iv_guid           = header_guid

   exceptions

     foreign_lock      = 1

     system_failure    = 2

     distributed_lock  = 3

     no_change_allowed = 4

     transferring      = 5

     others            = 6.

* Check if the service order is locked

  if sy-subrc = 1 or sy-subrc = 3.

* sent message to the user

  endif.

* Change the header status

   move header_guid to object_no.

   call function 'CRM_STATUS_CHANGE_EXTERN_OW'

   exporting

     objnr               = object_no

     user_status         = 'E0007'

     set_inact           = ' '

   exceptions

     object_not_found    = 1

     status_inconsistent = 2

     status_not_allowed  = 3

     others              = 4.

* Change the line item status

  CALL FUNCTION 'CRM_ORDERADM_I_READ_DB'

    EXPORTING

      IV_HEADER                 = header_guid

    IMPORTING

      ET_ORDERADM_I_DB          = order_items.

* read each item and change the status

loop at order_items into order_item where itm_type ne 'SRVS'.

   move order_item-guid to object_no.

   call function 'CRM_STATUS_CHANGE_EXTERN_OW'

   exporting

     objnr               = object_no

     user_status         = 'E0007'

     set_inact           = ' '

   exceptions

     object_not_found    = 1

     status_inconsistent = 2

     status_not_allowed  = 3

     others              = 4.

 endloop.

* Save the status

   if sy-subrc eq 0.

    call function 'CRM_STATUS_UPDATE_DIALOG'.

   endif.

* set the return processing status

if sy-subrc eq 0.

  rp_status = '1'.

else.

  rp_status = '2'.

endif.

endmethod.

Regards,

Madhu

Former Member
0 Kudos

Hi Madhu,

Thanks for u r answer, It can be achived also by using ORDER_SAVE badi.

Many Thanks,

Dipesh.

Former Member
0 Kudos

Hi Dipesh,

If i am not wrong ORDER_SAVE Badi can update the status upon saving the preceding document.

Will it solve your issue

Regards,

Madhu

Former Member
0 Kudos

Hi Madhu,

As of now we are updating the status of preceding doc by using ORDER_SAVE Badi,

since i saw the Method SET_DOCUMENT_STATUS in processign type which i never used could be

use for doing same, anyways i found one more way to do it same from u.

Thanks again,

Dipesh.

Former Member
0 Kudos

Hi Dipesh/Madhu,

I want to Update Lead Status on save of follow up opportunity using Action Profile. I am exploring the option to implement it using standard SAP CRM functionality. Please provide your input on the same. How it can be realised?

Regards,

Amit

Answers (0)