Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Calling Crystal Reports using Dexterity

(0) ShareShare
ReportReport
Posted on by

Hi All,

I am using Dexterity to call Crystal Reports. If the report is based on GP tables, the code works fine. But if the report is based on stored procedure, the code fails with error table 'stored procedure name' not found. How do I rectify this. The code is as follows:

local reference {CRAXDRT.DatabaseTable} myTable;
local reference {CRAXDRT.DatabaseTables} myTables;
local reference {CRAXDRT.DatabaseTable} sub1Table;
local reference {CRAXDRT.DatabaseTables} sub1Tables;
local reference {CRAXDRT.SubreportObject} subReport1;
local reference {CRAXDRT.Sections} crxSections;
local reference {CRXADRT.Section} crxSection;
local reference {CRXADRT.ReportObjects} crxReportObjects;
local reference {CRAXDRT.Report} crxSubreport;
local reference ReportObject;
local reference Report,crxApplication;
local reference crviewer;

local long x,a,b,c,iTableCount,iSub1TableCount,iSectionsCount,iReportObjectsCount;
local string DSN,sUser,sDatabase,sPassword;
local string connectionstring;
local text t;

if empty('(L) PathToReport') then
warning "Please select a Crystal Report to print.";
abort script;
end if;


DSN = Defaults_Read("SQLLastDataSource"); {the datasource Great Plains is using}
{sUser = 'User ID' of globals; {current logged in user}


if 'Password Unencrypted' of globals then
sPassword = Utility_DecodeString(SQLPassword of globals);
else
sPassword = SQLPassword of globals; {sPassword will be the password on the SQL server in whatever form}
end if;
}
sUser = "crystal";
sPassword = "Access@123";
sDatabase = 'Intercompany ID' of globals; {Current SQL database}

try

connectionstring = "Driver={SQL Server};Server=" + GetSQLInstanceName() + ";Database= " + sDatabase +";Trusted_Connection=yes;" ;

{create the Crystal Report object}
crxApplication = COM_CreateObject("CrystalRuntime.Application.10");

{open the report}
Report = crxApplication.OpenReport('(L) PathToReport');
Report.DiscardSavedData();

{count our tables and set the collection}
iTableCount = Report.Database.Tables.Count;
myTables = Report.Database.Tables;

{spin through the tables and log into the database for each}
for x = 1 to iTableCount do
myTable = myTables.Item[x];

myTable.SetLogOnInfo (DSN, sDatabase, sUser, sPassword);

myTable.Location = sDatabase + CH_PERIOD + ST_DBO + CH_PERIOD + myTable.Location; {such as TWO.dbo.RM00101}



end for;

crxSections = Report.Sections;
iSectionsCount = Report.Sections.Count;

for b = 1 to iSectionsCount do
crxSection = crxSections.Item[b];

crxReportObjects = crxSection.ReportObjects;
iReportObjectsCount = crxSection.ReportObjects.Count;

for c = 1 to iReportObjectsCount do
ReportObject = crxReportObjects.Item[c];
if ReportObject.Kind = CRAXDRT.crSubreportObject then
subReport1 = ReportObject;
crxSubreport = subReport1.OpenSubreport;

iSub1TableCount = crxSubreport.Database.Tables.Count;
sub1Tables = crxSubreport.Database.Tables;

{spin through the tables and log into the database for each}
for a = 1 to iSub1TableCount do
sub1Table = sub1Tables.Item[a];

sub1Table.SetLogOnInfo (DSN, sDatabase, sUser, sPassword);
sub1Table.Location = sDatabase + CH_PERIOD + ST_DBO + CH_PERIOD + sub1Table.Location; {such as TWO.dbo.RM00101}
end for;
end if;
end for;
end for;

if '(L) RptDestination' = 0 then

{Use the CR viewer created in VB6. Pass the report object to it and set the title of the window}
crviewer = COM_CreateObject("ReportView.CRView");
crviewer.ShowForm(Report,"Tax Invoice");

else

{Print to the Printer}
Report.PrintOut();
end if;

else
throw;
end try;

 

How can I resolve this? The error occurs when setting location.

Thanks in advance,

Regards,

Saras

*This post is locked for comments

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics

Product updates

Dynamics 365 release plans