Sample CICS Application Program

A Model CICS Application 
Preparatory work
Create the following PDS
userid.COBOL.SOURCE recsize=80,blksize=800,recfm=fb,PDS
userid.COBOL.COPYBOOK recsize=80,blksize=800,recfm=fb,PDS
userid.PROCLIB recsize=80,blksize=800,recfm=fb,PDS
userid.JCL recsize=80,blksize=800,recfm=fb,PDS
userid.MAPSET.SOURCE recsize=80,blksize=800,recfm=fb,PDS
userid.DBRMLIB recsize=80,blksize=800,recfm=fb,PDS
userid.LOADLIB blksize=32760,recfm=vb,PDS

Copy the following procedure into your userid.PROCLIB as CICSCOB1
//TRN EXEC PGM=DFHECP1$,
// PARM='COBOL2,SP',
// REGION=2M
//STEPLIB DD DSN=CICSTS13.CICS.SDFHLOAD,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSPUNCH DD DSN=&&SYSCIN,
// DISP=(,PASS),UNIT=SYSDA,
// DCB=BLKSIZE=400,
// SPACE=(400,(400,100))
//*
//COB EXEC PGM=IGYCRCTL,REGION=2M,
// PARM='NODYNAM,LIB,OBJECT,RENT,RES,APOST,XREF'
//STEPLIB DD DSN=IGY.V2R1M0.SIGYCOMP,DISP=SHR
//SYSLIB DD DSN=CICSTS13.CICS.SDFHCOB,DISP=SHR
// DD DSN=CICSTS13.CICS.SDFHMAC,DISP=SHR
// DD DSN=CICSTS13.CICS.SDFHSAMP,DISP=SHR
// DD DSN=userid.COBOL.COPYBOOK,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN DD DSN=&&SYSCIN,DISP=(OLD,DELETE)
//SYSLIN DD DSN=&&LOADSET,DISP=(MOD,PASS),
// UNIT=SYSDA,SPACE=(80,(250,100))
//SYSUT1 DD UNIT=SYSDA,SPACE=(460,(350,100))
//SYSUT2 DD UNIT=SYSDA,SPACE=(460,(350,100))
//SYSUT3 DD UNIT=SYSDA,SPACE=(460,(350,100))
//SYSUT4 DD UNIT=SYSDA,SPACE=(460,(350,100))
//SYSUT5 DD UNIT=SYSDA,SPACE=(460,(350,100))
//SYSUT6 DD UNIT=SYSDA,SPACE=(460,(350,100))
//SYSUT7 DD UNIT=SYSDA,SPACE=(460,(350,100))
//*
//COPYLINK EXEC PGM=IEBGENER,COND=(7,LT,COB)
//SYSUT1 DD DSN=CICSTS13.CICS.SDFHCOB(DFHEILIC),DISP=SHR
//SYSUT2 DD DSN=&&COPYLINK,DISP=(NEW,PASS),
// DCB=(LRECL=80,BLKSIZE=400,RECFM=FB),
// UNIT=SYSDA,SPACE=(400,(20,20))
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//*
//LKED EXEC PGM=IEWL,REGION=2M,
// PARM='LIST,XREF',COND=(5,LT,COB)
//SYSLIB DD DSN=CICSTS13.CICS.SDFHLOAD,DISP=SHR
// DD DSN=DSN510.SDSNLOAD,DISP=SHR
// DD DSN=CEE.SCEELKED,DISP=SHR
// DD DSN=CEE.SCEERUN,DISP=SHR
// DD DSN=userid.COBOL.OBJECT,DISP=SHR
//SYSUT1 DD UNIT=SYSDA,DCB=BLKSIZE=1024,
// SPACE=(1024,(200,20))
//SYSPRINT DD SYSOUT=*
//SYSLIN DD DSN=&&COPYLINK,DISP=(OLD,DELETE)
// DD DSN=&&LOADSET,DISP=(OLD,DELETE)
// DD DDNAME=SYSIN

