IBM Sterling Transformation Extender

 View Only
  • 1.  Regarding TextLines Spitting and wrapping logic

    Posted 11 days ago
    Hi I have below scenario
    Input is text blob
     
     Single field will capture data
     
     Each line is ended with /r/n
     
     Number of lines can be 35
     
     scenario is line can be greater than 50 or less than 50
     
    If any line is greater than 50 then we need to get the extra chars and add them to next line
     
     After that if new line crosses 50 then we can need to repeat the process
    If anyone implemented this scenario please let me know 


    ------------------------------
    sunil kumar chellu
    WTX DEVELOPER
    AIDIN
    vizag
    ------------------------------


  • 2.  RE: Regarding TextLines Spitting and wrapping logic

    Posted 10 days ago

    Hi Sunil,

    First, I would humbly suggest that you change the input type tree to one where you are parsing each line.  Text of no set limit,  terminated by <CR><LF> or make a variable syntax terminator if the line terminator could vary between environments.  Have another file defined (can be same tree or different tree definition) with the text field set to 50 char limit for the output definition and same delimiters. Then in your map you will create a functional map to process each line - it will need to work recursively. You can make use of flow variables to set and get remainder text values if any.  You will check to see if there is data in the flow variable and get it's length. If greater than 0, do the match and then chunk off any remaining data from the input line to make 50 and reset the variable to empty string, if variable length is greater than 50, then you will get the LEFT most 50 of the variable to write to output line and then do a MID function to get 50-remaining variable length and add the input line (plus maybe a space buffer at the beginning) and reinitialize the variable to this value.  This leaves whatever may be stored in the variable once you're out of input lines. You'll want a second output card and functional map to create lines based on the variable length divided by 50 to use as the index repeater value and then just use and reset the variable after chunking off the remaining 50 character sets.  Then in a 3rd output card you can use a blob field to PACKAGE(Card1) + PACKAGE(Card2) to retain line terminators and write out this final card.

    This of course, does not take into consideration breaking the 50 char line nicely - this solution will break exactly there in the middle of a word.  If needed you could use more flow variables to determine if the end of the input line is breaking over a word with the WORD function and whatever delimiters you want to use whether it is space, or punctuation.  The trick will be to design the recursive nature of the functional maps to not lose any data. Any more hints and I would need a development retainer!

    Happy mapping!

    Lisa



    ------------------------------
    Lisa Edwards
    Software Engineer / Subject Matter Expert
    Rainbow Data Systems, Inc
    ------------------------------



  • 3.  RE: Regarding TextLines Spitting and wrapping logic

    Posted 9 days ago

    I love that you are embracing the new Flow Variables in ITX and great advice! And I agree that some changes to the type tree (in particular the array of text items, each 50 chars) would make this task much easier. IF breaking on whitespace between words is a requirement I typically do something using MIDs to traverse the data in chunks and WORD to strip off the last WORD based on spaces in the chunk, calculate the size of what's left and start from there to get the next chunk of data via MID and so on.



    ------------------------------
    Stephanie Fetzer
    ------------------------------



  • 4.  RE: Regarding TextLines Spitting and wrapping logic

    Posted 9 days ago

    Thank you Lisa and Stephanie.



    ------------------------------
    sunil kumar chellu
    WTX DEVELOPER
    AIDIN
    vizag
    ------------------------------