I was in your same shoes last year... I was thrown the AX reporting and said "here, fix these and make them what we want". General things to note about AX reports, and then we'll get to POs:
- You can add datasets in 4 different ways from AX, but the most common you'll see is a Report Data Provider class. This class is usually handed a query defined as an attribute in the classDeclaration which can then be modified and processed (in the processReport method) to fill in a temporary data table(s), which is then handed back to the report for display (get[tableName] method). Often this is split into one or more "insert" methods. For POs, your RDP class is PurchPurchaseOrderDP.
- Reports can also have a Contract class, which is basically a class to declare specific parameters that you'd like to process in your RDP or display on the Report itself and to do some pre-processing. If you use one, this is also defined as an attribute in the RDP classDeclaration. For PurchPurchaseOrderDP, you can see it is tagged with "[SRSReportParameterAttribute(classStr(PurchPurchaseOrderContract))]" in its class declaration. PurchPurchaseOrderContract is the contract class for this report.
-Even with an RDP, reports will 99% of the time have a query that it calls, which many times is as I said another attribute of your RDP. You can modify these queries to add fields, more data sources via joins (relationships), etc. You'll then have to add the fields to your report's temporary data table. Then, you can modify your RDP to fill in these fields with the retrieved data. POs, however, are very different. They use the "PurchTableAllVersions" and "PurchLineAllVersions" queries to pull data, both of which are already pulling every field from their respective tables. Unless you're adding custom fields to the tables, there is no need to modify the queries.
-After you've modified your query, temp table, and RDP, you can go into VS and refresh the reports dataset to get the new fields in and design from there.
The trick most of the time is traversing AX's overly-normalized model to find what you're looking for. Anyway, back to specifically POs, there are several objects you will need to modify. I would recommend starting with a less complex report (SalesNotInvoiced is very straight forward) to understand how everything is put together, but I'll continue on with the PO stuff.
The most important question is... are you adding any fields to the PurchTable or PurchLine table? AKA, adding custom data to Purchase Orders/ Lines? We did. And that's more work. I'll assume your not.
The PO has 2 tmp tables: PurchPurchaseOrderHeader and PurchPurchaseOrderTmp. The header stores the header info (wow!) and the tmp stores your "rows". Remember those insert methods on the RDP? Well, for POs they decided to make one of those for the details (setPurchPurchaseOrderDetails), but for the PurchPurchaseOrderHeader they decided to write the methods on the table itself (initFrom***). Why did they do that? No clue. I listed what I changed on each object below.
Objects to modify:
- PurchPurchaseOrderHeader - Add any extra fields you want to show. Modify any initFrom*** methods for any added fields from those tables. For payment terms, assuming you added the field to the table already, it would be "this.PaymentTerms = _purchTableAllVersions.Payment;"
- PurchPurchaseOrderTmp - Add any extra fields you want to show.
- PurchPurchaseOrderController - I only changed the 'documentTitle' method to get our titles on.
- PurchPurchaseOrderDP - modify setPurchPurchaseOrderDetails() to fill any fields you added to the PurchPurchaseOrderTmp table.
That should be it. If you open the report in VS and refresh your dataset (or go in and select the new fields if the dataset doesn't "SELECT * FROM [table]") and your new fields should show up.
Good luck on your reporting adventures!