Extending a CICS web application using JCICS Extending a CICS web - - PowerPoint PPT Presentation

extending a cics web application using jcics extending a
SMART_READER_LITE
LIVE PREVIEW

Extending a CICS web application using JCICS Extending a CICS web - - PowerPoint PPT Presentation

Extending a CICS web application using JCICS Extending a CICS web application using JCICS Course introduction What youll see in this course Fundamentals of interacting with CICS Invoke other CICS programs Access CICS resources Units of


slide-1
SLIDE 1

Extending a CICS web application using JCICS

slide-2
SLIDE 2

Extending a CICS web application using JCICS

Course introduction

slide-3
SLIDE 3

Fundamentals of interacting with CICS Invoke other CICS programs Access CICS resources Units of work Error conditions

What you’ll see in this course

slide-4
SLIDE 4

github.com/cicsdev cics-java-liberty-restapp-ext Simple JAX-RS applications Only use HTTP GET verb Test using web browser

Sample application code

slide-5
SLIDE 5

Liberty JVM server configured Configured with jaxrs-1 . 1 feature Development environment for CICS Dynamic web project Deploy using drop-ins or CICS bundles

Assumptions

slide-6
SLIDE 6

Using Java to access CICS

Mixed-language communication

slide-7
SLIDE 7

Mixed-language communication

Single CICS task sharing resources Program interface COMMAREAs or channels Language-specific structures with fields Define storage layout and data types

slide-8
SLIDE 8

Language structures

Defined by COBOL copybooks C header files Used for sequential record data

slide-9
SLIDE 9

Structured records and Java beans

Structured record Java bean

6 7 14 6 5 4 2 4 1 S D O E J O

account number last name account type first name

accountNum accountType lastName

getLastName( ) setAccountType( ) getAccountNumber( ) etc.

slide-10
SLIDE 10

Sample COBOL record

03 PART-ID PIC 9(8) DISPLAY. 03 SUPPLIER PIC 9(8) DISPLAY. 03 UNIT-PRICE PIC 99999V99 PACKED-DECIMAL. 03 LAST-ORDER-DATE. 05 LAST-ORDER-DATE-YY PIC X(2). 05 FILLER PIC X(1) VALUE '-'. 05 LAST-ORDER-DATE-MM PIC X(2). 05 FILLER PIC X(1) VALUE '-'. 05 LAST-ORDER-DATE-DD PIC X(2). 03 STOCK-QUANTITY PIC 9(8) BINARY. 03 NEXT-ORDER-DATE. 05 NEXT-ORDER-DATE-YY PIC X(2). 05 FILLER PIC X(1) VALUE '-'. 05 NEXT-ORDER-DATE-MM PIC X(2). 05 FILLER PIC X(1) VALUE '-'. 05 NEXT-ORDER-DATE-DD PIC X(2). 03 DESCRIPTION PIC X(40).

slide-11
SLIDE 11

JZOS record generator tool COBOL copybook to Java object mapping

Next steps

slide-12
SLIDE 12

Using Java to access CICS

Java record generation

slide-13
SLIDE 13

The JZOS toolkit

Java records map native language structures IBM record generation tools J2C record importer JZOS record generator

slide-14
SLIDE 14

Record generation process

COBOL program COBOL copybook COBOL compiler ADATA file JZOS record generator Java source file

slide-15
SLIDE 15

Including generated Java source

Include source only when customization needed Import Java source file into Eclipse project Add JZOS library to the project build path Copybook change requires Regeneration of source Update of source in Eclipse project

slide-16
SLIDE 16

Building a library JAR

jar utility Java source file Java source file Java source file .class file .class file .class file .jar file Java compiler Java compiler Java compiler

slide-17
SLIDE 17

Summary

Java for CICS – Building Java records from COBOL with IBM JZOS

developer.ibm.com/cics/2016/ 05/12/java-cics-using-ibmjzos/

slide-18
SLIDE 18

Communication with CICS

Linking to CICS programs

slide-19
SLIDE 19

CICS program Unit of compiled code Implemented in any language LINK command Call another language Call another system

LINK command

slide-20
SLIDE 20

Program p = new Program(); p.setName("PROG1"); p.link();

JCICS link example

slide-21
SLIDE 21

Area of memory No structure defined to CICS Described using copybook or header file Referenced in Java as byte[] Create byte[] using generated Java

A COMMAREA

slide-22
SLIDE 22

StockPart sp = new StockPart(); sp.setPartId(12345); sp.setSupplier(34567); sp.setStockQuantity(100); sp.setDescription("Small green round metal plug"); byte[] buf = sp.getByteBuffer();

Example of COMMAREA and Java

slide-23
SLIDE 23

byte[] buf = sp.getByteBuffer(); Program p = new Program(); p.setName("PROG1"); p.link(buf); StockPart retSP = new StockPart(buf);

Example of LINK using a COMMAREA

slide-24
SLIDE 24

byte[] buf = sp.getByteBuffer(); Program p = new Program(); p.setName("GETSUPPL"); p.link(buf); Supplier supplier = new Supplier(buf);

Further use of COMMAREAs

slide-25
SLIDE 25

// getByteBuffer returns length 80 byte[] buf = sp.getByteBuffer(); Program p = new Program(); p.setName("GETPART"); p.link(buf, 8);

Data length optimization

slide-26
SLIDE 26

Channel Holds multiple containers Analogous to a parameter list Container Named block of data Stores more than 32 KB of data

Channels and containers

slide-27
SLIDE 27

Link to CICS program from Java Link from CICS program to Liberty

Summary and next steps

slide-28
SLIDE 28

Communication with CICS

Linking to a Java program in Liberty

slide-29
SLIDE 29

Link to Liberty Call Java EE applications from CICS POJOs invoked by CICS LINK Use annotation on Java method Auto creation of PROGRAM resource

Linking into Java applications

slide-30
SLIDE 30

public class LinkToLiberty { @CICSProgram("GETSUPPL") public void getSupplierInfo() { … } }

CICSProgram annotation example

slide-31
SLIDE 31

Link to CICS programs using JCICS COMMAREA interface Link from CICS programs to Liberty

Summary

slide-32
SLIDE 32

Using CICS resources

Accessing VSAM data

slide-33
SLIDE 33

Introduction to CICS resources

Temporary Storage Queue Unique to CICS VSAM files Common across z/OS

slide-34
SLIDE 34

VSAM concepts

CICS file control services Virtual Storage Access Method data sets Files shared: Within a CICS region (LSR) Across the sysplex (RLS)

slide-35
SLIDE 35

CICS file resource Unique name within CICS region No need to open or close file CICS manages file resource

VSAM concepts

slide-36
SLIDE 36

Accessing a VSAM data set

VSAM data set TEST.DATA.STOCK STOCK1 FILE resource Application

slide-37
SLIDE 37

VSAM data sets

Key-sequenced data set KSDS Entry-sequenced data set ESDS Relative record data set RRDS

slide-38
SLIDE 38

DEFINE CLUSTER ( - NAME ( TEST.DATA.STOCK ) - RECORDS ( 100 10 ) - INDEXED - KEYS ( 8 0 ) - RECORDSIZE ( 80 80 ) - )

IDCAMS sample input

slide-39
SLIDE 39

CICS FILE resource definition

Sample uses resource name SMPLXMPL Reference VSAM data set DD in CICS region JCL DSNAME attribute in definition Must enable all operations for sample Add, browse, delete, read, update

slide-40
SLIDE 40

@ApplicationPath( "rest/" ) public class CICSApplication extends Application { }

RESTful interface URI

slide-41
SLIDE 41

@Path( "ksds" ) @Produces( MediaType.APPLICATION_JSON ) public class VsamKsdsFileResource { } @GET @Path( "write" ) public StockPartCollection writeNewRecord() { } /rest/ksds/write

RESTful interface URI

slide-42
SLIDE 42

StockPart sp = StockPartHelper.generate(); byte[] record = sp.getByteBuffer(); byte[] key = StockPartHelper.getKey(sp);

writeNewRecord()

slide-43
SLIDE 43

KSDS ksds = new KSDS(); ksds.setName("SMPLXMPL"); ksds.write(key, record); Task.getTask().commit(); return queryFile(ksds);

writeNewRecord()

slide-44
SLIDE 44

RecordHolder rh = new RecordHolder(); byte[] keyZero = StockPartHelper.getKeyZero(); ksds.readForUpdate(keyZero, SearchType.GTEQ, rh); StockPart sp = new StockPart( rh.getValue() );

updateRecord()

slide-45
SLIDE 45

StockPart spRandom = StockPartHelper.generate(); spRandom.setPartId( sp.getPartId() ); ksds.rewrite( spRandom.getByteBuffer() ); Task.getTask().commit(); /rest/ksds/update

updateRecord()

slide-46
SLIDE 46

ksds.readForUpdate(keyZero, SearchType.GTEQ, rh); ksds.delete(); /rest/ksds/delete

deleteRecord()

slide-47
SLIDE 47

Summary

Accessed VSAM KSDS files Structured records Used generated JZOS class Object-oriented model

slide-48
SLIDE 48

Using CICS resources

Accessing temporary storage queues

slide-49
SLIDE 49

Sequence of data items Several possible storage locations Each entry maximum of 32,763 bytes Random access Dynamic definition com.ibm.cics.server.TSQ

Temporary storage concepts

slide-50
SLIDE 50

Sample TSQ application

