Application Development and Automation 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: 
Read only

OPEN DATASET FOR OUTPUT File Lock

Gaku
Explorer
0 Likes
1,440

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
Read only

RaymondGiuseppi
Active Contributor
1,331

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
Read only

former_member184158
Active Contributor
0 Likes
1,331

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.

Read only

1,331

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

Read only

0 Likes
1,331

I mean for update. Maybe it helps.

Read only

RaymondGiuseppi
Active Contributor
1,332

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