Sum of numeric field
Hi All
Is there a server behavior to calculate the sum in a numeric
field? I know how to do the total records, but can't find one to do
summation in Dreamweaver 8.
Please help.
JA
SQL will do a sum, e.g.,
SELECT SUM(quantity) AS total_orders
Use something like that to create a recordset which contains
a single value
(total_orders=200) or something.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com
- Template Triage!
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
==================
"jka_za" <[email protected]> wrote in
message
news:eeot05$da7$[email protected]..
> Hi All
> Is there a server behavior to calculate the sum in a
numeric field? I know
> how to do the total records, but can't find one to do
summation in
> Dreamweaver 8.
> Please help.
>
> JA
Similar Messages
-
Sum of Checkbox plus numeric field
I have a form in which there are up charges for larger sized garments xxLarge vs Large. I am unsure of the script to use for this.
I can generate a price from a pull down menu for the base size and send the price to a numeric field.
if
(xfa.event.newText=="Letter Sweater w/Stripes")
{(jacketprice.rawValue=
"129.90")}
I then repeat this for each style in the pull down, I also have check boxes named "size" and each has a On Value coresponding to its size. so one checkbox's On Value is "small" the next checkbox is "medium" and so on. I need to have the xxlarge and xxxLarge buttons send a value to the jacket price numeric field. The small - large check boxes will continue to send no price increase. I also dont want multiple buttons activated at the same time.1st thing is that checkboxes by default are not mutually exclusive meaning that you woudl have to write code to ensure that the user only picked one. However you can create radio buttons and make them look like checkboxes. Radiobuttons by default are mutually exclusive. Then on the RadioButton group change event you can have the price adjusted accordingly.
Hope that helps
Paul -
Hello Guys,
CAn any one tell me how to do the SUM for a particular column in ALV.It should display at the End of the records.The column field is TYPE N(4).
My CODE is like this:
CLEAR fc_tmp.
fc_tmp-col_pos = 5.
fc_tmp-reptext_ddic = 'POINTS'.
fc_tmp-fieldname = 'POINTS'.
fc_tmp-tabname = 'ITAB'.
fc_tmp-outputlen = 15.
fc_tmp-key = 'X'.
fc_tmp-do_sum = 'X'.
APPEND fc_tmp TO fieldcat.
This is not working.
Thanks in Advance,
Take careHi,
populate the IT_SORT internal table of REUSE_ALV_GRID_DISPLAY provided in the importing parameters.
fieldname = Company Code
append fieldname to it_sort.
fieldname = division.
append fieldname to it_sort.
If you explicitly need subtotals then add the following line
subtot = 'X'
For obtaining sum you have an attribute "do_sum" in fieldcatalog , set it to 'X' and you should be able to do sum on that field.
<b>Ensure that these should be numeric / currency or quantity datatypes only.</b>
wa_fieldcat-datatype = 'CURR'. or
wa_fieldcat-datatype = 'QUAN'.
Hope this solves your problem
Cheers,
Simha.
PS : Please reward points if solution is helpful -
Aggregate a numeric field in an internal table
Hi All,
I have a small requirement in ABAP it goes in this fashion
I need to aggregate a numeric field in an internal table, the table is as follows
FLD1 FLD2 NUM1 FLD3
123A B1 10 C1
123A B1 25 C1
123B B1 20 C2
123C B2 10 C3
Note: FLD1, FLD2, FLD3 are of type numeric characters and NUM1 is of type number or integer
I want the result to be as follows
FLD1 FLD2 NUM1 FLD3
123A B1 35 C1
123B B1 20 C2
123C B2 10 C3
i.e. values in field NUM1 should get add up when the values in all other fields are same
I am not able to use _collect_ for this as the fields contain numeric characters.
Regards and Thanks,
AntonyHi Antony
collect here works like this:-
use at new field
sum
end at.
Pls reward points if it wil be helpful.
Regards
Depanker -
Change the style of a numeric field when his value is 0
I need show a numeric field in some reports with color red and italic font, but only when the value of number is low than zero. In another case the text must be normal. Is really possible do that? That applies to section details or final summaries.
Many thanks for the help.Hi
To make your number filed in Red :
Right click on the field and go in format field click on Font tab and go in Color formula editor and give the following formula :
If Sum(fieldValue} < 0 Then CrRed else CrNoColor
Now go in Style formula editor and give the following :
if sum() < 0 then Critalic
This will make your field red and italic when it is less than 0
Thanks,
Sastry -
It was very easy to add a calculation field in previous versions of Adobe. This one has got me. I'm trying to create a field that sums other fields. I don't know where to add the script or the language. Any assistance would be greatly appreciated.
Add the script in the calculate field of the field that you want to display the calculation, ie something like
this.rawValue = form1.blaa.rawValue + form1.foo.rawValue
(where blaa and foo are the fields that you want to sum)
make sure all the fields are decimal fields or numerical fields if you want to sum them.
(oh, and you can set the text field to be Calculated in Object, Value, Type, but this is not essential) -
How Do You Change A Numeric Field To Blank When Zero?
I'm using Adobe Acrobat 6.0 Professional, version 6.0.6.
Can anyone help me with the code to change a numeric field to blank, when "0.00"?"no success" does not provide much to go on.
With your scripts, I get the concatenation of the sting values, so one has to force JavaScript to convert strings to numbers.
Make sure your field names are exact including case.
Make sure the calculation order is correct.
The following scripts all work:
var fa = 1 * this.getField("FeeN01").value;
var fb = 1 * this.getField("FeeN02").value;
var fc = 1 * this.getField("FeeN03").value;
event.value = fa + fb + fc;
if ((event.value == 0)) {
event.value = ""
// or
var fa = this.getField("FeeN01").value / 1;
var fb = this.getField("FeeN02").value / 1;
var fc = this.getField("FeeN03").value / 1;
event.value = fa + fb + fc;
if ((event.value == 0)) {
event.value = ""
// or
var fa = Number(this.getField("FeeN01").value);
var fb = Number(this.getField("FeeN02").value);
var fc = Number(this.getField("FeeN03").value);
event.value = fa + fb + fc;
if ((event.value == 0)) {
event.value = ""
The "sum of" also works with the "Custom validation script" of:
if (event.value == 0) event.value = ""; -
I think I've run into a bug with Designer. Can anyone confirm this? Or have I overlooked something?
Situation:
I have 5 numeric fields* in my form that use simple FormCalc calculations. All of them have the Object Field Display Pattern set as $z,zz9.99.
All calculations work perfectly. However, when I was testing the form I discovered something quite odd. The display is perfect until the dollar amount exceeds $9,999.99. Once over this amount the format disappears leaving just the correct result (e.g. What should be $12,345.67 is displaying as 1234567.). I tried editing the display pattern to $zzz,zzz,zz9.99 but this did not work.
Is there a JavaScript that will give me the formatting and calculations I need? Or do I need switch something else on in Designer? Thanks.
* Calculations used:
1) sum(BlackInkCost, ColourInkCost)
2) sum(WhitePaperCost, ColourPaperCost, CardStockCost, TabCost, TransparencyCost)
3) sum(CerloxCost, SpiralCost)
4) sum(ImpressionsSubTotal, PaperSubTotal, BinderySubTotal)
5) (CostSubtotal * NoDocumentsReqd)This would be the expected behaviour in the case of data entered into fields which do not match the pattern. This is not a bug, since you applied a pattern to display a certain number of characters and you entered something different, the pattern will fail and the form processor will leave the display as it is.
As for increasing the number of characters in the pattern, it should work. Make sure you dont have a conflict between the edit, display and binding patterns. If they are different, you may get unexpected results.
Also, if you do have a small pattern and can enter large numbers, then you should really apply some script to make sure your value is within legal limits. The rawValue of the field will always give you the pre-display pattern value. -
Hi All,
My requirement is I have one text field and one numeric field,
Text fields Numeric field
A 10
B 20
C 30
A 40
A 50
B 60
Now I need to add numeric field which having similar texts,
Pls any one help me how to do it.
Thanks®ds,
Sree.Hi,
Apart from COLLECT u can also use SUM option.
Declare ur itab with out header line i.e with explicit work area.
TYPES: BEGIN OF t_tab,
charfield TYPE c, "Specify the length as per ur req.
numericfield TYPE n, "Specify the length as per ur req.
END OF t_tab.
DATA: itab TYPE TABLE OF t_tab,
wa TYPE t_tab.
SORT itab BY char field.
LOOP AT itab INTO wa.
*SUM.*
AT END OF charfield.
"Write to out put.
WRITE: /1 wa-char field, wa-numericfield.
"If u want to use it further the take onemore itab and append
"this wa.
"APPEND wa TO itab1.
ENDAT.
ENDLOOP.
This logic will perfectly works.
Thanks,
Vinod.
Edited by: Vinod Kumar Vemuru on Jun 15, 2008 6:39 PM -
Discounting total amount due numeric field
I am working on a registration form and need to apply a discount if two particular checkboxes are selected.
Checkbox #1 – Early registration = $1595
Checkbox #2 – Standard registration = $1795
Checkbox #3 – Special rate = $495
Checkbox #4 – Optional workshop = $395
Numeric Field – Total Payment Due
If the user selects checkbox #1 (early) or #2 (standard), they have to pay the $395 for the optional workshop.
Total box =
sum (EarlyReg, StandardReg, SpecReg, WorkshopReg) <-- THIS WORKS
If the user selects BOTH checkbox #3 (special registration rate) AND checkbox #4 (optional workshop), they do not pay for the workshop.
So instead of $890, they will pay $495.
Total box =
I welcome any ideas you may have and would love to hear if you think I'm going at this in the wrong direction.
I am new to this...would appreciate a step-by-step with syntax. Thanks!TundraSteve, Thanks for the reply.
Your suggestion got me on the right path. Here's what worked using FormCalc on the TotalDue field:
if (SpecReg + WorkshopReg == 890) then
SpecReg
else
sum (EarlyReg, StandardReg, SpecReg, WorkshopReg)
endif
Thanks again! -
How to add different numeric fields
hai,
How to sum the different numeric fields like eno,esal and dno for a table EMP between eno= 51 to 57 of 100 records.
Please provide the code for this.
regards,
bhargav.hi,
first, i fully agree with Max. Wrong forum!
second, hard to understand what you want to do, but if you want to sum up the colummns for all rows where eno between 51 & 57 try this:
data: sum_eno type i, sum_esal type i, sum_dno type i.
select sum( eno ) sum( esal ) sum( dno )
from EMP into (sum_eno, sum_esal, sum_dno)
where eno between 51 and 57.
regards,
anton -
What is the initial value for a numeric field ??
Can someone tell me what the INITIAL VALUE FOR A NUMERIC FIELD is ?? Thank you
Rod.Using the following...
class MyClass
int myvar1; // Default initial value
int myvar2 = 3; // Default initial value and default value
MyOtherClass myclass1; // Default initial value
void doit()
int mylocal1; // No value
MyOtherClass myclass2; // No value
All number member variables, like myvar1 start off with andefault initial value which is zero. For booleans this is false. Object reference variables, like myclass1, have a null value.
All local numeric variables are considered undefined. So mylocal1 and myclass2 are undefined. Before you can use them you must explicitly provide a value.
Finally note that myvar2 will have two values during class instantiation. Initially it will have a value of zero. Sometime later it will have the value of 3. (When that happens is very definitely outside the scope of what this forum covers. If you want to know then ask in the advanced forum.) -
Null values in Numeric fields of Datasets
I am wondering if anyone has run into this problem before and
checking to see if anyone has an elegant solution.
I have a rather large data set. (actually 5 of them on a
single page) I am sorting certain columns in a table as numbers so
i assign the variable " ds1.setColumnType("somenumbercolumn",
"number")" In most cases Spry works great and it sorts by numbers
properly. The problem is some of the fields in the XML file are
null and I am trying to sort them as a number. Spry actually
adjusts for this (as far as i can tell) and treats them like a 0
which isn't exactly ideal considering there are real zero values in
the data. I know spry doesn't currently format numbers:
So here is my question. Does anyone one have a solution to
fixing null values in a table so that it is still sortable but
doesn't display a "0" and instead displays something like "--" or
whatever. I have the option of editing the XML file as well, but I
still need the table to sort by number.
If not null values, how about non numeric fields which can
still be sorted in a numeric column?Hi,
We have an old post that raised a similar problem with yours.
The post can be found
here
For you situation, you should add an if condition for the
rows that have 0 and to add a custom string instead 0.
for (var i = 0; i < numRows; i++)
if(rows
[ "field_name"] == 0)
rows[ "field_name" ] = '--';
Hope this helps you,
Diana -
Hello Guys,
I'm using 'REUSE_ALV_GRID_DISPLAY' in my prog.
There is a field in output table which is of type P(8) Decimals 3.
When I'm trying to get the sum of this field in ALV Display it gives the message " Desired operation cannot be performed for column 'Converted Quantity' ".
I have also tried do_sum = 'X'.
But it is not working. Please help guys.
Regards,
AbhinavThanks a lot guys for your inputs.
The program is working now.
Now I'm using :
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'QUAN'.
* wa_fieldcat-ref_tabname = 'I_OUT2'.
* wa_fieldcat-tabname = 'I_OUT2'.
wa_fieldcat-qfieldname = 'MEAS'.
wa_fieldcat-qtabname = 'I_OUT2'.
wa_fieldcat-outputlen = '15'.
wa_fieldcat-seltext_l = text-052.
APPEND wa_fieldcat TO i_fieldcat.
The program is working fine now.
I have commented tabname and -ref_tabname , and the program is working fine now.
Thanks a lot. -
Dump when summing up CURR field in ALV GRID display
Hi All,
I am getting dump when I try to sum the CURR field in my ALV Grid Display. The field is of CURR 23. I am using classes and methods to display alv grid.
I tried passing <fs_fieldcat>-do_sum = 'X'. When I did this, it is dumping without even displaying the alv grid.
Here is the part it is throwing dump:
ls_lvc_data-value = space.
clear ls_lvc_data-style.
loop at it_fcat_local assigning <ls_fcat>
where tech ne 'X' and no_out ne 'X'.
if l_invisible eq 'X'.
clear l_invisible.
if <ls_fcat>-do_sum is initial.
continue.
else.
clear ls_lvc_data-col_pos.
endif.
endif.
add 1 to ls_lvc_data-col_pos.
assign component <ls_fcat>-fieldname
of structure <ls_data> to <l_field_value>.
_if sy-subrc ne 0.
message x000(0k).
endif._
Regards,
GuruThomas,
Here is the dump:
Runtime Errors MESSAGE_TYPE_X
Date and Time 10/22/2010 23:30:53
Short text
The current application triggered a termination with a short dump.
What happened?
The current application program detected a situation which really
should not occur. Therefore, a termination with a short dump was
triggered on purpose by the key word MESSAGE (type X).
Error analysis
Short text of error message:
Long text of error message:
Technical information about the message:
Message class....... "0K"
Number.............. 000
Variable 1.......... " "
Variable 2.......... " "
Variable 3.......... " "
Variable 4.......... " "
How to correct the error
Probably the only way to eliminate the error is to correct the program.
If the error occures in a non-modified SAP program, you may be able to
find an interim solution in an SAP Note.
If you have access to SAP Notes, carry out a search with the following
keywords:
"MESSAGE_TYPE_X" " "
"SAPLSLVC" or "LSLVCF36"
"FILL_DATA_TABLE"
If you cannot solve the problem yourself and want to send an error
notification to SAP, include the following information:
1. The description of the current problem (short dump)
To save the description, choose "System->List->Save->Local File
(Unconverted)".
2. Corresponding system log
Display the system log by calling transaction SM21.
Restrict the time interval to 10 minutes before and five minutes
after the short dump. Then choose "System->List->Save->Local File
(Unconverted)".
3. If the problem occurs in a problem of your own or a modified SAP
program: The source code of the program
In the editor, choose "Utilities->More
Utilities->Upload/Download->Download".
4. Details about the conditions under which the error occurred or which
actions and input led to the error.
Source Code Extract
Line
SourceCde
2708
is_subtottxt_info = ls_subtot_info
2709
ip_subtot_line = lr_data
2710
changing
2711
c_subtottxt = l_subtottxt.
2712
ls_lvc_data-value = l_subtottxt.
2713
2714
append ls_lvc_data to ct_lvc_data.
2715
endif.
2716
2717
2718
Column per Fieldcat Entry
2719
2720
ls_lvc_data-value = space.
2721
clear ls_lvc_data-style.
2722
loop at it_fcat_local assigning <ls_fcat>
2723
where tech ne 'X' and no_out ne 'X'.
2724
if l_invisible eq 'X'.
2725
clear l_invisible.
2726
if <ls_fcat>-do_sum is initial.
2727
continue.
2728
else.
2729
clear ls_lvc_data-col_pos.
2730
endif.
2731
endif.
2732
2733
add 1 to ls_lvc_data-col_pos.
2734
2735
assign component <ls_fcat>-fieldname
2736
of structure <ls_data> to <l_field_value>.
2737
if sy-subrc ne 0.
>>>>>
message x000(0k).
2739
endif.
2740
2741
*... work on average
2742
if <ls_fcat>-do_sum eq 'C'.
2743
Initialize average result and entries
2744
<l_field_value> = 0.
2745
clear l_entries.
2746
2747
retrive unit from fieldcatalog
2748
assign space to <l_unit>.
2749
if not <ls_fcat>-cfieldname is initial.
2750
assign component <ls_fcat>-cfieldname
2751
of structure <ls_data> to <l_unit>.
2752
endif.
2753
if not <ls_fcat>-qfieldname is initial.
2754
assign component <ls_fcat>-qfieldname
2755
of structure <ls_data> to <l_unit>.
2756
endif.
2757
Maybe you are looking for
-
"Select All" in tableview does not trigger event?
Hi, I have a MULTISELECT table, and whenever I use the "Select all" or "Deselect all" feature, I don't seem to be able to capture the resulting event... Whenever I select one line, there's always a "tableView" event being triggered, allowing me to ru
-
2nd time machine as external HD
Hi, Can you kindly help me out: 1. I have a Time Capsule connected to the router and provides WiFi capability, I use this Time Capsule also as a HD to store files, files are transferred to this Time Capsule over the WiFi. 2. I bought a second larger
-
FI Gurus, We are implementing ACH payment method, currently everythign seems to be fine, we are able to e-mail and fax payment advices thru BTE 000002040. I am trying to also be able to print payment advices but can't figure it out. Can anyone tell
-
Hello, after much hassle, I finally determined that my shiny new 8.1.2 installation (which is sweet!) CANNOT PRINT *ANY* PDFs generated by the online journal PLOS One. The CUPS debug output shows that the foomatic-rip renderer *always* dies with an "
-
Just bought a new TX......much trouble installing with the CD. Failed to recognize my internet connection. Out of frustration (and lack of knowledge) I figured I would start from scratch by un-installing old Palm from my computer.(oooppps) Now the CD