2

In the salesInvoice ssrs Report i have added a table called carTableEquipTmp which is not there by default, which I insert into along with the other tables(SalesinvoiceTmp and SalesinvoiceHeaderFooterTmp) in SalesInvoiceDP.InsertIntoSalesInvoiceTmp().

Even though my table carTableEquipTmp is getting successfully inserted into, the data doesn't show up on the report if i print a proforma report.

If i add test values to the carTableEquipTmp table in SalesInvoiceDP.processReport() they show up on the proforma invoice, but there's no way for me to get any parameters needed to set in the correct data into the table at this point. If i stop at this point in the debugger none of the data is present because processreport() is being called from a lower level in the code.

I think it might be a problem with maybe pack/unpack or that the proforma code runs from a server instance as the code run when it is proforma is quite different.

I can see that SalesInvoiceJournalPostBase.CreateReportData() creates an instance of salesInvoiceDP

salesInvoiceDP = new SalesInvoiceDP();
salesInvoiceDP.parmDataContract(salesInvoiceContract);
salesInvoiceDP.parmUserConnection(new UserConnection(true));

salesInvoiceDP.createData();

And that this might have something to do with it... but i still cant get the data i want in the carTableEquipTmp table.

So any idea on how to make Ax 2012 accept this new table i have added as it gets inserted into just like the other tables and there seems to be no problem...

I hope you guys can help.

Heygar
  • 553
  • 1
  • 7
  • 19
  • Have you inserted your data as a new datasource in the rdp/ssrs or are you inserting it into salesInvoiceTmp? – Spencer Kershaw Mar 24 '16 at 14:55
  • It is new table called CarTableEquipTmp and it is returned from the RDP and added in the ssrs/report design. It works fine when the invoice is not proforma. Is there anywhere i must add a reference to the table to get it to show on the report? – Heygar Mar 26 '16 at 00:01
  • I ran into a similar situation a couple days ago, and my problem was that I had not set up the pre-processing code properly. can you tell me the following: - Have you modified SalesInvoiceDP.useExistingReportData()? - Is your temp table of type regular? I'll post an answer if both of those are "no" as you would likely need to create the code to handle this case (useExistingReportData gets called in the proforma scenario) – Spencer Kershaw Mar 30 '16 at 17:14
  • Hey. Thanks for answering. I have not modified SalesInvoiceDP.useExistingReportData() and my temp table is of tableType regular – Heygar Apr 19 '16 at 18:48

1 Answers1

1

The SalesInvoice report has two data classes you need to look at for the data provider, SalesInvoiceDP and SalesInvoiceDPBase. SalesInvoiceDPBase extends SrsReportDataProviderPreProcess, so there are a couple extra steps you need to take in order to add new datasources to the report.

In the salesInvoiceDP class, there is a method called useExistingReportData(), which re-inserts the pro-forma temp table data under a user connection, so the SrsReportDataProviderPreProcess framework will pick it up in your report. When the pro-forma process creates the report data, it doesn't insert with a user connection so it doesn't get added to the report. This method only gets called when the report is being run pro-forma.

You will need to add your temp table to this method, and follow the pattern for the other tables, so your code will look something like this:

//this is different from the buffer you insert your data with
CarTableEquipTmp localCarTableEquipTmp;

...

recordList = new RecordSortedList(tableNum(carTableEquipTmp));
recordList.sortOrder(fieldNum(carTableEquipTmp, RecId));

//You will need to add a field to relate your temp table 
//to the current invoice journal, and insert it in 
//InsertIntoSalesInvoiceTmp() if thats where you're inserting your table.
while select localCarTableEquipTmp
    where localCarTableEquipTmp.JournalRecId == jourRecId 
{
    recordList.ins(localCarTableEquipTmp);
}

delete_from localCarTableEquipTmp
    where localCarTableEquipTmp.JournalRecId == jourRecId;

recordList.insertDatabase(this.parmUserConnection());

This method re-inserts your data under the framework and deletes the original data. The data that was re-inserted will then get picked up by the framework and show in your report. If you open CarTableEquipTmp in the table browser, you will most likely see data still there from all the times you have tried running the report. This is why we have the delete_from operation after we re-insert the data. When data is inserted under a userConnection, it is automatically deleted when the report is finished

The other method you will want to modify is SalesInvoiceDP.setTableConnections(), and you will just need to add the following line:

CarTableEquipTmp.setConnection(this.parmUserConnection());

This will set the user connection for your table when running regular (not pro-forma). You will probably want to delete the data that is stored currently in your temp table using alt+F9 from the table browser.

Other than that it's all standard RDP stuff, but it sounds like you have that part working fine. Your temp table must be of type "Regular" for this to work.

Spencer Kershaw
  • 480
  • 5
  • 13
  • This was excactly what i was looking for. Thank you very much for assisting, works like a charm! – Heygar May 04 '16 at 08:49