Notes:-
  1. The shaded green text may change on your system depending on the versions of CICS and COBOL.
  1. The blue shaded portions are your TSO userid.

Copy this into your JCL PDS. This is for compiling a COBOL CICS program that does not use DB2.
//userid1 JOB NOTIFY=&SYSUID
// JCLLIB ORDER=(userid.PROCLIB)
//COMPILE EXEC CICSCOB1
//TRN.SYSIN DD DSN=userid.COBOL.SOURCE(memname),DISP=SHR
//LKED.SYSIN DD *
NAME memname(R)
/*
//* THIS IS THE USER LOADLIB FOR CICS
//LKED.SYSLMOD DD DSN=<-loadlib->,DISP=SHR
//

Copy this map preparation procedure into userid.PROCLIB
PROC DFHMAPT
//DFHMAPT PROC INDEX='CICSTS13.CICS', FOR SDFHMAC
// DSCTLIB='userid.COBOL.COPY', TARGET FOR DSECT
// MAPNAME=, NAME OF MAPSET - REQUIRED
// RMODE=24, 24/ANY
// ASMBLR=ASMA90, ASSEMBLER PROGRAM NAME
// REG=2048K, REGION FOR ASSEMBLY
// OUTC=A, PRINT SYSOUT CLASS
// WORK=SYSDA WORK FILE UNIT
//ASMMAP EXEC PGM=&ASMBLR,REGION=&REG,
// PARM='SYSPARM(MAP),DECK,NOOBJECT'
//SYSPRINT DD SYSOUT=&OUTC
//SYSLIB DD DSN=&INDEX..SDFHMAC,DISP=SHR
// DD DSN=SYS1.MACLIB,DISP=SHR
//SYSUT1 DD UNIT=&WORK,SPACE=(CYL,(5,5))
//SYSUT2 DD UNIT=&WORK,SPACE=(CYL,(5,5))
//SYSUT3 DD UNIT=&WORK,SPACE=(CYL,(5,5))
//SYSPUNCH DD DSN=&&MAP,DISP=(,PASS),UNIT=&WORK,
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=400),
// SPACE=(400,(50,50))
//SYSIN DD DSN=userid.MAPSET.SOURCE(&MAPNAME),DISP=SHR
//LINKMAP EXEC PGM=IEWL,PARM='LIST,LET,XREF,RMODE(&RMODE)'
//SYSPRINT DD SYSOUT=&OUTC
//SYSLMOD DD DSN=<- your CICS map set load library ->(&MAPNAME),DISP=SHR
//SYSUT1 DD UNIT=&WORK,SPACE=(1024,(20,20))
//SYSLIN DD DSN=&&MAP,DISP=(OLD,DELETE)
//ASMDSECT EXEC PGM=&ASMBLR,REGION=&REG,
// PARM='SYSPARM(DSECT),DECK,NOOBJECT'
//SYSPRINT DD SYSOUT=&OUTC
//SYSLIB DD DSN=&INDEX..SDFHMAC,DISP=SHR
// DD DSN=SYS1.MACLIB,DISP=SHR
//SYSUT1 DD UNIT=&WORK,SPACE=(CYL,(5,5))
//SYSUT2 DD UNIT=&WORK,SPACE=(CYL,(5,5))
//SYSUT3 DD UNIT=&WORK,SPACE=(CYL,(5,5))
//SYSPUNCH DD DSN=&DSCTLIB(&MAPNAME),DISP=OLD
//SYSIN DD DSN=user01.MAPSET.SOURCE(&MAPNAME),DISP=SHR

Copy this into userid.JCL
//USER011 JOB NOTIFY=&SYSUID,CLASS=A,MSGLEVEL=(1,1)
// JCLLIB ORDER=(userid.PROCLIB)
//STEP1 EXEC DFHMAPT,MAPNAME=member-name
//
  1. Two students will each form a group and the n will vary from 3 to 9 for the groups. 1 and 2 are reserved for the instructor!!.
  1. Each groups resources will be in a group TRNG0n
  1. The instructor will define the resources on request.
  1. All programs MUST be tested using CEDF before allowing them to run. This is to guard against programs going in a loop and disturbing other users of the system.
  1. The subprograms SYSERR,GETINV,INTEDIT and NUMEDIT will be defined in group TRNGCOMN and can be shared by all.
  1. Don’t forget to change the COBOL and BMS source to reflect the naming conventions above!.
Data Sets and Sample Data
CUSTMAS
01 CUSTOMER-MASTER-RECORD.
*
05 CM-CUSTOMER-NUMBER PIC X(6).
05 CM-FIRST-NAME PIC X(20).
05 CM-LAST-NAME PIC X(30).
05 CM-ADDRESS PIC X(30).
05 CM-CITY PIC X(20).
05 CM-STATE PIC X(2).
05 CM-ZIP-CODE PIC X(10).


Sample data
112233ANNE PRINCE 1122 ELM ST FRESNO CA93711-0000
123455COLUMBUS CHRISTOPHER 1122 NEW WORLD LN COLUMBUS OH92939
123456RAUL MENENDEZ 888 CICS WAY FRESNO CA93711-2765

Since the application has the facility to add a customer record, you can get that part of the application (CUSTMN1n, transid MN1n) to work and add these records.

Defining the data set
//userid1 JOB NOTIFY=&SYSUID,CLASS=A,MSGLEVEL=(1,1)
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE userid.CUSTMAS CLUSTER
DEFINE CLUSTER (NAME(userid.CUSTMAS) INDEXED KEYS(6,0) -
RECORDSIZE(118,118) TRACKS(2,2)) DATA(CONTROLINTERVALSIZE(1024))
//

PRODUCT
01 PRODUCT-MASTER-RECORD.
*
05 PRM-PRODUCT-CODE PIC X(10). 10
05 PRM-PRODUCT-DESCRIPTION PIC X(20). 20
05 PRM-UNIT-PRICE PIC S9(7)V99 COMP-3. 5
05 PRM-QUANTITY-ON-HAND PIC S9(7) COMP-3. 4
*
Sample Data
See PRODUCT file. Cut paste it into a data set userid.PRODUCT.DATA. A load using REPRO is suggested. It is also a good idea to print the data set using PRINT with HEX output. Note that the ORDRENT2 program wont work without this data set and data.


Optionally you can use the program SAMP18 earlier in this document to generate the data for this file automatically.
Defining the data set
//userid1 JOB NOTIFY=&SYSUID,CLASS=A,MSGLEVEL=(1,1)
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE userid.PRODUCT CLUSTER
DEFINE CLUSTER (NAME(userid.PRODUCT) INDEXED KEYS(10,0) -
RECORDSIZE(39,39) TRACKS(1,1)) DATA(CONTROLINTERVALSIZE(1024))
//


Loading the data set
//userid1 JOB NOTIFY=&SYSUID,CLASS=A,MSGLEVEL=(1,1)
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
REPRO INDATASET(userid.PRODUCT.DATA) -
OUTDATASET(userid.PRODUCT)
//

Printing the data set
//userid1 JOB NOTIFY=&SYSUID,CLASS=A,MSGLEVEL=(1,1)
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
PRINT INDATASET(userid.PRODUCT) HEX
//

INVOICE
01 INVOICE-RECORD.
*
05 INV-INVOICE-NUMBER PIC 9(6). 6
05 INV-INVOICE-NUMBER-R REDEFINES
INV-INVOICE-NUMBER PIC X(06). 0
05 INV-INVOICE-DATE PIC X(8). 8
05 INV-CUSTOMER-NUMBER PIC X(6). 6
05 INV-PO-NUMBER PIC X(10). 10
05 INV-LINE-ITEM OCCURS 10. 240
10 INV-PRODUCT-CODE PIC X(10). 10
10 INV-QUANTITY PIC S9(7) COMP-3. 4
10 INV-UNIT-PRICE PIC S9(7)V99 COMP-3. 5
10 INV-AMOUNT PIC S9(7)V99 COMP-3. 5
05 INV-INVOICE-TOTAL PIC S9(7)V99 COMP-3. 5
*
Defining the data set
//userid1 JOB NOTIFY=&SYSUID,CLASS=A,MSGLEVEL=(1,1)
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE userid.INVOICE CLUSTER
DEFINE CLUSTER (NAME(userid.INVOICE) INDEXED KEYS(6,0) LOG(NONE) -
RECORDSIZE(275,275) TRACKS(2,2)) DATA(CONTROLINTERVALSIZE(1024))
//
This data set has an alternate index built over the INV-CUSTOMER-NUMBER field. When using an alternate index, you simply specify the name of the path as a FILE resource to CICS.

Three Access Method Services commands are used as below:
  1. DEFINE ALTERNATEINDEX :-defines the alternate index as a data set to VSAM.
  1. BLDINDEX :-places the pointers to the relevant records in the alternate index.
  1. DEFINE PATH:-defines an entity that can be associated with a PL/I file in a DD statement.

DEFINING A ALTERNATE INDEX FOR A VSAM KSDS FILE
//userid1 JOB MSGCLASS=A,NOTIFY=&SYSUID
//STEP1 EXEC PGM=IDCAMS,REGION=512K
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE userid.INVOICE.ALTINDEX ALTERNATEINDEX
DEFINE ALTERNATEINDEX -
(NAME(userid.INVOICE.ALTINDEX)-
NONUNIQUEKEY -
KEYS(6 14) -
RECORDSIZE(40 400) -
TRACKS(2 2) -
RELATE(userid.INVOICE))
/*
//

EXAMPLE OF THE ALTERNATE INDEX AND DEFINING THE PATH
//userid1 JOB MSGCLASS=A,NOTIFY=&SYSUID
//STEP1 EXEC PGM=IDCAMS,REGION=512K
//SYSPRINT DD SYSOUT=*
//DD1 DD DSN=userid.INVOICE,DISP=OLD
//DD2 DD DSN=userid.INVOICE.ALTINDEX,DISP=OLD
//SYSIN DD *
DEFINE PATH-
(NAME(userid.INVOICE.PATH)-
PATHENTRY(userid.INVOICE.ALTINDEX))
/*
//

EXAMPLE OF RUNNING BLDINDEX
//userid1 JOB MSGCLASS=A,NOTIFY=&SYSUID
//STEP1 EXEC PGM=IDCAMS,REGION=512K
//SYSPRINT DD SYSOUT=*
//DD1 DD DSN=userid.INVOICE,DISP=OLD
//DD2 DD DSN=userid.INVOICE.ALTINDEX,DISP=OLD
//SYSIN DD *
BLDINDEX INFILE(DD1) OUTFILE(DD2)
/*
//

Define the userid.INVOICE as file INVOICE to CICS. Define userid.INVOICE.PATH as INVPATH to CICS. Read access to INVPATH is sufficient, For INVOICE full access needs to be provided. Define the files as non recoverable. Open only the INVOICE file first, as INVPATH wont open. Use ORDRENT2 to populate at least one record in the INVOICE file. Now close and disable both files. Go to batch and run BLDINDEX now, it should return rc=0. Go back to CICS and now both INVOICE and INVPATH will open correctly.

You can create invoices using the ORDRENT2 program. In case you want data, it is available in the file INVOICE. Note that the Product Code you enter here must be available in the PRODUCT file.

You can test the proper operation of the Alternate Index by using the Customer Inquiry program.


INVCTL
  1. INVCTL-RECORD.
*
05 INVCTL-RECORD-KEY PIC X.
  1. INVCTL-NEXT-RECORD-NUMBER PIC 9(6).
*
Defining the data set
//userid1 JOB NOTIFY=&SYSUID,CLASS=A,MSGLEVEL=(1,1)
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE userid.INVCTL CLUSTER
DEFINE CLUSTER (NAME(userid.INVCTL) INDEXED KEYS(1,0) -
RECORDSIZE(7,7) TRACKS(1,1)) DATA(CONTROLINTERVALSIZE(1024))
//
DB2 Setup.
Some preliminary permissions and definitions need to be done. Some of these will be by the SYSADM group. Rest will be by you. The definitions and grants are done using SPUFI.


SYSADM
--CREATE STOGROUP TRGSG02 VOLUMES(H6SDB2) VCAT TRGD1;
--CREATE DATABASE KAMATH STOGROUP TRGSG02;
--GRANT DBADM ON DATABASE KAMATH TO KAMATH;
--GRANT USE OF STOGROUP TRGSG02 TO KAMATH;
--GRANT CREATETS ON DATABASE KAMATH TO KAMATH;
--GRANT CREATETAB ON DATABASE KAMATH TO KAMATH;
--GRANT CREATE ON COLLECTION MURACH TO KAMATH;
--GRANT BINDADD TO KAMATH;
--GRANT ALL ON PACKAGE MURACH.* TO PUBLIC
--GRANT BIND,EXECUTE ON PLAN MURACHP TO KAMATH WITH GRANT OPTION;


KAMATH (User)
--CREATE TABLESPACE SPACE1 IN KAMATH USING STOGROUP TRGSG02
--PRIQTY 5 SECQTY 5 FREEPAGE 0 PCTFREE 0 LOCKSIZE ANY;
--CREATE TABLE KAMATH.CUSTMAS
-- (
-- CUSTNO CHAR (6),
-- FNAME CHAR (20),
-- LNAME CHAR (30),
-- ADDR CHAR (30),
-- CITY CHAR (20),
-- STATE CHAR (2),
-- ZIPCODE CHAR (10)
-- ) IN KAMATH.SPACE1;
--CREATE TABLE KAMATH.INVOICE
-- (
-- INVCUST CHAR (6) NOT NULL,
-- INVNO CHAR (6) NOT NULL,
-- INVDATE DATE NOT NULL,
-- INVSUBT DEC (9, 2) NOT NULL,
-- INVSHIP DEC (7, 2) NOT NULL,
-- INVTAX DEC (7, 2) NOT NULL,
-- INVTOTAL DEC (9, 2) NOT NULL,
-- INVPO CHAR (10) NOT NULL
-- ) IN KAMATH.SPACE1;
--GRANT ALL ON TABLE KAMATH.CUSTMAS TO PUBLIC;
--GRANT ALL ON TABLE KAMATH.INVOICE TO PUBLIC;
--GRANT BIND,EXECUTE ON PLAN MURACHP TO PUBLIC;


DML for testing
--SELECT * FROM KAMATH.INVOICE
--SELECT * FROM KAMATH.CUSTMAS
DCLGEN
Use DCLGEN to create INVDCL and CUSTDCL members.


JCL for compilation and creation of a PLAN
//userid1 JOB NOTIFY=&SYSUID,CLASS=A,MSGLEVEL=(1,1)
// JCLLIB ORDER=(userid.PROCLIB)
//*********************************************************
//* DB2 PRECOMPILE THE COBOL PROGRAM
//*********************************************************
//PC EXEC PGM=DSNHPC,
// PARM='HOST(COB2),XREF,SOURCE,FLAG(I),APOST'
//STEPLIB DD DISP=SHR,DSN=DSN510.SDSNLOAD
//DBRMLIB DD DISP=OLD,DSN=userid.DBRMLIB(member)
//SYSCIN DD DSN=&&DSNHOUT,DISP=(MOD,PASS),UNIT=SYSDA,
// SPACE=(800,(500,500))
//SYSLIB DD DSN=userid.DCLGEN.COBOL,DISP=SHR
// DD DSN=userid.COBOL.COPYBOOK,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSTERM DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSUT1 DD SPACE=(800,(500,500),,,ROUND),UNIT=SYSDA
//SYSUT2 DD SPACE=(800,(500,500),,,ROUND),UNIT=SYSDA
//SYSIN DD DISP=SHR,DSN=userid.COBOL.SOURCE(member)
//********************************************************************
//* COMPILE THE COBOL PROGRAM
//********************************************************************
//CICS EXEC CICSCOB1
//TRN.SYSIN DD DSN=&&DSNHOUT,DISP=(OLD,DELETE)
//LKED.SYSLMOD DD DSN=cics.loadlib(member),DISP=SHR
//LKED.DB2LOAD DD DISP=SHR,DSN=DSN510.SDSNLOAD
//LKED.SYSIN DD *
INCLUDE DB2LOAD(DSNCLI)
NAME DB2INQ2(R)
/*
//




//userid1 JOB NOTIFY=&SYSUID,CLASS=A,MSGLEVEL=(1,1)
// JCLLIB ORDER=(userid.PROCLIB)
//BIND EXEC PGM=IKJEFT01
//STEPLIB DD DISP=SHR,DSN=DSN510.SDSNLOAD
//DBRMLIB DD DISP=OLD,DSN=userid.DBRMLIB
//SYSPRINT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSTSIN DD *
DSN S(DSNA)
BIND PACKAGE(MURACH) MEMBER(ORDRENT2)
BIND PACKAGE(MURACH) MEMBER(CUSTMNT2)
BIND PACKAGE(MURACH) MEMBER(DB2INQ2)
END
/*
//


//userid1 JOB NOTIFY=&SYSUID,CLASS=A,MSGLEVEL=(1,1)
// JCLLIB ORDER=(userid.PROCLIB)
//BIND EXEC PGM=IKJEFT01
//STEPLIB DD DISP=SHR,DSN=DSN510.SDSNLOAD
//DBRMLIB DD DISP=OLD,DSN=userid.DBRMLIB
//SYSPRINT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSTSIN DD *
DSN S(DSNA)
BIND PLAN(MURACHP) PKLIST(MURACH.*) ACTION(REP) RETAIN ISOLATION(CS)
END
/*
//


Notes:-
  1. You create DBRM’s with the same name as the program being compiled.
  1. You first bind each of the DBRM’s into a package list called MURACH.
  1. You then bind the package list into a plan called MURACHP
  1. The one single plan will cater for all the programs involved in the transaction.
Resource Definitions that need to be done:-
Programs Mapset Transactions
  1. INVMENU2 MENSET1 MEN2
  2. CUSTMNT2 MNTSET1 MNT2
  3. ORDRENT2 ORDSET1 ORD2
  4. CUSTINQ2 INQSET1 INQ2
  5. DB2INQ2 DB2SET1 DIN2
  6. PUTINV ------- PUTI
  7. SETCWA ------- SCWA
  8. SAMP18 ------- SM18
  9. SYSERR ------- ----
  10. GETINV ------- ----
  11. INTEDIT ------- ----
  12. NUMEDIT ------- ----


Data Sets File-names
  1. Userid.CUSTMAS CUSTMAS
  2. Userid.INVOICE INVOICE
  3. Userid.INVCTL INVCTL
  4. Userid.PRODUCT PRODUCT
  5. Userid.INVOICE.PATH INVPATH
DB2ENTRY
DB2Entry ==> MURENT2
Group ==> KAMATH
TRansid ==> MNT2
PLAN ==> MURACHP

DB2TRAN
DB2Tran ==> MURTRN21 Group ==> KAMATH
Entry ==> MURENT2
Transid ==> ORD2

DB2TRAN
DB2Tran ==> MURTRN22 Group ==> KAMATH
Entry ==> MURENT2
Transid ==> INQ2

DB2TRAN
DB2Tran ==> MURTRN23 Group ==> KAMATH
Entry ==> MURENT2
Transid ==> DIN2  

0 comments:

Computers TopOfBlogs Technology Blogs Mainframe interview question and answers,mainframe jobs,cobol,vsam,jcl,cics,db2,rdbms,mvs,tso,ispf,ibm,hcl,tcs,cts,wibro Blog Directory