?
Solved

Dynamic column creation at runtime

Posted on 2006-05-28
2
Medium Priority
?
668 Views
Last Modified: 2013-12-26
I want to make an report in power builder.
I want to produce statistical information for each company. I will pass the company code as retrieval argument. Each company can have any number of  branchs. i want to make the report with branch name as column, based on the number of branchs retrieved the number of columns for the report will change. Below each branch name i want display their statistical information also i need the total summary for those informations.without using crosstab
0
Comment
Question by:batchakamal
2 Comments
 
LVL 5

Expert Comment

by:buasuwan
ID: 16815098
Hi batchakamal,

     The easiest way is using 'N-up' datawindow.  In this type of report, it cans diplay the brach names as columns. And you can display statistical information of these branches below.

     But you need to set 'Number of rows per detail band' to the maximum values.  And then you need some codes to hide the unused texts at the header band above brach names like this if you have.

long  rowcount, index
rowcount = dw_1.rowcount()

long  max_branches = 500

for index = rowcount + 1 to max_branches
    dw_1.modify("branchname_t_" + string(index) + ".visible = '0'")
next


Hope this help,
0
 
LVL 6

Accepted Solution

by:
tr1l0b1t earned 1000 total points
ID: 16844387
Hi,

I think easiest way is not to create fields but hide/show them. In this case
you could use nested reports. Imagine you put 10 nested reports vertically
(the needed to fit page width) in Summary band, all of them invisible,
all with the same dataobject which receives one argument, the branch code
(which will be supplied by script).

In the retrieve process we loop throught company branchs and make visible
the needed nested reports :

Long ll_row, ll_rows
Long ll_max_branchs = 10
String ls_branch
String ls_nobranch = '0'

// Retrieve company branchs ...
DataStore lds_branchs
lds_branchs.DataObject = 'd_ds_branchs'
lds_branchs.SetTransObject(SQLCA)
lds_branchs.Retrieve(ls_company)

ll_rows = lds_branchs.RowCount()
For ll_row = 1 to ll_max_branchs
      If ll_row <= ll_rows Then
            // Assign a nested and make it visible
            ls_branch = lds_branchs.GetItemString(ll_row, "branchID")
            dw_report.Modify("nested" + String(ll_row) + ".Nest_Arguments=((~"'" + ls_branch + "'~"))")
            dw_report.Modify("nested" + String(ll_row) + ".Visible = '1'")
      Else
            // Hide
            dw_report.Modify("nested" + String(ll_row) + ".Nest_Arguments=((~"'" + ls_nobranch + "'~"))")
            dw_report.Modify("nested" + String(ll_row) + ".Visible = '0'")
      End If
Next

DESTROY lds_branchs

dw_report.Retrieve(ls_company)

Well, just an idea ...i've tested and works.
At end, you'll have to get values from each nested to calculate totals.
Let me know if you have any question about it.
Regards
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question