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: 

Modify fails in some cases

ronaldo_aparecido
Contributor
0 Kudos

Hello community

I have the following code:

 IF option EQ 'SAVE_DATA'.
* Eliminar o registro existente para não gerar duplicidade..
DELETE ztbfi905 FROM TABLE it_ztbfi905_sel.
"
COMMIT WORK AND WAIT.
* Atualizar o registro da tabela ztbfi905 com as informações referentes ao estorno e correção da hora de criação do documento de provisão
MODIFY ztbfi905 FROM TABLE it_ztbfi905_sel.
"
COMMIT WORK AND WAIT.
"
LOOP AT it_ztbfi905_sel INTO wa_ztbfi905.
* Armazenar os registros que serão retornados pela função
APPEND wa_ztbfi905 TO it_ztbfi905_back.
ENDLOOP.
ELSE.
    

it deletes it first and then puts it back, but in some cases the update doesn't work

This only occurs in the production environment

Does anyone have any idea how to monitor this to know if the problem is really in the database?

4 REPLIES 4

Sandra_Rossi
Active Contributor
0 Kudos

The code is in one line and full of <br>.

Ctrl+Shift+V (unformatted paste) may help you.

Sandra_Rossi
Active Contributor
0 Kudos

Based on my experience, 99% of all such cases were due to a program bug. If there's a database error, the ABAP program should abort (or the exception is intercepted by a calling program). The 1% left were due to database triggers or database indexes which prevent the update.

Now, back to the 99%, I advise to debug the program to understand what the problem is. As always, if you can't find the issue, you must add ABAP code to facilitate the analysis.

FredericGirod
Active Contributor
0 Kudos

This program runs once at a time ?

(but why this do you use this strange code ??)

raymond_giuseppi
Active Contributor
0 Kudos

Why do you delete records before using MODIFY, the deletion should not be required, could you explain ?

  • Don't use COMMIT WORK AND WAIT but FM DB_COMMIT (if you only update your cusom database table)
  • Handle SY-SUBRC for errors or catch errors (unique secondary indexes?)