Ensuring VSAM files are closed before COBOL program updates

Tags:
CICS
COBOL
Mainframe
VSAM
We have several VSAM files within a CICS online system that need to be closed so that a batch job can run against the files and update some of them. Right now we issue the cemt commands in batch but the files aren't actually closed at the time the COBOL program runs against them and an abend occurs on the open statement. Is there a way, either in the COBOL program or in the JCL, to ensure the files are actually closed before the COBOL program executes?

Answer Wiki

Thanks. We'll let you know when a new response is added.

There are several ways of attacking this problem:

1. You can use one of any number of vendor products designed to allow opening and closing files from batch. These products can also be set up to wait for the close or issue a non-zero return code if it doesn’t happen within a reasonable time.

2. I’m not sure what you’re using to issue the CEMT commands from batch, but would it be possible to use the same mechanism to inquire on the file’s status repeatedly?

3. If you like to roll your own, CICSPlex Systems Manager (CPSM) provides an application programming interface (API) for inquiring and changing CICS resource status. I would recommend writing a Rexx program to set the files closed, then loop until the close completes. Then you can execute the Rexx in your job so the COBOL step will not run until the dataset truly closes.

CICS provides CPSM Rexx samples and I’m sure you could find others on the Internet.

4. If this is a record level sharing (RLS) dataset and you are in fact using the quiesce command, I would recommend employing close instead. The time a quiesce command takes depends on the number of regions using RLS and the size of your Sysplex. In fact, there are some conditions where a quiesce never quite completes. You can save time and increase your success rate by closing the file on each CICS using it.

************************************************************************************************************

Here is what we use,, a REXX exec issuing the CEMT command via a console. This is run as a batch TSO step prior to the COBOL program running. After issuing the clor or open, the REXX exec checks the status of the file via the response from CICS.

//******************************************************************
//* Control Card Format
//*
//* CICS REGION NAME, Filename, Command
//*******************************************************************
//DD2 DD *
TESTCICS,FILE123,CLOSE
TESTCICS,FILE987,OPEN
//DD1 DD SYSOUT=*

/* EXEC NAME: CICS1 FORM: REXX */
/* */
/* THIS CLIST WILL ISSUE CICS COMMANDS TO CLOSE AND */
/* OPEN FILES */
/* */
/* */
/* */
TRACE ERR

HOLDRC = 0
DD1OUT. = ‘ ‘
DD1OUT.0 = 0
DD2OUT. = ‘ ‘
DD2OUT.0 = 0
DD3OUT. = ‘ ‘
DD3OUT.0 = 0
MSGSS.0 = 0
MSGSS. = ‘ ‘

/********************************************************/
/******* READ THE CONTROL CARDS FROM THE JCL ***/
/***** **************************************************/

“EXECIO * DISKR DD2 ( FINIS STEM DD2OUT.”

DO I = 1 UNTIL I = DD2OUT.0
PARSE VAR DD2OUT.I REG ‘,’ DDN ‘,’ STAT .

/********************************************************/
/******* WRITE A MESSAGE IN THE OUTPUT PRT FILE ***/
/********************************************************/

DD1OUT.0 = 1
DD1OUT.1 = REG ‘ – ‘ DDN ‘ – ‘ STAT
“EXECIO 1 DISKW DD1 (STEM DD1OUT.”

IF STAT = ‘OPEN’
then
STAT1 = ‘OPEN ENA’

IF STAT = ‘CLOSE’
then
STAT1 = ‘CLOSE DIS’

/********************************************************/
/******* START AN EXTENDED MCS CONSOLE SESSION ***/
/******* AND ISSUE THE COMMAND ***/
/********************************************************/

DO X=1 UNTIL X = 20

“CONSPROF SOLDISP(NO) SOLNUM(2000) ”
“CONSOLE ACTIVATE,NAME(MCS1),CART(” || I || “)”

/********************************************************/
/******* IF RC NOT 0,,, CONSOLE IS ALREADY IN USE */
/********************************************************/

IF RC = 0
THEN
DO
LEAVE X
END

/********************************************************/
/******* WAIT 15 SECONDS and try again */
/********************************************************/

SECS = 15
RC = TIME(R)
DO FOREVER
N = TIME(E)
IF N >= SECS THEN LEAVE
END
END

CMD1 = ‘F ‘ || REG || ‘,CEMT S FI(‘ || DDN ||’) ‘ || STAT1

“CONSOLE SYSCMD(” || CMD1 || “)”

/********************************************************/
/******* WAIT UP TO 30 SECONDS TO GET THE OUTPUT ***/
/******* BACK FROM CICS ***/
/********************************************************/

ZZ = GETMSG(“MSGSS.”,”SOL”,I,,30)

IF ZZ \= ’0′
THEN
DO
DD1OUT.0 = 4
DD1OUT.1 = ‘*****************************************’
DD1OUT.2 = ‘ ERROR IN GETMSG RESPONSE FROM CICS ‘
DD1OUT.3 = ‘ RETURN CODE = ‘ || ZZ
DD1OUT.4 = ‘*****************************************’
“EXECIO ” DD1OUT.0 ” DISKW DD1 (STEM DD1OUT.”

EXIT 12
END

/********************************************************/
/******* PRINT THE RESPONSE FROM CICS */
/********************************************************/

DO Z = 1 UNTIL Z = MSGSS.0
DD1OUT.0 = 1
DD1OUT.1 = ‘ ‘ || MSGSS.Z
“EXECIO 1 DISKW DD1 (STEM DD1OUT.”
END

DD1OUT.0 = 1
DD1OUT.1 = ‘*********************************************’
“EXECIO 1 DISKW DD1 (STEM DD1OUT.”

/********************************************************/
/******* NOW PARSE THE OUTPUT TO MAKE SURE EVERYTHING */
/******* IS OK ***/
/********************************************************/

ERR1 = 1
DO Z = 1 UNTIL Z = MSGSS.0
PARSE VAR MSGSS.Z . ‘Openstatus( ‘ RET1 ‘ )’ .

IF RET1 = ‘Open’ & STAT = ‘OPEN’
THEN
DO
ERR1 = ”
LEAVE Z
END

IF RET1 = ‘Closed’ & STAT = ‘CLOSE’
THEN
DO
ERR1 = ”
LEAVE Z
END
END

IF ERR1 \= ”
THEN
DO
DD1OUT.0 = 3
DD1OUT.1 = ‘*****************************************’
DD1OUT.2 = ‘ ERROR IN CEMT RESPONSE FROM CICS ‘
DD1OUT.3 = ‘*****************************************’
“EXECIO ” DD1OUT.0 ” DISKW DD1 (STEM DD1OUT.”

HOLDRC = 12
END

CONSOLE DEACTIVATE

END

/********************************************************/
/******* WAIT 15 SECONDS FOR CICS TO CATCH UP */
/********************************************************/

secs = 15
rc = Time(R)
Do Forever
n = Time(E)
If n >= secs Then Leave
End

EXIT HOLDRC

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Db2idcam
    Prior to executing the batch step there would be an IDCAMS step which would issue an IDCAMS verify subcommand for all the files which will be referenced eitther for the job or the following steps.
    10 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following