I am trying to do the following scenario in Crystal. Normally, I would handle it with db Stored Procedures, but I don't have that option with my current data source - SAP ECC tables.
Example structure of report -
Table1.EmpId @Is Lead (logic) Table2.Reports To @Leader (logic)
1000 FALSE 2000 3000
Logic for Leader field is to be determined-
Step 1 -
For each employee (ex 1000), we first check with a logic if the it is a Lead position - If True then Is Lead is True and Leader is Null
If false, move to Step 2.
Step 2 -
Check if Employee No in the 'Reports To' field (ex. 2000) is a Lead position. If True then Leader field = Reports To
If false, move to Step 3
Step 3 -
Look up who the 'Reports To' Employee reports to (using same logic as before), ex. 3000. Again check if employee 3000 is a lead position. If True, then Leader = 3000. If false, repeat step 2 for Employee 3000.
Repeat until a Lead position is found.
I hope it is clear. Any help is appreciated !