Application Development 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: 

OPEN DATASET FOR OUTPUT File Lock

Gaku
Explorer
0 Kudos
428

Hello,experts.

Can "OPEN DATASET FOR OUTPUT" perform file locking(Write Lock)?

I want to prevent other systems from accessing the files.

Thanks.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
319

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..

4 REPLIES 4

former_member184158
Active Contributor
0 Kudos
319

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.

319

Are you able to use FOR OUTPUT and FOR UPDATE in the same statement?

0 Kudos
319

I mean for update. Maybe it helps.

raymond_giuseppi
Active Contributor
320

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..