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 » Finding position of a string in an array

Post new topic  Reply to topic
 Finding position of a string in an array « View previous topic :: View next topic » 
Author Message
Sathyambdev
PostPosted: Fri May 08, 2015 6:08 am    Post subject: Finding position of a string in an array Reply with quote

Newbie

Joined: 08 May 2015
Posts: 3

All,
Is it possible to find the postion of a string in an array.?

Basically I have a requirement to group items together based on a field.
I am mapping an Idoc to XML.
Current output:
Code:

<?xml version="1.0" encoding="UTF-8"?>
 <Payload>
  <BatchRegister>
   <Registration>
    <Info Name="test1">
    </Info>
    <Item Num="A1"/>
   </Registration>
   <Registration>
    <Info Name="test1">
    </Info>
    <Item Num="A2"/>
   </Registration>
   <Registration>
    <Info Name="test1">
    </Info>
    <Item Num="A3"/>
   </Registration>
   <Registration>
    <Info Name="test2">
    </Info>
    <Item Num="A4"/>
   </Registration>
   <Registration>
    <Info Name="test2">
    </Info>
    <Item Num="A5"/>
   </Registration>
    <Info Name="test3">
    </Info>
    <Item Num="A6"/>
   </Registration>
  </BatchRegister>
 </Payload>


Expected output:
Code:

<?xml version="1.0" encoding="UTF-8"?>
 <Payload>
  <BatchRegister>
   <Registration>
    <Info Name="test1">
    </Info>
    <Item Num="A1"/>
    <Item Num="A2"/>
    <Item Num="A3"/>
   </Registration>
   <Registration>
    <Info Name="test2">
    </Info>
    <Item Num="A4"/>
    <Item Num="A5"/>
   </Registration>
    <Info Name="test3">
    </Info>
    <Item Num="A6"/>
   </Registration>
  </BatchRegister>
 </Payload>

I am storing the condition field to env variable every time and trying to find the position of the string in that array. If I am able to find its position, I can then set the index to that position and set the output.

Correct me if this is the good approach and assist me in this.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri May 08, 2015 6:40 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

There are no arrays. There are only logical message trees made up of nodes, or list or rows.

The only notion of a "position" for an item in a logical message tree is relative to it's parent and it's siblings.

You will need to write code to walk the tree and gather the information you need.

You might consider using a logical message tree in Environment that gathers data as children of nodes named for the Info value.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Finding position of a string in an array
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.