cancel
Showing results for 
Search instead for 
Did you mean: 

Using Rule Container outside Workflow

svendelangle
Explorer
0 Kudos

I'd like to call the function me_rel_get_responsible( ) outside a workflow to check on possible agents of a purchase order.

The function itself tries to access the purchase order data from the ac_container:

swc_get_element ac_container 'purchaseorder' object.


How can this container be filled with the BOR in the calling programm using if_swf_cnt_container?



Method GET_AGENT

 data ls_bor          type sibflporb. data lt_ac_container type table of swcont.
 data lt_actor        type table of swhactor.
 data ls_bor          type sibflporb.


ls_bor-instid = gv_ebeln.
ls_bor-catid  = 'BO'.
ls_bor-typeid = 'BUS2012'. 


//*** need some Logic to bring the BOR Object into the container ***
//*** so that ME_REL_GET_RESPONSIBLE can read further details ***



lt_ac_container = value #( ( element = 'PURCHASEORDER' elemlength = '004' type = 'O'  value = '1' )
                           ( element = 'RELEASECODE'   elemlength = '002' type = 'C'  value = '0'  ) ).

    call function 'ME_REL_GET_RESPONSIBLE'
      tables
        actor_tab    = lt_actor
        ac_container = lt_ac_container
*       EXCEPTIONS
*       NOBODY_FOUND = 1
*       OTHERS       = 2
      .
..

Endmethod.
View Entire Topic
egor_malov
Contributor

Hi, Sven

I can think of three possible ways:

1. 'classic' way with macros

swc_create_object ls_bor 'BUS2012' gv_ebeln.
swc_set_element lt_ac_container 'ReleaseCode' gv_release_code.
swc_set_element lt_ac_container 'requisition' ls_bor.
swc_container_to_persistent lt_ac_container.
CALL FUNCTION 'ME_REL_GET_RESPONSIBLE'
TABLES
actor_tab = lt_actor
ac_container = lt_ac_container
* EXCEPTIONS
* NOBODY_FOUND = 1
* OTHERS = 2
.

This approach is well documented Writing an Object Reference into a Container

(btw it's possible to use macros in OO code).

2. the same as above but in a modern way with sibflporb

I think it should be possible, but I don't know how

3. just pass the key

If we debug, we can see that what actually passed is the order's key so why not just pass it as is.

Here is a blog post where you can see it done (with code) Workflow: Purchase Order/Requisition Approvers Simulation

I am not sure which one I would choose. #1 looks too 1995... On the other hand #3 looks a bit 'unofficial' to me.