Below is a rudimentary code I wrote to fetch tables and columns in a Crystal Report based on Oracle DB.
IInfoObject report = (IInfoObject)boInfoObjects.get(j); try { ReportClientDocument originalDoc = rptAppFactory.openDocument((IInfoObject)boInfoObjects.get(j),0,Locale.ENGLISH); DatabaseController dbc = originalDoc.getDatabaseController(); IDatabase db = dbc.getDatabase(); Tables tbs = db.getTables(); for(int i=0;i<tbs.size();i++) { ITable tb = tbs.getTable(i); String tbn = tb.getQualifiedName(); out.println(title+"::"+path+"::"+tbn+" - TableName </br>"); Fields fds = tb.getDataFields(); for(int k=0;k<fds.size();k++) { IField fd = fds.getField(k); out.println("</br>" + k); out.println("</br>" + fd.getName()); out.println("</br>" + fd.getKind()); out.println("</br>" + fd.getType()); } } originalDoc.close(); }
The problem with this code is that it returns all the fields available in the tables in the report. I require only the fields that are actually used in the report.
I tried DataDefinition also but couldn't make it work. Fields could be used in any section/object like groups, group headers, formulae etc. If it is used even once anywhere, I need that field name in the form QUALIFIED_TABLE_NAME.FIELD_NAME
Basically any DB field that would have that green tick in the Field Explorer.
Is there any way to get it?
Other Details : BI 4.0 SP9, Crystal Reports 2011
Thanks & Regards
Antony