1

While updating actual DB table (using SAP LUW), IN UPDATE TASK is always Rollback changes made in actual table.

APPEND ls_emp TO lt_up_emp.
call function 'ZFM_UPDATE_EMPLOYEE' in update task
      tables
        lt_update = lt_up_emp.
COMMIT WORK.
if sy-subrc <> 0.
  ROLLBACK WORK.
endif.

Here is my UPDATE FUNCTION MODULE for updating the actual DB table:

IF sy-subrc = 0.
  ""--- insert the data.
  IF lt_insert[] IS NOT INITIAL.
    INSERT ztadept FROM TABLE lt_insert.
    IF sy-subrc <> 0.
      RAISE not_inserted.
    ENDIF.
  ENDIF.
  "-- delete....
  IF lt_delete[] IS NOT INITIAL.
    DELETE ztadept FROM TABLE lt_delete.
    IF sy-subrc <> 0.
      RAISE not_deleted.
    ENDIF.
  ENDIF.
  "--Update.........
  IF lt_update[] IS NOT INITIAL.
    UPDATE ztadept FROM TABLE lt_update.
    IF sy-subrc <> 0.
      RAISE not_updated.
    ENDIF.
  ENDIF.
ENDIF.
CALL FUNCTION 'DEQUEUE_EZDEPT_LOC'.

Why is there a rollback of the updates?

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
divScorp
  • 498
  • 1
  • 8
  • 17
  • 1
    First of all: Have you checked ST22 for runtime errors? You have at least three points where you raise an exception: `not_updated`, `not_deleted`, `not_inserted`. Second of all: checking for `sy-subrc <> 0` does not make any sense, because firstly you do not ask for any `EXCEPTIONS` and secondly the execution of an update function module is done in a separate process (update process) and you do not get any errors from it. If an exception happens in the update task, then it ends in ST22 as a short dump. – Jagger Nov 24 '17 at 07:01
  • @Jagger i didn't get any runtime error here. but while debugging it shows that table update. after that it executes ROLLBACK. ... And if I'm trying COMMIT WORK AND WAIT. then it works fine. – divScorp Nov 24 '17 at 07:30
  • I'm having a hard time understanding what you are actually trying to achieve and what the exact problems are you are encountering. Would you care to clarify your question a bit? – vwegert Nov 24 '17 at 17:16
  • @vwegert Sorry for late reply..... Actually I'm trying to implement SAP LUW, where in Update Function Module (database LUW), actual UPDATE, INSERT and DELETE operation will be performed and it will update records in DB Table. – divScorp Nov 27 '17 at 11:50

1 Answers1

1

The ABAP documentation of COMMIT WORK says:

The statement COMMIT WORK always sets sy-subrc to 0 if the addition AND WAIT is not specified.

So it means that it's not your ROLLBACK WORK that rollbacks the updates (and you may cleanup your code by removing this useless line).

The only possibility left is that:

  • either the update function module has a bug and doesn't update anything,
  • or the update function module throws an exception (RAISE).

In the first case, you may debug the function module by activating the 'debug update', and in the second case, you might see the errors of update function modules by running the transaction code SM13.

Remark: it's uncommon to remove the lock explicitly in the update task, because usually the lock is set with a scope '2' (default value) which automatically releases the lock at the end of the update task.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48