OL Learn

Delete Data Page - Line Printer


#1

I have some data records presented as line print. I am splitting on FF. If I have a page with less than 10 lines in I need to remove it from my output files. Will it be best to do this in the datamapper or the workflow? I’m struggling to find a way of doing this.

All I want to do is:

if data page < 10 lines
delete


#2

You don’t need to remove the records from the data files, you simply need to skip them in the DataMapper. At the very top of your data mapping process, you insert a condition and in the True branch of that condition, you add a JavaScript Action step and set its action to Stop Processing Record, which instructs the process to immediately move on to the next record.

Now there is no way currently to know how many lines a record contains, but your condition can use some JavaScript code to achieve the same result. For instance, the following code will attempt to jump to line 11 and if that generates an error, then the condition will be deemed true (and since the error is trapped and handled, it won’t cause any issue with your process:

var curPos = steps.currentPosition;
var returnValue = false;
try {
	steps.moveTo(0, 11);
	// If this works, then there are at least 10 lines in the record
} catch(e) {
	// If an error occurs, then there are no more then 10 lines in the record
	returnValue = true;
}
steps.moveTo(1,curPos);
returnValue;

A simplified DM config using this method would look like this. Note how the condition needs to appear before any extraction step:


#3

Thank you, works perfectly