Skip to Content
0
Oct 30, 2019 at 02:43 PM

Insert statement following a Delete for ZTable not working

129 Views

Hi,

i have the below statements that does a full replace/refresh of a z table nightly....

when i run in debug it always writes the correct amount of entries, about 10,000. When it runs in background it only ever writes about 1,500. It seems the delete is not finished before the insert happens and overlaps/locks occur. This is why i added commit work and wait, but still the same outcome.

DELETE FROM zgenesis_mstdata. COMMIT WORK AND WAIT.

INSERT zgenesis_mstdata FROM TABLE lt_genesis ACCEPTING DUPLICATE KEYS.

Lots of ideas online on the forum (listed below) but not sure which is best;

- adding commit work and wait after the delete (like i did)

- other says that wont work unless the delete was in a functional module for example (a different luw)

- add commit after the insert

- add wait 5 seconds after the delete (to ensure the entries are definitely deleted before the insert happens)

- lock the ztable before the delete and unlock after and then do the same for the insert

- use modify and not delete

Which is right!?!?

Thanks