cancel
Showing results for 
Search instead for 
Did you mean: 

Terminating event 'Created' in ABAP OO context

Clucking
Participant
0 Kudos

Hi,

I need a little help here. A lot of times I have used terminating event ‘Created’ for different BOR types – and asynchronous tasks where users are asked to create an object using call transaction from a work item.

Now I am struggling with the same in ABAP OO and have an issue:

The goal is to have a terminating event raised on a custom class  - and received by a work item if a customer is fully created, that is the general part, the company code part and the sales area part.

Raising the event is working great. I have put in a class in trx. SWEC together with a function module which set the class as object type if the condition is fulfilled.

Then in trx. SWED I have entered another function module to set the key for class together with object_por-catid = ‘CL’.

Then when a customer master record is created I can see in the event trace that the event is raised with the correct key.

No I want to receive the new object into my asynchronous dialog task. I define the event as terminating event – and in the code call transaction XD01.

When the work item is created I find a waiting event linkage in trx. SWE3 – of cause without key; this is unknown until after creating.

But after executing the workitem and raising the event the workitem does not receive the event and is therefore not completed.

Is this approach not possible in ABAP OO – or do I miss something in the class definition / coding?

The event is defined as public instance – I have not coded any event handler method.

Thanks,

Claus.

Accepted Solutions (1)

Accepted Solutions (1)

pokrakam
Active Contributor
0 Kudos

Hello Claus,

Interesting question, unfortunately not with a simple answer.

The issue is that you are waiting for an instance event without a key. Your object raises an event with a key => No match.

If you raise the created event without a key, you won't be able to match up two near-simultaneous creations with their corresponding work items. Same thing if you wait for a static event.

So how does SAP do it with BOR events? By breaking the rules of course!

They do some hidden trickery to bypass this problem by doing an 'Export to Memory' of the work item ID, and the CREATED event raising code bypasses the usual event linking mechanisms and looks for it's creator by retrieving the memory variable. I don't have the exact spots of code in my head, but a bit of debugging should find it.

So what can you do? Given that you have full control of the class you could do something similar and maybe also create some kind of temporary key consisting of the Work Item ID and raise an event with that, or you could maybe skip the transaction concept completely and run the create GUI entirely within your WF step - maybe a custom screen gathering the initial data and then create the object via BAPI. Time to get creative!

Hope that helps,

Mike

Edit: Or you could do the quick and dirty solution and just use the BOR events for the step and instantiate the class during the binding back to WF...

Clucking
Participant
0 Kudos

Thanks, Mike. Thought of the quick and dirty solution myself since for a customer creation there is no good bapi's etc. in order to call the transaction and I therefore have to rely on the event raised automatically by the change document creation.

Thanks again - I'm sure I can get this to work - sadly using a BOR object ones again

Claus

Clucking
Participant
0 Kudos

Cannot even get it up running with a BOR object .

Have created a subtype to KNA1 with an asynchronous method calling XD01 and an event CREATED.

Did the delegation and entered an entry in SWEC for DEBI and KNA1.CREATED on create.

Event is raised fine with key - but my work item is still not receiving the event and thus not completed. Event is defined for the standard task and it is not marked as synchronous.

An entry is fine waiting in trx. SWE3.

Pretty sure I have did this some time in the past.

Any ideas?

pokrakam
Active Contributor
0 Kudos

Hi Claus,

If a created event doesn't exist, just adding one won't work without the 'special code'. I had assumed there was an existing one when I made the suggestion, sorry.

Does it have to be async? If you look e.g. in BUS2032 they do some fiddling with parameter ID's, I have used this technique in a class and it worked. Though a bit more control is useful, with a check that the parameter ID a) was changed and b) was one of a newly created document (time in the last few minutes or something like that). Not perfect, but it worked.

Regards,

Mike

Clucking
Participant
0 Kudos

Hi Mike,

No problem, - and thanks for the hint.

I will try to use BAPI_CUSTOMER_CREATE in a synchronous class method instead. It actually calls XD01 and it will also send back the new customer number - I guess then I can pick up the rest of the data - company code and sales area later in the code.

Regards,

Claus.

Answers (0)