IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Working with String lists

  • 1.  Working with String lists

    Posted Wed August 31, 2005 07:03 PM

    Hi,

    I have 2 string lists.String list A contains let’s say a,b,c and d.String list B contains b,d and x.i want to create a new String list C which should contain elements of A minus elements in String list B.i.e in the above example,new list should contain a and c only.

    Can someone tell me how to do this?

    ramesh.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 2.  RE: Working with String lists

    Posted Wed August 31, 2005 08:34 PM

    Hi,

    i got confused as i was mapping the wrong string list.anyway got the solution for this.

    ramesh.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 3.  RE: Working with String lists

    Posted Wed August 31, 2005 08:55 PM

    Convert each string list to a java.util.Collection object. The classes that implement Collection include Vector, HashSet, ArrayList, and others. Use the removeAll method to get the relative complement of the sets. Then convert the modified collection back to an array for the pipeline.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 4.  RE: Working with String lists

    Posted Wed August 31, 2005 09:25 PM

    Ramesh.,

    Can you share us with your solution.

    just curious to know,i know there are different approaches,as Rob also mentioned above.

    Thanks,


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 5.  RE: Working with String lists

    Posted Wed August 31, 2005 09:38 PM

    RMG,

    OuterLoop:Loop over List A
    Map:A to tempElement
    InnerLoop:Loop over List B
    Branch
    SEQ-----A<>B
    assign tempVar=0
    SEQ-----A=B
    assign tempVar=1
    Exit InnerLoop
    Branch on tempVar
    0:Map(append the tempElement to new StringList)

    ramesh.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 6.  RE: Working with String lists

    Posted Wed August 31, 2005 09:42 PM

    RMG,

    Indentation didn’t work in the previous post.

    OuterLoop:Loop over List A
    –Map:A to tempElement
    –InnerLoop:Loop over List B
    ----Branch
    ------SEQ(if A<>B)
    --------assign tempVar=0
    ------SEQ(if A=B)
    --------assign tempVar=1
    --------Exit InnerLoop
    –Branch on tempVar
    —0:Map(append the tempElement to new StringList)

    ramesh.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 7.  RE: Working with String lists

    Posted Wed August 31, 2005 10:18 PM

    Thanks,thought of the same solution.

    Anyways thanks for sharing with us.

    Cheers,


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 8.  RE: Working with String lists

    Posted Thu May 25, 2006 06:54 PM

    Hi all,
    I have a string list. I have a string field which has a value and should be mapped to the string list. Its in a loop.
    So each time it gets mapped, it should form a list of string in the string list with various values.

    I mapped the String field to the String list. But its not giving me any output.Do i need to add any transformer in between the string field and the stringlist or just a simple map.

    Please let me know. Thank you


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 9.  RE: Working with String lists

    Posted Thu May 25, 2006 07:20 PM

    See the built-in services guide description of pub.list:appendToStringList.

    Mark


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 10.  RE: Working with String lists

    Posted Thu May 25, 2006 07:23 PM

    Hi Stepheny,
    Do as follows:

    LOOP (InArray: SomeList, OutArray: DesiredStringList)
    ---- Map StringField to DesiredStringList (Here you will see that DesiredStringList appears as String: which is usual)
    ENDLOOP
    STEP AFTER LOOP

    When you complete the loop and come the step “STEP AFTER LOOP”, you will see the DesiredStringList as stringList with all the various values populated.

    Regards,
    Bhawesh


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 11.  RE: Working with String lists

    Posted Thu May 25, 2006 07:33 PM

    What should i write in the InArray ?
    What do u mean by somelist ??

    Plz let me know
    Thankyou


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 12.  RE: Working with String lists

    Posted Thu May 25, 2006 09:39 PM

    Hi Stepheny,
    As you wrote:
    “I have a string list. I have a string field which has a value and should be mapped to the string list. Its in a loop”.

    Based on this, I assumed you have another List and you are looping based on that List. If only List you have is this DesiredStringList, do as follows:

    LOOP (InArray: DesiredStringList)
    ---- Map StringField to DesiredStringList (Here you will see that DesiredStringList appears as String: which is usual)
    ENDLOOP
    STEP AFTER LOOP

    When you complete the loop and come the step “STEP AFTER LOOP”, you will see the DesiredStringList is back as stringList with all the elements in this list populated with the value of StringField.

    Regards,
    Bhawesh


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 13.  RE: Working with String lists

    Posted Thu May 25, 2006 10:55 PM

    I dont know, but something is going wrong. That doesn’t work.
    May be my question is wrong. Let me reframe my question.

    I have a document which contains a field- A which is a string.
    I have a document reference which contains a Stringlist- B
    (I dont know whether these documents could make any difference.)

    There is a loop on the document of A and each the time the loop runs A gets a new value. So if the loop runs 4 times then i have 4 values for A.
    I need to store this 4 values of A’s in B.
    So before i come out of the loop i should have the B ready with 4 values.

    Sorry if my question was wrong before.
    Please tell me what should i do for this ? iam trying to use list.append:stringlist,but its giving me error.
    In the tolist i have given B
    In the fromitem i have A
    and in the serviceout tolist i gave B.
    Am i going wrong somewhere ??

    Thankyou


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 14.  RE: Working with String lists

    Posted Fri May 26, 2006 12:45 AM

    Stepheny,

    From your problem statement it looks like the source (where you have string field A) is a document list and not a document, so when you loop over that document list, in each iteration of loop, there is a new value for field A.

    With the assumption above, what you are doing looks okay, except for one thing - the name of the service to append is pub.list:appendToStringList. May be you just made a typo. I tried this and it works -

    Loop [inArray = document that contains A]
    |—pub.list:appendToStringList [(inputs)A-> fromItem, docRef/B->toList (output)toList->docRef/B]

    This should get you the result you are looking for… if you are doing just this and still getting an error, post the error message that you are getting.

    HTH, Rohit


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 15.  RE: Working with String lists

    Posted Fri May 26, 2006 01:18 AM

    Place this service under Loop step pub.list:appendToStringList will do the trick.(Make sure you drop the fromItem,string)

    Loop(Stringlist)
    map string to appendToStringList (drop the fromItem)toList to originaltargetStringlist

    Come out of loop step,originallist should have the new list

    Rohit’s suggestion also works great…

    HTH,
    RMG


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 16.  RE: Working with String lists

    Posted Fri May 26, 2006 02:55 PM

    Iam sorry to ask u again about this.

    In the pub.list:appendToStringList i did not understand what are the inputs that are given to the service.

    In the “tolist” i could not give document reference as input … (it does not allow)
    Do i need to give the stringlist B as an input to the "tolist " which is in the document reference. As the service appends strings to stringlist i cannot give document reference as input to that service.
    When i tried giving the Stringlist B as an input to the service, it throws an exception.

    Let me make the question clear again.

    pipeline In

    Document
    field1
    field2
    string A

    Doc Reference
    Document
    DocumentList
    String1
    String2
    StringlistB

    pipelineout

    Doc Reference
    Document
    DocumentList
    String1
    String2
    StringlistB

    plz tell me the solution. Sorry for troubling u all.
    Thankyou


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 17.  RE: Working with String lists

    Posted Fri May 26, 2006 03:28 PM

    The error its giving is “error occured while tracing”


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 18.  RE: Working with String lists

    Posted Fri May 26, 2006 03:47 PM

    Hey i got the solution…May be its temporary.
    Its not allowing me to map when its in a document reference, but if i store the values in a stringlist which is not in any document or reference document, then its allowing me to append.
    And after i appended all the strings to that stringlist, then i mapped that list to tha list in the document.

    Thank you for all your help.
    If there is some other solution, plz let me know.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 19.  RE: Working with String lists

    Posted Fri May 26, 2006 03:51 PM

    hi all,
    I have one more question on this.
    Now i got a stringlist, but I should check before inserting into the stringlist that the string already exists or not . If the string already exists, then i should not insert. If it doesn’t exist, then i should insert.
    Can someone give me ideas, how to do that ?
    Are there any builtinservices to do that ?
    Thankyou


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 20.  RE: Working with String lists

    Posted Fri May 26, 2006 07:36 PM

    Hi Stepheny,
    To conditionally append the string to a stringList, use the branch statement.

    Also, wrote about your pipeline In/Out again something like this:

    Document
    —field1
    —field2
    —string A

    AND

    Doc Reference
    —Document
    —DocumentList
    ------String1
    ------String2
    ------StringlistB

    Then only we could suggest you the correct advice. The mapping logic will chage based on your document structure.

    Regards,
    Bhawesh


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services