Progress0 of 0 lessons

CICS DOCUMENT CREATE - Document Creation

CICS DOCUMENT CREATE provides document creation capabilities in CICS environments. It enables programs to create documents, manage document operations, and handle document creation for business applications and data management.

Command Syntax

cobol
1
2
3
4
5
6
EXEC CICS DOCUMENT CREATE [DOCUMENT(document-name)] [TEMPLATE(template-name)] [RESP(response-code)] [RESP2(response-code-2)] END-EXEC.

Parameters

DOCUMENT(document-name)

Specifies the name of the document to be created. This parameter identifies the specific document for creation operations.

TEMPLATE(template-name)

Specifies the template to be used for document creation. This parameter defines the structure and format of the created document.

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.

Document Types

Business Documents

DOCUMENT CREATE generates business documents such as invoices, reports, statements, and other business-related documents.

Formatted Documents

The command creates formatted documents with specific layouts, styles, and presentation formats for professional output.

Template-Based Documents

Documents are created using predefined templates that ensure consistency and standardization across document types.

Dynamic Documents

Dynamic documents are created with variable content and data that can be customized based on specific requirements.

Programming Examples

Basic Document Creation

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
WORKING-STORAGE SECTION. 01 DOCUMENT-NAME PIC X(16) VALUE 'INVOICE-001'. 01 TEMPLATE-NAME PIC X(16) VALUE 'INVOICE-TEMPLATE'. 01 RESPONSE-CODE PIC S9(8) COMP. 01 RESPONSE-CODE-2 PIC S9(8) COMP. PROCEDURE DIVISION. EXEC CICS DOCUMENT CREATE DOCUMENT(DOCUMENT-NAME) TEMPLATE(TEMPLATE-NAME) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 DISPLAY 'Document created successfully' ELSE DISPLAY 'Error creating document: ' RESPONSE-CODE END-IF.

Multiple Document Creation

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
WORKING-STORAGE SECTION. 01 DOCUMENT-NAME PIC X(16). 01 TEMPLATE-NAME PIC X(16). 01 RESPONSE-CODE PIC S9(8) COMP. 01 RESPONSE-CODE-2 PIC S9(8) COMP. 01 CREATE-COUNT PIC S9(8) COMP VALUE 0. PROCEDURE DIVISION. PERFORM CREATE-INVOICE-DOCUMENT PERFORM CREATE-STATEMENT-DOCUMENT PERFORM CREATE-REPORT-DOCUMENT. CREATE-INVOICE-DOCUMENT. MOVE 'INVOICE-001' TO DOCUMENT-NAME MOVE 'INVOICE-TEMPLATE' TO TEMPLATE-NAME EXEC CICS DOCUMENT CREATE DOCUMENT(DOCUMENT-NAME) TEMPLATE(TEMPLATE-NAME) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO CREATE-COUNT DISPLAY 'Invoice document created' END-IF. CREATE-STATEMENT-DOCUMENT. MOVE 'STATEMENT-001' TO DOCUMENT-NAME MOVE 'STATEMENT-TEMPLATE' TO TEMPLATE-NAME EXEC CICS DOCUMENT CREATE DOCUMENT(DOCUMENT-NAME) TEMPLATE(TEMPLATE-NAME) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO CREATE-COUNT DISPLAY 'Statement document created' END-IF. CREATE-REPORT-DOCUMENT. MOVE 'REPORT-001' TO DOCUMENT-NAME MOVE 'REPORT-TEMPLATE' TO TEMPLATE-NAME EXEC CICS DOCUMENT CREATE DOCUMENT(DOCUMENT-NAME) TEMPLATE(TEMPLATE-NAME) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO CREATE-COUNT DISPLAY 'Report document created' END-IF.

Dynamic Document Creation

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
WORKING-STORAGE SECTION. 01 DOCUMENT-NAME PIC X(16). 01 TEMPLATE-NAME PIC X(16). 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-DOCUMENT-NAME PERFORM SELECT-TEMPLATE PERFORM CREATE-DOCUMENT END-PERFORM. BUILD-DOCUMENT-NAME. STRING 'DOC-' DELIMITED BY SIZE PROCESSING-COUNT DELIMITED BY SIZE '-' DELIMITED BY SIZE FUNCTION CURRENT-DATE DELIMITED BY SIZE INTO DOCUMENT-NAME. SELECT-TEMPLATE. EVALUATE PROCESSING-COUNT WHEN 1 MOVE 'INVOICE-TEMPLATE' TO TEMPLATE-NAME WHEN 2 MOVE 'STATEMENT-TEMPLATE' TO TEMPLATE-NAME WHEN 3 MOVE 'REPORT-TEMPLATE' TO TEMPLATE-NAME END-EVALUATE. CREATE-DOCUMENT. EXEC CICS DOCUMENT CREATE DOCUMENT(DOCUMENT-NAME) TEMPLATE(TEMPLATE-NAME) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 DISPLAY 'Document ' DOCUMENT-NAME ' created successfully' ELSE DISPLAY 'Error creating document ' DOCUMENT-NAME ': ' RESPONSE-CODE END-IF.

Error Handling

Response Code 0

Successful document creation. The document has been successfully created and is ready for use.

Response Code 8

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

Response Code 12

Invalid template. The specified template is invalid or not found.

Response Code 16

Document already exists. A document with the specified name already exists.

Response Code 20

Insufficient resources. There are not enough resources available to create the document.

Performance Considerations

Template Processing

DOCUMENT CREATE processes templates efficiently, but complex templates may impact creation performance.

Resource Management

Proper resource management ensures efficient document creation and prevents resource exhaustion in high-volume environments.

Document Storage

Document storage requirements should be considered to ensure adequate space for document creation and management.

Best Practices

Error Handling

Always check response codes and handle errors appropriately, especially for template validation and resource limitations.

Document Naming

Use meaningful document names that clearly identify the document type and purpose for better management.

Template Management

Ensure templates are properly defined and available before attempting document creation operations.

Resource Optimization

Optimize document creation by using appropriate templates and implementing efficient document management strategies.

Explain It Like I'm 5 Years Old

Imagine you want to make a special card for your friend. CICS DOCUMENT CREATE is like using a special machine that makes cards using a template (like a cookie cutter).

The document name is like giving your card a special name, and the template is like choosing which cookie cutter shape to use. The machine uses the template to make sure your card looks just right.

Just like you need to make sure you have the right cookie cutter before making cookies, the program needs to make sure the template exists before it can create the document.

Exercises

Exercise 1: Basic Document Creation

Write a program that uses DOCUMENT CREATE to create a document with a specific name and template.

Exercise 2: Multiple Document Types

Create a program that generates different types of documents (invoices, statements, reports) using appropriate templates.

Exercise 3: Dynamic Document Management

Implement a document management system that creates documents dynamically based on business requirements and data.