cancel
Showing results for 
Search instead for 
Did you mean: 

Alternate of CREATE_PROCESS_FORECAST for PO

ashish_shah
Contributor
0 Kudos

Hi All,

I am using method CREATE_PROCESS_FORECAST of class /sapsrm/cl_wf_apv_facade to validate ADHOC approvers added by the user in Purchase order in DOC Check badi.

However i noticed that this method does not return any process levels for a purchase order.

The same method works for Shopping cart and Confirmations, somehow for PO it does not work.

Does anyone have any suggestion on alternative of method CREATE_PROCESS_FORECAST of class /sapsrm/cl_wf_apv_facade for PO?

Regards,

Ashish Shah

Accepted Solutions (1)

Accepted Solutions (1)

konstantin_anikeev
Active Contributor
0 Kudos

Hi Ashish,

I'm afraid you are using the wrong approach.

Why don't you check ADHOC via specially designed BADI /SAPSRM/BD_WF_ADHOC_AGENT_F4?

As for Process Info - you could try to get reference to your PO as

lo_po = /SAPSRM/CL_PDO_FACTORY_PO_ADV=>GET_BUFFERED_INSTANCE( guid )

than call

lo_po->/SAPSRM/IF_PDO_DO_APV_EXT~GET_PROCESS_INFO_REF

(lo_po type ref to /SAPSRM/IF_PDO_BO_PO_ADV)

so should be able to get complete Workflow information

Best Regards

Konstantin

ashish_shah
Contributor
0 Kudos

Hi Konstantin,

Thanks for your suggestion about BADI /SAPSRM/BD_WF_ADHOC_AGENT_F4.

When i used this BADI, i was not able to throw custom messages during validations in method CHECK_INPUT_ADHOC_AGENT.

Do you know a way to throw custom messages from this BADI?

I will check your other suggestion about using /SAPSRM/IF_PDO_DO_APV_EXT class and will get back to you.

Regards,

Ashish

konstantin_anikeev
Active Contributor
0 Kudos

Hi Ashish,

I'm afraid it will not work via BADI with customer message.

You may need a workaround for that.

Best Regards

Konstantin

ashish_shah
Contributor
0 Kudos

Hi Konstantin,

I tried following:

DATA: lo_ebp_po_adv TYPE REF TO /sapsrm/if_pdo_bo_po_adv.

   CALL METHOD /sapsrm/cl_pdo_factory_po_adv=>get_buffered_instance
     EXPORTING
       iv_header_guid = iv_guid
     RECEIVING
       ro_instance    = lo_ebp_po_adv.

I am always passing correct PO header GUID.

This never returns any instance of lo_ebp_po_adv any idea what could be the reason?

Also i tried to get the reference using.

CALL METHOD /sapsrm/cl_pdo_factory_po_adv=>get_instance
     EXPORTING
       iv_header_guid  = gv_guid
       iv_mode         = 'DISPLAY'"'APPROVAL'
       iv_process_type = 'ECPO'
*      iv_wiid         =
       iv_user_id      = sy-uname
     RECEIVING
       ro_instance     = lo_ebp_po_adv       .

here i got the instance, however

lo_ebp_po_adv->/sapsrm/if_pdo_do_apv_ext~get_process_info_ref

Did not return any process schema.

Any other suggestion?

Regards,

Ashish

konstantin_anikeev
Active Contributor
0 Kudos

Hi Ashish,

following code works fine for me...

METHOD if_ex_bbp_doc_check_badi~bbp_doc_check.

   DATA lo_ebp_po TYPE REF TO /sapsrm/if_pdo_bo_po_adv.

   DATA lo_process_info TYPE REF TO /sapsrm/s_pdo_wf_process_info.

   DATA lo_message_handler TYPE REF TO /sapsrm/if_pdo_msg_consumer.

   lo_ebp_po = /sapsrm/cl_pdo_factory_po_adv=>get_buffered_instance( iv_doc_guid ).

   TRY .

       lo_ebp_po->/sapsrm/if_pdo_do_apv_ext~get_process_info_ref(

         IMPORTING

           er_process_info    =     lo_process_info

         CHANGING

           co_message_handler =     lo_message_handler

       ).

     CATCH /sapsrm/cx_pdo_abort.    " Fatal error caught by PDO Layer

   ENDTRY.

ENDMETHOD.

Best Regards

Konstantin

ashish_shah
Contributor
0 Kudos

Hi Konstantin,

For my requirement PO workflow was only getting triggered for changed version.

So i had to get the PO instance / PO GUID as following

          CALL FUNCTION 'BBP_PD_PO_GETDETAIL'
          EXPORTING
            i_guid          = iv_document_guid
            i_with_itemdata = space
          TABLES
            e_version       = lt_version.

        READ TABLE lt_version INTO ls_version WITH KEY version_type = 'C'.
        IF sy-subrc IS INITIAL.
          lv_guid = ls_version-guid.
        ELSE.
          lv_guid = iv_document_guid.
        ENDIF.

After this when i used the code provided by you it worked.

Thanks For your help.

Regards,

Ashish

Answers (0)