2.选择“Java代码”;String xuhaotemp;String chanpintemp;public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException{ // First, get a row from the default input hop Object[] r = getRow(); // If the row object is null, we are done processing. if (r == null) { setOutputDone(); return false; } if (first){ first = false; } // It is always safest to call createOutputRow() to ensure that your output row's Object[] is large // enough to handle any new fields you are creating in this step. Object[] outputRow = createOutputRow(r, data.outputRowMeta.size()); String xuhao = get(Fields.In, 'Number').getString(r); String chanpin = get(Fields.In, 'NumCode').getString(r); // Set the value in the output field String newxuhao = ''; String newchanpin = ''; if (xuhao == null) { newxuhao = xuhaotemp; } else { newxuhao = xuhao; xuhaotemp = xuhao; } if (chanpin == null) { newchanpin = chanpintemp; } else { newchanpin = chanpin; chanpintemp = chanpin; } get(Fields.Out, 'newxuhao').setValue(outputRow, newxuhao); get(Fields.Out, 'newchanpin').setValue(outputRow, newchanpin); // putRow will send the row on to the default output hop. putRow(data.outputRowMeta, outputRow); return true;}
结果流程: