Thursday, March 18, 2021

Writing in Excel Using Excel Writer Step

 Failing During Writing in Excel while writing in excel , scenario can be as below

  • 1 Transformation
  • Multiple Excel Writer step
  • All Excel Writer Step trying to write in 1 excel
What i noticed due to time or speed, if 1st step locked the excel to writing then 2nd excel writer step will failed to write. Which lead to fail whole transformation

How you can save yourself from your error, some how i found this after google it:



// for compatibility with Kettle 3.2 and 4.0: choose correct flag
var STATUS_FINISHED;
var STATUS_STOPPED;
var STATUS_HALTED;
var STATUS_HALTING;
if(STATUS_FINISHED == null) {
	try {
		// Kettle 3.2 flag
		STATUS_FINISHED = Packages.org.pentaho.di.trans.step.StepDataInterface.STATUS_FINISHED;
		STATUS_HALTING = Packages.org.pentaho.di.trans.step.StepDataInterface.STATUS_HALTING;
		STATUS_HALTED = Packages.org.pentaho.di.trans.step.StepDataInterface.STATUS_HALTED;
		STATUS_FINISHED = Packages.org.pentaho.di.trans.step.StepDataInterface.STATUS_FINISHED;
		STATUS_STOPPED = Packages.org.pentaho.di.trans.step.StepDataInterface.STATUS_STOPPED;
	} catch(e) {
		// Kettle 4.0 flag
		STATUS_FINISHED = Packages.org.pentaho.di.trans.step.BaseStepData.StepExecutionStatus.STATUS_FINISHED;
		STATUS_HALTING = Packages.org.pentaho.di.trans.step.BaseStepData.StepExecutionStatus.STATUS_HALTING;
		STATUS_HALTED = Packages.org.pentaho.di.trans.step.BaseStepData.StepExecutionStatus.STATUS_HALTED;
		STATUS_STOPPED = Packages.org.pentaho.di.trans.step.BaseStepData.StepExecutionStatus.STATUS_STOPPED;
	}
}
// this is the step that must complete before moving on
var waitForStep;
if(waitForStep == null) {
	waitForStep = _step_.getDispatcher().findBaseSteps("WritingObjectProperties").get(0);
}
// sleep until the step we wait for is done
while(waitForStep.getStatus() != STATUS_FINISHED && waitForStep.getStatus() != STATUS_STOPPED && waitForStep.getStatus() != STATUS_HALTING && waitForStep.getStatus() != STATUS_HALTED) {
	println("waiting for the step to finish");
	java.lang.Thread.currentThread().sleep(5);
}


Keep "Check" the checkboxinside step "Java Script"

See screenshot from reference 


No comments:

Post a Comment

web stats