Posted: Tue May 18, 2004 11:43 am Post subject: What's my problem: Assigning to Environment Variables
Centurion
Joined: 17 May 2002 Posts: 108
I am routing a message thru a compute node that is generating a new XML message to a queue. I would like to alter the logic to have the elements of the new XML message actually assigned to environment variables. I was hoping this would be a simple change of replacing "OutputRoot.XML" variable "Environment.Variable" in the code below... but this is not giving the expected results (particularly, the 'construct diagnostic message' section are not showing up in the variable tree). Thoughts/pointers appreciated.
Code:
-- Enter SQL below this line. SQL above this line might be regenerated,
-- causing any modifications to be lost.
-- This Variable determines whether Specific or General Diagnostic
-- Information is generated.
DECLARE IsSpecific Boolean;
-- Can be dynamically set using the Environment Variable.
SET IsSpecific = True;
DECLARE I Integer;
DECLARE J Integer;
SET J = CARDINALITY("InputRoot".*[]);
SET I = 1;
-- Copying(Properties,MQMD,other headers) the Message Tree except for
-- the Body to the Output.
While I < J do
SET OutputRoot.*[I] = InputRoot.*[I];
SET I=I+1;
End While;
-- Sets the Output Diagnostic Message's Format to be XML.
SET "OutputRoot"."Properties"."MessageFormat" = 'XML';
SET OutputRoot.MQMD.Expiry = -1;
-- Source of the message, which caused the error.
SET OutputRoot.XML.Error.MessageSource.QueueManager =
"InputRoot".MQMD.ReplyToQMgr;
SET OutputRoot.XML.Error.MessageSource.Queue =
"InputRoot".MQMD.SourceQueue;
-- If isSpecific is True Specific Diagnostic Information is Generated.
If IsSpecific = True then
-- Point to the First Child to the ExceptionList Root.
DECLARE Location character;
DECLARE Diagnostics character;
DECLARE DiagnosticsInfo character;
DECLARE Width Integer;
SET Width = 1;
DECLARE Path REFERENCE TO InputExceptionList.*[Width];
-- Check whether the Width of the Exception Tree is more and Proceed.
While LastMove(Path) do
SET Diagnostics = '';
SET DiagnosticsInfo = '';
While FieldName(Path) = 'RecoverableException' or FieldName(Path) =
'DatabaseException' or
FieldName(Path) = 'ConversionException' or FieldName(Path) =
'ParserException' or FieldName(Path) = 'UserException'
do
IF Length(Path.Label) > 0 THEN
SET Location = Path.Label;
End if;
IF Length(Path.Text) > 0 THEN
SET Diagnostics = Diagnostics || Path.Text || '. ';
End if;
MOVE Path Lastchild;
End while;
[b]-- Construct the Specific Diagnostic Message.
MOVE Path Parent;
-- Determine the source of message which caused the error.
SET OutputRoot.XML.Error.Detail[Width].ExceptionType = FieldName(Path);
SET OutputRoot.XML.Error.Detail[Width].ErrorNumber = Path.Number;
SET OutputRoot.XML.Error.Detail[Width].SeverityLevel = Path.Severity;
SET OutputRoot.XML.Error.Detail[Width].ErrorSource = Location;
SET OutputRoot.XML.Error.Detail[Width].DiagnosticMessage= Diagnostics;
MOVE Path FirstChild; [/b]
-- while loop included to generalize coding to ensure future
-- compatiblity in case of change in tree structure and to move
-- the insert's Field.
While FieldName(Path) <> 'Insert' do
MOVE Path NextSibling;
End while;
-- while loop to traverse all the inserts and construct the
-- additional diagnostic message.
While LastMove(Path) do
IF Length(Path.Text) > 0 THEN
SET DiagnosticsInfo = DiagnosticsInfo || Path.Text || '. ';
End if;
MOVE Path NextSibling;
End while;
SET OutputRoot.XML.Error.Detail[Width].CauseOfError = DiagnosticsInfo;
SET OutputRoot.XML.Error.Detail[Width].MessageState =
cast(bitstream(InputBody) as CHAR ccsid 437);
SET Width = Width +1;
MOVE Path TO InputExceptionList.*[Width];
End while;
-- Else part to generate diagnostic message which has the structure
-- of all the trees as when the exception had occured
else
SET I = 1;
While I < J do
SET OutputRoot.XML.Error.*[I] = InputRoot.*[I];
SET I = I + 1;
End while;
SET OutputRoot.XML.Error.Environment = Environment;
SET OutputRoot.XML.Error.LocalEnvironment = InputLocalEnvironment;
SET OutputRoot.XML.Error.MessageState =
cast(bitstream(InputBody) as CHAR ccsid 437);
SET OutputRoot.XML.Error.ExceptionList = InputExceptionList;
End if;
SET OutputRoot.XML.Error.TimeStamp =
SUBSTRING(CAST(CURRENT_TIMESTAMP AS CHAR) FROM 12 FOR 23);
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum