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
  • 1.  EDI addGroupEnvelope Service Delimiters

    Posted Wed April 17, 2002 03:29 PM

    I’m running into an error using unicode delimiters with the ‘addGroupEnvelope’ service. My flow is similar to the example given in the ‘processXMLSource’ flow of the ‘WmEDISamples’ package in that I initialize the ‘delimiters’ record in a map step then call ‘convertToString’ and ‘addGroupEnvelope’. My field seperator is ‘\u002f’ and my segment terminator is ‘\u0015’. The delimiters work correctly in the ‘convertToString’ service, but the ‘addGroupEnvelope’ service reads the values as literals and creates the GS and GE segments with ‘GS\u002f’ rather than ‘GS/’.


    #Integration-Server-and-ESB
    #edi
    #webMethods


  • 2.  RE: EDI addGroupEnvelope Service Delimiters

    Posted Wed April 17, 2002 06:49 PM

    I ran into this too. These types of inconsistencies can be really quite maddening. The trick is to convert the values yourself. Here is a Java service I use to do this. Call it and assign the output to the desired delimiter field. Hope this helps.

    Service: <YourTopFolder>.utils.x12.toChar

    – Converts Java and Unicode character escape literals to their character equivalent.

    – Various services may require the use of special characters that cannot normally be typed at the keyboard, such as a newline or carriage return. These characters can be supported through the use of escape sequences. These escape sequences are interpreted and converted to their character equivalent.

    – The following escaped characters can be specified as the input variable and will be converted as described:

    \b - Backspace
    \t - Horizontal tab
    \n - Newline
    \f - Form feed
    \r - Carriage return
    \uXXXX - The Unicode character with encoding XXXX, where XXXX is four hexadecimal digits. For example, \u000a represents a newline character.

    If the input variable unitCode contains any other values, the first character is returned. If unitCode is null or empty, the returned character is 0 (nul - not the character ‘0’).

    Inputs:
    unitCode - The string to be converted. The input string should contain only a single character or one of the above escape sequences.

    Outputs:
    char - A single character that represents the escape sequence specified in unitCode. If unitCode is not one of the above sequences, the first character in unitCode is returned. If unitCode is null or empty, a binary 0 is returned.

    Imports:
    java.util.Date
    java.text.*

    Code:

    String unitCode = null;
    char theChar = 0;

    // pipeline
    IDataHashCursor pipelineCursor = pipeline.getHashCursor();
    if ( pipelineCursor.first( “unitCode” ) )
    {
    unitCode = (String) pipelineCursor.getValue();
    }
    pipelineCursor.destroy();

    if(unitCode != null)
    {
    unitCode = unitCode.trim();
    if(unitCode.length() > 0)
    {
    theChar = unitCode.charAt(0); // default to return 1st character
    if(unitCode.charAt(0) == ‘\’)
    {
    if(unitCode.length() == 1)
    {
    theChar = ‘\’;
    }
    else if(unitCode.length() == 2)
    {
    switch(unitCode.charAt(1))
    {
    case ‘r’:
    theChar = ‘\r’;
    break;
    case ‘n’:
    theChar = ‘\n’;
    break;
    case ‘b’:
    theChar = ‘\b’;
    break;
    case ‘t’:
    theChar = ‘\t’;
    break;
    case ‘f’:
    theChar = ‘\f’;
    break;
    }
    }
    else if((unitCode.charAt(1) == ‘u’) && (unitCode.length() >= 6))
    {
    theChar = (char) Integer.parseInt(unitCode.substring(2, 6), 16);
    }
    }
    }
    }

    // pipeline
    IDataHashCursor pipelineCursor_1 = pipeline.getHashCursor();
    pipelineCursor_1.last(); <BR


    #Integration-Server-and-ESB
    #edi
    #webMethods


  • 3.  RE: EDI addGroupEnvelope Service Delimiters

    Posted Thu May 16, 2002 09:48 PM

    The imports can be ignored. They are there for other services with the package that I have this service in.


    #edi
    #Integration-Server-and-ESB
    #webMethods


  • 4.  RE: EDI addGroupEnvelope Service Delimiters

    Posted Wed July 17, 2002 08:19 PM

    Looks like I didn’t escape a couple of the literals enough to make them appear properly in the forum. Here are the right literals (they will look funky in e-mail–they look right in the wMUsers forum):


    if(unitCode.charAt(0) == ‘\’) // was ''
    {
    if(unitCode.length() == 1)
    {
    theChar = ‘\’; // was ''

    Sorry for any confusion!


    #edi
    #webMethods
    #Integration-Server-and-ESB