cancel
Showing results for 
Search instead for 
Did you mean: 

Place for "z-programing" when workflow starts

martin_svik2
Participant
0 Kudos

Hi,

i have a general workflow question: i have to do some z-coding (sending data to another system) for all worklows in our system. So everytime a workflow is starting(!) i want to use some z-coding.

so is there any "central point" (enhancement in standard method/function module or something else....) where i can place my z-coding ? As said, i need that every time a workflow is triggered.

br Martin

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hello Martin,

you would need an event FLOWITEM.CREATED, from where you could create an event type coupling for your coding as a receiver FM... or you place your piece of ZZ'zz into the place, where the event is created.

For more flexibility, I'd suggest to use the Flowitem.Created event.

DATA: ls_zz_wi_header              TYPE SWWWIHEAD.
    ls_zz_wi_header = m_wi_handle->GET_WI_HEADER( ).

    IF ls_zz_wi_header-wi_type      = 'F'      and  "Flowitem executed?
      ls_zz_wi_header-wi_cd        = sy-datum and  "today...
      ls_zz_wi_header-retry_cnt    = 0        and  "not restarted, yet (due to error)
      ls_zz_wi_header-wi_stat      = 'STARTED'.    "and started

      "... Well there's possibly a more precise way to catch the situation,
      "    when the Workflow-Item is initially started .. the very first time
      "    but for the moment, it'll do it.

      DATA: lv_zz_flowitem_key            TYPE SWEINSTCOU-OBJKEY.
      lv_zz_flowitem_key = ls_zz_wi_header-wi_id.

      CALL FUNCTION 'SWE_EVENT_CREATE'
            EXPORTING
              objtype = 'FLOWITEM'
              objkey  = lv_zz_flowitem_key
              event  = 'CREATED'
            EXCEPTIONS
              OTHERS  = 0.

    ENDIF.



Class CL_SWF_RUN_WIM_EXECUTION_MRG

Method Start_execution( )

Enhance with coding at end of FM


Or the following section could be more suitable:


Class CL_SWF_RUN_WORKFLOW_START

Method start_workitem

Enhance with coding at end of FM


Happy coding.


Not release safe.



Florin


former_member185167
Active Contributor
0 Kudos

" i have to do some z-coding (sending data to another system) for all worklows in our system. So everytime a workflow is starting(!) i want to use some z-coding."

May I ask... Why?

martin_svik2
Participant
0 Kudos

Hi Rick,

because there is an external system (intranet) which holds an counter for open workflows for each user and this counter has to be "real time".

br Martin

sbl
Active Contributor
0 Kudos

Hi Martin,

With this explanation, it is not starting a workflow that should trigger something, but the fact that a workitem of type dialog is triggered or ending.

And I would opt for another strategy.

Your Intranet certainly has access to certain programming language (PHP, PERL, Python....) and those language certainly have an API for RFC,  then I would call the FM SAP_WAPI_CREATE_WORKLIST for a user in order to get all the workitem the user is in charge of.

Or you can develop a webservice (SOAP) for the same.

Then you would dynamically check if the user has something to execute

Cheers

Stephane

pokrakam
Active Contributor
0 Kudos

SAP_WAPI_COUNT_WORKITEMS

Has some handy performance settings that make it viable for polling from an external system. We used it to implement an inbox traffic light using a portal java app, it would check every 5 minutes and update the status.

sbl
Active Contributor
0 Kudos

Mike,

Funny I am learning every day, even though I am looking after SAP_WAPI functions for quite a long time I have never taken a particular attention to this one.

Thanks for the input,

Cheers

Stephane

sbl
Active Contributor
0 Kudos

Hi

Why not using the workflow exit ?

There are several event available and you could set it up for the steps of your workflow that are relevant for you.

It is one one of the tab of the steps in the workflow.

Cheers

Stephane

martin_svik2
Participant
0 Kudos

Hi,

i have about 40 different workflows ! i need a central(!) point for doing this, not in every single workflow-definition.

br martin

sbl
Active Contributor
0 Kudos

Ok Sorry I had not understood, the 40 workflows...

So just a thought why not doing a subobject of WORKITEM and make the delegation, then you create an attribute on your object and this attribute refers to a Z method, there you can insert your code. (which could be triggered only if the type of workitem is of type workflow)

Or better use the event created put your condition and manage it via workflow !

Cheers

Stephane

pokrakam
Active Contributor
0 Kudos

My sneaky hack would be an implicit enhancement on the caller of the workflow exit. Simple, no frills.

martin_svik2
Participant
0 Kudos

Hi Mike,

i like sneaky hacks

do you have an object name for the caller of the workflow exit ? It is not always sure if impl. enhancement is allowed on a sap standard object.

br Martin

pokrakam
Active Contributor
0 Kudos

I don't have the time to check, but just implement the WF Exit with a local object and stick a breakpoint or log point in it to find out where it's called from.


Implicit enhancements are there for us to do our thing. It's up to the developer to ascertain what can safely be added. Hence my reasoning that using the WF Exit as a reference means we're putting our enhancement at the right place.

Former Member
0 Kudos

Hi,

you would need to hook in a central Workflow-Exit (CONTRUCTOR/DESTRUCTOR) in the global read-access to the Workflow definitions (all workflows), which is here:

Function SWD_WF_DEFINITION_READ

Tables "Functions" needs to be extended with the generic workitem exit definition.

I've checked that and found out, that somewhat - not always - the function is processed ... sometimes not. So I went to check the workflow-start functionality.

By the way, an Enhancements in CL_SWF_RUN_WIM_FACTORY->create_via_API( ) could also be neat, as all the workitem types run through the factory, including the Workflow itself.

Florin

vinita_kasliwal
Active Contributor
0 Kudos

Hi Martin

I did something like this before ..

So for example whenever a user is accepting . rejecting a document . An event trigger occurs .

in SWEL you will see the events generated after you activate the trace .

You can manually activate this event if it does not get automatically triggered using below code :

CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'
EXPORTING
object_type            
= 'BUS2121'
object_key             
= lvObject_key
EVENT                   = lv_event
COMMIT_WORK            
= ' '
*   IMPORTING
*     RETURN_CODE             =
*     EVENT_ID                =
*   TABLES
*     INPUT_CONTAINER         =
*     MESSAGE_LINES           =
*     MESSAGE_STRUCT          =

Place the above code in any of the BADI's which you know will get triggered .I placed it in BBP_DOC_SAVE_BADI for SRM Shopping cart 


Now you can link this event to your FM in tcode SWETYPV and thus everytime it will trigger it will

automatically trigger your FM .


Regards

Vinita

martin_svik2
Participant
0 Kudos

Hi Vinita,

this is also an approach, but i need this on a central point as i have about 40 different workflows.

br martin

anjan_paul
Active Contributor
0 Kudos

hi,

My   suggestion, check the table SWWWIHEAD or transaction SWI1, based on Time selection, excute a batchjob with your zcode report.

martin_svik2
Participant
0 Kudos

hi,

well, my problem is that this has to be in REAL time. so it would not be a good idea to do it with a batchjob

br Martin

Former Member
0 Kudos

Hi Martin ,

what you can do is to copy standard receiver FM and add your coding in that either in start or last. By this , you will have a central source. Now you need to use this copied FM in every event binding as receiver FM.

Thanks

Rakesh