cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow fu00FCr TA: OKENN

Former Member
0 Kudos

In the Transaction OKENN it is possible to create AND change Kostcenter.

an this is my Problem:

I Created a Eventtrigger in the Function EXIT_SAPLKMA1_003 -> Include ZXKM1U03

In this Include i placed the trigger for the Function SWE_EVENT_CREATE. So far so good.

to avoid double Workflow aktivation is made a Dynpronumber Check like

IF SYST-UCOMM = 'SAVE' and SY-TCODE = 'OKENN'." Nur für Hirachiewanwendungen OKENN und save
      IF SYST-DYNNR = 3299.

But in Newdays the Dynpronumber STST-DYNNR is not always 3299. In some Cases it ist 1000 and then my WF wont start!

if i dont check the syst-dynnr Number the Workflow would start serverel Times.

How is it Possible to Know whitch SYST-DYNNR is uses in the TA OKENN ???

Or is there an onter way to avoid the double start of the WF?

Im hope i get some usefull Inforation.

KR

Tkuebler

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

now Implementet the 2 FM

first SAP_WAPI_WORKITEMS_TO_OBJECT to check if some WF ist already there second the FM for Creating

SAP_WAPI_CREATE_EVENT'

the Event is correktly, i traced it but with the FM SAP_WAPI_WORKITEMS_TO_OBJECT i could not get any data.

The FM SAP_WAPI_CREATE_EVENT produced a Event_id, i saw this in the debugger and the Object_Key for

SAP_WAPI_CREATE_EVENT and SAP_WAPI_WORKITEMS_TO_OBJECT are the same.

Normaly SAP_WAPI_WORKITEMS_TO_OBJECT should find extistin WF and puts all data in the variable "worklist" but nothing apeard in it...

I think i use this FM SAP_WAPI_WORKITEMS_TO_OBJECT wrong somehow....

Regads

Tkuebler

former_member185167
Active Contributor
0 Kudos

Hello,

Can you see the workflow in SWI1? Just because an event was created doesn't mean a workflow was started.

Also try:

SELECTION_STATUS_VARIANT = 0000 "All

and use

lv_objtype type SWO_OBJTYP.

instead of hardcoding the object name and finally I hope you are checking the returncode table for messages.

regards

Rick Bakker

hanabi technology

Former Member
0 Kudos

Hello,

Yes i see the WF in SWI1!!

Now my Check FM looks like this

CALL FUNCTION 'SAP_WAPI_WORKITEMS_TO_OBJECT'
 EXPORTING
*   OBJECT_POR                     =
   OBJTYPE                        = lv_objtype
   OBJKEY                         = WF_OBJKEY2
*   TOP_LEVEL_ITEMS                = 'X'
   SELECTION_STATUS_VARIANT       = 0000
*   TIME                           =
*   TEXT                           = 'X'
*   OUTPUT_ONLY_TOP_LEVEL          = ' '
*   LANGUAGE                       = SY-LANGU
*   DETERMINE_TASK_FILTER          = 'X'
*   REMOVED_OBJECTS                = ' '
 IMPORTING
   RETURN_CODE                    = l_retcode
  TABLES
*   TASK_FILTER                    =
    worklist                       = lt_workitem
*   MESSAGE_LINES                  =
*   MESSAGE_STRUCT                 =
          .

severel lines later comes the FM SAP_WAPI_CREATE_EVENT

CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'
  EXPORTING
    object_type             = 'ZKOSTL2'
    object_key              = WF_OBJKEY2
    event                   = event
   COMMIT_WORK             = 'X' " Löst den Event aus! WICHTIG
*   EVENT_LANGUAGE          = SY-LANGU
*   LANGUAGE                = SY-LANGU
*   USER                    = SY-UNAME
*   IFS_XML_CONTAINER       =
 IMPORTING
   RETURN_CODE             = R_CODE
   EVENT_ID                = event_id2
* TABLES
*   INPUT_CONTAINER         =
*   MESSAGE_LINES           =
*   MESSAGE_STRUCT          =
          .

All Coding is embeddet in the Include ZXKM1U03

and this Include starts a bout 3 or 4 times i push the Save Button in the OKENN

The FM SAP_WAPI_WORKITEMS_TO_OBJECT sould give me data about the started WF but nothig apears in the Variable

lt_workitem

former_member185167
Active Contributor
0 Kudos

Hello,

What happens if you test SAP_WAPI_WORKITEMS_TO_OBJECT separately with the same values?

Did you check the return_code table?

regards

Rick Bakker

hanabi technology

Former Member
0 Kudos

Now i coded this

CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'
  EXPORTING
    object_type             = 'ZKOSTL2'
    object_key              = WF_OBJKEY2
    event                   = event
   COMMIT_WORK             = 'X' " Löst den Event aus! WICHTIG
*   EVENT_LANGUAGE          = SY-LANGU
*   LANGUAGE                = SY-LANGU
*   USER                    = SY-UNAME
*   IFS_XML_CONTAINER       =
 IMPORTING
   RETURN_CODE             = R_CODE
   EVENT_ID                = event_id2
* TABLES
*   INPUT_CONTAINER         =
*   MESSAGE_LINES           =
*   MESSAGE_STRUCT          =
          .

CALL FUNCTION 'SAP_WAPI_WORKITEMS_TO_OBJECT'
 EXPORTING
*   OBJECT_POR                     =
   OBJTYPE                        = 'ZKOSTL2'
   OBJKEY                         = WF_OBJKEY2
*   TOP_LEVEL_ITEMS                = 'X'
   SELECTION_STATUS_VARIANT       = 0000
*   TIME                           =
*   TEXT                           = 'X'
*   OUTPUT_ONLY_TOP_LEVEL          = ' '
*   LANGUAGE                       = SY-LANGU
*   DETERMINE_TASK_FILTER          = 'X'
*   REMOVED_OBJECTS                = ' '
 IMPORTING
   RETURN_CODE                    = l_retcode
  TABLES
*   TASK_FILTER                    =
    worklist                       = lt_workitem
*   MESSAGE_LINES                  =
*   MESSAGE_STRUCT                 =
          .

to Check but also here nothing apears in the second FM the l_retcode is always 0

what the hell am i doing wrong?

nabheetscn
Active Contributor
0 Kudos

Hi,

As an alternative Before raising an event you do a select on table SWW_WI2OBJ where you pass TYPEID as your custom business object and INSTID as combination of all three fields if sy-subrc is 0 means workflow is already triggered else you raise the event.

Nabheet

Former Member
0 Kudos

Hello,

i made this

SELECT * from SWW_WI2OBJ INTO check_SWW_WI2OBJ.
  ENDSELECT.

but in this Struckture is nothing usefull

former_member185167
Active Contributor
0 Kudos

Hello,

Just concentrate first on getting SAP_WAPI_WORKITEMS_TO_OBJECT to find a workflow that has already run for your object.

Forget SAP_WAPI_CREATE_EVENT for now.

Look in SWI1, find a workflow for your object (ZKOSTL2), tell us what the key value was for the object instance used in that workflow and then please show a standalone piece of code (with full declarations of all variables) that calls SAP_WAPI_WORKITEMS_TO_OBJECT. It works for everyone else so it will work for you.

regards

Rick Bakker

hanabi technology

Former Member
0 Kudos

Ok,

in my SWI1 is list of all Tasks with task Number, Status etc. but an Object like ZKOSTEL2 is not listet. It is sad that i cant show u a Screenshot.

It is nice to see that the task is in the Status READY so the WF has already started. But no Object or Objekt type is listed here!

The TaskID is helpfull. But how helps me this in connection with SAP_WAPI_WORKITEMS_TO_OBJECT ?

kr

tkuebler

Former Member
0 Kudos

Hi,

Update:

now i try to test the FM SAP_WAPI_WORKITEMS_TO_OBJECT in SE37

i can see now the "open" Tasks but i have the Problem to find the exact OBJKEY.

The OBJKEY is defined in my Objekct (SWO1) ...

I think this is my Main Problem to find the right Objektkey (OBJKEY) is there a way to see it?

In SWi1 it is not shown also not in the Worklist of SAP_WAPI_WORKITEMS_TO_OBJECT.

i am so close ...i feel it..

regards

tkuebler

former_member185167
Active Contributor
0 Kudos

Hello,

Just look in the workflow log, in the container, if you want the object instance.

Maybe you should consider taking a workflow course.

regards

Rick Bakker

hanabi technology

Former Member
0 Kudos

hehe,

in september i take 2 sap coursees...

i think i have some gabs in generell...

Former Member
0 Kudos

...

Edited by: Tobias Kübler on Jul 15, 2011 11:45 AM

Former Member
0 Kudos

this is so strage in my trace list SWEL

is this line

ZKOSTL2 CHANGED 15.07.2011 09:45:02 WS90100014 @5B@ JWGU001010000099991231 SWW_WI_CREATE_VIA_EVENT_IBF

ZKOSTL2 is the BOR Objekt and

JWGU001010000099991231 is the Key

Now i use SE37 with SAP_WAPI_WORKITEMS_TO_OBJECT and tested with this data

Import-Parameter Wert

OBJECT_POR

OBJTYPE ZKOSTL2

OBJKEY JWGU001010000099991231

TOP_LEVEL_ITEMS

SELECTION_STATUS_VARIANT 0000

TIME 00.00.000000.00.0000

TEXT X

OUTPUT_ONLY_TOP_LEVEL

LANGUAGE DE

DETERMINE_TASK_FILTER X

REMOVED_OBJECTS

and nothing apears....?!?!?

Regards

TKübler

former_member185167
Active Contributor
0 Kudos

Hello,

I shall repeat:

Look in SWI1, find a workflow for your object (ZKOSTL2), tell us what the key value was for the object instance used in that workflow and then please show a standalone piece of code (with full declarations of all variables) that calls SAP_WAPI_WORKITEMS_TO_OBJECT. It works for everyone else so it will work for you.

Is JWGU001010000099991231 really the key? A bit unusual to include a date in a key.

regards

Rick Bakker

hanabi technology

Former Member
0 Kudos

Hello,

ok this is a line of the SWi1

WS90100014 425245 (Sub)Workflow F Z_Kostenstelle ändern 15.07.2011 09:45:02 Z_Kostenstelle ändern

WS90100014 is the Name of the Workflow

425245 this is the Workitem ID

the BOR Object was not listed here.

The Worklfow WS90100014 is getting stardet by the BOR ZKOSTL2 Event CHANGED

The Keyfields of this BOR are

ZKOSTL2.ControllingArea

ZKOSTL2.CostCenter

ZKOSTL2.ValidTo

This is the Coding for the data declaration and the Event creation


DATA:     WF_OBJKEY2 LIKE SWEINSTCOU-OBJKEY,
               event    LIKE swetypecou-event,
               event_id2 like SWR_STRUCT-EVENT_ID.

READ TABLE icsksp INDEX 1 INTO WA_KOST2 .

  WF_ID-KOKRS  = WA_KOST2-KOKRS.
  WF_ID-KOSTL  = WA_KOST2-KOSTL.
  WF_ID-DATBI  = WA_KOST2-DATBI.

  WF_OBJKEY2   = WF_ID.

MOVE 'CHANGED' TO event.

CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'
  EXPORTING
    object_type             = 'ZKOSTL2'
    object_key              = WF_OBJKEY2
    event                   = EVENT
   COMMIT_WORK             = 'X' " Löst den Event aus! WICHTIG
*   EVENT_LANGUAGE          = SY-LANGU
*   LANGUAGE                = SY-LANGU
*   USER                    = SY-UNAME
*   IFS_XML_CONTAINER       =
 IMPORTING
   RETURN_CODE             = R_CODE
   EVENT_ID                = event_id2
* TABLES
*   INPUT_CONTAINER         =
*   MESSAGE_LINES           =
*   MESSAGE_STRUCT          =
          .

CALL FUNCTION 'SAP_WAPI_WORKITEMS_TO_OBJECT'
 EXPORTING
*   OBJECT_POR                     =
   OBJTYPE                        = 'ZKOSTL2'
   OBJKEY                         =  WF_OBJKEY2
*   TOP_LEVEL_ITEMS                = 'X'
   SELECTION_STATUS_VARIANT       = '0000'
*   TIME                           =
*   TEXT                           = 'X'
*   OUTPUT_ONLY_TOP_LEVEL          = ' '
*   LANGUAGE                       = SY-LANGU
*   DETERMINE_TASK_FILTER          = 'X'
*   REMOVED_OBJECTS                = ' '
 IMPORTING
   RETURN_CODE                    = l_retcode
  TABLES
