CICS DOCUMENT RETRIEVE provides document content retrieval capabilities in CICS environments. It enables programs to retrieve document content, manage document operations, and handle document content retrieval for processing and display purposes.
12345678EXEC CICS DOCUMENT RETRIEVE [DOCUMENT(document-name)] [INTO(data-area)] [LENGTH(data-length)] [POSITION(position-value)] [RESP(response-code)] [RESP2(response-code-2)] END-EXEC.
Specifies the name of the document from which content will be retrieved. This parameter identifies the source document for retrieval operations.
Specifies the data area to receive the retrieved document content. This parameter provides the destination for retrieved data.
Specifies the length of the data area to receive retrieved content. This parameter controls the amount of content retrieved.
Specifies the position within the document from which content will be retrieved. This parameter determines the retrieval starting point.
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 RETRIEVE retrieves complete document content, enabling full document processing and analysis operations.
The command supports partial content retrieval for accessing specific sections or portions of documents efficiently.
Position-based retrieval allows content retrieval starting from specific positions within documents for targeted access.
Sequential retrieval enables step-by-step content access for processing large documents in manageable chunks.
123456789101112131415161718192021222324WORKING-STORAGE SECTION. 01 DOCUMENT-NAME PIC X(16) VALUE 'INVOICE-001'. 01 RETRIEVE-DATA PIC X(1000). 01 DATA-LENGTH PIC S9(8) COMP VALUE 1000. 01 RETRIEVE-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 RETRIEVE DOCUMENT(DOCUMENT-NAME) INTO(RETRIEVE-DATA) LENGTH(DATA-LENGTH) POSITION(RETRIEVE-POSITION) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 DISPLAY 'Document content retrieved successfully' DISPLAY 'Retrieved data: ' RETRIEVE-DATA ELSE DISPLAY 'Error retrieving document: ' RESPONSE-CODE END-IF.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061WORKING-STORAGE SECTION. 01 DOCUMENT-NAME PIC X(16) VALUE 'REPORT-001'. 01 RETRIEVE-DATA PIC X(500). 01 DATA-LENGTH PIC S9(8) COMP VALUE 500. 01 RETRIEVE-POSITION PIC S9(8) COMP. 01 RESPONSE-CODE PIC S9(8) COMP. 01 RESPONSE-CODE-2 PIC S9(8) COMP. 01 RETRIEVE-COUNT PIC S9(8) COMP VALUE 0. PROCEDURE DIVISION. PERFORM RETRIEVE-HEADER-SECTION PERFORM RETRIEVE-DETAIL-SECTION PERFORM RETRIEVE-FOOTER-SECTION. RETRIEVE-HEADER-SECTION. MOVE 1 TO RETRIEVE-POSITION EXEC CICS DOCUMENT RETRIEVE DOCUMENT(DOCUMENT-NAME) INTO(RETRIEVE-DATA) LENGTH(DATA-LENGTH) POSITION(RETRIEVE-POSITION) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO RETRIEVE-COUNT DISPLAY 'Header section retrieved' DISPLAY 'Header: ' RETRIEVE-DATA END-IF. RETRIEVE-DETAIL-SECTION. MOVE 501 TO RETRIEVE-POSITION EXEC CICS DOCUMENT RETRIEVE DOCUMENT(DOCUMENT-NAME) INTO(RETRIEVE-DATA) LENGTH(DATA-LENGTH) POSITION(RETRIEVE-POSITION) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO RETRIEVE-COUNT DISPLAY 'Detail section retrieved' DISPLAY 'Details: ' RETRIEVE-DATA END-IF. RETRIEVE-FOOTER-SECTION. MOVE 1001 TO RETRIEVE-POSITION EXEC CICS DOCUMENT RETRIEVE DOCUMENT(DOCUMENT-NAME) INTO(RETRIEVE-DATA) LENGTH(DATA-LENGTH) POSITION(RETRIEVE-POSITION) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 ADD 1 TO RETRIEVE-COUNT DISPLAY 'Footer section retrieved' DISPLAY 'Footer: ' RETRIEVE-DATA END-IF.
1234567891011121314151617181920212223242526272829303132333435363738394041WORKING-STORAGE SECTION. 01 DOCUMENT-NAME PIC X(16) VALUE 'LARGE-DOCUMENT'. 01 RETRIEVE-DATA PIC X(200). 01 DATA-LENGTH PIC S9(8) COMP VALUE 200. 01 RETRIEVE-POSITION PIC S9(8) COMP VALUE 1. 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 > 10 PERFORM CALCULATE-POSITION PERFORM RETRIEVE-CONTENT PERFORM PROCESS-CONTENT END-PERFORM. CALCULATE-POSITION. COMPUTE RETRIEVE-POSITION = (PROCESSING-COUNT - 1) * 200 + 1. RETRIEVE-CONTENT. EXEC CICS DOCUMENT RETRIEVE DOCUMENT(DOCUMENT-NAME) INTO(RETRIEVE-DATA) LENGTH(DATA-LENGTH) POSITION(RETRIEVE-POSITION) RESP(RESPONSE-CODE) RESP2(RESPONSE-CODE-2) END-EXEC IF RESPONSE-CODE = 0 DISPLAY 'Content retrieved at position ' RETRIEVE-POSITION ELSE DISPLAY 'Error retrieving content: ' RESPONSE-CODE END-IF. PROCESS-CONTENT. IF RESPONSE-CODE = 0 DISPLAY 'Processing content: ' RETRIEVE-DATA PERFORM BUSINESS-LOGIC-PROCESSING END-IF.
Successful content retrieval. The document content has been successfully retrieved into the specified data area.
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 retrieval position is invalid or out of range.
Retrieval failed. The content retrieval operation failed due to system conditions.
DOCUMENT RETRIEVE efficiently transfers document content, but large retrievals may impact system performance temporarily.
Proper memory management ensures efficient content retrieval and prevents memory exhaustion in high-volume operations.
Optimize retrieval positions to minimize data transfer overhead and improve processing efficiency.
Always check response codes and handle errors appropriately, especially for document existence and position validation.
Validate retrieved content to ensure data integrity and proper processing of document information.
Allocate appropriate memory sizes for data areas to accommodate retrieved content without overflow.
Optimize retrieval operations by using appropriate data lengths and efficient retrieval strategies.
Imagine you have a big book with lots of stories, and you want to read a specific part of the book. CICS DOCUMENT RETRIEVE is like opening the book to a specific page and reading the words from that page.
The document name is like the name of the book, and the position is like telling the program which page to open. The program reads the words from that page and puts them in a special place for you to use.
Just like you need to make sure you have enough space to write down the words you read, the program needs to make sure it has enough space to store the words it retrieves.
Write a program that uses DOCUMENT RETRIEVE to get content from a document and display the retrieved information.
Create a program that retrieves specific sections of a document by using different position values.
Implement a document processing system that retrieves and processes document content in sequential chunks.