Discussion:
Return all work entries from one AL to other
(too old to reply)
a***@gmail.com
2017-05-04 21:59:32 UTC
Permalink
Raw Message
I have a main AL that call other AL to select some records with a JDBC connector.
I want to return all records (work entries) from the second AL to the first (caller).
I know that I can do this using accumulator but I didn't understood how to use this.
The select return 3 fields, so each work entry have 3 properties.
This is the script I use to call the second:

var iwe = new com.ibm.di.entry.Entry();
iwe.setAttribute("Param1", "KM");

//Criando o bloco de execução do AL de DELETE
var tcb = system.newTCB();
var vector = new java.util.Vector();
tcb.setInitialWorkEntry(iwe);
vector.add(tcb);
vector.add(task.getLog());

var al = main.startAL("SecondAL",vector);
al.join();

//At this point I need to get all work entries returned by "SecondAL"
a***@gmail.com
2017-05-05 22:30:55 UTC
Permalink
Raw Message
Post by a***@gmail.com
I have a main AL that call other AL to select some records with a JDBC connector.
I want to return all records (work entries) from the second AL to the first (caller).
I know that I can do this using accumulator but I didn't understood how to use this.
The select return 3 fields, so each work entry have 3 properties.
var iwe = new com.ibm.di.entry.Entry();
iwe.setAttribute("Param1", "KM");
//Criando o bloco de execução do AL de DELETE
var tcb = system.newTCB();
var vector = new java.util.Vector();
tcb.setInitialWorkEntry(iwe);
vector.add(tcb);
vector.add(task.getLog());
var al = main.startAL("SecondAL",vector);
al.join();
//At this point I need to get all work entries returned by "SecondAL"
I found how to do this. Just to return to community i did this change on above script:

var iwe = new com.ibm.di.entry.Entry();
iwe.setAttribute("Param1", "KM");

//Criando o bloco de execução do AL de DELETE
var tcb = system.newTCB();
var vector = new java.util.Vector();
var entries = new java.util.ArrayList();
tcb.setInitialWorkEntry(iwe);
tcb.setAccumulator(entries);
vector.add(tcb);
vector.add(task.getLog());

var al = main.startAL("SecondAL",vector);
al.join();

Here I have the entries that is a Collection of entry and can do a for loop. The SecondAL doesn't need any change.
Eddie Hartman
2017-05-07 18:31:53 UTC
Permalink
Raw Message
Post by a***@gmail.com
Post by a***@gmail.com
I have a main AL that call other AL to select some records with a JDBC connector.
I want to return all records (work entries) from the second AL to the first (caller).
I know that I can do this using accumulator but I didn't understood how to use this.
The select return 3 fields, so each work entry have 3 properties.
var iwe = new com.ibm.di.entry.Entry();
iwe.setAttribute("Param1", "KM");
//Criando o bloco de execução do AL de DELETE
var tcb = system.newTCB();
var vector = new java.util.Vector();
tcb.setInitialWorkEntry(iwe);
vector.add(tcb);
vector.add(task.getLog());
var al = main.startAL("SecondAL",vector);
al.join();
//At this point I need to get all work entries returned by "SecondAL"
var iwe = new com.ibm.di.entry.Entry();
iwe.setAttribute("Param1", "KM");
//Criando o bloco de execução do AL de DELETE
var tcb = system.newTCB();
var vector = new java.util.Vector();
var entries = new java.util.ArrayList();
tcb.setInitialWorkEntry(iwe);
tcb.setAccumulator(entries);
vector.add(tcb);
vector.add(task.getLog());
var al = main.startAL("SecondAL",vector);
al.join();
Here I have the entries that is a Collection of entry and can do a for loop. The SecondAL doesn't need any change.
Thanks for sharing! You are absolutely right and can use an Java collection passed in as an Accumulator. You can also pass in a Connector whose putEntry() method is called at the end of each cycle. If you have a look at the Javadoc page for the TaskCallBlock (tcb) then you'll see the other two types of objects accepted as an Accumulator: https://www.stephen-swann.co.uk/javadoc/tdi7.1.1/index.html