*   TASK_FILTER                    =
    worklist                       = lt_workitem
   MESSAGE_LINES                  = lt_message_lines
*   MESSAGE_STRUCT                 =
          .

Edited by: Tobias Kübler on Jul 18, 2011 10:41 AM

Edited by: Tobias Kübler on Jul 18, 2011 10:43 AM

Former Member
0 Kudos

sry for doublepost cant delete here

former_member185167
Active Contributor
0 Kudos

I give up. Please read my previous post. Good luck.

Former Member
0 Kudos

i did all you sad.

the swi1 and the coding with variables ...

Kind Regards

tkuebler

nabheetscn
Active Contributor
0 Kudos

Hi,

The problem you are facing is to map the object key to the workitem id. As objeckey is combinatrion of controlling area cost centre and valida to date. Just do one thing go to SWW_WI2OBJ table and in field TYPEID enter ZKOSTL2 and execute. The instid field will give you the object key.

So in your code apply the following logic.

select up to one rows into lwa_wi2obj from SWW_WI2OBJ WHERE TYPEID EQ 'ZKOSTL2' INSTID EQ 'OBJECTKEY' AND WI_RH_TASK EQ ' GIVE YOU WORKFLOW NUMBER HERE' 

It will return some value if workflow has been triggered else not.

Nabheet

Former Member
0 Kudos

Hi,

>

> The problem you are facing is to map the object key to the workitem id. As objeckey is combinatrion of controlling area cost centre and valida to date. Just do one thing go to SWW_WI2OBJ table and in field TYPEID enter ZKOSTL2 and execute. The instid field will give you the object key.

>

> So in your code apply the following logic.

>

>

select up to one rows into lwa_wi2obj from SWW_WI2OBJ WHERE TYPEID EQ 'ZKOSTL2' INSTID EQ 'OBJECTKEY' AND WI_RH_TASK EQ ' GIVE YOU WORKFLOW NUMBER HERE' 

>

> It will return some value if workflow has been triggered else not.

>

> Nabheet

Hello,

no this is interesting. I did as You told me

"Just do one thing go to SWW_WI2OBJ table and in field TYPEID enter ZKOSTL2 and execute"

And the instid field was the BOR (ZKOSTL2) Keyfield (ombinatrion of controlling area cost centre and valida to date.)

For Example JWGU001010000499991231

But in this list only Old Workflows apear. Not one of my new developments apeare in this list.

Also i tryed your coding

select * into check_SWW_WI2OBJ from SWW_WI2OBJ WHERE TYPEID EQ 'ZKOSTL2' and INSTID EQ WF_OBJKEY2.
  ENDSELECT.

and nothing was found in the Table check_SWW_WI2OBJ or SWW_WI2OBJ with this Key.

Maybe i have a Main Problem in My BOR Object ZKOSTL2. I have to check my Work...

But strange for me is that the Workflow works... it prduces Workitems etc...

Thank you for your patience.

Regards TKuebler

nabheetscn
Active Contributor
0 Kudos

Hi

For you new wrokflows as you mentioned there is no entry do one thing. Get header workitemid from workflow log and put it in WF_ID field in SWW_WI2OBJ table you will find an entry. check what is object key in that case.

Nabheet

nabheetscn
Active Contributor
0 Kudos

Also check you are passing the value of WF_OBJKEY2 as correct one. Check it in debugging.

Nabheet

Former Member
0 Kudos

I did as you told, In SWi1 there was severel entries.

there i get the workitemid and search in the table SWW_WI2OBJ with this id, but also here...nothing to found!

Former Member
0 Kudos

the value of the Objekct is korrekt.

nabheetscn
Active Contributor
0 Kudos

Please the workitemid you have selected should be the header workitemid. you can get it in technical detail where you can see your workflow number as WS that workitem id you put it in WF_ID or TOP_WF_ID.

Nabheet

Former Member
0 Kudos

Hello

aha...the WF Produced 3 woritems with Id's

1. Dialog worktiem 425256

2. Background workitem 425255

3. Subworkflow worktiem 425254

Now it searched in the table SWW_WI2OBJ

for these 3 id's but only 2 of them apeard....al the time i searched for the id 425256 ( dialog workitem) but this id was not shown

only id 425255 and 425254 apeard.

Annd the Objectype of this are SELFITEM and SOFM !!!

So it was logical that nothing was found with the objecttype ZKOSTL2.

i am a step ahead now!!! thank you

nabheetscn
Active Contributor
0 Kudos

The dialog workitem can be found in SWWUSERWI table. Based on as mentioned by you, you can code the logic.

Can you please also check when you are raising the event you are passing the correct object--type...

Thanks

Nabheet

Former Member
0 Kudos

Ha ok,

in the Table SWWUSERWI the id 425256 is foundet, thanks.

now i must find a logic to know when my workflow got started. now i think i try a litte bit .

Regards TKuebler

former_member185167
Active Contributor
0 Kudos

Hi Tobias,

It might be time to start a new thread with a summary of your issue, not many will want to read all of this (just add a link back to this thread).

If I remember correctly you wanted to find some way of determining if a workflow has already been started for a certain key before starting a new workflow. For this you can use fm SAP_WAPI_WORKITEMS_TO_OBJECT. It may even be an idea to use SAP_WAPI_WORKITEMS_TO_OBJECT first and then create the event if no workflow is found. But if this can't be done (for whatever reason) I think you will need to do a COMMIT after the call of SAP_WAPI_CREATE_EVENT before SAP_WAPI_WORKITEMS_TO_OBJECT will find the workflow just started.

regards

Rick Bakker

hanabi technology

Former Member
0 Kudos

Hello,

today i found somting verry Interesting for my Problem.

[|]

i Checked this for my Problem because my "typenkopplung" <- dont know the word in english sorry ist procuced whith

SWW_WI_CREATE_VIA_EVENT_IBF

But this FM is only for WF with Classes, but i only use traditionel old BOR Objects.

I Change the FM no to SWW_WI_CREATE_VIA_EVENT i hope this will make the things work.

Regards TKuebler

Former Member
0 Kudos

Finaly i did it!

now it is possible to "trace" the WF with the FM SAP_WAPI_WORKITEMS_TO_OBJECT.

The Reason why it dindnt work where

1. In SWETYPV my BOR Objecttype ZKOSTL2 where matched with the FM SWW_WI_CREATE_VIA_EVENT_IBF

This FM is normaly used for Classes.

2. It was Important to impemented the Object ZKOSTL2 (SWDD Workflow Buildner) in the Workflow-Container and get a 1:1 match with the EVENTOBJECT out of the data Transfair at the Start Event.

Thank Everybody for Your Help.

Kind Regards

Tobias Kübler

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

One approach can be as below,

Once you trigger a workflow insert a record in a ztable which can have fields like workflow id, workitem id and key fields of the workflow instance.

So before you trigger a workflow you can querry this table to ensure that an entry does not exist already. if it already exists then it means that the workflow has been triggered already.

in the last step of the workflow you can delete the record from this custom table ..

Cheers,

Bharath

Former Member
0 Kudos

i worth case this is my only chance but if its possible i like to trigger it whit syst fields.

For me it is not logical why the syst-dynnr always change...dammit..

former_member185167
Active Contributor
0 Kudos

Hello,

"if i dont check the syst-dynnr Number the Workflow would start serverel Times."

Build in a check (in that same ABAP) to see if the workflow is already running; if so then don't create the event.

No need for z tables.

By the way, you should use SAP_WAPI_CREATE_EVENT, not SWE_EVENT_CREATE.

regards

Rick Bakker

hanabi technology

Former Member
0 Kudos

Hi Rick,

Build in a check (in that same ABAP) to see if the workflow is already running; if so then don't create the event.

Can you please tell me the logic for this check and how this can be done effectively without going for z tables.

Cheers,

Bharath

former_member185167
Active Contributor
0 Kudos

Hello,

FM SAP_WAPI_WORKITEMS_TO_OBJECT is a good way to start. Only as a last resort access the workflow tables (SW*) directly. There is so much information stored about workflows, there is no need to create your own tables!

regards

Rick Bakker

hanabi technology

Former Member
0 Kudos

Thanks a lot for the nice feedback,

i am a littlebit confused now

can i implement the check with the old function ? SWE_EVENT_CREATE or do i have to use SAP_WAPI_CREATE_EVENT,

