ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » LAST MOVE loop is not working

Post new topic  Reply to topic Goto page 1, 2  Next
 LAST MOVE loop is not working « View previous topic :: View next topic » 
Author Message
ydeonia
PostPosted: Thu May 09, 2013 9:46 pm    Post subject: LAST MOVE loop is not working Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

Hi

my xml looks like

Code:
- <ItemMaster>
     - <ItemMasterHeader>
        + <ItemID>
        + <ItemStatus>
        + <UserArea>
         - <Classification Type="HOMOLOGATION CLASS">
           - <Codes>
             <Code>E</Code>
           </Codes>
         </Classification>
       + <Classification Type="LP">
       + <Classification>
        - <Classification Type="BRAND">
          - <Codes>
              <Code>002</Code>
          </Codes>
        </Classification>


I need to fetch the value of Classification with attribute TYPE= "BRAND" but with below code, it only fetchs the classification with attribute TYPE = "HOMOLOGATION CLASS" which I dont want since I am calling for "BRAND". I tried to apply LASTMOVE but dosent work. Please tell me where I am wrong.

Code:
DECLARE rResource REFERENCE TO InputRoot.XMLNSC.*:SyncItemMaster.*:DataArea.*:ItemMaster.*:ItemMasterHeader[1];
      SET rowCnt = rowCnt+1;      
      DECLARE LineCount INTEGER 1;

      WHILE LASTMOVE(rResource) = TRUE DO   
      SET OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd = THE (SELECT  ITEM FIELDVALUE(T) FROM itemMaster.*:ItemMasterHeader[LineCount].*:Classification.*:Codes.*:Code AS T WHERE FIELDVALUE(itemMaster.*:ItemMasterHeader[LineCount].*:Classification.(XMLNSC.Attribute)Type) = 'BRAND');
            SET LineCount = LineCount + 1;
      MOVE rResource NEXTSIBLING REPEAT TYPE NAME;
       END WHILE;            
   RETURN TRUE;
   END;


Thanks


Last edited by ydeonia on Thu May 09, 2013 10:37 pm; edited 1 time in total
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu May 09, 2013 10:18 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

What does a user trace of your code tell you?

Any 'element does not exists' cases?
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
ydeonia
PostPosted: Thu May 09, 2013 10:36 pm    Post subject: Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

smdavies99 wrote:
What does a user trace of your code tell you?

Any 'element does not exists' cases?


It trace log it maches the value like This resolved to '''HOMOLOGATION CLASS' = 'BRAND'''. The result was ''FALSE''.

Code:
013-05-10 14:26:51.740131    11804   UserTrace   BIP2540I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Finished evaluating expression ''FIELDVALUE(itemMaster.*:ItemMasterHeader.*:Classification.(XMLNSC.Attribute)*:*)'' at ('.WMB_9D1_PROD_SUB00_001.Main', '23.6'). The result was '''HOMOLOGATION CLASS'''.


2013-05-10 14:26:51.740150    11804   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''FIELDVALUE(itemMaster.*:ItemMasterHeader.*:Classification.(XMLNSC.Attribute)*:*) = 'BRAND''' at ('.WMB_9D1_PROD_SUB00_001.Main', '23.85'). This resolved to '''HOMOLOGATION CLASS' = 'BRAND'''. The result was ''FALSE''.
Back to top
View user's profile Send private message
RAJASHEKAR REDDY
PostPosted: Thu May 09, 2013 11:08 pm    Post subject: Reply with quote

Novice

Joined: 09 May 2013
Posts: 13

Hi ,

may be you are taking declaration was wroung, whenever your using LastMove you shoud take repeated field in LASTMOVE().

so in your code take reference to classification like bellow

DECLARE rResource REFERENCE TO InputRoot.XMLNSC.*:SyncItemMaster.*:DataArea.*:ItemMaster.*:ItemMasterHeader.*:classification[1];

small information for good practice of code ( better to dnt use wildcards, it will take time process)
Back to top
View user's profile Send private message
adubya
PostPosted: Fri May 10, 2013 12:10 am    Post subject: Reply with quote

Partisan

Joined: 25 Aug 2011
Posts: 377
Location: GU12, UK

