Recursion In Abinitio
Input as well Lookup labeled as "EmpMgrDtails" having fields as EMPID, MGRID
EMPID, MGRID Level topmostmgrid 1007, 1006 4 1006, 1003 3 1003, 1002 2 1002, 1001 1 1001, 1000 0 3007, 3006 5 3006, 3003 4 3003, 3002 3 3002, 3001 2 3001, 1001 1 4008, 4002 2 4002, 4000 0 4003, 4002 2 5009, 5004 4 5004, 4003 3 9900, 9001 2 9001, 9000 1 9000, 8000 0 ========== The Input dataset will be used as input and lookup as well.
Input data -> Refromat (lookup) -> Output out:reformat(in)= begin out.empid :: in.EMPID; out.topMgrId :: top_mgrid(in.EMPID,in.MGRID); //Call the top_mgrid recursive function end; //topmgid is a recusive function which returns the ultimate mgrid out::top_mgrid(string(int) empid,string(int) mgrid)= begin out:1:if(!(lookup_match("EmpMgrDtails",mgrid)) mgrid; out::top_mgrid(mgrid,lookup("EmpMgrDtails",mgrid).MGRID); end succession -recursion Other example of Resucursion:
factorial N=n*n-1*n-2*....1. empid, topMgrId 1007, 1000 1006, 1000 1003, 1000 1002, 1000 1001, 1000 3007, 1000 3006, 1000 3003, 1000 3001, 1000 4008, 4000 4002, 4000 4003, 4000 5009, 4000 5004, 4000 9900, 8000 9001, 8000 9000, 8000 For More Abinitio AWS Database content please visit my youTube channel.
https://www.youtube.com/@datapundit
@datapundit
Comments
Post a Comment