‎2011 Jun 07 9:37 PM
Hello experts,
Using syntax DELETE database table where..........commit work works fine in the foreground but will not work in the background. Tried inserting WAIT FOR.....did not help
Anybody had this issue before.
Any ideas appreciated.
‎2011 Jun 07 10:04 PM
> ...will not work in the background.
What exactly does "will not work" mean?
Rob
‎2011 Jun 07 10:04 PM
> ...will not work in the background.
What exactly does "will not work" mean?
Rob
‎2011 Jun 07 10:14 PM
hello Rob,
'will not work' means it does the delete the content from the database table. When run in the foreground the deletion takes place...have checked the DELETE syntax over and over again and using COMMIT WORK and WAIT.
‎2011 Jun 07 10:30 PM
DELETE works in the background. The error lies elsewhere.
Rob
‎2011 Jun 07 11:47 PM
‎2011 Jun 08 7:10 AM
Hi,
There is no restriction on Delete to not work in background.
Please check your where clause, or delete statement.Error lies somewhere else.
‎2011 Jun 08 7:06 AM
Hi,
Try with a single record in back ground which record is available in database table. If it is working fine then your where condition is problem.
Example:
delete mara where matnr = '10000011'.
commit work.
Ram.
‎2011 Jun 08 7:35 AM
Hi,
Try debugging the completed job in SM37 using jdbg.
Go to SM37 and display the jobs. Select your job and enter 'JDBG' in command area. Keep on pressing F7 till you reach code in your program.
Then step by step analyse the program and check the conditions given to DELETE statement.
‎2011 Jun 08 12:15 PM
Hi David,
After the delete statement.
Use this:
Commit Work and WAIT.
The program will not go further until the commit has happened. This will ensure that the table entries get deleted.
Let me know if it worked.
Cheers,
Saurabh Mathuria
‎2011 Jun 08 12:59 PM
Hi,
I'm confused with your terms "foreground" and "background". Foreground means you execute a report and background, you run a job or?...
Might be an authority issue, whereas I've never seen one with DML-statements.
In my opinion: Run ST01, Run your background-whatever_it_is, check ST01 log for SQL or Authority errors.
regards, Lukas
‎2011 Jun 08 1:16 PM
Hi David;
Can you write your code with little up and down rows?
Maybe your code has small problem.
Best ragards.
‎2011 Jun 08 5:14 PM
Hello All,
I checked my code over and over again and there is only one way to do it. The existing code posts correctly in dialogue mode (from the screen). However when I executed it in the background the same issue.
I debugged the completed background job from SM37 using transaction JDBG (thank you Vinraaj) and F7 until my program appeared and debugged again. The code was correctly executing.
However when I hit F7 multiple times and the completed program executed again (without my debugging thru single step) from the output in SM37 , the output was correct. (my code executed correcly)
Has anybody encountered this issue before, could this be a SAP issue. It is not an authorization problem. I am in a developmet system and have SAP all.
Any suggestions would be helpful.
‎2011 Jun 08 5:18 PM
when you run in foreground it works because you have authorization. However, when you run in background it doesn't use your userid it will be a generic background id (refer your security team they will know). I would say it is this id that needs the authorization update.
‎2011 Jun 08 8:35 PM
Can you paste your code and is your program dialog screen - module pool ? How are you running it in background ?
‎2011 Jun 08 8:50 PM
An obvious question - what is sy-subrc after the delete in the background?
Rob
‎2011 Jun 08 9:38 PM
Hello Rob,
When I run the completed program in the background using JDBG sy-subrc = 0 after the delete. This indicates that the code is correct. If the code was incorrect it would not work running it from the screen, right.
I am awaiting an answer from the security person as to the authorisation for batch and background. There might be some restrictions on DELETE and COMMIT WORK and WAIT.
Thanks for the input
‎2011 Jun 08 9:57 PM
If sy-subrc = 0, then the delete was done. How do you know it wasn't?
Rob
‎2011 Jun 08 10:19 PM
hi, can you try SM13 to see if there's any error in DB update??
‎2011 Jun 08 10:29 PM
Also check if any other program or same program is creating entries after delete.
‎2011 Jun 09 12:34 AM
I just had a requirement to create a simple FM containing only a DELETE statement. This FM executes as part of an event in background mode. Works beautifully! No commit work whatsoever...
A security problem with the user that runs background processes seems likely, as suggested above.
...And let us know what was the problem!
‎2011 Jun 23 1:03 PM
Thank you All for the help. The issue has been finally traced to Authorisation issue. JDBG also useful..awarding points
‎2011 Jun 23 1:06 PM