Code:
DECLARE rResource REFERENCE TO InputRoot.XMLNSC.*:SyncItemMaster.*:DataArea.*:ItemMaster.*:ItemMasterHeader[1];
      SET rowCnt = rowCnt+1;       
      DECLARE LineCount INTEGER 1;

      WHILE LASTMOVE(rResource) = TRUE DO   
      SET OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd = THE (SELECT  ITEM FIELDVALUE(T) FROM itemMaster.*:ItemMasterHeader[LineCount].*:Classification.*:Codes.*:Code AS T WHERE FIELDVALUE(itemMaster.*:ItemMasterHeader[LineCount].*:Classification.(XMLNSC.Attribute)Type) = 'BRAND');
            SET LineCount = LineCount + 1;
      MOVE rResource NEXTSIBLING REPEAT TYPE NAME;
       END WHILE;             
   RETURN TRUE;
   END;


In your SELECT you're referencing "itemMaster" as a variable, I can't see this defined anywhere.

Did you actually mean the following ?

Code:
DECLARE rResource REFERENCE TO InputRoot.XMLNSC.*:SyncItemMaster.*:DataArea.*:ItemMaster.*:ItemMasterHeader[1];
      SET rowCnt = rowCnt+1;       
      DECLARE LineCount INTEGER 1;

      WHILE LASTMOVE(rResource) = TRUE DO   
      SET OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd = THE (SELECT  ITEM FIELDVALUE(T) FROM rResource.*:Classification.*:Codes.*:Code AS T WHERE FIELDVALUE(rResource.*:Classification.(XMLNSC.Attribute)Type) = 'BRAND');
            SET LineCount = LineCount + 1;
      MOVE rResource NEXTSIBLING REPEAT TYPE NAME;
       END WHILE;             
   RETURN TRUE;
   END;


I haven't addressed the issue you have over the use of rowCnt when populating the OutputRoot structure, I'll let you sort that
Back to top
View user's profile Send private message Send e-mail
ydeonia
PostPosted: Fri May 10, 2013 1:13 am    Post subject: Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

adubya wrote:

I haven't addressed the issue you have over the use of rowCnt when populating the OutputRoot structure, I'll let you sort that


Thanks a lot but it didnt worked. Below is trace . Its not iterating .

Code:
2013-05-10 17:09:42.540618     9188   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''myref.*:Classification.*:Codes.*:Code'' at ('.WMB_9D1_PROD_SUB00_001.Main', '25.108'). This resolved to ''myref.*:Classification.*:Codes.*:Code''. The result was ''ROW... Root Element Type=50331648 NameSpace='' Name='Code' Value='E'''.
2013-05-10 17:09:42.540637     9188   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''XMLNSC.Attribute'' at ('.WMB_9D1_PROD_SUB00_001.Main', '25.192'). This resolved to ''XMLNSC.Attribute''. The result was ''1095266992384''.
2013-05-10 17:09:42.540653     9188   UserTrace   BIP2540I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Finished evaluating expression ''FIELDVALUE(myref.*:Classification.(XMLNSC.Attribute)Type)'' at ('.WMB_9D1_PROD_SUB00_001.Main', '25.157'). The result was '''HOMOLOGATION CLASS'''.
2013-05-10 17:09:42.540668     9188   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''FIELDVALUE(myref.*:Classification.(XMLNSC.Attribute)Type) = 'BRAND''' at ('.WMB_9D1_PROD_SUB00_001.Main', '25.215'). This resolved to '''HOMOLOGATION CLASS' = 'BRAND'''. The result was ''FALSE''.
2013-05-10 17:09:42.540676     9188   UserTrace   BIP2569W: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': ('.WMB_9D1_PROD_SUB00_001.Main', '25.72') : WHERE clause evaluated to false or unknown.  Iterating FROM clause.
2013-05-10 17:09:42.540687     9188   UserTrace   BIP2570W: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': ('.WMB_9D1_PROD_SUB00_001.Main', '25.72') : There were no items in the FROM clause satisfying the WHERE clause.
2013-05-10 17:09:42.540702     9188   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''rowCnt'' at ('.WMB_9D1_PROD_SUB00_001.Main', '25.37'). This resolved to ''rowCnt''. The result was ''1''.
2013-05-10 17:09:42.540718     9188   UserTrace   BIP2567I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Assigning NULL to ''OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd'', thus deleting it.



The code I used