to check if the wf is already running ?

the check could be handelt whit the function SAP_WAPI_WORKITEMS_TO_OBJECT right? and i dont have to implement it in the SWE2 ?

KR

TKübler

Edited by: Tobias Kübler on Jul 12, 2011 7:59 AM

former_member186746
Active Contributor
0 Kudos

hi,

Of course you can use the old function modules... for now.

They are not supported by SAP so if anything changes in the technicalities of workflow events in the near future SAP is not obliged to change the swe_event_create function module.

And also yes, if the event is triggered in some abap anyway just check if a workflow already exists for that key and skip triggering.

Kind regards, Rob Dielemans

Former Member
0 Kudos

Thank You verry mutch Mr. Dielemans

now i try to implement the Function SAP_WAPI_WORKITEMS_TO_OBJECT to Check if the WF is already started.

is there a Webpage whits examples ?

Or can u tel me a good traing for Workflows in this stage?

KR

Tkubler

former_member186746
Active Contributor
0 Kudos

Hi,

Just use the where-used list to see examples of this FM.

It also has online documentation, but only in german so you should log in the system in german.

Judging from the title of this thread reading German is the least of your worries.

As for self training just go through the workflow tutorial on help.sap.com end check the workflow for dummies blogs here at sdn.

Kind regards, Rob Dielemans

Former Member
0 Kudos

"Just use the where-used list to see examples of this FM."

where can if find this ???

former_member186746
Active Contributor
0 Kudos

In Se37.

display

and then double click the function module name

or go to se37 type in the function module name and then clcik the button next to the execute button, or use CTRLSHIFTF3

Kind regards, Rob Dielemans

Former Member
0 Kudos

Hi,

i tryed to use the FM

but it wont give me that information i wanted.

my Coding looks like this...

Include ZXKM1U03

coding for data selects etc.

FM: SAP_WAPI_WORKITEMS_TO_OBJECT

FM: Z_ZKOSTL_EVENT -> FM: SWE_EVENT_CREATE

The Evet Creation itself starts in the FM: SWE_EVENT_CREATE and this is includet in the FM: Z_ZKOSTL_EVENT.

So the FM: SAP_WAPI_WORKITEMS_TO_OBJECT wont spit any data out.

this is my Coding for SAP_WAPI_WORKITEMS_TO_OBJECT

DATA:     WF_OBJKEY2 LIKE SWEINSTCOU-OBJKEY,
          lt_workitem TYPE TABLE OF swr_wihdr,
          l_retcode TYPE sy-subrc,
          WA_KOST2 TYPE CSKSP.

  DATA:    BEGIN OF WF_ID.
  DATA:    KOKRS  LIKE CSKS-KOKRS.
  DATA:    KOSTL  LIKE CSKS-KOSTL.
  DATA:    DATBI  LIKE CSKS-DATBI.
  DATA:    END OF WF_ID.

READ TABLE icsksp INDEX 1 INTO WA_KOST2 .

  WF_ID-KOKRS  = WA_KOST2-KOKRS.
  WF_ID-KOSTL  = WA_KOST2-KOSTL.
  WF_ID-DATBI  = WA_KOST2-DATBI.

  WF_OBJKEY2   = WF_ID.
CALL FUNCTION 'SAP_WAPI_WORKITEMS_TO_OBJECT'
 EXPORTING
*   OBJECT_POR                     =
   OBJTYPE                        = 'ZKOSTL2'
   OBJKEY                         = WF_OBJKEY2
*   TOP_LEVEL_ITEMS                = 'X'
*   SELECTION_STATUS_VARIANT       = 0001
*   TIME                           =
*   TEXT                           = 'X'
*   OUTPUT_ONLY_TOP_LEVEL          = ' '
*   LANGUAGE                       = SY-LANGU
*   DETERMINE_TASK_FILTER          = 'X'
*   REMOVED_OBJECTS                = ' '
 IMPORTING
   RETURN_CODE                    = l_retcode
  TABLES
*   TASK_FILTER                    =
    worklist                       = lt_workitem
*   MESSAGE_LINES                  =
*   MESSAGE_STRUCT                 =
          .

This is my Coding for Z_ZKOSTL_EVENT