GET /rest/tsq/write (no cookie) GET /rest/tsq/write (existing cookie) New HTTP session cookie GET /rest/tsq/write (existing cookie) public class TemporaryStorageResource

Application Browser

slide-51
SLIDE 51

generateQueueName()

QN000158D6496C3C

Prefix Timestamp in hex

slide-52
SLIDE 52

writeNewRecord( )

TSQ tsq = getQueue(); StockPart sp = StockPartHelper.generate(); byte[] record = sp.getByteBuffer(); tsq.writeItem(record); return queryQueue(tsq);

slide-53
SLIDE 53

queryQueue( )

ItemHolder holder = new ItemHolder(); tsq.readItem(1, holder);

slide-54
SLIDE 54

updateRecord( )

TSQ tsq = getQueue(); StockPart sp = StockPartHelper.generate(); byte[] record = sp.getByteBuffer(); tsq.rewriteItem(1, record); return queryQueue(tsq);

slide-55
SLIDE 55

deleteQueue( )

TSQ tsq = getQueue(); tsq.delete(); return queryQueue(tsq);

slide-56
SLIDE 56

Using CICS resources

CICS units of work

slide-57
SLIDE 57

Atomicity Consistency Isolation Durability Commit or rollback unit of work

Principles of transaction processing

slide-58
SLIDE 58

Start of task: begin Normal end of task: commit Abnormal end of task: rollback

CICS unit of work support

slide-59
SLIDE 59

Task t = Task.getTask() t.commit()

  • r

t.rollback()

Using JCICS to manage the unit of work

slide-60
SLIDE 60

Units of work VSAM files Temporary storage queues Transient data queues

Summary

slide-61
SLIDE 61

Coping with errors

Error and exception handling

slide-62
SLIDE 62

Expected errors Unexpected errors Fatal errors

Types of errors

slide-63
SLIDE 63

Throwing and catching

try { myMethod() } catch ( . . . ) { } myMethod throw Throwable

Error info

slide-64
SLIDE 64

Java exceptions

java.lang.Throwable java.lang.Exception java.lang.Error java.lang.RuntimeException

slide-65
SLIDE 65

java.lang.Exception Checked exception java.lang.RuntimeException Unchecked exception java.lang.Error Fatal error

Checked and unchecked exceptions

slide-66
SLIDE 66

Per-command response code EXEC CICS READQ TS … RESP(resp-data) Active condition handler EXEC CICS HANDLE CONDITION QIDERR(error-handler) Active abend handler EXEC CICS HANDLE ABEND LABEL(error-handler)

CICS command error handling

1. 2. 3.

slide-67
SLIDE 67

CICS condition exceptions

java.lang.Exception +- c.i.c.s.CicsException +- c.i.c.s.CicsConditionException +- c.i.c.s.CicsResponseConditionException +- c.i.c.s.ItemErrorException +- c.i.c.s.InvalidQueueIdException ... c.i.c.s = com.ibm.cics.server

slide-68
SLIDE 68

public int readItem(int,ItemHolder) throws ItemErrorException, ITEMERROR InvalidQueueIdException, QIDERR . . . TemporaryStorageResource.queryQueue(TSQ)

CICS condition exceptions

slide-69
SLIDE 69

Runtime exceptions

java.lang.RuntimeException +- c.i.c.s.CicsRuntimeException +- c.i.c.s.AbendCancelException +- c.i.c.s.AbendException +- c.i.c.s.CicsThreadingRuntimeException +- c.i.c.s.EndOfProgramException +- c.i.c.s.TransferOfControlException c.i.c.s = com.ibm.cics.server

slide-70
SLIDE 70

try { … } catch ( Exception e ) { // Ignore and continue } try { … } catch ( Exception e ) { // Log and rethrow logger.log(e); throw e; }

Catching exceptions

Do not use Acceptable

slide-71
SLIDE 71

Fatal errors

java.lang.Error com.ibm.cics.server.CicsError

slide-72
SLIDE 72

AJxx abend codes EXEC CICS ABEND abend(), abend(String), abend(String, boolean) EXEC CICS ABEND CANCEL forceAbend(…)

Propagating exceptions to CICS

slide-73
SLIDE 73

try { // Delete the record we have just read ksds.delete(); } catch (RecordNotFoundException rnfe) { // Initial browse failed - no records in file } catch (CicsConditionException cce) { // Some other CICS failure throw new InternalServerErrorException(cce); }

Exception handling example

slide-74
SLIDE 74

Exceptions Checked and unchecked Throwing and catching CICS error conditions and abends Abends and Java exceptions

Summary

slide-75
SLIDE 75

Summary

Course review

slide-76
SLIDE 76

Course review

Invoke CICS programs from Liberty Used JCICS to access VSAM files TSQs Unit of work support Error handling