Statement Design

Hi I am trying to get a field from the Sales Invoice Header table to appear on the statement against the line entries (the Cust Ledger Entry). The field is not pushed through to the Customer Ledger Entry table so I am trying to pull it directly from the Sales Invoice Header file. I have tried redesigning the statement to include the Sales Invoice Header table and linked it to the Customer Ledger Entry table by invoice number. Then created global variables and then entered a new field in the Cust Ledger Entry Body referencing the global and the required field, however this appears as blank everytime on the statement, but I know the field is populated. I feel I am close, but missing some vital step (the one that gets it to work!) Any pointers appreciated. Steve

You need to create a variable of type record-Sales Invoice Header, from View Globals Call it something like SalesHeader Then on the OnAfterGetRecord trigger of the Cust Ledger Entry line. You see this by going on the line and pressing F9 the trigger names are highlighted. IF (“Cust Ledger Entry”.“Document Type” <> “Cust Ledger Entry”.“Document Type”::Invoice) OR NOT(SalesHeader.GET(“Cust Ledger Entry”.“Document No.”) THEN SalesHeader.INIT; This will populate the SalesHeader table only if the ledger entry table is for an invoice. On you report create a control and in the source field put SalesHeader.“What Ever Field” I Hope this helps, and you should find it easier that adding the record to the report structure. Paul Baxter

Hi Paul Thanks for the input, unfortunately it only half works. I am bringing the “Your Reference” field onto the line. The code you gave me (so kindly) now populates the field on the line, but in many instances the field can be blank in the table, but this is now seen as a different entry rather than blank. I presume I need to say what to do if the field I am collecting is blank. Any more ideas? Cheers Steve

Now just to make sure youe are trying to get Invoice headers from the “Cust Ledger Entry” table. If you are then is should pull the “Your Reference” field from the header if it is blank or not. Try putting the invoice No on the report and looking at the invoice header, to try and see what is happening. If the cust ledger entry is not an invoice or the invoice the salesheder variable should be blank. The other thing to check is that you put the code on the correct OnAfterGetRecord trigger. From the report designer go onto the “Cust Ledger Entry” line and press F9 and make sure the code is there and not on another table?? Thats about all I can suggest with out more information Paul Baxter

Hi Paul I am trying to pull the field from the Sales Invoice Header table. I have put the invoice field from the Sales Header Invoice Table on the report and it is only capturing one record, the one with an entry in the “Your Reference” field. Essentially I have two sales orders that have been invoiced. One contained a reference in the “Your Reference” field, the other did not. If I run the statement the entries from the Custonmer Ledger Entry table calculate correctly (I am only looking at invoices) but for the fields I am pulling from the Sales Invoice Header table I get the invoice with an entry in the “Your REference” field repeated twice, both the number and the reference. It seems to me that I need to additionally say where the invoice number in the Cust. Ledger Entry table equals the Invoice number in the Sales Header Invoice table. I hope this helps you help me! Steve

Hi Paul It was my fault as I was referencing a different Cust Ledger section form teh one the code was in, so a slight alteration as seen below solved the problem. IF (“Document Type” <> “Document Type”::Invoice) OR NOT (SalesInvoiceHeader.GET(“Document No.”)) THEN SalesInvoiceHeader.INIT ; Thanks for your guidance though - it is greatly appreciated. Steve

Steve Yes that is the way it goes, now you can just modify the code to use the same principles in any report. Paul Baxter