The temporary storage classes, IccTempStore and IccTempStoreId, allow you to store data in temporary storage queues.
You can:
An IccTempStore object is used to represent a temporary storage queue. An IccTempStoreId object is used to identify a queue by name. Once the IccTempStoreId object is initialized it can be used to identify the queue as an alternative to using its name, with the advantage of additional error detection by the C++ compiler.
The methods available in IccTempStore class are similar to those in the IccDataQueue class. For more information on these see Transient Data.
The readItem method of IccTempStore reads the specified item from the temporary storage queue. It returns a reference to the IccBuf object that contains the information.
Writing items is also known as "adding" items. This section describes writing items that have not previously been written. Writing items that already exist can be done using the rewriteItem method. See Updating items for more information.
The writeItem method of IccTempStore adds a new item at the end of the queue, taking the data from the buffer specified. If this is done successfully, the item number of the record added is returned.
Updating an item is also known as "rewriting" an item. The rewriteItem method of IccTempStore class is used to update the specified item in the temporary storage queue.
You cannot delete individual items in a temporary storage queue. To delete all the temporary data associated with an IccTempStore object use the empty method of IccTempStore class.
This sample program demonstrates how to use the IccTempStore and IccTempStoreId classes. This program can be found in the samples directory (see Sample source code) as file ICC$TMP. The sample is presented here without the terminal IO requests.
#include "icceh.hpp"
#include "iccmain.hpp"
#include <stdlib.h>
The first three lines include the header files for the foundation classes, the standard main function that sets up the operating environment for the application program, and the standard library.
const char* bufferItems[] =
{
"Hello World - item 1",
"Hello World - item 2",
"Hello World - item 3"
};
This defines some buffer for the sample program.
void IccUserControl::run()
{
The run method of IccUserControl class contains the user code for this example.
short itemNum = 1;
IccTempStoreId id("ICCSTORE");
IccTempStore store( id );
IccBuf buffer( 50 );
store.empty();
This fragment first creates an identification object, IccTempStoreId containing the field "ICCSTORE". It then creates an IccTempStore object representing the temporary storage queue "ICCSTORE", which it empties of records.
for (short j=1 ; j <= 3 ; j++)
{
buffer = bufferItems[j-1];
store.writeItem( buffer );
}
This loop writes the three data items to the Temporary Storage object. The data is passed by means of an IccBuf object that was created for this purpose.
buffer = store.readItem( itemNum );
while ( store.condition() == IccCondition::NORMAL )
{
buffer.insert( 9, "Modified " );
store.rewriteItem( itemNum, buffer );
itemNum++;
buffer = store.readItem( itemNum );
}
This next fragment reads the items back in, modifies the item, and rewrites it to the temporary storage queue. First, the readItem method is used to read the buffer from the temporary storage object. The data in the buffer object is changed using the insert method of IccBuf class and then the rewriteItem method overwrites the buffer. The loop continues with the next buffer item being read.
itemNum = 1;
buffer = store.readItem( itemNum );
while ( store.condition() == IccCondition::NORMAL )
{
term->sendLine( " - record #%d = [%s]", itemNum,
(const char*)buffer );
buffer = store.readNextItem();
}
This loop reads the temporary storage queue items again to show they have been updated.
return;
}
The end of run, which returns control to CICS®.
See Appendix C. Output from sample programs for the expected output from this sample program.
[[ Contents Previous Page | Next Page Index ]]