SWC_CONTAINER CONTAINER_INSTANZ.

  DATA:    BEGIN OF WF_ID.
  DATA:    KOKRS  LIKE CSKS-KOKRS.
  DATA:    KOSTL  LIKE CSKS-KOSTL.
  DATA:    DATBI  LIKE CSKS-DATBI.
  DATA:    END OF WF_ID.

  DATA:    WF_CREATOR LIKE SWEINSTCOU-RECID.

  DATA:     WF_OBJKEY LIKE SWEINSTCOU-OBJKEY.

  SWC_CLEAR_CONTAINER CONTAINER_INSTANZ.

  WF_ID-KOKRS  = KOKRS.
  WF_ID-KOSTL  = KOSTL.
  WF_ID-DATBI  = DATBI.

  WF_OBJKEY   = WF_ID.

* Ereignis erzeugen
  CALL FUNCTION 'SWE_EVENT_CREATE'
       EXPORTING
* Änderung am 25.8.2009 Objekttype 'ZKOSTL' zu 'ZKOSTL2'  TKübler
            OBJTYPE                 = 'ZKOSTL2'
            OBJKEY                  = WF_OBJKEY
            EVENT                   = EVENT
*           creator                 = sy-uname
*         TAKE_WORKITEM_REQUESTER = ' '
*         START_WITH_DELAY        = ' '
*         START_RECFB_SYNCHRON    = ' '
*         DEBUG_FLAG              = ' '
      IMPORTING
           EVENT_ID                = EVENT_ID
     TABLES
           EVENT_CONTAINER         = CONTAINER_INSTANZ
      EXCEPTIONS
          OBJTYPE_NOT_FOUND       = 1
          OTHERS                  = 2
            .

former_member185167
Active Contributor
0 Kudos

Hello,

"So the FM: SAP_WAPI_WORKITEMS_TO_OBJECT wont spit any data out."

Have any workflows been started for that object instance? If not, then it won't return anything.

I told you, use SAP_WAPI_CREATE_EVENT, not SWE_EVENT_CREATE.

regards

Rick Bakker

hanabi technology

Former Member
0 Kudos

Hello,

Yes the Workflow had started, but i could not get any data.

i try now to use the FM SAP_WAPI_CREATE_EVENT for the event start.

Thank You for your patience.

KR

TKübler

former_member185167
Active Contributor
0 Kudos

Hello,

"OBJTYPE = 'ZKOSTL2'"

Is that a custom BOR? Or a delegated one? If delegated, you shouldn't be using the Z version here.

regards

Rick Bakker

hanabi technology

Former Member
0 Kudos

Hi,

this BOR was coded by me, so i have to used Z.

KR

TKübler

former_member186746
Active Contributor
0 Kudos

Hi,

You could add a check function module to the event-->wf linkage in SWE2

In that function module raise an exception if a workflow already is started for that key.

Or you look at a better logic to trigger the event.

Kind regards, Rob Dielemans

Former Member
0 Kudos

> You could add a check function module to the event-->wf linkage in SWE2

mh dont know how to do that. have you any helpflull information?

Edited by: Tobias Kübler on Jul 11, 2011 2:52 PM

Former Member
0 Kudos

Hi...

In tcode SWE2 where you enter your BOR and workflow template and enable the event linkage there is a option to mention check FM ..

Normally Start Conditions are used in a Workflow to selectively start the workflow based upon certain conditions.

Example, Start a workflow only when the plant is equal to 1000. In case of complex conditions we go for check FM.

The Signature of a Check FM is fixed by system as below,

Importing parameters

1. OBJTYPE LIKE SWETYPECOU-OBJTYPE

2. OBJKEY LIKE SWEINSTCOU-OBJKEY

3. EVENT LIKE SWETYPECOU-EVENT

4. RECTYPE LIKE SWETYPECOU-RECTYPE

Table parameters,

1.EVENT_CONTAINER LIKE SWCONT

You can have user defined exceptions.

Within the Check Function Module, we receive the Event Container. We can read and evaluate the contents of the container.

If the Workflow is not to be started, we need to raise an exception as RAISE <Exception name as in EXCEPTIONS tab>.

If no exception is raised, the processing moves further and the control goes to the workflow.

Hope this helps.

Cheers,

Bharath