Skip to Content
0

Binding between Task and Static Business Object Method - Get_Instance

Jul 20, 2017 at 12:07 PM

121

avatar image

Hello Gurus,

I'm developing a new workflow, class based. I'm trying to instantiate the business object(the class) using a first background task and a static business method(get instance) returning the reference of the class. My problem is that the binding between the TASK and the METHOD seems not to work. The method(get_instance) works fine, I've tested it!

After reading quite a lot on the internet and even trying to make the return parameter an exporting one, to use an explicit variable in the TASK container and even debugging the standard framework I still wasn't able to solve the problem. Please help.

Regards,

Ioan.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Best Answer
Mike Pokraka Jul 21, 2017 at 10:18 AM
0

First off, you should never ever ever touch task-method binding unless you really have a very very specific reason to do so. The system maintains this automatically based on your available elements, and I've never had to do anything custom in 15+ years of working with WF.

The problem is that once you change something here, SAP stops maintaining it because it's now flagged as under your control. So don't touch that button. Ever.

To reset it, create a new task.

As to static functional methods, you can write these directly into bindings or assignment steps. Far better performance. Please refer to my answer to the very recent question Language Dependent Element in Workflow Container for the syntax.

Share
10 |10000 characters needed characters left characters exceeded
Stéphane Bailleul Jul 21, 2017 at 07:32 AM
0

Hi,

There is two ways to achieve a class instanciation from workflow

1- Using a specific task to instanciate it.

2- using the WF System class_create

So

1- Using a specific task to instanciate it.

You'll find the bidding I am doing to instanciate a PO Item class

GO_WF_EKPO is defined in the container as a class (/cdlg/wf02_ekpo)

The Step binding

the task binding

the signature in the method

2- using the WF System class_create

Now in more recent version you can also directly from a container create an instance of a class

The result being the container class and the expression %_WFSYST.OBJECT.CREATE_CL(OBJTYPE= ;OBJKEY= )%

You can use from the expression the create_class

Then you can use the "wizard" to include the expression (access to your key and class from container value of your workflow)


binding.png (11.7 kB)
taskbinding.png (7.4 kB)
taskbinding.png (7.4 kB)
new-wf.png (10.2 kB)
new-wf-key.png (4.4 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded

I've implemented it like in your first option but it seems the binding for the returning parameter is not working. Have you ever experienced this scenario? Import ok returning not ok.

I'm calling the method in background and synchronous.

Regards,

Ioan.

0
Johann Konstantin Jul 24, 2017 at 09:19 AM
0

binding.pngtest.pngHello and thank you for your answers,

I have deleted the task and created it again like Mike suggested but unfortunately that didn't solve the problem.

Stéphane, thank you very much for the screen shots. I'm using a specific task for the instantiation but like in your first example but it's not working :(

Pavan, I'm starting without an event. I have implemented the task like in the example from Stéphane but when testing the task with SWUD I don't get the instance back in the task container from the method.

Regards,

Ioan.


binding.png (12.5 kB)
test.png (12.1 kB)
Share
10 |10000 characters needed characters left characters exceeded
Pavan Bhamidipati Jul 21, 2017 at 07:13 AM
0

Hi,

 I'm trying to instantiate the business object(the class) using a first background task and a static business method(get instance) returning the reference of the class. My problem is that the binding between the TASK and the METHOD seems not to work. The method(get_instance) works fine, I've tested it!

How are you instantiating the workflow? Are you using an event or directly by using the start workflow functions. I would try to create start workflow by creating an event in this way you can avoid of explicitly instantiating the class and exporting back to the workflow.

If there is no possiblity to do so, then make sure you need to always import and export the instance of the class in all the tasks defined in the workflow.

Thanks,

Pavan

Share
10 |10000 characters needed characters left characters exceeded
Johann Konstantin Jul 25, 2017 at 11:13 AM
0

Any ideas anyone?

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Have you tried my suggestion to write it into an assignment step? Please see the link I provided for a syntax example. It's very easy and doesn't even need a task or instance of any sorts.

0

Hello Mike,

I have read it again and I finally managed to get it right. Thanks a bunch!

I've bought a book on workflows which turned out to be pretty bad ...

I've managed to instantiate the class in the binding! %/HRG/CD_WF_REL_REQ.GET_INSTANCE(IV_VALUE=&VALUE&)%

For other users that might need this, the method get_instance is static and the value variable is from the workflow container.

Thank you very much Mike.

Regards,

Ioan

0

Oh dear, I hope it wasn't the SAP Press WF book??? ;-) Because that one contains exact examples of the above.

The tiny edit box in the WF builder is a bit of a pain, you may find it easier to write/edit OO expressions like this in notepad and pasting them in. It's been on the suggestions list for SAP to make it a little friendlier, but so far no joy.

0