Code:
CREATE COMPUTE MODULE WMB_9D1_PROD_SUB00_001
   CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
   CALL CopyMessageHeaders();
   --CALL CopyEntireMessage();
   DECLARE itemMaster REFERENCE TO InputRoot.XMLNSC.*:SyncItemMaster.*:DataArea.*:ItemMaster;   
   -- Construct Final Response XML
   
      DECLARE rowCnt INTEGER 0;
      DECLARE LineCount INTEGER 1;
      --DECLARE rResource REFERENCE TO InputRoot.XMLNSC.*:SyncItemMaster.*:DataArea.*:ItemMaster.*:ItemMasterHeader[1];
      
      DECLARE myref REFERENCE TO InputRoot.XMLNSC.*:SyncItemMaster.*:DataArea.*:ItemMaster.*:ItemMasterHeader[1];   
      
      SET rowCnt = rowCnt+1;      
      SET OutputRoot.XMLNSC.root.(XMLNSC.Attribute)name='Product';
      SET OutputRoot.XMLNSC.root.row[rowCnt].product_Info.ProductCd =  THE (SELECT ITEM FIELDVALUE(T) FROM itemMaster.*:ItemMasterHeader.*:ItemID.*:VariationID AS T where FIELDVALUE(T.(XMLNSC.Attribute)SchemeName)='CAI');
      
      WHILE LASTMOVE(myref)= TRUE DO   

       SET OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd = THE (SELECT ITEM FIELDVALUE(T) FROM myref.*:Classification.*:Codes.*:Code AS T WHERE FIELDVALUE(myref.*:Classification.(XMLNSC.Attribute)Type) = 'BRAND');
       
       SET LineCount = LineCount + 1;
      MOVE myref NEXTSIBLING;
      END WHILE;            
   RETURN TRUE;
   END;
Back to top
View user's profile Send private message
ydeonia
PostPosted: Fri May 10, 2013 1:21 am    Post subject: Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

RAJASHEKAR REDDY wrote:

small information for good practice of code ( better to dnt use wildcards, it will take time process)


Thanks to you also .

it somewhat worked

But I dont know inspite of that it found teh value . it dont set the value in the output field

here are trace log

