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

commit work in FQevents in FICA(PERFORM commitroutine ON COMMIT )

Former Member
0 Likes
1,095

Hello Experts,

i am trying to create an event to trigger a workflow using function module swe_event_create.

i am doing this in an FICA event 5500 after triggering this workflow i need to stop the further processing so i am using Error message statement.

when i am calling swe_event_create without commit work the event is not getting triggered .

when i checked the documentation of this event it was written that

To ensure the consistency of the system, note that you must not use the following language elements in events:

COMMIT WORK

ROLLBACK WORK

CALL FUNCTION 'DEQUEUE ALL'

Deletion of locks that you have not set yourself.

If you update additional data in an event and use the construction PERFORM commitroutine ON COMMIT to do this, note that:

At the end of the commitroutine, all internal tables from which data was updated must be initialized again to prevent a duplicate update in the next call.

A PERFORM rollbacktroutine ON ROLLBACK must also be called. In the rollbackroutine initialize the same data that is initialized at the end of the commitroutine.

If you want to carry out checks in an event, when you issue messages, note that background processing of the process terminates with warning messages. You should therefore avoid issuing warning messages if possible. However, you should definitely issue warning messages if the value of SY-BATCH is initial.

how i can use PERFORM commitroutine ON COMMIT could you please paste the code for this

also plz tell me

why my event is not getting generated without commit work . do we have any better way to do it

1 REPLY 1
Read only

Abhijeet-K
Active Participant
0 Likes
583

Hi Anit,

The FM SWE_EVENT_CREATE does its job, only when 'COMMIT WORK' is executed, after it. Now, as per the general programming guidelines (quoted in your question), you can't write COMMIT WORK in your code. You shouldn't, because it would write half baked document into database. Something that's undesirable. The workaround prescribed in the event documentation (again, as quoted in your question) allows to achieve the goal in following manner-

1. Do all calculations in your event and put the final values - that are necessary for the workflow - in global variables. Refer to the ABAP documentation for PERFORM ... ON COMMIT for choosing global variables over parameter passing.

2. Once that's done, make the call to the FM, as given below-


PERFORM start_wf ON COMMIT.   "Within the FM implementing the event 5500.


*&---------------------------------------------------------------------*
*&      Form  start_wf
*&---------------------------------------------------------------------*
*       The form routine to initiate the workflow
*----------------------------------------------------------------------*
FORM start_wf.
  CALL FUNCTION 'SWE_EVENT_CREATE'
    EXPORTING
      objtype           = objtype
      objkey            = objkey
      event             = event
    TABLES
      event_container   = event_container
    EXCEPTIONS
      objtype_not_found = 1
      OTHERS            = 2.
  IF sy-subrc <> 0.
    RETURN.
  ENDIF.

  CLEAR: objtype.
  CLEAR: objkey.
  CLEAR: event.
  CLEAR: event_container.
  "And all other global variables that are used in your call for this FM
ENDFORM.                    "start_wf

3. Note that you need to clean up the global variable set up in step 1 (also mentioned in the event documentation) . It is to ensure that some other call to the same FM doesn't use those values.

You needn't issue a COMMIT WORK statement anywhere in your code written in event 5500 implementation. The standard FMs, that update the SAP tables with document information have COMMIT WORK in them. As you have registered the FM 'start_wf' by PERFORM ... ON COMMIT, it would be executed along with the database update triggered by standard FM.