Posted: Mon Nov 10, 2003 9:00 am Post subject: ESQL Odd behaviour
Partisan
Joined: 19 Aug 2002 Posts: 305 Location: Green Mountains of Vermont
I have been experiencing some odd behaviour with ESQL processing within a loop either by using a WHILE or LOOP statement. both present the same issue. Perhaps someone has seen this before. I'm about to submit a PMR on it, but though I would try this first.
Scenario: In simple context in a loop, the iterator is being incremented as soon as it enters the loop, without any statement that causes this.
DECLARE I INTEGER;
DECLARE C INTEGER;
SET I = 1;
SET C = 2;
-- Value of I here is 1
WHILE I <= C
-- Value of I here is 2!
SET I = I + 1;
- Value of I here is 3
END WHILE;
Below is the ESQL which is in error and I have included exceprts of a trace out put which shows this.
The problem is occuring on a WIndows 2000 installation in a compute node iterating through the cardinality.
-- Enter SQL below this line. SQL above this line might be regenerated, causing any modifications to be lost.
DECLARE data_segment REFERENCE TO "InputBody"."Data_record"."BO_SAP_z_shipment_cwdata"."BO_SAP_z_shipment_z2shipment_data000";
DECLARE C INTEGER;
SET C = CARDINALITY (data_segment.BO_SAP_z_shipment_z2shipment_data000[]);
-- Carry along the original MQMD header, leaving the RFH2 header behind.
SET OutputRoot.MQMD = InputRoot.MQMD;
SET OutputRoot.Properties.MessageFormat='XML';
--Create an XML Declaration
SET OutputRoot.XML.(XML.XmlDecl)='';
--Set the Version within the XML Declaration
SET OutputRoot.XML.(XML.XmlDecl).(XML.Version)='1.0';
--Set the Encoding within the XML Declaration
SET OutputRoot.XML.(XML.XmlDecl).(XML."Encoding")='UTF-8';
-- Set XML root
SET OutputRoot.XML.(XML.DocTypeDecl)Z_SHIPMENT ='';
SET OutputRoot.XML.(XML.DocTypeDecl).(XML.SystemId)='NewDtdName.dtd';
-- Set IDOC Header
SET OutputRoot.XML.(XML.Element)IDOC.(XML.Attribute)BEGIN= '1';
--SET C = CAST("InputBody"."Data_record"."BO_SAP_z_shipment_cwdata"."BO_SAP_z_shipment_z2shipment_data000"."size" AS INTEGER);
SET OutputRoot.XML.(XML.Element)COUNT.(XML.Attribute)VALUE= CAST(C AS CHARACTER);
SET OutputRoot.XML.(XML.Element)COUNT1.(XML.Attribute)VALUE= CAST(CARDINALITY (data_segment.BO_SAP_z_shipment_z2shipment_data000[]) AS CHARACTER);
--SET OutputRoot.XML.(XML.Element)Pre_Loop_I_Count.(XML.Attribute)VALUE= CAST(I AS CHARACTER);
DECLARE I INTEGER;
SET I = 1;
SET OutputRoot.XML.(XML.Element)Pre_Set_I_Count.(XML.Attribute)VALUE= CAST(I AS CHARACTER);
WHILE I <= C DO
-- Add some traceing to verify odd behaviour
SET OutputRoot.XML.(XML.Element)Loop_C_Count.(XML.Attribute)VALUE= CAST(C AS CHARACTER);
SET OutputRoot.XML.(XML.Element)Loop_I_Count.(XML.Attribute)VALUE= CAST(I AS CHARACTER);
SET OutputRoot.XML.(XML.Element)Z1SHIPMENT_DATA.(XML.Attribute)SEGMENT= '1';
SET OutputRoot.XML.(XML.Element)LOT_NUMBER=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].LOT_NUMBER;
SET OutputRoot.XML.(XML.Element)PART_NUMBER=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].PART_NUMBER;
SET OutputRoot.XML.(XML.Element)BUILD_LEVEL=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].BUILD_LEVEL;
SET OutputRoot.XML.(XML.Element)SOURCE_LOCATION=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].SOURCE_LOCATION;
SET OutputRoot.XML.(XML.Element)STORAGE_LOCATION=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].STORAGE_LOCATION;
SET OutputRoot.XML.(XML.Element)SOLD_TO_LOCATION=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].SOLD_TO_LOCATION;
SET OutputRoot.XML.(XML.Element)SOLD_TO_DESCRIPTION=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].SOLD_TO_DESCRIPTION;
SET OutputRoot.XML.(XML.Element)SHIP_TO_LOCATION=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].SHIP_TO_LOCATION;
SET OutputRoot.XML.(XML.Element)SHIP_TO_DESCRIPTION=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].SHIP_TO_DESCRIPTION;
SET OutputRoot.XML.(XML.Element)SHIP_DATE=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].SHIP_DATE;
SET OutputRoot.XML.(XML.Element)SHIP_TIME=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].SHIP_TIME;
SET OutputRoot.XML.(XML.Element)DELIVERY_NUMBER=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].DELIVERY_NUMBER;
SET OutputRoot.XML.(XML.Element)DELIVERY_LINE_ITEM=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].DELIVERY_LINE_ITEM;
SET OutputRoot.XML.(XML.Element)DELIVERY_QTY=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].DELIVERY_QTY;
SET OutputRoot.XML.(XML.Element)SALES_ORDER_NUMBER=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].SALES_ORDER_NUMBER;
SET OutputRoot.XML.(XML.Element)POI=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].POI;
SET OutputRoot.XML.(XML.Element)TRANSACTION_ID=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].TRANSACTION_ID;
SET OutputRoot.XML.(XML.Element)MOVEMENT_TYPE=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].MOVEMENT_TYPE;
SET OutputRoot.XML.(XML.Element)MATERIAL_DOC_NUM=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].MATERIAL_DOC_NUM;
SET OutputRoot.XML.(XML.Element)USER_ID=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].USER_ID;
SET OutputRoot.XML.(XML.Element)TRANSACTION_DATE=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].TRANSACTION_DATE;
SET OutputRoot.XML.(XML.Element)TRANSACTION_TIME=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].TRANSACTION_TIME;
SET OutputRoot.XML.(XML.Element)LOT_NUMBER=data_segment.BO_SAP_z_shipment_z2shipment_data000[I].LOT_NUMBER;
SET I = I + 1;
SET OutputRoot.XML.(XML.Element)Post_Loop_I_Count.(XML.Attribute)VALUE= CAST(I AS CHARACTER);
SET OutputRoot.XML.(XML.Element)Post_Loop_C_Count.(XML.Attribute)VALUE= CAST(C AS CHARACTER);
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