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

How to find the last element in a string

  • 1.  How to find the last element in a string

    Posted Sun January 31, 2010 12:56 AM

    Hi all,

    I have a requirement…

    For eg: If a string has a value…lets say 1234.50

    I must do left padding with zeroes and remove the decimal to a length of 13.

    I have done till that…the output is 0000000123450. Now, My requirement is that…the last digit has 0 value…so i have to replace it with {

    if the last digit is 1 i must replace it with A.
    2 with B and so on.

    So, For eg…here 0000000123450 must appear as 000000012345{
    0000000123451 must appear as 000000012345A
    0000000123452 must appear as 000000012345B

    Can anyone tell the logic how to replace the last digit. If possible, please include the steps…so that it would be clear for me.

    Thanks in advance,
    David.


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


  • 2.  RE: How to find the last element in a string

    Posted Sun January 31, 2010 05:26 AM

    Hi David

    Use pub.string:substring and set beginIndex =13 and endIndex =14.
    Then add a branch then paste the /value in the Switch property.
    After that add Sequences below the branch and label each one 0,1,2,…,9.
    In the sequence with the label 0 add a pub.string:substring below it and take the first 14 digit then add pub.string:concat to concatenate the value retuen with the { symbol.

    Thats all.


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


  • 3.  RE: How to find the last element in a string

    Posted Sun January 31, 2010 11:32 PM

    Thank you very much alamir. That really worked.


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


  • 4.  RE: How to find the last element in a string

    Posted Mon February 01, 2010 05:51 AM


  • 5.  RE: How to find the last element in a string

    Posted Mon February 01, 2010 05:20 PM

    What you’re describing as the target format is known as zoned decimal. The PSUtilities package from SAG/wM has a convertStringToZonedDecimal service you can copy. It handles leading signs, negative numbers, padding, stripping the decimal, etc.


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