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: 

DB update not working properly by standared FM in update task after commit work.

Former Member
0 Kudos

Hi experts,

There is sap standared FM  'LECI_UPDATE_xxxx' . where  database update is happening in update task.


* event
   CALL FUNCTION 'LECI_INSERT_table1' IN UPDATE TASK
        EXPORTING
             IS_EVENT = LS_1.

* event_data
   CALL FUNCTION 'LECI_INSERT_table2' IN UPDATE TASK
        EXPORTING
             IS_EVENT_DATA = LS2.

And within the  above FM there is insert statement

" within FM LECI_INSERT_table1


INSERT INTO Table1 VALUES LS1.


" within FM LECI_INSERT_table2


INSERT INTO Table2 VALUES IS2.


Now After ' COMMIT  Work'  records are getting updated in database table


but for some cases data gets updated in table 1 but not in table2 and vise vera.


What w'd be the reason for this .


why after commits records not getting updated in one table while it gets updated in second table ?


                                                   

2 REPLIES 2

yogendra_bhaskar
Contributor
0 Kudos

Hi Rahul ,

saving data in update task is always the correct approach. COMMIT WORK should not be used in any kind of called function (user exit, BAdi etc.) because the COMMIT WORK will commit all pending database changes and trigger the start of all functions called in update task, executes all subroutines registered using PERFORM ON COMMIT, triggers an internal event for the persistence service of the Object Services, closes all database cursors,...

Usually, the calling application will COMMIT if everything has been done without error and ROLLBACK in case of any error. This helps to keep database consistency.

You have to omit the COMMIT WORK and it will work.

Note: As a rule of thumb, an LUW is started with a job, report, transaction, RFC call and is ended by the next interruption (screen, message, RFC call).

Regards ,

Yogendra Bhaskar

0 Kudos

Hi Bhaskar,

COMMIT WORK has Not been used in any kind of called function.


Pls read the post carefully.


Its a sap standared FM and within that perform has been used and than commit work . I m not talking about z codes .