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

Padding FF Fields Using FormatService

  • 1.  Padding FF Fields Using FormatService

    Posted Thu January 08, 2004 07:10 PM

    Greetings,

    I’m using IS 6.0.1 and am a little new to the wmFlatFile package…

    Basically, I’ve created a schema referencing records from a dictionary. It’s a delimited record parser. I also used fixed position extractors on the dictionary fields for each record.

    The problem I am having is that I now have a requirement to pad all numeric values with zeros, and I’m not sure how to do that. I’ve heard about using FormatServices, but I’m not sure how I could get one to help me in this instance.

    Any thoughts?

    Thanks in advance!


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


  • 2.  RE: Padding FF Fields Using FormatService

    Posted Thu January 08, 2004 07:40 PM

    This is a pad utility in the WmEDI package if you happen to have this package:

    wm.b2b.edi.util:pad

    I usually create two wrapper services that call this particular utility. One that pads numbers (left with zeros); one that pads strings (right with spaces).

    The wrapper utilities expect inputs of string, totalLength and type.

    Then, it figures out based on number or string which way to pad, what to pad with and how many padded locations are needed.

    For example, a string, whose length is 6, but requires a total amount of 12 spaces for the document would have 6 char(32) spaces concatenated to the end of the string. So, the string ‘wmuser’ would appear as 'wmuser '. For the number 123, whose whole length is 10, it would appear as ‘0000000123’.

    This is assuming that you are padding left with zeros for numbers and padding right for strings with spaces.

    HTH

    Ray


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


  • 3.  RE: Padding FF Fields Using FormatService

    Posted Thu January 08, 2004 07:43 PM

    Peterson,

    Format Services are like any other services except the inputs and outputs of the format service should be specified by invoking the specification which is in WmFlatFile Package from the input/output tab of the format service(i.e Specification which is in WmFlatFile Package must be invoked from format service to specify inputs and outputs of format service).And map the input to the value(one of inputs in specification) and after logic is performed map the resultant output to the formattedOutput(one of outputs in specification).And inovoke the format service in Dictionary for corresponding field.


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


  • 4.  RE: Padding FF Fields Using FormatService

    Posted Thu January 08, 2004 08:19 PM

    Thanks for the quick responses!

    Usha, the problem I am having with this is, since I am using a fixed length extractor on a delimiter record parsed schema the maxLength pipeline input will only return the length extracted as opposed to the total length that the field should be. Any thoughts on how I could get the total length of the field?

    Ray, I do have that package, but was not aware of that util. How does the service know what to use as the padding?

    Thanks again!


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


  • 5.  RE: Padding FF Fields Using FormatService

    Posted Thu January 08, 2004 08:58 PM

    Grant,

    I stand corrected. It will ONLY PAD STRINGS.

    However, I gleamed through the packages because I KNOW there must be something that does this and there is:

    pub.string:padLeft
    pub.string:padRight

    Write a wrapper as I specified earlier and call either padLeft for the number or padRight for the string.

    Should be easier now that I am steering you to the right place. Sorry.

    Ray


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


  • 6.  RE: Padding FF Fields Using FormatService

    Posted Thu January 08, 2004 09:26 PM

    I didn’t get the formatservice working. Did anybody try to get it working ?


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


  • 7.  RE: Padding FF Fields Using FormatService

    Posted Thu January 08, 2004 10:05 PM

    Mike,

    That’s because I was reading cross-eyed. My last post rectifies this. Sorry again.

    Ray


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


  • 8.  RE: Padding FF Fields Using FormatService

    Posted Thu January 08, 2004 10:11 PM

    In fact, to rectify my ills, I have included a package here that will do the padding for you, just copy the flow to your utils package and rename. Cheers.

    Ray

    String Pad Utility
    RayMoserUtils.zip (4.7 k)


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


  • 9.  RE: Padding FF Fields Using FormatService

    Posted Fri January 09, 2004 03:46 PM

    Ray,

    Thanks for the code example. I think that will work well, but I’m having a hard time using it in conjunction with my flat file schema. As I said above, I’m using a delimiter record parser, and on the dictionary, I’m using a fixed position extractor to pull the appropriate fields. But doing this limits my ability to use your code in a FormatService, since the pipeline value MaxLength will only be equal to the length of the field extracted, and not the total length possible.

    Since I can’t seem to form my schema any differently, is there any way for me to pad the numeric values using your code in a format service?


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


  • 10.  RE: Padding FF Fields Using FormatService

    Posted Fri January 09, 2004 04:12 PM

    At some given point, your data should be in an IData object in the pipeline. Before you run the pub.flatFile:convertToString service, add a loop above it and loop through the data. In the loop, create a map step and call the service that you have now to pad as a transformer and set the appropriate padding and length. Should work.

    This is the older methodology that was used prior to the FF adapter.

    HTH

    Ray


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