-2

I need to ensure consistent editing of SAP tables for Fiori Backend calls. I have multiple situations, where single call to backend changes more than one table on the backend side. The changes are written to transport request.

I want to implement error-free stable solution, so that if first table was changed fine, but second table failed (duplicate entry, missing authorization), the whole bunch of changes is rejected. However, it seems that there is only "perform FM in update task" available, which requires to put all logic of every backend db change into a FM.

Am I missing something, or SAP really has no Object Oriented way to perform consistent database updates?

The only workaround I have is to check all these preconditions upwards, which is not so nice anymore.

@Florian: Backend call is for example action "Approve" on the document, which changes: 1) Document header table, field status changes from "in workflow" to something else. 2) Approval table - current approver entry is changed. Or it is adding a new document, where 1) Document header table entry is added 2) Document history table entry is added. I do not want to call Function Modules, I want to implement solution using only classes and class methods. I was working earlier with other ERP systems and there are statements like "Start transaction", "Commit transaction" or "Rollback transaction". Start transcation means you start a LUW, which is only committed on "Commit transaction", and if you call "Rollback transaction", all current database changes of that LUW would be cancelled. I wonder why modern SAP has none of these except for old update task FM (or is it just me not noticing a correct way to process this).

2
  • 2
    Could you elaborate on some things? What's your "Fiori Backend call"? An OData request to the ABAP server? What kind of request? A single POST that deep-creates a single OData entity with all the tables inside? Or a batch request that POSTs changes to multiple OData entities? Why do you need to write the changes to a transport request? Are you building a UI that changes Customizing in a development/test system that needs to be transported later on? What is "FM" - function module? Why do you need to call a function module to update the database tables instead of a simple MODIFY statement?
    – Florian
    May 7, 2020 at 15:34
  • You say "error-prone solution", which means a solution which tends to produce errors, so you obviously mean the opposite. An update task is only for special cases (updates to be executed after several SAP GUI screens, or do the updates asynchronously to free the workprocess sooner - for overall better performance). Instead you can use the classic concept of transactions (database LUW), by using COMMIT WORK and ROLLBACK WORK. No? May 7, 2020 at 16:40

1 Answer 1

2

CALL UPDATE FUNCTION MODULE in UPDATE TASK is the only way. How it works in Fiori transnational App, for example,

  1. Database A: You do some business logic, everything is fine. call UPDATE task to CUD database table A.
  2. Database B: You do some business logic, there is some issue regarding authorization, you raise the exception(Error). UPDATE TASK to CUD database table B is NOT called.

After all the business logic are processed, in case any exception is raised, the SADL/Gateway layer would catch the exception, it would call ROLLBACK WORK which means everything is rollback. Otherwise, if there are no errors, it would call COMMIT WORK which means consistent CUDs to all tables,

btw, anything abnormal like DUPLICATE ENTRY happens within the UPDATE Function Module, depending on your coding, you can ignore it or raise MESSAGE E to abort the DB operations. From my point of view, those kinds of issue should be avoided before your call the UPDATE Function Module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.