Progress0 of 0 lessons

CICS ASSIGN - Resource Assignment

CICS ASSIGN provides resource assignment capabilities in CICS environments. It enables programs to assign resources, manage resource operations, and handle resource assignment for system control and data management purposes.

Command Syntax

cobol
1
2
3
4
5
6
7
EXEC CICS ASSIGN [RESOURCE(resource-name)] [VALUE(assignment-value)] [TYPE(resource-type)] [RESP(response-code)] [RESP2(response-code-2)] END-EXEC.

Parameters

RESOURCE(resource-name)

Specifies the name of the resource to be assigned. This parameter identifies the specific resource for assignment operations.

VALUE(assignment-value)

Specifies the value to be assigned to the resource. This parameter provides the assignment value for the resource configuration.

TYPE(resource-type)

Specifies the type of resource being assigned. This parameter identifies the resource type for proper assignment handling.

RESP(response-code)

Specifies the response code variable to receive the operation result. This parameter provides error handling and status information.

RESP2(response-code-2)

Specifies the secondary response code variable for additional error information. This parameter provides extended error details when available.

Assignment Types

System Resource Assignment

ASSIGN assigns system resources such as terminals, files, and queues, enabling programs to control resource allocation and usage.

Data Resource Assignment

The command supports data resource assignment for managing data areas, temporary storage, and data queue resources.

Communication Resource Assignment

Communication resource assignment enables control of communication channels, sessions, and network resources.

Processing Resource Assignment

Processing resource assignment controls program execution, transaction processing, and system operation parameters.

Programming Examples

Basic Resource Assignment

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
WORKING-STORAGE SECTION. 01 RESOURCE-NAME PIC X(16) VALUE 'TERMINAL-001'. 01 ASSIGNMENT-VALUE PIC X(20) VALUE 'ONLINE'. 01 RESOURCE-TYPE PIC X(10) VALUE 'TERMINAL'. 01 RESPONSE-CODE PIC S9(8) COMP. 01 RESPONSE-CODE-2 PIC S9(8) COMP. PROCEDURE DIVISION. EXEC CICS ASSIGN RESOURCE(RESOURCE-NAME) VALUE(ASSIGNMENT-VALUE) TYPE(RESOURCE-TYPE) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 DISPLAY 'Resource assigned successfully' DISPLAY 'Resource: ' RESOURCE-NAME DISPLAY 'Value: ' ASSIGNMENT-VALUE DISPLAY 'Type: ' RESOURCE-TYPE ELSE DISPLAY 'Error assigning resource: ' RESPONSE-CODE END-IF.

Multiple Resource Assignment

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
WORKING-STORAGE SECTION. 01 RESOURCE-NAME PIC X(16). 01 ASSIGNMENT-VALUE PIC X(20). 01 RESOURCE-TYPE PIC X(10). 01 RESPONSE-CODE PIC S9(8) COMP. 01 RESPONSE-CODE-2 PIC S9(8) COMP. 01 ASSIGN-COUNT PIC S9(8) COMP VALUE 0. PROCEDURE DIVISION. PERFORM ASSIGN-TERMINAL-RESOURCE PERFORM ASSIGN-FILE-RESOURCE PERFORM ASSIGN-QUEUE-RESOURCE. ASSIGN-TERMINAL-RESOURCE. MOVE 'TERMINAL-001' TO RESOURCE-NAME MOVE 'ONLINE' TO ASSIGNMENT-VALUE MOVE 'TERMINAL' TO RESOURCE-TYPE EXEC CICS ASSIGN RESOURCE(RESOURCE-NAME) VALUE(ASSIGNMENT-VALUE) TYPE(RESOURCE-TYPE) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO ASSIGN-COUNT DISPLAY 'Terminal resource assigned' END-IF. ASSIGN-FILE-RESOURCE. MOVE 'FILE-001' TO RESOURCE-NAME MOVE 'OPEN' TO ASSIGNMENT-VALUE MOVE 'FILE' TO RESOURCE-TYPE EXEC CICS ASSIGN RESOURCE(RESOURCE-NAME) VALUE(ASSIGNMENT-VALUE) TYPE(RESOURCE-TYPE) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO ASSIGN-COUNT DISPLAY 'File resource assigned' END-IF. ASSIGN-QUEUE-RESOURCE. MOVE 'QUEUE-001' TO RESOURCE-NAME MOVE 'ACTIVE' TO ASSIGNMENT-VALUE MOVE 'QUEUE' TO RESOURCE-TYPE EXEC CICS ASSIGN RESOURCE(RESOURCE-NAME) VALUE(ASSIGNMENT-VALUE) TYPE(RESOURCE-TYPE) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO ASSIGN-COUNT DISPLAY 'Queue resource assigned' END-IF.