o java.util.Collection - All work entries are cloned and added to the collection (e.g. ArrayList, Vector ..)
o ConnectorInterface - The putEntry() method is called
o ParserInterface - The writeEntry() method is called
o AssemblyLineComponent - The add() method is called

And of course you've got all the java docs installed locally under $TDI_INSTALLDIR$/docs/api

-Eddie
Andre Crespo
2017-10-02 21:06:18 UTC
Permalink
Raw Message
Post by a***@gmail.com
I have a main AL that call other AL to select some records with a JDBC connector.
I want to return all records (work entries) from the second AL to the first (caller).
I know that I can do this using accumulator but I didn't understood how to use this.
The select return 3 fields, so each work entry have 3 properties.
var iwe = new com.ibm.di.entry.Entry();
iwe.setAttribute("Param1", "KM");
//Criando o bloco de execução do AL de DELETE
var tcb = system.newTCB();
var vector = new java.util.Vector();
tcb.setInitialWorkEntry(iwe);
vector.add(tcb);
vector.add(task.getLog());
var al = main.startAL("SecondAL",vector);
al.join();
//At this point I need to get all work entries returned by "SecondAL"
Is there any way to accumulator not accumulate the first entry passed by tcb.setInitialWorkEntry method? I want my arraylist to return only entries from called AL, I need to ignore the first entry returned by "SecondAL" because it is the Initial Work Entry.
Franzw
2017-10-03 06:34:19 UTC
Permalink
Raw Message
Post by Andre Crespo
Post by a***@gmail.com
I have a main AL that call other AL to select some records with a JDBC connector.
I want to return all records (work entries) from the second AL to the first (caller).
I know that I can do this using accumulator but I didn't understood how to use this.
The select return 3 fields, so each work entry have 3 properties.
var iwe = new com.ibm.di.entry.Entry();
iwe.setAttribute("Param1", "KM");
//Criando o bloco de execução do AL de DELETE
var tcb = system.newTCB();
var vector = new java.util.Vector();
tcb.setInitialWorkEntry(iwe);
vector.add(tcb);
vector.add(task.getLog());
var al = main.startAL("SecondAL",vector);
al.join();
//At this point I need to get all work entries returned by "SecondAL"
Is there any way to accumulator not accumulate the first entry passed by tcb.setInitialWorkEntry method? I want my arraylist to return only entries from called AL, I need to ignore the first entry returned by "SecondAL" because it is the Initial Work Entry.
That should be pretty easy - just remove the work entry at the end of the loop. The easiest way is probably to use the AL hooks to do so.

HTH
Regards
Franz Wolfhagen
Eddie Hartman
2017-10-03 08:41:16 UTC
Permalink
Raw Message
Post by Franzw
Post by Andre Crespo
Post by a***@gmail.com
I have a main AL that call other AL to select some records with a JDBC connector.
I want to return all records (work entries) from the second AL to the first (caller).
I know that I can do this using accumulator but I didn't understood how to use this.
The select return 3 fields, so each work entry have 3 properties.
var iwe = new com.ibm.di.entry.Entry();
iwe.setAttribute("Param1", "KM");
//Criando o bloco de execução do AL de DELETE
var tcb = system.newTCB();
var vector = new java.util.Vector();
tcb.setInitialWorkEntry(iwe);
vector.add(tcb);
vector.add(task.getLog());
var al = main.startAL("SecondAL",vector);
al.join();
//At this point I need to get all work entries returned by "SecondAL"
Is there any way to accumulator not accumulate the first entry passed by tcb.setInitialWorkEntry method? I want my arraylist to return only entries from called AL, I need to ignore the first entry returned by "SecondAL" because it is the Initial Work Entry.
That should be pretty easy - just remove the work entry at the end of the loop. The easiest way is probably to use the AL hooks to do so.
HTH
Regards
Franz Wolfhagen
Franz is right, Andre, in that you can use task.setWork(null) to zero out the Work Entry. If you don't want the AL to cycle on the Initial Work Entry, use this call in one of the AL Prolog Hooks.
Loading...