IBM Sterling Transformation Extender

Sterling Transformation Extender

Come for answers, stay for best practices. All we're missing is you.


#Sterling
#Supplychain
 View Only
  • 1.  Implement recursion in WTX

    Posted 08/03/10 03:55 AM

    Originally posted by: SystemAdmin


    Hello,

    I am new to WTX, need help in implementing a simple recursive logic. Input 1 is a plain text and input 2 is an integer number which is fixed length. Requirement is to get an output file with lines of fixed length given in input2.

    e.g. Input1 = "abcdefgh" Input2= 3
    Output-
    abc
    def
    gh

    I am thinking of using LEFT function recursively.. but not sure how to store the intermediate values and use it again. i.e. if I do LEFT (Input1, Input2) it gives "abc" but after tht Input1 should be "defgh".. I am not able to achieve this.

    Thanks
    #DataExchange
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender


  • 2.  Re: Implement recursion in WTX

    Posted 08/03/10 05:08 AM

    Originally posted by: thorstenhirsch


    You wouldn't solve this problem in a recursive way in WTX. You would create a functional map on a sequence and provide INDEX($) in the parameters:

    outcard
    -sequence(s)
    --text

    on sequence(s) you call:

    =f_cut("abcdefgh", 3, INDEX($))
    (call the input cards: string, length, index)

    and f_cut will be implemented like this:

    =MID(string, index * length, length)
    #IBMSterlingTransformationExtender
    #DataExchange
    #IBM-Websphere-Transformation-Extender


  • 3.  Re: Implement recursion in WTX

    Posted 08/03/10 05:48 AM
      |   view attached

    Originally posted by: SystemAdmin


    Hey thorstenhirsch,

    Thanks for solution, but I have doubts -

    1. What is use of outcard text?
    2. We have input as plain text how index($) will increase and run F_cut 3 times in this case.
    3. In first run of F_cut index * length will be 3 do it will pick "cde"

    I tried to code your solution but no success :( (may be I didnt got u)
    Please chk attached map and tree and suggest how can I achive this.

    thanks,
    #DataExchange
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender

    Attachment(s)



  • 4.  Re: Implement recursion in WTX

    Posted 08/03/10 05:11 AM

    Originally posted by: SystemAdmin


    I would use the CLONE function so that multiple calls to a functional map are made:

    
    =fmap (CLONE (data, ROUND(SIZE(data)/ length)), INDEX($), length)
    


    in the functional map have the following to extract out the part of the data you're interested in:

    
    =MID(data, (Index*length)-length+1, length)
    


    This way is probably the simplest but not very efficient, it will slow down quickly as the data size increases.
    If the data is likely to be long, use a RUN map and call it recursively (each iteration trimming off a bit more data) - as you suggest.
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender
    #DataExchange


  • 5.  Re: Implement recursion in WTX

    Posted 08/03/10 07:10 AM

    Originally posted by: SystemAdmin


    Thanks Oliver,

    It is working with small modification in Functional map -

    =fmap (CLONE (data, (ROUND(SIZE(data)/ length))+1), INDEX($), length)

    if we dont give +1 then it will not show remaining characters "gh"

    Regards,
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange