Progress0 of 0 lessons

CICS UPDATE - Data Updating

CICS UPDATE modifies existing data in various destinations, including files, databases, and other storage systems in CICS environments. It enables data modification, record updating, and change processing for CICS applications.

What is CICS UPDATE?

CICS UPDATE modifies existing data in various destinations, including files, databases, and other storage systems. It enables data modification, record updating, and change processing, providing a standardized way to update data in CICS applications.

Command Syntax

cobol
1
2
3
4
5
6
7
8
EXEC CICS UPDATE FILE(file-name) FROM(data-area) LENGTH(length-value) [RIDFLD(record-id)] [RESP(response-code)] [RESP2(response-code-2)] END-EXEC.

Parameters Explained

FILE Parameter

Specifies the file to update:

  • Must be defined in FCT
  • Identifies the target file
  • Required for all UPDATE operations
  • Must be accessible

FROM Parameter

Specifies the data area to update:

  • Must contain valid data to update
  • Contains updated data
  • Required for all UPDATE operations
  • Must be properly aligned

LENGTH Parameter

Specifies the length of the data:

  • Must match actual data length
  • Used for data updating
  • Required for all UPDATE operations
  • Prevents buffer overflow

RIDFLD Parameter

Specifies the record identifier:

  • Optional parameter
  • Used for keyed files
  • Identifies specific record
  • Required for some file types

RESP Parameters

Response codes returned by the command:

  • RESP: Primary response code
  • RESP2: Secondary response code
  • Always check these codes for command success
  • Handle command failures appropriately

Update Types

1. Record Update

  • Full record update: Update entire record
  • Partial record update: Update specific fields
  • Field-level update: Update individual fields
  • Conditional update: Update based on conditions

2. Data Modification

  • Data correction: Correct data errors
  • Data enhancement: Enhance existing data
  • Data transformation: Transform data format
  • Data validation: Validate updated data

3. Change Processing

  • Change tracking: Track data changes
  • Change auditing: Audit data changes
  • Change notification: Notify of changes
  • Change rollback: Rollback changes

Implementation Example

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
WORKING-STORAGE SECTION. 01 WS-RESPONSE PIC S9(8) COMP. 01 WS-RESPONSE2 PIC S9(8) COMP. 01 WS-FILE-NAME PIC X(8) VALUE 'CUSTOMER'. 01 WS-DATA-LENGTH PIC S9(8) COMP VALUE 100. 01 WS-RECORD-ID PIC X(10). 01 WS-CUSTOMER-RECORD. 05 WS-CUSTOMER-ID PIC X(10). 05 WS-CUSTOMER-NAME PIC X(30). 05 WS-CUSTOMER-ADDR PIC X(50). 05 WS-CUSTOMER-PHONE PIC X(10). PROCEDURE DIVISION. * Update customer record in file EXEC CICS UPDATE FILE(WS-FILE-NAME) FROM(WS-CUSTOMER-RECORD) LENGTH(WS-DATA-LENGTH) RIDFLD(WS-RECORD-ID) RESP(WS-RESPONSE) RESP2(WS-RESPONSE2) END-EXEC. IF WS-RESPONSE NOT EQUAL DFHRESP(NORMAL) EXEC CICS WRITE OPERATOR TEXT('UPDATE command failed') END-EXEC EXEC CICS RETURN END-EXEC END-IF. * Record updated successfully * Continue processing

Update Processing

1. Data Preparation

Data preparation includes:

  • Data validation
  • Data formatting
  • Data transformation
  • Data encoding

2. Update Operations

Update operations include:

  • Record locking
  • Data modification
  • Index updating
  • Change tracking

3. Error Handling

Error handling includes:

  • Update error detection
  • Error message generation
  • Error recovery procedures
  • User notification

Common Response Codes

Success Response Codes

  • NORMAL (0): Record updated successfully
  • UPDATE (4): Record updated

Error Response Codes

  • INVREQ (16): Invalid request
  • NOTFND (20): File not found
  • LENGERR (22): Length error
  • UPDATE (24): Update error

Best Practices

1. Data Validation

  • Validate data before updating
  • Check data integrity
  • Handle different data types
  • Ensure data consistency

2. Error Handling

  • Check all response codes
  • Handle update failures
  • Implement retry logic
  • Log error conditions

3. Change Management

  • Track data changes
  • Implement change auditing
  • Handle change rollback
  • Maintain change history

Explain It Like I'm 5 Years Old

Imagine you're editing a drawing:

Sometimes when you're drawing a picture, you want to change something. Maybe you want to make the sun bigger, or change the color of the house, or add more flowers. You don't throw away the whole drawing and start over - you just change the parts you want to be different.

CICS UPDATE is like editing your drawing. The computer program finds the information it wants to change (like finding the part of the drawing you want to edit), makes the changes (like changing the color or size), and saves the updated information (like saving your edited drawing).

Just like you need to be careful when editing your drawing so you don't mess up the whole picture, the computer program needs to be careful when updating information so it doesn't mess up the whole file!

Exercises

Exercise 1: Record Update

Write a CICS UPDATE command to update a customer record in file 'CUSTOMER' with record ID 'CUST001'.

cobol
1
2
3
4
5
6
7
8
EXEC CICS UPDATE FILE('CUSTOMER') FROM(WS-CUSTOMER-RECORD) LENGTH(100) RIDFLD('CUST001') RESP(WS-RESPONSE) RESP2(WS-RESPONSE2) END-EXEC.

Exercise 2: Change Management

How would you implement comprehensive change management that tracks data modifications and handles error conditions?

Answer: Implement change tracking with timestamps and user identification, validate data before updating, handle update failures with proper error messages, implement change auditing for compliance, provide rollback capabilities for critical changes, and maintain change history for audit purposes.

Quiz

Question 1

What is the primary purpose of CICS UPDATE?

Answer: B) To modify existing data

Question 2

Which parameter specifies the file to update?

Answer: A) FILE