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

Call function in update task.

ronaldo_aparecido
Contributor
0 Likes
3,895

Hello.

My Abap program, has a loop with the update command:

    DO.

       UPDATE zcaixa_loja SET seqp2k t_header-numseq

                        WHERE vkbur  t_loja-vkbur.


       IF sy-subrc EQ 0.

         EXIT.

       ELSE.

        WAIT UP TO 2 SECONDS.


       ENDIF.

       IF sy-index > 10.

         EXIT.

       ENDIF.


     ENDDO.

This command does not work sometimes.

The key is correct in "where condition."

Moving this code to a call function  "in update Task" resolves ?

A typical R/3 installation contains dialog work processes and at least one update work process. The update work processes are responsible for updating the database. When an ABAP program reaches a COMMIT WORK statement, any function modules from CALL FUNCTION... IN UPDATE TASK statements are released for processing in an update work process. The dialog process does not wait for the update to finish. This kind of update is called asynchronous update.

Thanks !!!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,913

You're using that inside an User-exit? If it's not inside a user-exit/badi/etc and it's a simple "report", I see no reason why you should use call function.. in update task.

Also, that "DO..ENDO" construction is very ugly. "Update" command when used correctly does works. You're probably having a program error somewhere else, and are trying to correct the program at the wrong place (dbaccess).

Finally, if you're trying to update multiple values in a  database table from your internal tables "T_HEADER" and "T_LOJA", use MODIFY..FROM TABLE instead. Less dbaccess for updates = better performance.

Best Regards,
Mauricio

6 REPLIES 6
Read only

former_member188251
Active Participant
0 Likes
2,913

Hi Ronaldo,

It is going to make no difference if you put the code in "Update task" . Update tasks are mainly used to mainatin database consistency if one is working with a transaction with many dialog steps (screens) . In your case , I feel the record you are trying to update is most probably locked by another process which does not allow you to update . PLease let me know if it helps.

BR,

Shankar..

Read only

uppu_narayan
Active Participant
0 Likes
2,913

Hi Ronaldo,

    

     what exactly you are trying to do can u plz explain?

Regards,

Narayan

Read only

0 Likes
2,913

i try insert values in table via update but do not work.

Read only

Former Member
0 Likes
2,914

You're using that inside an User-exit? If it's not inside a user-exit/badi/etc and it's a simple "report", I see no reason why you should use call function.. in update task.

Also, that "DO..ENDO" construction is very ugly. "Update" command when used correctly does works. You're probably having a program error somewhere else, and are trying to correct the program at the wrong place (dbaccess).

Finally, if you're trying to update multiple values in a  database table from your internal tables "T_HEADER" and "T_LOJA", use MODIFY..FROM TABLE instead. Less dbaccess for updates = better performance.

Best Regards,
Mauricio

Read only

Former Member
0 Likes
2,913

Hi Ronaldo Aparecido

If i m not getting it wrong you want to update your database completely on COMMIT WORK or ROLLBACK if the condition failed. For this it will be better to use the CALL FUNCTION...IN UPDATE TASK. It will do work and won't show errors either.

Create a Function Module and write the Modify query in that and use it in your report/program.

Best Regards,

D Amarnath

Read only

uppu_narayan
Active Participant
0 Likes
2,913

i didn't understand y u have used the do loop and y u r waiting for 2 second and y u r exiting from the the loop when index is > 10, if you want to update the values back in the database.

you can loop the table and use Modify stmt to update table based on the work area or you can use MODIFY dbtable FROM TABLE itab <b>transporting <fields> if both the structures are matching..

Regards,

Narayan