cancel
Showing results for 
Search instead for 
Did you mean: 

how to pass instance of class to workflow container

Former Member
0 Kudos

Hi Guys:

i want to pass the instance of ZCLASS to my workflow container, I use FM SWW_WI_START to start my workflow template directly,when I try to use SWC_ELEMENT_SET to pass instance to container table, i get exception type_conflict = 1, pls help me, and i don't want to use EVENT way to trigger WF, bcs i almost finish the trigger WF FM by this way.

the following the a part of code in my FM.

DATA lo_wf TYPE REF TO CL_PT_REQ_WF_ATTRIBS.

DATA swconttab TYPE swconttab.

CREATE OBJECT lo_wf.

CALL FUNCTION 'SWC_ELEMENT_SET'

EXPORTING

element = 'ZBMW_CL_WORKFLOW'

field = lo_wf

TABLES

container = swconttab

EXCEPTIONS

type_conflict = 1

OTHERS = 2.

Edited by: lizhong deng on Aug 24, 2011 2:07 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I am actually interested how you expect that your lo_wf is instantiated properly since you don't give the request id for the constructor? And how you expect that you can just turn CL_PT_REQ_WF_ATTRIBS into ZBMW_CL_WORKFLOW (or is the type of ZBMW_CL_WORKFLOW same as CL_PT_REQ_WF_ATTRIBS?)?

I don't even know if you can write an ABAP class into a container? You can try this, but I would perhaps try it with SAP_WAPI_WRITE_CONTAINER instead of the function that you try to use. But I actually doubt that it will work since you should give the object in simple_container and I am not sure whether it can take ABAP classes...

I would probably create a step for instantiating the class in workflow. Just simple "create object" statemenent in a method. But really the best way probably would be to start the WF with an event of your class if that is possible.

Regards,

Karri

Former Member
0 Kudos

Hi Karri:

thanks.

it's just for testing, - so I just hard code field lpor-instid = '123465' in constructor. and class ZBMW_CL_WORKFLOW is

a customizing class, it's different from CL_PT_REQ_WF_ATTRIBS , but also inherited IF_WORKFLOW interface.

and i already find a example (CL_DEF_IM_PT_GEN_REQ->IF_EX_PT_GEN_REQ~START_WF), we can put the instance of class into if_swf_cnt_container, and then conver it to simple container by method if_swf_cnt_container->to_simple_container.

I think 'instantiating class in WF' is way, just like BO 'system'. thank you!

Answers (1)

Answers (1)

former_member185167
Active Contributor
0 Kudos

Hello,

"i don't want to use EVENT way to trigger WF, bcs i almost finish the trigger WF FM by this way."

There's a unique reason to do something the wrong way.

Use SAP_WAPI* functions and DO use an event to start your workflow.

As for the class, I would do it inside the workflow as Karri suggests. Just pass the key as an event parameter (if necessary).

regards

Rick Bakker

hanabi technology

Former Member
0 Kudos

Hi Rick:

I think 'Trigger EVENT' is not the only way to start WF with passing instance of class/BO,

SAP_WAPI_START_WORKFLOW and SWW_WI_START can do the same thing, just need to

conver the type of container. and thanks for discussing. -

former_member185167
Active Contributor
0 Kudos

You can do it your way, or you can do it the right way. It's up to you.