2023 Mar 01 5:51 AM
Hello,experts.
Can "OPEN DATASET FOR OUTPUT" perform file locking(Write Lock)?
I want to prevent other systems from accessing the files.
Thanks.
2023 Mar 01 4:06 PM
AFAIK SAP didn't handle such lock (read 27 - Recommendations for ABAP file interface - 9. Locks)
You could create a lock object in SAP to handle locks from your SAP system, but for other systems look for other solutions to manage files with some external tool..
2023 Mar 01 6:21 AM
Hi,
To lock a file when opening it for output, you can use the addition FOR UPDATE in the OPEN DATASET statement. I think, this addition ensures that no other process can open the file for writing at the same time.
OPEN DATASET p_file FOR UPDATE IN TEXT MODE ENCODING DEFAULT.
Try it. it may help.
2023 Mar 01 5:26 PM
Are you able to use FOR OUTPUT and FOR UPDATE in the same statement?
2023 Mar 01 7:17 PM
2023 Mar 01 4:06 PM
AFAIK SAP didn't handle such lock (read 27 - Recommendations for ABAP file interface - 9. Locks)
You could create a lock object in SAP to handle locks from your SAP system, but for other systems look for other solutions to manage files with some external tool..