TOPIC: Question regarding reports
#1957
Question regarding reports 2 Weeks ago
Hi,

I am returning to using Suneido after a long time and have been fighting my way through by trying to recode some old stuff I once wrote which doesn't work in the current version. I have solved everything but just can't get my head around why the reports are not working. I have reverted back to the good old handbook and reduced the handbook code to the following which works fine as a test (although of course does nothing useful):
Code:

#(Params
    title: "Invoice"
    name: "Invoice_Rpt"
    Params: (Form )
    QueryFormat
        {
        Query()
            {
            return "invoice sort invoice "
            }
        Before_invoice(data)
            {
            return Object("Vert"
                Object("Text", "test" $ data.invoice,
                    font: #(name: Arial size: 12 weight: 600))
                "header")
            }
        Output: false
        After_invoice(data)
            {
            .Append(Object(
                QueryFormat
                    {
                    Query()
                        {
                        return "invoicelines";
                        }
                    Output: (Row product qty price total_price)
                    }
                Hdr: data))
            return 'pg'
            }
        }
    )


I have been trying to use my own tables and just replace the table names and field names with my own table and field names and got the message "no data found for report". The tables are of course populated. I then simply changed the query line to:

Query()
{
return "invoice"
}

and I get the same message.

also this gets the same result:

Query()
{
return "invoice sort invoice_number"
}


On my own tables no matter what I enter I can't get the report to show any data. Why is this? It would be great if some one could help me out here as I am stumped.
 
 
Last Edit: 2010/08/09 17:31 By andrew.
 
#1962
Re:Question regarding reports 1 Week, 6 Days ago
Hi Andrew,

Your code looks mostly correct. I am not sure exactly what is failing. (I do not write many reports these days so I am out of practice too.) I am not sure what "header" is for?

That message means that the report did not produce any output. Usually that is because a user has entered options that do not select any records. But it can also come from a bug in a report not actually outputting anything, even though there is data.

Here is a comparable example:
Code:

#(Params
    QueryFormat
        {
        Query()
            {
            return "tables sort tablename"
            }
        Output: false
        Before_tablename(data)
            {
            return Object("Text", "test_" $ data.tablename,
                font: #(name: "Arial" size: 12 weight: 600))
            }
        After_tablename(data)
            {
//          .Append(Object(
//              QueryFormat
//                  {
//                  New(hdr)
//                      {
//                      super("columns where table = " $ Display(hdr.table))
//                      }
//                  },
//              data))
            .Append(Object("Query", 
                "columns where table = " $ Display(data.table)))
            return "pg"
            }
        }
    )


It is a little tricky to get the header data into the nested query format. (Partly because the Query() method is called before New) I have shown the two easiest ways.

NOTE: To use Before_ and After_ you must have the sort on the query or the methods will not get called. (put Print in to check)

For this example, it would be easier to just join the tables and not use the nested query:
Code:

#(Params
    QueryFormat
        {
        Query()
            {
            return "tables join columns sort tablename"
            }
        Before_tablename(data)
            {
            return Object("Text", "test_" $ data.tablename,
                font: #(name: "Arial" size: 12 weight: 600))
            }
        After_tablename()
            {
            return "pg"
            }
        }
    )


However, there is a difference in where the column headings show up, which may or may not be an issue.

(If you noticed this reply coming and going, it is because the page was intermittently coming up blank and we were testing. Kaspersky Web Anti-Virus seems to be blocking it for some reason.)
 
 
andrew