Code:
2013-05-10 17:17:04.131209    11056   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''LineCount'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.152'). This resolved to ''LineCount''. The result was ''6''.
2013-05-10 17:17:04.131220    11056   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''LineCount'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.152'). This resolved to ''LineCount''. The result was ''6''.
2013-05-10 17:17:04.131262    11056   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''itemMaster.*:ItemMasterHeader.*:Classification[LineCount].*:Codes.*:Code'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.105'). This resolved to ''itemMaster.*:ItemMasterHeader.*:Classification[6].*:Codes.*:Code''. The result was ''ROW... Root Element Type=50331648 NameSpace='' Name='Code' Value='002'''.
2013-05-10 17:17:04.131276    11056   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''LineCount'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.247'). This resolved to ''LineCount''. The result was ''6''.
2013-05-10 17:17:04.131292    11056   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''XMLNSC.Attribute'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.259'). This resolved to ''XMLNSC.Attribute''. The result was ''1095266992384''.
2013-05-10 17:17:04.131305    11056   UserTrace   BIP2540I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Finished evaluating expression ''FIELDVALUE(itemMaster.*:ItemMasterHeader.*:Classification[LineCount].(XMLNSC.Attribute)Type)'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.189'). The result was '''BRAND'''.
2013-05-10 17:17:04.131319    11056   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''FIELDVALUE(itemMaster.*:ItemMasterHeader.*:Classification[LineCount].(XMLNSC.Attribute)Type) = 'BRAND''' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.282'). This resolved [b]to '''BRAND' = 'BRAND'''. The result was ''TRUE''. [/b]
2013-05-10 17:17:04.131330    11056   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''rowCnt'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.34'). This resolved to ''rowCnt''. The result was ''1''.
2013-05-10 17:17:04.131351    11056   UserTrace   BIP2540I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Finished evaluating expression ''FIELDVALUE(T)'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.86'). The result was '''002'''.
2013-05-10 17:17:04.131363    11056   UserTrace   BIP2566I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': [b]Assigning value       '''002''' to field / variable [/b]''OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd''.
2013-05-10 17:17:04.131379    11056   UserTrace   BIP2537I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Executing statement   ''SET LineCount = LineCount + 1;'' at ('.WMB_9D1_PROD_SUB00_001.Main', '23.6').
2013-05-10 17:17:04.131389    11056   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''LineCount'' at ('.WMB_9D1_PROD_SUB00_001.Main', '23.22'). This resolved to ''LineCount''. The result was ''6''.
2013-05-10 17:17:04.131398    11056   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''LineCount + 1'' at ('.WMB_9D1_PROD_SUB00_001.Main', '23.32'). This resolved to ''6 + 1''. The result was ''7''.
2013-05-10 17:17:04.131409    11056   UserTrace   BIP2537I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Executing statement   ''MOVE myref NEXTSIBLING;'' at ('.WMB_9D1_PROD_SUB00_001.Main', '24.3').
2013-05-10 17:17:04.131419    11056   UserTrace   BIP2540I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Finished evaluating expression ''LASTMOVE(myref)'' at ('.WMB_9D1_PROD_SUB00_001.Main', '20.9'). The result was ''TRUE''.
2013-05-10 17:17:04.131433    11056   UserTrace   BIP2537I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Executing statement   ''SET OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd = THE (SELECT ITEM FIELDVALUE(T) FROM itemMaster.*:ItemMasterHeader.*:Classification[LineCount].*:Codes.*:Code AS T WHERE FIELDVALUE(itemMaster.*:ItemMasterHeader.*:Classification[LineCount].(XMLNSC.Attribute)Type) = 'BRAND');'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.3').
2013-05-10 17:17:04.131441    11056   UserTrace   BIP2538I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''THE (SELECT ITEM FIELDVALUE(T) FROM itemMaster.*:ItemMasterHeader.*:Classification[LineCount].*:Codes.*:Code AS T WHERE FIELDVALUE(itemMaster.*:ItemMasterHeader.*:Classification[LineCount].(XMLNSC.Attribute)Type) = 'BRAND')'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.69').
2013-05-10 17:17:04.131473    11056   UserTrace   BIP2572W: Node: 'WMB_9D1_PROD_SUB00_001.9D1_PROD': ('.WMB_9D1_PROD_SUB00_001.Main', '22.69') : Finding one and only SELECT result.
2013-05-10 17:17:04.131483    11056   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''LineCount'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.152'). This resolved to ''LineCount''. The result was ''7''.
2013-05-10 17:17:04.131491    11056   UserTrace   BIP2543I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': ('.WMB_9D1_PROD_SUB00_001.Main', '22.105') : [b]Failed to navigate to path element number '4' because it does not exist. [/b]
2013-05-10 17:17:04.131499    11056   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''LineCount'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.152'). This resolved to ''LineCount''. The result was ''7''.
2013-05-10 17:17:04.131508    11056   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''itemMaster.*:ItemMasterHeader.*:Classification[LineCount].*:Codes.*:Code'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.105'). This resolved to ''itemMaster.*:ItemMasterHeader.*:Classification[7].*:Codes.*:Code''. The result was ''EMPTY ROW''.
2013-05-10 17:17:04.131516    11056   UserTrace   BIP2570W: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': ('.WMB_9D1_PROD_SUB00_001.Main', '22.69') : There were no items in the FROM clause satisfying the WHERE clause.
2013-05-10 17:17:04.131525    11056   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''rowCnt'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.34'). This resolved to ''rowCnt''. The result was ''1''.
2013-05-10 17:17:04.131536    11056   UserTrace   BIP2567I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD':[b] Assigning NULL to ''OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd'', thus deleting it.[/b]



here is the code I used for this

Code:
CREATE COMPUTE MODULE WMB_9D1_PROD_SUB00_001
   CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
   CALL CopyMessageHeaders();
   --CALL CopyEntireMessage();
   DECLARE itemMaster REFERENCE TO InputRoot.XMLNSC.*:SyncItemMaster.*:DataArea.*:ItemMaster;   
   -- Construct Final Response XML
   
      DECLARE rowCnt INTEGER 0;
      DECLARE LineCount INTEGER 1;
      DECLARE myref REFERENCE TO InputRoot.XMLNSC.*:SyncItemMaster.*:DataArea.*:ItemMaster.*:ItemMasterHeader.*:Classification[1];   
      
      SET rowCnt = rowCnt+1;      
      SET OutputRoot.XMLNSC.root.(XMLNSC.Attribute)name='Product';
      SET OutputRoot.XMLNSC.root.row[rowCnt].product_Info.ProductCd =  THE (SELECT ITEM FIELDVALUE(T) FROM itemMaster.*:ItemMasterHeader.*:ItemID.*:VariationID AS T where FIELDVALUE(T.(XMLNSC.Attribute)SchemeName)='CAI');
      
      WHILE LASTMOVE(myref) DO   
         
      SET OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd = THE (SELECT ITEM FIELDVALUE(T) FROM itemMaster.*:ItemMasterHeader.*:Classification[LineCount].*:Codes.*:Code AS T WHERE FIELDVALUE(itemMaster.*:ItemMasterHeader.*:Classification[LineCount].(XMLNSC.Attribute)Type) = 'BRAND');
       SET LineCount = LineCount + 1;
      MOVE myref NEXTSIBLING;
      END WHILE;            
   RETURN TRUE;
   END;


Any other suggestion . here is the xml http://www.speedyshare.com/MgCCA/download/ItemMaster-2.xml
Back to top
View user's profile Send private message
Esa
PostPosted: Fri May 10, 2013 2:19 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

You clearly don't understand references clearly yet. You are using them "offshore style" like people who have been told to use references. They declare a reference but still do the actual coding with their beloved loop counters and array indexes.

Maybe something like this could work:

Code:

...
DECLARE myref REFERENCE TO InputRoot.XMLNSC.*:SyncItemMaster.*:DataArea.*:ItemMaster.*:ItemMasterHeader;   
     
      SET rowCnt = rowCnt+1;     
      SET OutputRoot.XMLNSC.root.(XMLNSC.Attribute)name='Product';
      SET OutputRoot.XMLNSC.root.row[rowCnt].product_Info.ProductCd =  THE (SELECT ITEM FIELDVALUE(T) FROM myRef:ItemID.*:VariationID AS T where FIELDVALUE(T.(XMLNSC.Attribute)SchemeName)='CAI');

     MOVE myref FIRSTCHILD NAME 'Classification';
     
      WHILE LASTMOVE(myref)= TRUE DO   
      IF myref.Type = 'BRAND' THEN

       SET OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd = myref.Codes.Code;
       
       SET LineCount = LineCount + 1;
      MOVE myref NEXTSIBLING;
      END WHILE;             


The next task on your way to professional ESQL coding is to get rid of rowCnt variable by declaring a reference to OutputRoot.root and creating LASTCHILD OF it NAME 'row' each time you get a match within your while loop.
Back to top
View user's profile Send private message
ydeonia
PostPosted: Fri May 10, 2013 2:54 am    Post subject: Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

Esa wrote:

The next task on your way to professional ESQL coding is to get rid of rowCnt variable by declaring a reference to OutputRoot.root and creating LASTCHILD OF it NAME 'row' each time you get a match within your while loop.


Hi Didint worked'


Code:
2013-05-10 18:51:18.783157     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''myref.Type'' at ('.WMB_9D1_PROD_SUB00_001.Main', '24.7'). This resolved to ''myref.Type''. The result was ''EMPTY ROW''.
2013-05-10 18:51:18.783164     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''myref.Type = 'BRAND''' at ('.WMB_9D1_PROD_SUB00_001.Main', '24.18'). This resolved to ''EMPTY ROW = 'BRAND'''. The result was ''NULL''.
2013-05-10 18:51:18.783174     2604   UserTrace   BIP2537I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Executing statement   ''SET LineCount = LineCount + 1;'' at ('.WMB_9D1_PROD_SUB00_001.Main', '27.6').
2013-05-10 18:51:18.783182     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''LineCount'' at ('.WMB_9D1_PROD_SUB00_001.Main', '27.22'). This resolved to ''LineCount''. The result was ''5''.
2013-05-10 18:51:18.783191     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''LineCount + 1'' at ('.WMB_9D1_PROD_SUB00_001.Main', '27.32'). This resolved to ''5 + 1''. The result was ''6''.
2013-05-10 18:51:18.783203     2604   UserTrace   BIP2537I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Executing statement   ''MOVE myref NEXTSIBLING;'' at ('.WMB_9D1_PROD_SUB00_001.Main', '28.3').
2013-05-10 18:51:18.783210     2604   UserTrace   BIP2540I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Finished evaluating expression ''LASTMOVE(myref)'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.14'). The result was ''TRUE''.
2013-05-10 18:51:18.783220     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''LASTMOVE(myref) = TRUE'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.14'). This resolved to ''TRUE = TRUE''. The result was ''TRUE''.
2013-05-10 18:51:18.783227     2604   UserTrace   BIP2537I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Executing statement   ''IF myref.Type = 'BRAND' THEN... END IF;'' at ('.WMB_9D1_PROD_SUB00_001.Main', '24.4').
2013-05-10 18:51:18.783237     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''myref.Type'' at ('.WMB_9D1_PROD_SUB00_001.Main', '24.7'). This resolved to ''myref.Type''. The result was ''ROW... Root Element Type=50331904 NameSpace='' Name='Type' Value='BRAND'''.
2013-05-10 18:51:18.783246     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''myref.Type = 'BRAND''' at ('.WMB_9D1_PROD_SUB00_001.Main', '24.18'). This resolved to ''ROW... Root Element Type=50331904 NameSpace=''[b] Name='Type' Value='BRAND' = 'BRAND'''. The result was ''TRUE''. [/b]
2013-05-10 18:51:18.783262     2604   UserTrace   BIP2537I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Executing statement   ''SET OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd = myref.Codes.Code;'' at ('.WMB_9D1_PROD_SUB00_001.Main', '25.4').
2013-05-10 18:51:18.783273     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''myref.Codes.Code'' at ('.WMB_9D1_PROD_SUB00_001.Main', '25.70'). This resolved to ''myref.Codes.Code''. The result was ''ROW... Root Element Type=50331648 NameSpace='' Name='Code' Value='002'''.
2013-05-10 18:51:18.783283     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''rowCnt'' at ('.WMB_9D1_PROD_SUB00_001.Main', '25.35'). This resolved to ''rowCnt''. The result was ''1''.
2013-05-10 18:51:18.783292     2604   UserTrace   BIP2568I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Copying sub-tree from ''myref.Codes.Code'' to ''OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd''.
2013-05-10 18:51:18.783304     2604   UserTrace   BIP2537I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Executing statement   ''SET LineCount = LineCount + 1;'' at ('.WMB_9D1_PROD_SUB00_001.Main', '27.6').
2013-05-10 18:51:18.783313     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''LineCount'' at ('.WMB_9D1_PROD_SUB00_001.Main', '27.22'). This resolved to ''LineCount''. The result was ''6''.
2013-05-10 18:51:18.783321     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''LineCount + 1'' at ('.WMB_9D1_PROD_SUB00_001.Main', '27.32'). This resolved to ''6 + 1''. The result was ''7''.
2013-05-10 18:51:18.783332     2604   UserTrace   BIP2537I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Executing statement   ''MOVE myref NEXTSIBLING;'' at ('.WMB_9D1_PROD_SUB00_001.Main', '28.3').
2013-05-10 18:51:18.783342     2604   UserTrace   BIP2540I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Finished evaluating expression ''LASTMOVE(myref)'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.14'). The result was ''TRUE''.
2013-05-10 18:51:18.783351     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''LASTMOVE(myref) = TRUE'' at ('.WMB_9D1_PROD_SUB00_001.Main', '22.14'). This resolved to ''TRUE = TRUE''. The result was ''TRUE''.
2013-05-10 18:51:18.783357     2604   UserTrace   BIP2537I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Executing statement   ''IF myref.Type = 'BRAND' THEN... END IF;'' at ('.WMB_9D1_PROD_SUB00_001.Main', '24.4').
2013-05-10 18:51:18.783367     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''myref.Type'' at ('.WMB_9D1_PROD_SUB00_001.Main', '24.7'). This resolved to ''myref.Type''. The result was ''ROW... Root Element Type=50331904 NameSpace='' Name='Type' Value='BRAND'''.
2013-05-10 18:51:18.783376     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''myref.Type = 'BRAND''' at ('.WMB_9D1_PROD_SUB00_001.Main', '24.18'). This resolved to ''ROW... Root Element Type=50331904 NameSpace='' Name='Type' Value='BRAND' = 'BRAND'''. The result was ''TRUE''.
2013-05-10 18:51:18.783388     2604   UserTrace   BIP2537I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Executing statement   ''SET OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd = myref.Codes.Code;'' at ('.WMB_9D1_PROD_SUB00_001.Main', '25.4').
2013-05-10 18:51:18.783397     2604   UserTrace   BIP2543I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': ('.WMB_9D1_PROD_SUB00_001.Main', '25.70') : Failed to navigate to path element number '2' because it does not exist.
2013-05-10 18:51:18.783405     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''myref.Codes.Code'' at ('.WMB_9D1_PROD_SUB00_001.Main', '25.70'). This resolved to ''myref.Codes.Code''. The result was ''EMPTY ROW''.
2013-05-10 18:51:18.783414     2604   UserTrace   BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''rowCnt'' at ('.WMB_9D1_PROD_SUB00_001.Main', '25.35'). This resolved to ''rowCnt''. The result was ''1''.
2013-05-10 18:51:18.783422     2604   UserTrace   BIP2567I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Assigning NULL to ''OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd'', thus deleting it.



