on 2011 Jul 11 1:09 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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?
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
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
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
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
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
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
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
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
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
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
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
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
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
.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
57 | |
10 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.