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

Concurrent writing records to VSAM from COBOL program


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

New User


Joined: 22 Jul 2022
Posts: 3
Location: India

PostPosted: Fri Jul 22, 2022 11:30 pm
Reply with quote

Hello,

We are building a cobol program that will be called from hundreds of jobs at the same time,

Call would be line shown below

Job A -> Cobol A -> My Cobol
Job B -> Cobol A -> Cobol B -> My Cobol and so on.

Each time my cobol program is being called it has to do some calculation and write to a file. Only write.

My cobol program could be called simultaneously by hundreds of callers. I used VSAM (KSDS) file for this with SHAREOPTIONS(3,3).

For testing I ran 4 Jobs simultaneously. 1, 2 or sometimes 3 of the jobs have an PUT error while writing to the VSAM file described below.

[Date] [JOBID] *IDAI1001E PUT FAILED, ERROR FOUND WHILE UPDATING THE INDEX 405
405 DSN: [Dsn of the file]
405 REASON: OUT OF SEQUENCE INDEX RECORD

As far as I know, and I know very little, the jobs would run fine with SHAREOPTIONS(3,3).

Also as I don't know which Jobs will call this program, I used BPXWDYN to dynamically allocate the file in COBOL in SHR mode.

I tried to search for this issue using IDAI1001E and came across IBM article but cant find sufficient information to solve this.

All help or insights would be welcome.

Thanks in advance.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1564

PostPosted: Fri Jul 22, 2022 11:44 pm
Reply with quote

The real samples of your exact code are required:
- how do you create your VSAM dataset?
- how do you "write only" to your dataset?
- how do you choose the RID (the key) for your record(s)?
- are you overriding the same record from "hundreds of jobs", or adding new records for different jobs?
. . . . etc. etc. etc. . . . . . . . .

Without such details this is a dummy blah-blah-blah.
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 381
Location: Inside the SPEW (Cincinnati OH USA)

PostPosted: Fri Jul 22, 2022 11:49 pm
Reply with quote

you must realize

Code:
Cross-region SHAREOPTIONS 3: The data set can be fully shared by any number of users. With this option, each user is responsible for maintaining both read and write integrity for the data the program accesses. This setting does not allow any type of non-RLS access when the data set is already open for RLS processing.
This option requires that the user's program use ENQ/DEQ to maintain data integrity while sharing the data set, including the OPEN and CLOSE processing. User programs that ignore the write integrity guidelines can cause VSAM program checks, lost or inaccessible records, uncorrectable data set failures, and other unpredictable results. This option places responsibility on each user sharing the data set.
Back to top
View user's profile Send private message
anuj1411

New User


Joined: 22 Jul 2022
Posts: 3
Location: India

PostPosted: Sat Jul 23, 2022 12:04 am
Reply with quote

Quote:
how do you create your VSAM dataset?

1) The VSAM file is created seperately through a JCL using IDCAMS

DEF CL (NAME([DSN]) -
RECORDSIZE(316 316) -
BUFSP(74545) -
KEYS(39 0) -
FREESPACE(20 20) -
REUSE -
SHR(3 3) -
CYL(200 200) -
LOG(NONE) -
STORCLAS(SCCSLOW) -
SPEED) -
DATA -
(NAME([DSN].DATA) -
CISZ(2048)) -
INDEX -
(NAME([DSN].INDEX)-
CISZ(2048))

Quote:
- how do you "write only" to your dataset?


2) Record is written with just the WRITE keyword

WRITE Vsam-Record

Quote:
how do you choose the RID (the key) for your record(s)?


3) Key is the timestamp in below format concatenated with Jobname and calling program

20220722070436783307 [JOBNAME] [PROGRAM-NAME]
<------19 characters----><8 characters><8 characters>

Quote:
- are you overriding the same record from "hundreds of jobs", or adding new records for different jobs?

4) Adding new records for every job.

Sorry for the missing details in OP
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1564

PostPosted: Sat Jul 23, 2022 12:08 am
Reply with quote

Since it seems to be your very first attempt to "write to VSAM file", I suggest to begin from scratch.

First of all, run a unit test on your "My Cobol" program, running from a single test job, and writing at least several, or better multiple records to your VSAM.

If this test is successful, you can move forward after that.

The details of each step are needed, with exact code, and exact data written; not only abstract notes about your intentions...

P.S.
Step #1: Learn how to use the Code button when presenting your samples.
Back to top
View user's profile Send private message
anuj1411

New User


Joined: 22 Jul 2022
Posts: 3
Location: India

PostPosted: Sat Jul 23, 2022 12:15 am
Reply with quote

Yes you are right, this is my first attempt,

Quote:
If this test is successful, you can move forward after that.


I have tested this and a single job was able to write all the records(around 16000) to the VSAM file successfully, the issue arises when the jobs are run in parallel.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Sat Jul 23, 2022 9:27 pm
Reply with quote

You did not implement any enqueue / dequeue logic in your COBOL program, yet you are surprised that the results you get are not what you predicted? Read dneufarth's post again about what shareoptions 3 means. What you are seeing is "unpredictable results" and IBM warns you that what you are doing will cause them. In other words, the results you are seeing are PRECISELY what you should see, according to IBM.

Unless and until you implement enqueue / dequeue logic, you will continue to have problems. And before you ask, IBM does not provide any enqueue / dequeue mechanism in COBOL. It is available for CICS programs but not batch COBOL. You'll have to find a way to implement the logic outside of COBOL. The method I've seen most often used is a subprogram in HLASM that is called from the COBOL program.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 2915
Location: NYC,USA

PostPosted: Mon Jul 25, 2022 5:32 pm
Reply with quote

You can set negative dependency in scheduling between the jobs.

Second how do you get the job name and program name in the same called module? Someone may have a typo in the job name if parm is used across the jobs, did you check that ?
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1284
Location: Vilnius, Lithuania

PostPosted: Mon Jul 25, 2022 6:17 pm
Reply with quote

anuj1411 wrote:
We are building a cobol program that will be called from hundreds of jobs at the same time,

And which imbecile/incompetent PHB came up with this ludicrous "requirement", and more importantly, WHY?
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 740
Location: Whitby, ON, Canada

PostPosted: Mon Jul 25, 2022 9:32 pm
Reply with quote

prino wrote:
anuj1411 wrote:
We are building a cobol program that will be called from hundreds of jobs at the same time,

And which imbecile/incompetent PHB came up with this ludicrous "requirement", and more importantly, WHY?
Sounds like they are looking for a database solution without paying for a DBMS. That rarely ends well.
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 COBOL - create and write to output fi... COBOL Programming 0
No new posts COBOL to JSON COBOL Programming 1
No new posts Writing the output file name from a p... JCL & VSAM 7
No new posts writing into VSAM indexed tabl in PL1... PL/I & Assembler 8
No new posts Injecting HTTPHEADER parameters in th... PL/I & Assembler 0
Search our Forums:

Back to Top