web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Cannot execute the required database operation. Invalid physical table name specified

(3) ShareShare
ReportReport
Posted on by 11
Hello, I have created a batch job to send the customer account statement to the customers via email by passing the parameters of the report from a table that i have created but when running the batch it's throwing the error.

Below is the code that i have added to the run method :
 public void run ()
 {
     SysMailerMessageBuilder mailer = new SysMailerMessageBuilder();
     SysMailerSMTP smtp = new SysMailerSMTP();
     SrsReportEMailDataContract emailContract;
     str fileContentType;
     SysEmailContents body;
     int i,pagecount;
     System.IO.Stream copyto;
     System.IO.MemoryStream stream;
     DocuRef docuref;
     DocuValue DocuValue;
     GRML_CustSOAParm GRML_CustSOAParm;
     System.Byte[] reportBytes;
     while select forupdate * from GRML_CustSOAParm where GRML_CustSOAParm.IsSent == NoYesError::No
     {
         CustAccountStatementExtController controller = new CustAccountStatementExtController();
         controller.parmReportName(ssrsReportStr(CustAccountStatementExt,Report));
         controller.parmShowDialog(false);
         CustAccountStatementExtContract contract = new CustAccountStatementExtContract();
         contract.parmCustAccount(GRML_CustSOAParm.CustAccount);
         contract.parmFromDate(GRML_CustSOAParm.FromDate);
         contract.parmToDate(GRML_CustSOAParm.ToDate);
         contract.parmCustAccountStatementExtTmp(tableStr(CustAccountStatementExtTmp));
         controller.parmReportContract().parmRdpContract(contract);
         controller.parmReportContract().parmReportExecutionInfo(new SRSReportExecutionInfo());
         controller.parmReportContract().parmReportServerConfig(SRSConfiguration::getDefaultServerConfiguration());
         SRSPrintDestinationSettings printerSettings = controller.parmReportContract().parmPrintSettings();
         printerSettings.printMediumType(SRSPrintMediumType::File);
         printerSettings.fileFormat(SRSReportFileFormat::PDF);
         printerSettings.parmFileName("Account Statement.pdf");
         printerSettings.overwriteFile(true);
         SrsReportRunService SrsReportRunService = new SrsReportRunService();
         SrsReportRunService.getReportDataContract(controller.parmReportContract().parmReportName());
         SrsReportRunService.preRunReport(controller.parmReportContract());
         Map reportParametersMap = SrsReportRunService.createParamMapFromContract(controller.parmReportContract());
         Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService.ParameterValue[] parameterValueArray =
             SrsReportRunUtil::getParameterValueArray(reportParametersMap);
         SRSProxy srsProxy = SRSProxy::constructWithConfiguration(controller.parmReportContract().parmReportServerConfig());
         reportBytes = srsProxy.renderReportToByteArray(
             controller.parmReportContract().parmReportPath(),
             parameterValueArray,
             printerSettings.fileFormat(),
             printerSettings.deviceInfo()
             );
         
         stream = new System.IO.MemoryStream();
         if(reportBytes)
         {
             stream.Write(reportBytes,0,reportBytes.Length);
             fileContentType = System.Web.MimeMapping::GetMimeMapping("Account Statement.pdf");
             stream.Position = 0;
             mailer.addAttachment(stream,"Account Statement.pdf",fileContentType);
             mailer.setSubject("Account statement");
             mailer.setFrom(SysEmailParameters::find().SMTPUserName);
             mailer.setBody("Kindly find your account statement in the attachement");
             mailer.addTo("");
             try
             {
                 smtp.sendNonInteractive(mailer.getMessage());
                 mailer.reset();
             }
             catch
             {
                 throw Error ("Email failed to send");
             }
         }
     }
 }
It is throwing the exception for this line :  SrsReportRunService.preRunReport(controller.parmReportContract());
 
Kindly help me fix this issue.
 
Categories:
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    236,336 Most Valuable Professional on at
    Cannot execute the required database operation. Invalid physical table name specified
    First of all, let me remove unnecessary code and re-post the remaining in the right way:
    GRML_CustSOAParm custSOAParm;
    
    select firstOnly custSOAParm
       where custSOAParm.IsSent == NoYesError::Noů
    
    CustAccountStatementExtController controller = new CustAccountStatementExtController();
    controller.parmReportName(ssrsReportStr(CustAccountStatementExt, Report));
    controller.parmShowDialog(false);
    
    CustAccountStatementExtContract contract = new CustAccountStatementExtContract();
    contract.parmCustAccount(custSOAParm.CustAccount);
    contract.parmFromDate(custSOAParm.FromDate);
    contract.parmToDate(custSOAParm.ToDate);
    contract.parmCustAccountStatementExtTmp(tableStr(CustAccountStatementExtTmp));
    
    controller.parmReportContract().parmRdpContract(contract);
    controller.parmReportContract().parmReportExecutionInfo(new SRSReportExecutionInfo());
    controller.parmReportContract().parmReportServerConfig(SRSConfiguration::getDefaultServerConfiguration());
    
    SRSPrintDestinationSettings printerSettings = controller.parmReportContract().parmPrintSettings();
    printerSettings.printMediumType(SRSPrintMediumType::File);
    printerSettings.fileFormat(SRSReportFileFormat::PDF);
    printerSettings.parmFileName("Account Statement.pdf");
    printerSettings.overwriteFile(true);
    
    SrsReportRunService SrsReportRunService = new SrsReportRunService();
    SrsReportRunService.getReportDataContract(controller.parmReportContract().parmReportName());
    SrsReportRunService.preRunReport(controller.parmReportContract());
    You're passing a wrong value to parmCustAccountStatementExtTmp(). It should be the name of an a physical table in TempDB database, i.e. a particular instance of CustAccountStatementExtTmp with data. You need insert some data to CustAccountStatementExtTmp and call getPhysicalTableName() on the table buffer to get the name. You can see an example in CustAccountStatementExtController class: insertCustAccountStatementExtTmp() inserts a record and populateReportSettingsByCustomer() passes the physical table name to the contract.
  • CU26110824-0 Profile Picture
    11 on at
    Cannot execute the required database operation. Invalid physical table name specified
    Hello martin, I added the parmCustAccountStatementExtTmp() to my code just to check if that would solve the issue because i was getting that issue by just passing the dates and customer number parameters.
    Wouldn't i be able to run the report by just passing the other 3 parameters without the parmCustAccountStatementExtTmp?
  • Martin Dráb Profile Picture
    236,336 Most Valuable Professional on at
    Cannot execute the required database operation. Invalid physical table name specified
    I think you already know the answer: you already tried it and it failed.
     
    If you look at references of parmCustAccountStatementExtTmp(), you'll see that the data provider class depends on it:
    public void processReport()
    {
        CustAccountStatementExtTmp custAccountStatementExtTmp;
        CustAccountStatementExtContract contract = this.parmDataContract() as CustAccountStatementExtContract;
    
        //Set the correct tmpDB table instance to use
        custAccountStatementExtTmp.useExistingTempDBTable(contract.parmCustAccountStatementExtTmp());
  • CU26110824-0 Profile Picture
    11 on at
    Cannot execute the required database operation. Invalid physical table name specified
    could you please advice on how i could fix it in my code, i was trying to look into it and wasn't able to break down how to solve it.
    Thank you.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,029

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 871 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 582 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans