‎2009 Feb 03 10:06 AM
Hi Experts,
I have a issue where i have to update a custom table in an User exit.
I am using Lock object for ENQUE/DEQUE.
I have tried to use statements like UPDATE/MODIFY inside the user exit.
But the problem is that it's not updating the database table at the same time.
I know if i use COMMIT WORK it can update at the same time but it's not advisable to use COMMIT inside a work.and also it gives a short dump.
The real issue is that this custom table is read for batch creation at the same time for different users.
Now if it the program does not update the database table at the same time then other users also read the same data and create the same Batch number..
While requirement is to create a different/unique batch numbers.
Program is updating the table but it's taking time..so in between other users are creating the same batch number.
Please guide me what would be the best solution for this.
Regards,
Amit Kumar Singh
‎2009 Feb 03 10:16 AM
may I ask the specific fields you have on your customized table?
‎2009 Feb 03 10:16 AM
Hi,
Seems you want to create new batch for material inside a user exit. What i did not get is why you need to update a database table? It is anyways not advisable.
Please collect necessary data and pass it to BAPI_BATCH_CREATE. It will automatically solve your update problem.
Hope this helps.
Vivekanand
‎2009 Feb 03 10:31 AM
Thanks for your quick reply.
My actually requirement is like that.
I have to create a Process Order using tcode COR1.
After passing some input value it goes inside an User Exit.
There one Custom table is maintained which stores some fields like month,year,numeric key field,etc.
The new batch number is created using the combination of these table fields.
Once a new batch number is created it increment the numeric key field number by one.
Issue is we have to update this new numeric field value into the database field so that other users can read a diffrent numeric field value.hence it will create a new/different batch number.
Here i am not able to update the database table inside this User Exit.
Table is geeting updated but after some time and out of this User Exit.
Please suggest what's required in that case?
Regards,
Amit Kumar Singh
Edited by: Amit Singh on Feb 3, 2009 11:33 AM
‎2009 Feb 03 11:00 AM
Hi,
You can wrap your database update and commit work in a function module and then call this function module with the addition starting new task.
The function call will then start asynchornously in another task and the calling program will continue.
Note that the function module should be a remote enabled function module.
For details see F1 help for calling a function module starting new task.
regards,
Advait
‎2009 Feb 07 5:13 AM
Hi all,
Thanks for your quick response.
Now my issue has been resolved.
Solution:
To update a database table in an User exit I used the select statement as given below.
SELECT SINGLE FOR UPDATE * FROM Ztable
where test conditions.
By using this it's locks the database table until it gets updated.
So there is no use of using ABAP Lock Objects like ENQUE/DEQUE.
It allows to read and update the database table for a single user at a time.
Regards,
Amit
Edited by: Amit Singh on Feb 7, 2009 6:13 AM
‎2009 Feb 03 10:55 AM
Hello,
If you wish other users to be able to read the stored values before a database commit has been done, you should also store them in shared memory and read from there instead. You might want to take a look at this instruction about Shared Object Memory:
Best regards,
Erik