Dynamic Resource Assignment

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
WORKING-STORAGE SECTION. 01 RESOURCE-NAME PIC X(16). 01 ASSIGNMENT-VALUE PIC X(20). 01 RESOURCE-TYPE PIC X(10). 01 RESPONSE-CODE PIC S9(8) COMP. 01 RESPONSE-CODE-2 PIC S9(8) COMP. 01 PROCESSING-COUNT PIC S9(8) COMP VALUE 0. PROCEDURE DIVISION. PERFORM VARYING PROCESSING-COUNT FROM 1 BY 1 UNTIL PROCESSING-COUNT > 3 PERFORM BUILD-RESOURCE-NAME PERFORM BUILD-ASSIGNMENT-VALUE PERFORM SELECT-RESOURCE-TYPE PERFORM ASSIGN-RESOURCE END-PERFORM. BUILD-RESOURCE-NAME. STRING 'RESOURCE-' DELIMITED BY SIZE PROCESSING-COUNT DELIMITED BY SIZE INTO RESOURCE-NAME. BUILD-ASSIGNMENT-VALUE. EVALUATE PROCESSING-COUNT WHEN 1 MOVE 'ONLINE' TO ASSIGNMENT-VALUE WHEN 2 MOVE 'OPEN' TO ASSIGNMENT-VALUE WHEN 3 MOVE 'ACTIVE' TO ASSIGNMENT-VALUE END-EVALUATE. SELECT-RESOURCE-TYPE. EVALUATE PROCESSING-COUNT WHEN 1 MOVE 'TERMINAL' TO RESOURCE-TYPE WHEN 2 MOVE 'FILE' TO RESOURCE-TYPE WHEN 3 MOVE 'QUEUE' TO RESOURCE-TYPE END-EVALUATE. ASSIGN-RESOURCE. EXEC CICS ASSIGN RESOURCE(RESOURCE-NAME) VALUE(ASSIGNMENT-VALUE) TYPE(RESOURCE-TYPE) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 DISPLAY 'Resource ' RESOURCE-NAME ' assigned successfully' DISPLAY 'Value: ' ASSIGNMENT-VALUE DISPLAY 'Type: ' RESOURCE-TYPE ELSE DISPLAY 'Error assigning resource ' RESOURCE-NAME ': ' RESPONSE-CODE END-IF.

Error Handling

Response Code 0

Successful resource assignment. The resource has been successfully assigned with the specified value.

Response Code 8

Invalid resource name. The specified resource name is invalid or not supported.

Response Code 12

Invalid assignment value. The specified assignment value is invalid or not compatible with the resource.

Response Code 16

Resource not available. The specified resource is not available for assignment.

Response Code 20

Assignment failed. The resource assignment operation failed due to system conditions.

Performance Considerations

Resource Allocation Efficiency

ASSIGN efficiently allocates resources, but frequent resource assignment operations may impact system performance.

Resource Management

Proper resource management ensures efficient assignment operations and prevents resource conflicts and exhaustion.

Assignment Validation

Assignment validation ensures that resource assignments are valid and compatible with system requirements.

Best Practices

Error Handling

Always check response codes and handle errors appropriately, especially for resource availability and assignment validation.

Resource Validation

Validate resource names and assignment values before assignment to ensure compatibility and prevent errors.

Resource Management

Implement proper resource management strategies to ensure efficient assignment and prevent resource conflicts.

Assignment Optimization

Optimize resource assignments by using appropriate resource types and values for specific use cases.

Explain It Like I's 5 Years Old

Imagine you're organizing your toys and you want to give each toy a special job. CICS ASSIGN is like telling each toy what job it should do and how it should do it.

The resource name is like the name of your toy, the assignment value is like what job you want it to do, and the resource type is like what kind of toy it is. You tell each toy its job so everything works together nicely.

Just like you need to make sure each toy can do the job you give it, the program needs to make sure each resource can do the job it's assigned to do.

Exercises

Exercise 1: Basic Resource Assignment

Write a program that uses ASSIGN to assign a resource with a specific name, value, and type.

Exercise 2: Multiple Resource Management

Create a program that assigns multiple resources of different types and manages their assignments.

Exercise 3: Dynamic Resource Assignment

Implement a resource assignment system that dynamically assigns resources based on business requirements.