Here is the code

Code:
CREATE COMPUTE MODULE WMB_9D1_PROD_SUB00_001
   CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
   CALL CopyMessageHeaders();
   --CALL CopyEntireMessage();
   DECLARE itemMaster REFERENCE TO InputRoot.XMLNSC.*:SyncItemMaster.*:DataArea.*:ItemMaster;   
   -- Construct Final Response XML
   
      DECLARE rowCnt INTEGER 0;
      DECLARE LineCount INTEGER 1;
      DECLARE temp ROW;
      DECLARE myref REFERENCE TO InputRoot.XMLNSC.*:SyncItemMaster.*:DataArea.*:ItemMaster.*:ItemMasterHeader;   
      
      SET rowCnt = rowCnt+1;      
      SET OutputRoot.XMLNSC.root.(XMLNSC.Attribute)name='Product';
      SET OutputRoot.XMLNSC.root.row[rowCnt].product_Info.ProductCd =  THE (SELECT ITEM FIELDVALUE(T) FROM itemMaster.*:ItemMasterHeader.*:ItemID.*:VariationID AS T where FIELDVALUE(T.(XMLNSC.Attribute)SchemeName)='CAI');
      MOVE myref FIRSTCHILD NAME 'Classification';
     
         WHILE LASTMOVE(myref)= TRUE DO

         IF myref.Type = 'BRAND' THEN
         SET OutputRoot.XMLNSC.root.row[rowCnt].product_Info.TyreBrandCd = myref.Codes.Code;
         END IF;
       SET LineCount = LineCount + 1;
      MOVE myref NEXTSIBLING;
      END WHILE;            
   RETURN TRUE;
   END;
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri May 10, 2013 5:30 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

