Skip to Content

Create a Workflow forecast for shopping cart

Sometimes one needs to create Workflow forecast for the case if workflow must be restarted.

Want to share a solution, I found.

First you need to have a shopping cart header guid.


DATA lo_process     TYPE REF TO /sapsrm/if_wf_process.
lo_process = /sapsrm/cl_wf_process_manager=>get_process_by_document( header_guid ).

So you get a worflow process instance. Then you need to reinitialize process (simulate restart)


/sapsrm/cl_wf_process_manager=>reinitialize_process( lo_process ).

This call returns true, if re-initialization was successful.

So, it’s better to pack it in IF operator


IF abap_true = /sapsrm/cl_wf_process_manager=>reinitialize_process( lo_process ).
........
ENDIF.

Now you are ready to simulate workflow


DATA ls_process_forecast TYPE /SAPSRM/S_WF_PROCESS.
/sapsrm/cl_wf_apv_facade=>create_process_forecast(
  EXPORTING
    iv_document_guid       = header_guid
    iv_document_type       = /sapsrm/if_pdo_obj_types_c=>gc_pdo_shop
    iv_agent_id            = sc_header_created_by
    iv_language            = sc_header_language
  IMPORTING
    es_process             = ls_process_forecast ).

So, in ls_process_forecast you will get a workflow simulation for the restart case.

After processing of simulation you may need to rollback the work or clear workflow simulation cache.


/sapsrm/cl_wf_process_manager=>delete_runtime_config_cache( ).

Regards

Konstantin

P.S.:  English language is not my native language, and any person is not insured from mistakes and typing errors. If you have found an error in the text, please let me know – I’ll correct the post.

P.P.S.: If you have some ideas, how to correct/improve this post – please don’t hesitate to leave a comment.

5 Comments
You must be Logged on to comment or reply to a post.