IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to put exclusive lock on a file in Cobol


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sudarshan.srivathsav

New User


Joined: 10 Jul 2012
Posts: 24
Location: USA

PostPosted: Fri Jun 05, 2015 10:36 pm
Reply with quote

I see there is something called "LOCK MODE IS EXCLUSIVE", but it gives me a INVALID keyword error on compiling . It would be of great help if someone could give a FILE-CONTROL section example of how to specify LOCK.

Code:

FILE-CONTROL.                                             
    SELECT IN-FILE  ASSIGN INPUTI FILE STATUS INP-STATUS. 
    SELECT PIPE ASSIGN PIPE                               
    ORGANIZATION IS LINE SEQUENTIAL                       
    ACCESS MODE IS SEQUENTIAL                             
    FILE STATUS PIPE-STATUS.                   


I want to keep a exclusive lock on the file PIPE until I close the same. [/code]
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Jun 05, 2015 10:38 pm
Reply with quote

just use DISP=OLD in the jcl.
Back to top
View user's profile Send private message
sudarshan.srivathsav

New User


Joined: 10 Jul 2012
Posts: 24
Location: USA

PostPosted: Fri Jun 05, 2015 10:47 pm
Reply with quote

Enrico,

I cannot do that , my output is a unix file as below, the DISP parameter cannot go with PATH, PATHDISP cannot understand OLD. Any other way in program to put exclusive lock on the UNIX file. Basically I am trying to avoid data comingle since another process is also writing data to this pipe, and sometime the data in the pipe gets corrupted.

Code:


//WWCSRSA  JOB CLASS=A,NOTIFY=&SYSUID,MSGCLASS=H,REGION=0M           
//         JCLLIB ORDER=WWCSRS.PROCLIB                               
//STEP1    EXEC PGM=WRITEPIP                                         
//STEPLIB  DD DSN=WWCSRS.PGMLIB,DISP=SHR                             
//PIPE     DD  PATH='/u/wwcsrs/.mfxsplunk',                         
//             PATHDISP=(KEEP,KEEP),                                 
//             FILEDATA=TEXT,DSNTYPE=PIPE,                           
//             PATHOPTS=(ORDWR,OCREAT)                               
//*INPUTI   DD  DSN=WWCSRS.SAMPLE.INPUT.FILE,DISP=SHR               
//INPUTI  DD *                                                       
JOSEPH SMITH        02506240                                         
JAMES JONES         12345678                                         
JOHN JACKSON        00987654                                         

Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Jun 06, 2015 12:15 am
Reply with quote

Can different JOBs not have different (hfs) names for the pipe?

One way, assuming that it is z/OS JOBs only causing this issue, is to make a // INCLUDE for your pipe definition, which also contains a z/OS dataset with DISP=OLD. The additional dataset will provide the "locking" by not allowing another JOB to be selected whilst another JOB is already running.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Jun 06, 2015 3:52 am
Reply with quote

Quote:
I see there is something called "LOCK MODE IS EXCLUSIVE", but it gives me a INVALID keyword error on compiling
Which Enterprise COBOL manual did you find this in? LOCK MODE is used in a number of COBOL versions, but as far as I am aware it is not available for z/OS Enterprise COBOL.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top