on 07-08-2004 8:44 AM
Hello expert,
could you please tell me how to create a subtotal line in a table control, that can automatically give the total of some specific numric columns? (just like ALV)
thanks and best regards.
Jun
Hi Jun,
assume a value node A to which the table's dataSource is bound. A has two value attributes C1 and C2, type integer. You want to display the summarized value of C2. The cell editors are TextViews:
1. Add a boolean attribute "VIsSumLine" to A.
2. Add a readonly attribute "VNoSumColumnVisible", type Visibility, to A. Set calculated to true and insert the following code lines into the calculated getter:
if (element.getVIsSumLine()) {
return WDVisibility.BLANK;
} else {
return WDVisibility.VISIBLE;
}
3. Add a readonly attribute "VSumCellTextViewDesign", type TextViewDesign to A. Set calculated to true and insert the following code lines into the calculated getter:
if (!element.getVIsSumLine()) {
return WDTextViewDesign.STANDARD;
} else {
return WDTextViewDesign.EMPHASIZED;
}
This will display the sum cells bold lateron.
4. Bind the C1_editor-visible property to A.VNoSumColumnVisible.
5. Bind the C2_editor-design property to A.VSumCellTextViewDesign.
6. Context filling for testing (in wdDoInit() of the view controller for example):
int sumC2 = 0;
for (int ix = 0; ix < 10; ix++) {
sumC2 += ix * 20;
I<YourView>.IAElement el = wdContext.nodeA().createAElement();
el.setC1(ix * 10);
el.setC2(ix * 20);
el.setVIsSumLine(false);
wdContext.nodeA().addElement(el);
}
/* Add the sum line */
I<YourView>.IAElement el = wdContext.nodeA().createAElement();
el.setC2(sumC2);
el.setVIsSumLine(true);
wdContext.nodeA().addElement(el);
/* Set the sum line to display as selected table entry */
wdContext.nodeA().setLeadSelection(wdContext.nodeA().size() - 1);
This does not work, if A is bound to a structure, since you can't add value attributes to nodes which are bound to structures. Adaptive RFC model nodes are bound to the structure created from the function module interface in the ABAP system. But there's a workaround:
1. Create value node A with structure binding, select the corresponding structure which were created on model import. Select the attributes you want to display in the table. After that, delete the structure binding from A (the attributes are kept and still have the correct SimpleType).
2. Add the attributes which control the visibility and summing as described before.
3. Bind the table's dataSource to A instead of the RFC model node (including the editor settings).
4. In the method which fills the model, create the elements of A and copy the value attributes which are part of the original model from the model to the A-elements. Do the summing and setting of "VIsSumLine" as requested.
This is not really automatically, but at least it works
Hope that helps.
Regards
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
All nice and well. But:
The current IWDTable has not been designed to provide such features and, as you have shown, there is no easy method to add them via the existing API.
So I would recommend to wait until the ALV like table will be provided. It is already planned for the (not so far) future.
Regards, Armin
Hi Net Zilla,
I don't know if I can help you, but how are you populating the data in the table? I presume it's from some context.
How much data are you looking at summing up?
Message was edited by: Michael Phorn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
any help / hints are highly appreciated.
we are facing this issue right now, we find it's very hard to build a sub title line of a table control.
we have to calculate the totals and append another small table below the table and put the total numbers into it.
is there any good idear?
best regards.
netz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.