There are a lot of broken loops in that code.

Try using a FOR value AS loop.

And really, every time you start to write "value[n]", stop. Use a reference instead.
Back to top
View user's profile Send private message
ydeonia
PostPosted: Fri May 10, 2013 5:44 am    Post subject: Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

mqjeff wrote:
There are a lot of broken loops in that code.

Try using a FOR value AS loop.

And really, every time you start to write "value[n]", stop. Use a reference instead.


Thanks mqjeff.. really i tried my best and i tried all suggestions poted here .. can you please show me what you are trying to tell me please with example .. i didnt get your point
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri May 10, 2013 6:39 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

ydeonia wrote:
can you please show me what you are trying to tell me please with example .. i didnt get your point


Rather than
Code:
WHILE .....DO

END DO


use

Code:
FOR .....DO


END DO


and never use

Code:
 value(n)


use

Code:
MOVE myRef ....


Hope that helps.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
ydeonia
PostPosted: Fri May 10, 2013 7:29 am    Post subject: Reply with quote

Acolyte

Joined: 29 Oct 2012
Posts: 74

[quote="Vitor"]
ydeonia wrote:


Code:
 value(n)


use

Code:
MOVE myRef ....


Hope that helps.


Which part of code you are pointing me at for this value[n] ?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri May 10, 2013 7:30 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Examples here: http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/topic/com.ibm.etools.mft.doc/ak05030_.htm
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri May 10, 2013 7:32 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Any part of your code that uses [] to address a specific child by a numeric value should be replaced.

ANY part.

If you ask for [1], the broker goes to the first child. If you ask for [2], the Broker goes to the first child, and then counts next children to get to 2. If you ask for [3], the broker goes to the first child and then counts next children to get to 3. If you ask for [n], the broker goes to the first child and counts next children to get to n. If you ask for [n+1], the broker goes to the first child and counts next children to get to n+1. EVERY TIME.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » LAST MOVE loop is not working
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.