Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

object for VBAP - VBAK

Former Member
0 Kudos
475

Hello,

I need to catch (by event, user exit, BADI,...) the changes occurred in VBAP & VBAK to be transferred to other system by XI.

I tried to turn on the event for object VBAP, but no event was triggered after changed or created (via transaction VA52).

Doe's anyone know how can I do it??

Thanks in advance for any help,

Fariba

1 REPLY 1

Former Member
0 Kudos
113

You might get away with using Business Transaction Events in the IMG but IMO I'd go for using generic Workflow (especially when transferring to XI).

I'm not too sure if you can use an approriate Business Transaction Event in SD but looking at the documentation in the IMG (transaction SPRO) there might be possibilities there. However the Workflow method is so easy and general I'd go for the workflow solution.

Use transaction SWE2 to define an entry for business object (BOR) VBAK for example CHANGED. Ensure also the top box (on the 2nd screen in SWE2) has an X in it or the event won't be registered.

Transaction SWO1 alows you to examine, test creat, manipulate BOR's.

Define a task that you want to start when this event occurs (use PFTC to create task). This task can run in background and doesn't have to be a dialog task. If you want the task to terminate (normally) after it's been run then define it as synchronous otherwise define it as asynchronous in which case you'll have to define another event (and trigger it) when you want the task to terminate.

In the workflow builder just define a single task (type TS) which will pass your data to XI. You'll need to code what you need to pass to XI but the event handler will give you the instance of the sales order (VBAK) so you can see what's been changed and react accordingly.

If your workflow system isn't switched on then you've got a much more difficult problem as there isn't any easy way of catching these type of events.

In this case you'll have to modify transaction VA02 / VA52 and stick in code you want to execute when the sales order is changed. I wouldn't do this as you have to ensure the data is actually saved to the database and the comit executed before you can be sure data has been changed and modifying complex sap programs such as the Sales order programs is not a task to be undertaken lightly --and is a nightmare to maintain.

Using a very small part of the workflow system eases the process considerably, is standard SAP and easy to maintain -- and it can run in batch --useful for example if you have external processes / systems changing / creating sales orders in background using BAPI's.

Change documents (transaction SWEC) might be OK - but I usually avoid using these and in any case you still need to launch a Workflow task.

Workflow is really the tool to use since event handling is built right into it. When your event occurs (e.g Sales order changed) the system will launch your task automatically without any extra coding on your part.

To test your workflow task without actually changing a sales order you can use

FM in test mode "SAP_WAPI_CREATE_EVENT" and see if your task gets triggered.

You can look in your SAP INBOX to (SBWP) to see if the task was actually started or examine the workflow log.

Added: Whilst using BOR is not the best way forward you'll have to rely on it in this case since the VA02 transaction creates the event CHANGED itself and this is part of the BOR VBAK.

For your own totally custom stuff you can define a class rather than a BOR and insert this in SWE2. Your custom transaction will create the event by a call to function module SAP_WAPI_CREATE_EVENT or to a method in a self defined class.

Cheers

jimbo