Application Development and Automation 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: 
Read only

creating events

Former Member
0 Likes
787

I want to create events from application or system program.how can i do it?

5 REPLIES 5
Read only

Former Member
0 Likes
737

hi,

You can use 'SWE_EVENT_CREATE' functin to create system events.

take eg from this program...

CALL FUNCTION 'SWE_EVENT_CREATE'

EXPORTING

OBJTYPE = 'ZYMBOR'

OBJKEY = OBJKY

EVENT = 'ADD_ENTRY'

  • CREATOR = ' '

  • TAKE_WORKITEM_REQUESTER = ' '

  • START_WITH_DELAY = ' '

  • START_RECFB_SYNCHRON = ' '

  • NO_COMMIT_FOR_QUEUE = ' '

  • DEBUG_FLAG = ' '

  • NO_LOGGING = ' '

  • IDENT =

  • IMPORTING

  • EVENT_ID =

TABLES

EVENT_CONTAINER = i_cont

EXCEPTIONS

OBJTYPE_NOT_FOUND = 1

OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF

hope this will clear your doubt.

please reward if it helps.

thanks

Read only

Former Member
0 Likes
737

Hi Pooja,

Using Function Module SWE_EVENT_CREATE

you can Create event from application program.

You Can get the Deatils in the link-

http://help.sap.com/saphelp_nw2004s/helpdata/en/c5/e4af4a453d11d189430000e829fbbd/content.htm

Here is a sample Code for your reference-


DATA:
  key LIKE sweinstcou-objkey,
  w_creator TYPE swhactor.

key = 'MM017'. " Material Number (hard-coded)

w_creator-otype = 'US'.
w_creator-objid = 'SAPDEV02'.


CALL FUNCTION 'SWE_EVENT_CREATE'
EXPORTING
objtype = 'Y1151_MAT2'
objkey = key
event = 'Ecreate'
 creator = w_creator
* TAKE_WORKITEM_REQUESTER = ' '
* START_WITH_DELAY = ' '
* START_RECFB_SYNCHRON = ' '
* NO_COMMIT_FOR_QUEUE = ' '
* DEBUG_FLAG = ' '
* NO_LOGGING = ' '
* IDENT =
* IMPORTING
* EVENT_ID =
* TABLES
* EVENT_CONTAINER =
EXCEPTIONS
objtype_not_found = 1
OTHERS = 2
.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
  WRITE 'Event Triggered'.
ENDIF.

Regards,

Sujit

Read only

0 Likes
737

Hi guys

That's only (The EASY) part of the answer.

What the OP wants I suspect is an explanation of actually how to process an action when the event takes place.

Anybody can say use FMOD xxxxxx. Actually the FMOD you want these days is actually SAP_WAPI_CREATE_EVENT.

Also I think the OP would like to know HOW to use the FMOD.

Now you need to do a bit of prep before your application can use your event. (Note it's better these days to use classes but for simplicity I'll stick to the old method as you can try this out on your own system quite easily (or even the ABAP demo minisystem downloadable from SDN).

1) Define an event in a Business object (BOR). Use transaction SWO1 to build a simple business object and define an event in it.

I suggest you create say a ZTABLE with two or 3 fields in it -- a number (key) and two fields. Now your BOR should be an instance of the ZTABLE object. So define in your BOR two events CREATE and CHANGE. You don't need any code.

In the Methods section of your BOR define two methods do_when_changed and do_when_created -- these can be really simple stuff like just send an express mail to yourself to prove the process works.

2) Define two tasks with transaction PFTC. these will be TSXXXXXXXXX. In the task specify your business object (ZTABLE) and the method you want executed such as do_when_changed.

3) Now use transaction SWE2 and put your Business object, the events CREATE and CHANGE and the TSXXXXXXX task numbers . (You can start an entire Workflow like this but keep it simple to start with so I use a one step task for each event).

Fill in the rest of the table fields as per other entries in SWE2.

4) Code an application program which calls the function module specified above. You'll need to pass the key of your business object to the function module and specify the event.

5) if it all works properly you should get an express mail in your inbox or whatever process you used as a task to be performed when the evnt is triggered.

Note that to start with use "synchronous" tasks - when you use PFTC you'll see the checkbox. If you use Asynchronous tasks the task won't end until you raise another event to specifically terminate the process. This is a bit more complex (not too difficult) but I suggest you try the easy way first..

Cheers

jimbo

Read only

Former Member