Multi-column reports and multi-column reports

Source: Internet
Author: User
ArticleDirectory
    • Multi column report
Multi column report [edit] Data Structure

This is Tutorial how to create multiple columns on a report. the report designer has no support for multi column rendering; like in word where you can set a "Number of columns" property on a paragraph. as workaround create a temporary table with exactly the same fields as needed on the report. for example if you want to display salesid, custaccount, Itemid and qty from the salesline, the temporary table for two columns has 8 columns.

The getfreeslot () method is needed in the report to determine if there is a free column slot or if it is necessary to create a new line on the table.

Public static tmpsalestable2col getfreeslot (tmpsalestable2col TMP, int column) {; If (column = 1) {select firstonly TMP where TMP. salesid_1 = ""; return TMP;} else if (column = 2) {select firstonly TMP where TMP. salesid_2 = ""; return TMP;} else {Throw error ("column number must be between 0 and 1 ");}}
[Edit] Report

Create a new report and declare a variable from type of the temporary table.

 
Public class reportrun extends objectrun {tmpsalestable2col tmpsalestable ;}

Create a new method to populate the temporary table. in this example the salesline is fetched. if it was created in 2007 it belongs to column number 1 and if it was created in 2008 it belongs to column number 2. I assume here that there are only rows for 2007 or 2008. otherwise it wocould be good to filter the select by year. the find () method is used to find a free slot; that means a record exists but with a free slot for the needed column.

Private void populatetmptable () {salesline; tmpsalestable2col temp; int Col; While select salesline order by salesid {// 2007 is first column if (Year (salesline. createddate) == 2007) {temp = tmpsalestable2col: getfreeslot (tmpsalestable, 1); // existing record with free slot in first column if (temp) {temp. salesid_1 = salesline. salesid; temp. itemid_1 = salesline. itemid; temp. custaccount_1 = salesline. custaccount; temp. qty_1 = salesline. qtyordered; temp. update ();} else {tmpsalestable. clear (); tmpsalestable. salesid_1 = salesline. salesid; tmpsalestable. itemid_1 = salesline. itemid; tmpsalestable. custaccount_1 = salesline. custaccount; tmpsalestable. qty_1 = salesline. qtyordered; tmpsalestable. insert () ;}/// 2008 is second column if (Year (salesline. createddate) == 2008) {temp = tmpsalestable2col: getfreeslot (tmpsalestable, 2); // existing record with free slot in second column if (temp) {temp. salesid_2 = salesline. salesid; temp. itemid_2 = salesline. itemid; temp. custaccount_2 = salesline. custaccount; temp. qty_2 = salesline. qtyordered; temp. update ();} else {tmpsalestable. clear (); tmpsalestable. salesid_2 = salesline. salesid; tmpsalestable. itemid_2 = salesline. itemid; tmpsalestable. custaccount_2 = salesline. custaccount; tmpsalestable. qty_2 = salesline. qtyordered; tmpsalestable. insert ();}}}}

Override the fetch () method on the report. Call the populatetmptable and then send line after line to the report design.

 
Public Boolean fetch () {; element. populatetmptable (); While select tmpsalestable {element. Send (tmpsalestable);} return true ;}

Create a new section group for tmpsalestable2col and a body. put the fields from the table in the body or use a filedgroup. if necessary add a sum section, header etc. the report shoshould look like this

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.