CICS DOCUMENT INSERT provides document content insertion capabilities in CICS environments. It enables programs to insert content into documents, manage document operations, and handle document content insertion for dynamic document generation.
12345678EXEC CICS DOCUMENT INSERT [DOCUMENT(document-name)] [FROM(data-area)] [LENGTH(data-length)] [POSITION(position-value)] [RESP(response-code)] [RESP2(response-code-2)] END-EXEC.
Specifies the name of the document into which content will be inserted. This parameter identifies the target document for insertion operations.
Specifies the data area containing the content to be inserted into the document. This parameter provides the source data for insertion.
Specifies the length of the data to be inserted into the document. This parameter controls the amount of content inserted.
Specifies the position within the document where content will be inserted. This parameter determines the insertion location.
Specifies the response code variable to receive the operation result. This parameter provides error handling and status information.
Specifies the secondary response code variable for additional error information. This parameter provides extended error details when available.
DOCUMENT INSERT adds text content to documents, enabling dynamic text generation and content customization for business documents.
The command supports data insertion operations for incorporating variable data such as customer information, amounts, and dates.
Template insertion allows insertion of predefined content blocks and formatted sections into document templates.
Conditional insertion enables content insertion based on specific business rules and data conditions.
1234567891011121314151617181920212223WORKING-STORAGE SECTION. 01 DOCUMENT-NAME PIC X(16) VALUE 'INVOICE-001'. 01 INSERT-DATA PIC X(100) VALUE 'Customer: ABC Company'. 01 DATA-LENGTH PIC S9(8) COMP VALUE 100. 01 INSERT-POSITION PIC S9(8) COMP VALUE 1. 01 RESPONSE-CODE PIC S9(8) COMP. 01 RESPONSE-CODE-2 PIC S9(8) COMP. PROCEDURE DIVISION. EXEC CICS DOCUMENT INSERT DOCUMENT(DOCUMENT-NAME) FROM(INSERT-DATA) LENGTH(DATA-LENGTH) POSITION(INSERT-POSITION) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 DISPLAY 'Content inserted successfully' ELSE DISPLAY 'Error inserting content: ' RESPONSE-CODE END-IF.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364WORKING-STORAGE SECTION. 01 DOCUMENT-NAME PIC X(16) VALUE 'INVOICE-001'. 01 INSERT-DATA PIC X(200). 01 DATA-LENGTH PIC S9(8) COMP. 01 INSERT-POSITION PIC S9(8) COMP. 01 RESPONSE-CODE PIC S9(8) COMP. 01 RESPONSE-CODE-2 PIC S9(8) COMP. 01 INSERT-COUNT PIC S9(8) COMP VALUE 0. PROCEDURE DIVISION. PERFORM INSERT-CUSTOMER-INFO PERFORM INSERT-INVOICE-DETAILS PERFORM INSERT-TOTAL-AMOUNT. INSERT-CUSTOMER-INFO. MOVE 'Customer: ABC Company' TO INSERT-DATA MOVE FUNCTION LENGTH(INSERT-DATA) TO DATA-LENGTH MOVE 1 TO INSERT-POSITION EXEC CICS DOCUMENT INSERT DOCUMENT(DOCUMENT-NAME) FROM(INSERT-DATA) LENGTH(DATA-LENGTH) POSITION(INSERT-POSITION) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO INSERT-COUNT DISPLAY 'Customer info inserted' END-IF. INSERT-INVOICE-DETAILS. MOVE 'Invoice Number: INV-001' TO INSERT-DATA MOVE FUNCTION LENGTH(INSERT-DATA) TO DATA-LENGTH MOVE 50 TO INSERT-POSITION EXEC CICS DOCUMENT INSERT DOCUMENT(DOCUMENT-NAME) FROM(INSERT-DATA) LENGTH(DATA-LENGTH) POSITION(INSERT-POSITION) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO INSERT-COUNT DISPLAY 'Invoice details inserted' END-IF. INSERT-TOTAL-AMOUNT. MOVE 'Total Amount: $1,250.00' TO INSERT-DATA MOVE FUNCTION LENGTH(INSERT-DATA) TO DATA-LENGTH MOVE 100 TO INSERT-POSITION EXEC CICS DOCUMENT INSERT DOCUMENT(DOCUMENT-NAME) FROM(INSERT-DATA) LENGTH(DATA-LENGTH) POSITION(INSERT-POSITION) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO INSERT-COUNT DISPLAY 'Total amount inserted' END-IF.
123456789101112131415161718192021222324252627282930313233343536373839404142434445WORKING-STORAGE SECTION. 01 DOCUMENT-NAME PIC X(16) VALUE 'REPORT-001'. 01 INSERT-DATA PIC X(500). 01 DATA-LENGTH PIC S9(8) COMP. 01 INSERT-POSITION PIC S9(8) COMP. 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 > 5 PERFORM BUILD-INSERT-DATA PERFORM CALCULATE-POSITION PERFORM INSERT-CONTENT END-PERFORM. BUILD-INSERT-DATA. STRING 'Section ' DELIMITED BY SIZE PROCESSING-COUNT DELIMITED BY SIZE ': Processing data for step ' DELIMITED BY SIZE PROCESSING-COUNT DELIMITED BY SIZE ' completed at ' DELIMITED BY SIZE FUNCTION CURRENT-DATE DELIMITED BY SIZE INTO INSERT-DATA. MOVE FUNCTION LENGTH(INSERT-DATA) TO DATA-LENGTH. CALCULATE-POSITION. COMPUTE INSERT-POSITION = (PROCESSING-COUNT - 1) * 100 + 1. INSERT-CONTENT. EXEC CICS DOCUMENT INSERT DOCUMENT(DOCUMENT-NAME) FROM(INSERT-DATA) LENGTH(DATA-LENGTH) POSITION(INSERT-POSITION) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 DISPLAY 'Content inserted at position ' INSERT-POSITION ELSE DISPLAY 'Error inserting content: ' RESPONSE-CODE END-IF.
Successful content insertion. The content has been successfully inserted into the document.
Invalid document name. The specified document name is invalid or not supported.
Document not found. The specified document does not exist in the system.
Invalid position. The specified insertion position is invalid or out of range.
Insertion failed. The content insertion operation failed due to system conditions.
DOCUMENT INSERT efficiently manages document size, but large content insertions may impact document processing performance.
Proper position management ensures efficient content insertion and prevents document structure issues.
Content validation before insertion ensures data integrity and prevents document corruption.
Always check response codes and handle errors appropriately, especially for document existence and position validation.
Validate content before insertion to ensure data integrity and prevent document corruption.
Use appropriate insertion positions to maintain document structure and formatting integrity.
Optimize content insertion by using appropriate data lengths and efficient insertion strategies.
Imagine you're writing a story in a notebook, and you want to add more words to your story. CICS DOCUMENT INSERT is like adding new words to your story at a specific place.
The document name is like the name of your story, and the position is like telling the program exactly where in your story to add the new words. The new words go right where you tell them to go.
Just like you need to make sure your notebook has enough space for the new words, the program needs to make sure the document has enough space for the new content.
Write a program that uses DOCUMENT INSERT to add content to a document at a specific position.
Create a program that inserts different types of content (text, data, formatting) into various positions in a document.
Implement a dynamic document building system that inserts content based on business data and requirements.
Understanding CICS document management and operations
Learning about CICS content management and formatting
Understanding CICS dynamic processing and data handling
Learning about CICS error handling and response codes