cancel
Showing results for 
Search instead for 
Did you mean: 

Class instantiation like BOR in Workflow

soumya_ranjan_patel
Participant
0 Kudos

Hi guys,

I have a requirement where I need to use event of one class(CL_EHHSS_PCO_INC_INV_LC) as a terminating event in another WF where another class(CL_EHHSS_PCO_INC_LC) is used.

So just like BOR Instantiation I need the class instantiation. So when the 2nd WF completes one step I need the 1st WF to respond and send some notification mails.

As I am not that good in classes can you please help in litle detailed steps.

Regards,

Soumya.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Instantiating a class is basically easy. You can for example create a new task/step in your workflow. In this task you call your own simple method (if there aren't any standard one available). In the method you just take the key as an input parameter, and then just use simple CREATE OBJECT statement to create the object instance, and then return/export this from the method. Now if you call this new method as a background task in your workflow, you can get the object instance in your workflow (you can perhaps do this already in the beginning of the workflow, so you will have the instance during the whole WF).

After saying this, I need to say that it might be a bit more difficult (I cannot check this class in my system to see the details), but in its easiest format, the above is really the only thing that is needed.

I would also like to confirm what Sandy said. Check also the alternative (easier?) solutions. If your aim is just to cancel the workflow, you can do it also other ways than using the terminating event.

Regards,

Karri

SandySingh
Active Contributor
0 Kudos

"So just like BOR Instantiation I need the class instantiation. So when the 2nd WF completes one step I need the 1st WF to respond and send some notification mails."

In 1st WF; you can create a FORK with one waiting event "SEND_NOTIF" followed by email step. In second workflow, you can trigger the event "SEND_NOTIF" using Class cl_swf_evt_event

CALL METHOD cl_swf_evt_event=>raise

Regards

Sandy

SandySingh
Active Contributor
0 Kudos

Hello

As per my understanding; terminating events can work for same key objects.

Instead of using the terminating events why dont you use the FM 'SAP_WAPI_ADM_WORKFLOW_CANCEL' in a backgroun step to Cancel the 1st  workflow

   

CALL FUNCTION 'SAP_WAPI_ADM_WORKFLOW_CANCEL'

      EXPORTING

        workitem_id    = ist_tasks-eawid

        language       = sy-langu

        do_commit      = abap_false

      IMPORTING

        return_code    = lfd_return_code

      TABLES

        message_lines  = ltb_msgln

        message_struct = ltb_msgstr.

Regards

Sandy

I042439
Employee
Employee
0 Kudos

Hello Soumya

I do not have access to a system where the above classes are available; hence I do not know the keys of these classes.

My First assumption is that the workflow using class CL_EHHSS_PCO_INC_LC can get the KEY of the class CL_EHHSS_PCO_INC_INV_LC.

Second assumption is that the workflow is a custom workflow.

Create a Z class, if you really do not have one. Follow the rule of implementing IF_WORKFLOW interface in that class . Just activate the methods of the interface in the class (no need for coding if you really do not know workflow classes ...just keep it simple.

Create a static public method in the class - input is the key of CL_EHHSS_PCO_INC_INV_LC and output is TYPE REF TO CL_EHHSS_PCO_INC_INV_LC. In the method, simply use CREATE OBJECT statement to create an instance of the class CL_EHHSS_PCO_INC_INV_LC , pass the keys (if there is a constructor defined for it with those key). Pass back this created object.

In your workflow, call a background activity, which calls a task , which calls this method. Pass the key and receive the Class Instance (CL_EHHSS_PCO_INC_INV_LC) as a container element (of type Object - CL ,  CL_EHHSS_PCO_INC_INV_LC) in task and then in the WF.

Now your workflow has a "living" object. Pass it to the step (bind it to the task from WF) where you want to use it's event as a terminating event.

Of course, the place where you are triggering the event should also have the same key.

Regards,

Modak