cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a method before execution of workflow

03-14-2014 2:31 PM
977 views 7 comments
0 Likes
SAP Managed Tags
Subscribe

Hi all,

What I want to do is to call a method (or write a method somewhere in workflow) to check somedata (e.g. manager of some user, or maktx of some material, just a simple method) and check whether the workflow should execute or not using the output of this method.

I'm not sure where should I write or call this method in workflow. Anyone help me about this ?

Thanks.

0 Likes

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Likes

Hi,

Also consider using check function module in event linkage SWE2. The check FM gets executed before starting the workflow. You can put any condition in it, if condition evaluates to false and you do not want to trigger the workflow, simply raise an exception in this FM and workflow will not trigger.

http://saptechnical.com/Tutorials/Workflow/checkfunctionmodule/demo.htm

Regards,

Ibrahim

ronen_weisz
Active Contributor
0 Likes

Don't use a method, create an attribute for the object and then add a starting condition to check that attribute (transaction SWB_COND)  https://help.sap.com/saphelp_erp2004/helpdata/en/4c/86bf43feca11d2a64f0060087a79ea/frameset.htm).

You can also add more complicated checks in a check function module and link it via transaction SWE2 (Function Modules for Processing Events (SAP Library - Embedded Processes (SAP Business Workflow)), but usually the an attribute work well. 

Former Member
0 Likes

Hi Ronen,

SWB_COND is different from the condition screen which is inside the workflow screen. Because I can just add controls with checking something inside Purchase Requisition such as, Release Code = 50, Requisitioner = "SOMEONE" etc.

I have to write some code which is totally irrelevant to Purchase Requisition. Can I do this with SWB_COND ? I clicked new condition and see this screen. Then I click the line which I highlighted below, nothing happens

Former Member
0 Likes

you always can create another step performing a background method and checking the output of the step. Your method could be anything, but most likely you will want to create one with your wi_object_id

ronen_weisz
Active Contributor
0 Likes

1. you should get a screen similar to the IF conditions in the workflow. the purchase requisition object for your workflow  should be BUS2105 (or BUS2009 for PR items) not EBAN.  maybe that's the problem.

2. The code could be placed in the object attribute. there is no problem to create an attribute not relevant to the PR. you can write what you want - it's ABAP.

3. you can also use SWE2 (the second option I wrote) and then it's a regular function module.

4. using a method to check the data and cancel the workflow is possible but less recommended - it's better to not start the workflow at all. 

Former Member
0 Likes

Thanks for your answer Ronen,

I'm kind of new to workflow so;

2. The code could be placed in the object attribute.


What is object attribute and how to place the code there ?


Thanks.

ronen_weisz
Active Contributor
0 Likes

Maybe consider bringing in an someone more experienced to help you get started?

anyhow, here are a few explanations:

Extending Object Types: Inheritance and Delegation (SAP Library - SAP Business Workflow (BC-BMT-WFM)...

Tutorial: Workflow Programming (SAP Library - Business Task Management)