问题
Is there any way can we add two datapools to a single script? Or in other words how can we get inputs from two different datapools to a single script.
Thanks in advance.
回答1:
Yes, you can manually load and manage any number of datapools.
/**
* Creates a IDatapoolIterator pointing the first record
* @param datastore default project path
* @param dataPoolPath relative path in the project
* @return IDatapoolIterator pointing the first record
*/
public static IDatapoolIterator getDataPoolIterator(String datastore, String dataPoolPath)
{
java.io.File dpFile = new java.io.File(datastore, dataPoolPath+".rftdp");
DatapoolScriptSupport dss = new DatapoolScriptSupport();
IDatapool dp = (IDatapool) dss.dpFactory().load(dpFile, true);
IDatapoolIterator dpIter = dss.dpFactory().open(dp, null);
dpIter.dpInitialize(dp);
dpIter.dpReset();
return dpIter;
}
then in your code
myDatapool = getDataPoolIterator((String)getOption(IOptionName.DATASTORE), "relative/path/intheproject");
You can access any Variable in the datapool by
myDatapool.dpString("Variable");
Use the correct method depending the type of the variable you need. Using
myDatapool.dpNext();
you will advance to the next record in the datapool. Hope this will help. Further informations here: IBM Help System: Datapool
来源:https://stackoverflow.com/questions/8532061/more-than-one-datapool-to-a-script-in-rft