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.  Trim spaces in IData record object

    Posted Thu December 19, 2002 09:07 PM

    I am parsing a small positional flat file using template and EDI adapter. I use wm.b2b.edi:convertToValues service to build the records. The problem is positional files tend to have many blank fields and they transform into spaces in IData record fields. I try to set option on wm.b2b.edi:convertToValues to skip white spaces but aparently it only does this to front of record and not to every fields in a template. I was thinking of creating a java service that runs through any IData object and trim all fields. I want to know if somebody already had this problem and found some better solutions or have code to share?


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


  • 2.  RE: Trim spaces in IData record object

    Posted Wed January 08, 2003 01:50 PM

    Hi,
    we had the same problem and here is the service.

    NOTE: The service name is initRecord, plz keep as it is
    or modify the code as well

    System.out.println(“Hello world In Init record”);
    // pipeline
    IDataCursor pipelineCursor = pipeline.getCursor();

    Object tempObj = null;
    String tempKey = null;

    //System.out.println(“Size is :”+IDataUtil.size(pipelineCursor));

    while(pipelineCursor.hasMoreData())
    {
    System.out.println(“MOVING NEXT RECORD >>>>>>>>>>>>>>>>>>>>>>>>>>”);
    pipelineCursor.next();

    tempObj = pipelineCursor.getValue();
    tempKey = pipelineCursor.getKey();

    System.out.println("Rec Key: "+tempKey);
    System.out.println("Rec Value: "+tempObj);

    System.out.println("IS STRING: "+(tempObj instanceof String));

    if(tempObj instanceof IData)
    {
    System.out.println(“THIS IS A RECORD >>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>”);

    initRecord((IData)tempObj);
    }
    else
    {
    if(tempObj instanceof IData)
    {
    System.out.println("Its a record array: “);
    IData recs = (IData)tempObj;
    for(int i=0; i>>>>>>>>>>>>>>>>>>>>>>>>>”);
    IDataUtil.put( pipelineCursor, tempKey, “” );
    }
    catch(Exception ex)
    {
    System.out.println(“ERROR:”+ex);
    }
    }//if
    }//else

    }//else

    }//while

    pipelineCursor.destroy();


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


  • 3.  RE: Trim spaces in IData record object

    Posted Wed January 08, 2003 02:23 PM

    Maheboob,

    Could you explain what the inputs to this service are and what needs to be mapped to them?


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


  • 4.  RE: Trim spaces in IData record object

    Posted Wed January 08, 2003 02:43 PM

    Can we tokenize the output of convertTovalues on space and then append all the elements? This method should remove all the white spaces inside the document and we wont have to write any java code either.
    Thx


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