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

How to read data from pipleine, where variable name change during runtime?

  • 1.  How to read data from pipleine, where variable name change during runtime?

    Posted Thu September 13, 2018 06:47 AM

    Hi

    We have a requirement where the field names under a document can change during run time and data needs to be read from those fields. How to achieve this in flow service?

    Document
    Field-1
    Field-2


    Field-N

    As shown above, the number of fields under Document can change during run time and we want to read data from them and use it further.

    At beginning of the flow, we will know how many fields are expected under document and we can repeat that many times to read the data. But how to substitute the field names during runtime, as this may change like Field-1, Field-2 …Field-N.


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


  • 2.  RE: How to read data from pipleine, where variable name change during runtime?

    Posted Thu September 13, 2018 11:16 AM

    You can get more information on IData object using the IS Java API documentation.

    
    ArrayList<IData> outputDocarr = new ArrayList<IData>();		
    IData	inputDoc = inDoc;
    if ( inputDoc != null)
    {
    IDataCursor idc=inputDoc.getCursor();
    IData output=null;
    IDataCursor idcOut=null;
    
    while(idc.next()){
    output= IDataFactory.create();
    idcOut= output.getCursor();
    
    if ((idc.getValue() instanceof String) ||((idc.getValue() instanceof Object))){
    IDataUtil.put(idcOut, "key", idc.getKey());
    IDataUtil.put(idcOut, "value", idc.getValue());
    idcOut.destroy();
    outputDocarr.add(output);
    }
    else if(idc.getValue() instanceof IData){
    idc.next();
    }
    }
    }
    return outputDocarr.toArray(new IData[outputDocarr.size()]);

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