Mapper procedures and functions
The following sections describe the procedures and functions for the ISF to batch mapper.
CopyEntireMessage
This is a standard procedure that is created by the IBM® App Connect Toolkit. It copies the entire message tree from the InputRoot to the OutputRoot. For outbound mappers, the message tree contains only properties and MQMD headers, so the entire message tree can be copied from the InputRoot.
CREATE PROCEDURE CopyEntireMessage()
BEGIN
SET OutputRoot = InputRoot;
END;
ProcessBatch
This is the procedure to encapsulate the processing of a single batch. References are initialized for the batch and batch headers. The code then loops for each transaction within the batch. Mapping is done by a call to ProcessTransaction() and, after each batch is mapped, the code checks to see if it should be propagated to free memory. After all of the transactions are mapped, the batch header is completed.
CREATE PROCEDURE ProcessBatch()
BEGIN
-- Init rOutputBat and create a placeholder for BatchHeader
CREATE LASTCHILD OF rOutputBody AS rOutputBat NAME 'Batch';
CREATE LASTCHILD OF rOutputBat NAME 'BatchHeader';
-- reset batch counts
SET nBatTxnCount = 0;
MOVE rInputTxn TO rInputBat.Transaction[1];
--------------------------------------------------
-- TXN_ITER loop runs for each object transitioned
--------------------------------------------------
TXN_ITER: WHILE LASTMOVE(rInputTxn) DO
-- this maps one transaction
CALL ProcessTransaction();
IF MOD(nTxnIndex, PROPAGATE_EVERY) = 0 THEN -- control how often we propagate
PROPAGATE TO TERMINAL 1; -- propagate to free memory
END IF;
SET nTxnIndex = nTxnIndex + 1;
SET nBatTxnCount = nBatTxnCount + 1;
-- Go on to the next object
MOVE rInputTxn NEXTSIBLING REPEAT NAME;
END WHILE TXN_ITER;
CALL MapBatchHeader();
END;
ProcessTransaction
This is the procedure to encapsulate the processing of a single transaction. It is similar to the single transaction outbound mapper.
CREATE PROCEDURE ProcessTransaction()
BEGIN
-- this parses the ISF & points rIsf to the root of the ISF tree (ISFMessage)
CALL InitTransactionReference();
-- map the header
CALL MapTransactionHeader();
-- map the transaction body
CALL MapTransaction();
-- collapse tree to a bitstream to save memory
CALL ConvertToFolderBitstream();
END;
InitTransactionReference
This procedure parses the ISF_DATA for a transaction and moves the rIsf reference to point to the ISFMessage element ready for use in mapping.
CREATE PROCEDURE InitTransactionReference()
BEGIN
DECLARE cCacheId CHAR Cache.GetFlowInstanceCacheId(rEnv);
-- Parse the ISF Data into the LocalEnvironment so it can be deleted afterwards
CREATE LASTCHILD OF OutputLocalEnvironment AS rIsf DOMAIN INPUT_DOMAIN
PARSE (rInputTxn.ISF_DATA
OPTIONS Common.GetBitstreamOptionsBitmask(0)
ENCODING 0
CCSID 1208
SET Cache.MessageSet(cCacheId, ISF_FORMAT_NAME)
TYPE Cache.MessageType(cCacheId, ISF_FORMAT_NAME)
FORMAT Cache.MessageFormat(cCacheId, ISF_FORMAT_NAME));
-- TODO BEGIN
-- you can comment this out as a minor optimization if using MRM
IF EXISTS(rIsf.{isf}:ISFMessage[]) THEN
MOVE rIsf TO rIsf.{isf}:ISFMessage; -- required if using XMLNSC
END IF;
-- TODO END
END;
ConvertToFolderBitstream
This procedure takes a single transaction in the message tree and converts it to a folder bit stream, which is the BLOB format. The original transaction tree is removed. This has the effect of maintaining the mapped data on the tree, but releases the tree nodes to conserve memory.
CREATE PROCEDURE ConvertToFolderBitstream()
BEGIN
DECLARE cCacheId CHAR Cache.GetFlowInstanceCacheId(rEnv);
-- convert rOutputTxn to a BLOB
-- and add it in the tree as the next sibling
-- combined into 1 statement to save a extra BLOB copy
CREATE NEXTSIBLING OF rOutputTxn
TYPE OUTPUT_FOLDER_TYPE
NAME FIELDNAME(rOutputTxn)
VALUE ASBITSTREAM(rOutputTxn
OPTIONS FolderBitStream
ENCODING InputProperties.Encoding
CCSID InputProperties.CodedCharSetId
SET Cache.MessageSet(cCacheId, OUTPUT_FORMAT_NAME)
TYPE Cache.MessageType(cCacheId, OUTPUT_FORMAT_NAME)
FORMAT Cache.MessageFormat(cCacheId, OUTPUT_FORMAT_NAME));
-- Move on to the new bitstream field
MOVE rOutputTxn NEXTSIBLING;
-- and then Delete the previous sibling, which is the original
DELETE PREVIOUSSIBLING OF rOutputTxn;
END;