You can place bookmarks in a document to delimit an area of
data
that can be replaced by a later insertion, or deleted. This technique lets
you provide a default item of text or other data in your document,
which can
be used if your application finds that no data is available to replace
it.
About this task
To set up and replace, or delete, a default item of data in a
document:
Procedure
- Create the document, specifying any data to be used at the
beginning
of the document. For this example, a document is
created with some initial text, and its token is returned in the variable
MYDOCREP:
EXEC CICS DOCUMENT CREATE
DOCTOKEN(MYDOCREP)
TEXT('Initial sample text. ')
LENGTH(21)
- Use the DOCUMENT INSERT command to specify the first bookmark:
EXEC CICS DOCUMENT INSERT
DOCTOKEN(MYDOCREP)
BOOKMARK('BMark1 ')
- Use the DOCUMENT INSERT command to specify the item of text or
other data to be replaced:
EXEC CICS DOCUMENT INSERT
DOCTOKEN(MYDOCREP)
TEXT('Text to be replaced. ')
LENGTH(21)
- Use the DOCUMENT INSERT command to specify the closing
bookmark:
EXEC CICS DOCUMENT INSERT
DOCTOKEN(MYDOCREP)
BOOKMARK('BMark2 ')
- Use the DOCUMENT INSERT command to add any data to be used at
the
end of the document:
EXEC CICS DOCUMENT INSERT
DOCTOKEN(MYDOCREP)
TEXT('Final sample text. ')
LENGTH(19)
At this point, the logical
structure of this example document is:
Initial sample text. <BMark1>Text to be replaced.
<BMark2>Final
sample text.
The names of the bookmarks do not appear in the
document.
- To replace the text between the two bookmarks, BMark1 and
BMark2,
use the DOCUMENT INSERT command with the AT and TO options:
EXEC CICS DOCUMENT INSERT
DOCTOKEN(ATOKEN)
TEXT('Replacement Text. ')
LENGTH(18)
AT('BMark1 ')
TO('BMark2 ')
Now the
example document appears as follows:
Initial sample text. Replacement Text. Final
sample text.
- To delete the text between the two bookmarks, use the DOCUMENT
INSERT command with the AT and TO options as above, but use the
TEXT or BINARY
option to specify a null string, with a LENGTH of zero.