Sum of variable
I have a report data as following:
Invoice | Invoice Line | Supplier | Total Amt
Inv 1 0001 A 100
Inv 1 0002 B 100
Inv 2 0001 A 200
Inv 2 0002 B 200
I have done the report into grouping the data by suppress the Duplicate amount and become following
Invoice | Invoice Line | Supplier | Total Amt
Inv 1 0001 A 100
0002 B
Inv 2 0001 A 200
0002 B
I have use a variable to calculate how much of Supplier available by using count. In order to avoid duplicate Total Amt = 200, I create a variable C = sum(Total Amt) / count(Supplier). But one things is if I want to do the sum for Total Amt for the entire report. I am not able to use the Sum(Total Amt) in Report footer. And I am not able to do the Sum (Variable C). Any idea?
i gather you are grouping your report by customer then invoice number
use MANUAL running totals, the wizard may be the reason it is incorrect.
create 1 set of the 3 formulas listed below for customer and one set for invoice id.
RESET
The reset formula is placed in a group header report header to reset the summary to zero for each unique record it groups by.
whileprintingrecords;
Numbervar X := 0;
CALCULATION
The calculation is placed adjacent to the field or formula that is being calculated.
(if there are duplicate values; create a group on the field that is being calculated on. If there are not duplicate records, the detail section is used.
whileprintingrecords;
Numbervar X := x + ; ( or formula)
DISPLAY
The display is the sum of what is being calculated. This is placed in a group, page or report footer. (generally placed in the group footer of the group header where the reset is placed.)
whileprintingrecords;
Numbervar X;
Similar Messages
-
Is it possible to SUM 2 variables?
I have to loop through some nodes that are laid out like so, then group based off the ATTRIBUTE_CAT while summing up their total amounts. Then i need to add specific ones up together. In the example I'm just showing 2, but there are 7.
<G_INVOICE_NUM>
<NAME>BOB</NAME>
<ATTRIBUTE_CAT>UP</ATTRIBUTE_CAT>
<AMOUNT>10</AMOUNT>
</G_INVOICE_NUM>
<G_INVOICE_NUM>
<NAME>JOHN</NAME>
<ATTRIBUTE_CAT>UP</ATTRIBUTE_CAT>
<AMOUNT>5</AMOUNT>
</G_INVOICE_NUM>
<G_INVOICE_NUM>
<NAME>JOE</NAME>
<ATTRIBUTE_CAT>GP</ATTRIBUTE_CAT>
<AMOUNT>5</AMOUNT>
</G_INVOICE_NUM>
So i go though and do this..
<?for-each-group:G_INVOICE_NUM;ATTRIBUTE_CAT?>
<?if:ATTRIBUTE_CATEGORY='UP'?>
<?sum(current-group()//AMOUNT)?>
<?xdoxslt:set_variable($_XDOCTX, 'UPTotalVar', xdoxslt:get_variable($_XDOCTX, 'UPTotalVar') + sum(current-group()//AMOUNT))?>
<?end if?>
<?if:ATTRIBUTE_CATEGORY='GP'?>
<?sum(current-group()//AMOUNT)?>
<?xdoxslt:set_variable($_XDOCTX, 'GPTotalVar', xdoxslt:get_variable($_XDOCTX, 'GPTotalVar') + sum(current-group()//AMOUNT))?>
<?end if?>
<?end for-each-group?>
Now this might not be the best way to do this... but it's working, even setting the variables and retreiving them. But I can't seem to add the differerent variables together.
I've tried various versions... the first 2 error out, the last one doesn't show me anything...
<?sum(current-group()xdoxslt:get_variable($_XDOCTX, 'UPTotalVar')+ xdoxslt:get_variable($_XDOCTX, 'GPTotalVar'))?>
<?sum(xdoxslt:get_variable($_XDOCTX, 'UPTotalVar')+ xdoxslt:get_variable($_XDOCTX, 'GPTotalVar'))?>
<?xdofx:xdoxslt:get_variable($_XDOCTX, 'UPTotalVar')+ xdoxslt:get_variable($_XDOCTX, 'GPTotalVar')?>
I thought about wrapping them with a to_number(), but i'm not sure about that syntax...
Any ideas?
Thanks,
JeremyHi Jeremy ,
You can do the same way used for setting and retrieving the elements, The one i tried is as below and worked fine, give a try and let me know if it suits you....
<?xdoxslt:set_variable($_XDOCTX,'UPTotalVar',xdoxslt:get_variable($_XDOCTX, 'UPTotalVar') + xdoxslt:get_variable($_XDOCTX,'GPTotalVar'))?>
and as the length constraint in Status Bar Tab, use the below code in the Help Key Tab of the form field..
<?xdoxslt:get_variable($_XDOCTX, ’UPTotalVar’)?>
this will display the total sum of both the variables..
This is just an sample to run thru the variable additions,
As you said your data file have 7 ones like this, you can implement a sub-template concept to achive it.
All the best
PBV. -
Hi, i'm trying to make a sum from an user defined table, and retrieve this value into a variable, the problem is when don't satisfy the conditions (where), the variable sy-subrc never goes to 4, i need to know when the select retrieves me a value and where is not.
The select statement is this:
SELECT SUM( cant )
FROM zcmtt_envase
INTO v_cant
WHERE docsap = p_tipo
AND ref = p_ti_zcmtt_envase-ref
AND matnr = ti_sumlips-matnr.
sy-subr it's always 0 !!!HI ,
check the value of variable.
if v_cant is not initial. " means sy-subrc eq 0.
else.
endif.
Mahesh -
Hi all,
I am developing a report that have sections by profit centers.. and its subtotals.
I created 2 new columns aside subtotals and I filled with 2 variables:
1-) =If (Sum([Main].[Montante]*[Perc].[Montante])) > 0 Then (Sum([Main].[Montante]*[Perc].[Montante])) Else 0
2-) =If (Sum([Main].[Montante]*[Perc].[Montante])) < 0 Then (Sum([Main].[Montante]*[Perc].[Montante])) Else 0
I need to sum those values and store on another variable that I will use soon. But I have a problem: Webi doesn't allow to sum by itself, so I did it manually and the result is not according to the real sum.
Does anybody has any idea about how to I can do this?
Thanks in advance.Hi David,
I Mean that that button to sum is deactivated, and I needed to write the formula.
ForEach doesnt work in this case because I have already the profit center dimension in the block.
To clarify more, I had the sections as below situation:
Company | Profit Center | Amount
XXXXXX | YYYYYYY | 11111,11
XXXXXX | YYYYYYY | 11111,11
Subtotal . . . . . . . . . . | 22222,22
I developed the following:
Company | Profit Center | Amount | If Positive, Amount here | Else (Negative) Amount Here
Then now I have:
Company | Profit Center | Amount | If Positive, Amount here | Else (Negative) Amount Here
XXXXXX | YYYYYYY | -33333,33 |
XXXXXX | YYYYYYY | -11111,11 |
Subtotal . . . . . . . . . . | - 44444,44 | . . . . . . . . . . . . . . . . . . . | -44444,44
Company | Profit Center | Amount | If Positive, Amount here | Else (Negative) Amount Here
XXXXXX | YYYYYYY | 11111,11 |
XXXXXX | YYYYYYY | 11111,11 |
Subtotal . . . . . . . . . . | 22222,22 | . . . . . 22222,22 . . . . . . . | . . . . . . . . . . . . . . .
Company | Profit Center | Amount | If Positive, Amount here | Else (Negative) Amount Here
XXXXXX | YYYYYYY | 22222,22 |
XXXXXX | YYYYYYY | 22222,22 |
Subtotal . . . . . . . . . . | 44444,44 | . . . . . 44444,44 . . . . . . . | . . . . . . . . . . . . . . .
And on this Subtotals I may have positive and negative values, right? I wish to sum positives and store in one variable, and sum the negatives and store in another variable. Those variables I have here I need to Sum (Because I will assign a new field, out of sections).
For the case above the amount of my variable should be:
SumofPositives: 66666,66
SumofNegatives: -44444,44
ok?
But here I can not progress, because due to the inconstancy I am facing on Webi the sum is returning inconsistent value.. It returns for example:
SumofPositives: 180000,99
SumofNegatives: -409834233,43
Due to this situation I need to change the way to works. -
Achieving Sum with Variable Rows
Greetings!
Here is a description of my situation:
In Field 1, the user enters an amount. Let's say $10.
In Field 2, the user enters a piece of metadata. The user may then click a button to enter another piece of metadata (another Field 2 displays). There is only one piece of metadata allowed per line, however there is no limit to how many pieces of metadata may be entered. Basically, Field 2 is just a repeating subform with a text field in it.
Field 3 is a calculated field. This is where I need to place some JavaScript or FormCalc. What I need is the amount in Field 1 (in this example, $10) to be multiplied by the number of instances of Field 2, however many that may be.
Any help would be appreciated.
Thank you.Make a var that counts how many fields are not blank;
var intCountMetaData = 0;
for (var i = 0; i < this.resolveNode("YourSubform").instanceManager.count - 1; i++){
if (this.resolveNode("YourSubForm[" + i.toString() + "].Field2").rawValue != null){
intCountMetaData += 1; -
Hello gurus,
I am trying to use the SUMMING command in SAPScript to output a total on each page of a transfer order.
According to the sap help, I need to declare the summing total variable within the print program using the TABLES statement, I'm trying to total LTAP-VSOLA so should I be declaring a table of this type? ANd if so, shouldn't I be using a DATA statement for this? I'm confused as to what the help actually means?
Has anyone used this statement before and have an example that I can see?
Thanks,
RubyTry like:
/: DEFINE &TOT_PRICE&
/: SUMMING &KOMVD-KBERT& INTO &TOT_PRICE&
or
/: DEFINE &SUM& TYPE NETWR and write in the loop
/ &SUM& = &SUM& + &BSEG-WRBTR&
and use this SUM field
normally I would prefer to calculate this kind of stuff in the print program. But I guess you are using the original SAP program.
Amit. -
Product Costs Split is required, that is fixed and Variable costs
Hi All,
In a Sales Order screen (VA03), if we check the Costing, by clicking on EXTRAS -> COSTING, we get Total Costs, Fixed Costs and Variable Costs.
Can someone please help me in getting these costs, I have used Table KEKO,
In KEKO (filtered based on Material, Plant, Sales Document, Item) and executed it, taken the resultant ProdCstgNo (KALNR)
In KEPH used that KALNR, as a result I am getting 4 records, However 2 records are not correct, and 2 are correct.
In correct ones I have to add few costs to get FIXED COSTS and few costs to get VARIABLE COSTS.
My question is, which filter should I use to get the correct record (probably just one record) ?
Can I in some table get the summed up VARIABLE COSTS and FIXED COSTS, rather that I have to add them seperately ?
Please help, will award points promptly. ThanksHi,
In KEKO (filtered based on Material, Plant, Sales Document, Item) and executed it, taken the resultantProdCstgNo (KALNR)
In KEPH used that KALNR, as a result I am getting 4 records, However 2 records are not correct, and 2 are correct.
The table you mentioned CKMLKEPH is used for Material Ledger actual cost components.
Regd,
Khan. -
Changes Interactive forms after SAP_BASIS SP19, SUM in formcalc
Hi,
after updating to SP19 of SAP_BASIS, formcalc has changed in sum() evaluation (I know it is strange):
Before SP19 in this expression:
Sum($form.IK.IN.DATA[*].N_HOD), Sum returns zero value if table has zero rows (nothing to count)
now I get error (if table have zero rows) :
Script error:.....Error:accesor '$form.IK.IN.DATA[*].N_HOD' is unknown.
Before SP19 behaviour was better, now I have to check all tables if have data, perform sum into variables and then sum variables...
this means 4x longer formcalc code........
Many thank for any explanation or workaround.Hi,
It's my problem only.
Coming to my FORMCALC/JAVASCRIPT Problem,I made some mistakes in my scripts, which lead me to this confusion.
And coming to my BADI Method problem which I mentioned below...I didnt activate my BADI Method, but I was expecting those changes to be there in EP. I checked these methods carefully and found that my METHOD is not ACTIVE.After ACTIVATION of my method, I can see the CHANGES happening perfectly.
So there is absolutely <b>NO BUFFER PROBLEM</b> from <i>ADOBE INTERACTIVE FORMS</i>.
Regards,
Raja Sekhar -
Hi all, I hope someone can help me.
I'm trying to write a report to show production orders and their cost price.
I currently have an internal table with all the production orders and header material & i have another internal table with the BOM components and their cost per component line.
Please could someone tell me how to sum these components against the header material?
please see this code.
FORM get_bom_comp_costs.
SELECT aa~matnr aa~stlnr bb~idnrk bb~menge
cc~verpr
FROM mast AS aa INNER JOIN stpo AS bb ON aa~stlnr = bb~stlnr
INNER JOIN mbew AS cc ON bb~idnrk = cc~matnr
INTO wa_bom_comp_costs
FOR ALL ENTRIES IN it_prod_ord_comps
WHERE aa~matnr = it_prod_ord_comps-plnbez.
wa_bom_comp_costs-bomcost = wa_bom_comp_costs-verpr * wa_bom_comp_costs-menge.
APPEND wa_bom_comp_costs TO it_bom_comp_costs.
ENDSELECT.
FORM get_prod_ord_costs.
LOOP AT it_prod_ord_comps INTO wa_prod_ord_comps.
wa_prod_ord_costs-plnbez = wa_prod_ord_comps-plnbez.
wa_prod_ord_costs-maktx = wa_prod_ord_comps-maktx.
wa_prod_ord_costs-mvgr5 = wa_prod_ord_comps-mvgr5.
wa_prod_ord_costs-gamng = wa_prod_ord_comps-gamng.
wa_prod_ord_costs-aufnr = wa_prod_ord_comps-aufnr.
wa_prod_ord_costs-auart = wa_prod_ord_comps-auart.
wa_prod_ord_costs-ftrms = wa_prod_ord_comps-ftrms.
wa_prod_ord_costs-loekz = wa_prod_ord_comps-loekz.
wa_prod_ord_costs-elikz = wa_prod_ord_comps-elikz.
wa_prod_ord_costs-asttx = wa_prod_ord_comps-asttx.
wa_prod_ord_costs-prodord1 = ???????????????????????.
wa_prod_ord_costs-prodord2 = wa_prod_ord_comps-gamng * wa_prod_ord_costs-prodord1.
APPEND wa_prod_ord_costs TO it_prod_ord_costs.
the prodord1 field needs to look at the header material and sum the cost of the components
many thanks>
MLockett wrote:
> Hi all, I hope someone can help me.
>
> I'm trying to write a report to show production orders and their cost price.
>
> I currently have an internal table with all the production orders and header material & i have another internal table with the BOM components and their cost per component line.
>
> Please could someone tell me how to sum these components against the header material?
>
> please see this code.
>
>
FORM get_bom_comp_costs.
>
> SELECT aa~matnr aa~stlnr bb~idnrk bb~menge
> cc~verpr
> FROM mast AS aa INNER JOIN stpo AS bb ON aa~stlnr = bb~stlnr
> INNER JOIN mbew AS cc ON bb~idnrk = cc~matnr
>
> INTO wa_bom_comp_costs
> FOR ALL ENTRIES IN it_prod_ord_comps
> WHERE aa~matnr = it_prod_ord_comps-plnbez.
>
> wa_bom_comp_costs-bomcost = wa_bom_comp_costs-verpr * wa_bom_comp_costs-menge.
>
> APPEND wa_bom_comp_costs TO it_bom_comp_costs.
>
> ENDSELECT.
>
>
>
FORM get_prod_ord_costs.
>
> LOOP AT it_prod_ord_comps INTO wa_prod_ord_comps.
>
> wa_prod_ord_costs-plnbez = wa_prod_ord_comps-plnbez.
> wa_prod_ord_costs-maktx = wa_prod_ord_comps-maktx.
> wa_prod_ord_costs-mvgr5 = wa_prod_ord_comps-mvgr5.
> wa_prod_ord_costs-gamng = wa_prod_ord_comps-gamng.
> wa_prod_ord_costs-aufnr = wa_prod_ord_comps-aufnr.
> wa_prod_ord_costs-auart = wa_prod_ord_comps-auart.
> wa_prod_ord_costs-ftrms = wa_prod_ord_comps-ftrms.
> wa_prod_ord_costs-loekz = wa_prod_ord_comps-loekz.
> wa_prod_ord_costs-elikz = wa_prod_ord_comps-elikz.
> wa_prod_ord_costs-asttx = wa_prod_ord_comps-asttx.
>
> wa_prod_ord_costs-prodord1 = ???????????????????????.
>
> wa_prod_ord_costs-prodord2 = wa_prod_ord_comps-gamng * wa_prod_ord_costs-prodord1.
>
> APPEND wa_prod_ord_costs TO it_prod_ord_costs.
>
> the prodord1 field needs to look at the header material and sum the cost of the components
>
> many thanks
Alright man.
The question is not clear. By the way what do you want to sum? if you want to sum a variable, cant you do like
targetvariable = targetvariable + sourcevariable.
I am not sure what do you want to sum i mean which two variables. -
Please explain the Functinality given ASAP
General Description
Teac Electronics (M) Sdn Bhd currently is requesting for a new customized report which list down by finished products, sales quantity, sales amount, material cost and scrap plus variable and fixed expense.
The customized report should only include the finished product of category ZTFG and generated by center selection and the source of each cell is extracted as indicated and as per existing reports ZCOAVT01 (program), ZSL2/ZSL3 (transaction code), FBL3 (transaction code) and J1SIPAAX (program).
ZCOAVT01 is a product costing report, which includes both sub-assemblies (ZTSA) and finished goods (ZTFG).
Description
A new customized report, which list down by finished products, sales quantity, sales amount, material cost and scrap plus variable and fixed expense.
The customized report should only include the material type (finished product of category) ZTFG and generated by center selection and the source of each cell is extracted as indicated and as per existing reports ZCOAVT01 (program ZCOAVT01), ZSL2 (program JZSL2AAX) / ZSL3 (program JZSL3AAX), FBL3 (program RFEPOS00) and J1SIPAAX (program J1SIPAAX).
ZCOAVT01 is a product costing report, which includes both sub-assemblies (ZTSA) and finished goods (ZTFG).
Screen Layout
Selection Parameter layout:
Selection Parameter
Below are the user selection parameters:
No. Description Technical Name Format Opt/Mand?
1 Company code BUKRS 4 CHARS Mandatory
2 Controlling Area KOKRS 4 CHARS Mandatory
3 Plant WERKS 4 CHARS Mandatory
4 Division SPART 2 CHARS Optional
5 Product Group KSTRG 12 CHARS Optional
6 Material Number MATNR 18 CHARS Optional
7 Plan Version VERSN 3 CHARS Optional
8 Fiscal Year GJAHR 4 CHARS Mandatory
9 First Half N/A OPTION BUTTON
10 Second Half N/A OPTION BUTTON
11 Cost Center group KSGRU 4 CHARS Optional
12 Or Values KOSTL 4 CHARS Optional
13 Cost Element Group KAGRU USER DEFINE Optional
14 Or Values KSTAR 4 CHARS Optional
15 Controlling Area Currency N/A OPTION BUTTON
16 Company Code Currency N/A OPTION BUTTON
Remarks: Selection screen is a combination of Report ZCOAVT01 and ZSL2/ZSL3
Expected Output and Mapping of User selection entry to SAP Tables
1. Expected Output
2. Below is the mapping logic of the selection criteria to SAP tables.
(R)ow Cost elements
Formula Refer program
1 till 7 retrieve from report ZCOAVT01 and FBL3
Your program should only pick up figures from those material which belong to type ZTFG only (Table name = RMMG1, Field name = MTART), refer to appendix A1 and A2
ODD Media Budget Expenses
1 Actual Sales Quantity refer to appendix A1 ZCOAVT01
2
Sales Amount
refer to appendix A1 and A2 ZCOAVT01
(Plan sales amount)
FBL3
(Actual sales amount)
3 Material used refer to appendix A1 ZCOAVT01
4 Scrap refer to appendix A1 ZCOAVT01
5 Balanced Sales amount (R5) material used (R6) scrap(R7)
6 Recovery Amount Balance (R8) Valuable Expenses (R17)
7 Recovery Ratio Recovery Amount (R9) / Fixed Expenses (R24) * 100
8 till R25 retrieve from report ZSL2 and ZSL3, refer to Appendix B
8
DIRECT LABOUR
Sum of cost element :
5013101
5013111
5013131
5013133
5013136
5013141
5013152
5013153
JZSL2AAX
J1SIPAAX
9
WELFARE
Sum of cost element :
5013302
5013311
5013312
5013313
5013321
5013341
5013361
JZSL2AAX
J1SIPAAX
10
SUNDRY TOOLS, L;INE SUPPLIES
Sum of cost element :
5015202
5015211
5015231
5015241
JZSL2AAX
J1SIPAAX
11
MAINTENANCE
Sum of cost element :
5015411
JZSL2AAX
J1SIPAAX
12
OTHER EXPENSES
Sum of cost element :
5015601
5015631
5015691
JZSL2AAX
J1SIPAAX
13 VARIABLE EXPENSES
Sum(R12~ R16)
14
INDIRECT LABOUR
Sum of cost element :
5013201
5013211
5013231
5013233
5013241
5013252
5013253
JZSL2AAX
J1SIPAAX
15
WELFARE
Sum of cost element :
5013301
5013332
5013342
5013351
5013361
JZSL2AAX
J1SIPAAX
16
DEPRECIATION
Sum of cost element :
5014300
5014600
5014700
5014800
JZSL2AAX
J1SIPAAX
17
UTILITIES
Sum of cost element :
5015301
5015311
JZSL2AAX
J1SIPAAX
18
ALLOCATION SUPPORT SEC
Sum of cost element :
9100001
9100002
9100003
JZSL2AAX
J1SIPAAX
19 FIXED EXPENSES R19R20R21R22R23
20 TOTAL EXPENSES R17+R24
21 P & L R9 R24
22 Scrap ratio R7/(R6 + R7)
From the Expected Output file, to derive the amounts for column Q and R:-
Cell Formula
Q5 Sum of actual sales amount. Sum(C5, E5, G5, I5, K5, M5)
Q6 Sum of actual material used
Q7 Sum of actual scrap figure
Q12 Average of Sum of actual direct labour cost
Q13 Average of Sum of actual welfare
Q14 Average of Sum of actual SUNDRY TOOLS, L;INE SUPPLIES
Q15 Average of Sum of actual Maintenance
Q16 Average of Sum of actual other expenses
Q17 Average of Sum of actual variable expenses
Q19 Average of Sum of actual Indirect labour
Q20 Average of Sum of actual Welfare
Q21 Average of Sum of actual Depreciation
Q22 Average of Sum of actual Utilities
Q23 Average of Sum of actual Allocation support sec
Q24 Average of Sum of actual fixed expenses
Q25 Sum of variable expenses (Q17) + fixed expenses (Q24)
R12 (Q12/Q25) * 100
R13 (Q13/Q25) * 100
R14 (Q14/Q25) * 100
R15 (Q15/Q25) * 100
R16 (Q16/Q25) * 100
R19 (Q19/Q25) * 100
R20 (Q20/Q25) * 100
R21 (Q21/Q25) * 100
R22 (Q22/Q25) * 100
R23 (Q23/Q25) * 100
R25 100%
Appendix A1
Path: Accounting>Controlling>Cost oRject controlling>Product cost Ry period>Information System>Report selection
Application tree report selection product cost Ry period>Product cost Ry period>COPC customized reports>customized reports>Product costing: Actual Vs Target Cost(ZCOAVT01)
Sample variant: Z3140
Appendix A2
For Actual Sales amount, the values will be obtained from the following GL accounts:-
4011100 SALES-THIRD PARTIES-FINISHED GOODS
4011101 SALES-THIRD PARTIES-BENQ-FINISHED GOODS
4012100 SALES-TEAC CORPORATION-FINISHED GOODS
4015100 SALES-TEAC INDONESIA-FINISHED GOODS
4016100 SALES-TEAC AMERICA INC-FINISHED GOODS
4017100 SALES-TEAC RELATED GROUP-FINISHED GOODS
4150120 INTRACOMPANY SALES (IPC-FG&SA)
1) Go to tcode FBL3, select the above mentioned GL accounts to get the following listing. Thereafter, drill down further to get the material number:-
Appendix B
WORKING TO SPLIT THE VARIABLE AND FIXED EXPENSES FOR MATERIAL ZTFG
1) Go to the following patch
Path: Information system>general report selection
Application tree report selection general>report selection>controlling>customized reports>cost center reports
2) From the above ZSL2 / ZSL 3 report, in order to get the mapping of the allocation to material, go to Cost Center Report (program J1SIPAAX).
EXAMPLE :-
The following is the sample file extracted from Cost Center Actual Line Item Report for period 1 fiscal year 2007:-
From the above sample file, material 4900154401 (ZTFG) received 16.80 (0.2%) out of total 8,526.56. Hence, the following sender cost elements will be split as below:-
5014700 => 296.87 x 0.2% = 0.59
5014800 => 157.49 x 0.2% = 0.32
5015202 => 314.29 x 0.2% = 0.63
and so on
According to the mapping logic in page 6, since 5014700 and 5014800 is categorised as Depreciation = Fixed Expenses, the sum received will be 0.91 (0.59 + 0.32). Whereas, for 5015202, it will be categorised as Sundry Tools = Variable Expenses in the new customised report.ok... I will come back if i had any query...
There is nobody to help me out thats why... -
Instantiation and Encapsulation
Hi
Can any one explain me about instantiation and Encasulation with example, i am new to ABAP Objects.
Please dont send any links.
Arun JosephHi,
First let me give small introduction to OO ABAP programing.
Object-oriented programming is a method of implementation in which programs are organized as cooperative collections of objects, each of which represents an instance of some class...?
A class is a set of objects that share a common
structure and a common behavior
A class will have attributes ( i.e data definition) and methods ( nothing but functions )
We can also call object as Instance of the class.
Lets see a simple demo class to calcualte SUM of 2 numbers.
define 2 variables a and b of type i. (Attributes)
SUM is the method name. this will have the logic to do the sum.
2 importing paramers and an exporting parameter res for the method.
Note: you can either create a class either globally or locally..
Goto SE24 to create Global class, this class will be avaialable for use in all the programs, this is like class library with all global classes.
Local class is the one which you create in SE38 i.e; your own program,
by this it is understood that it's scope is only upto that program
SO let us discuss the example with SE24(global class)
give a class name, description,
In the attributes tab, define a and b of type i, level as instance attribute and
visibility as public That means these attributes are available outside this class also. we will come to this later.
in the methods tab give name, level as instance, visibilty as pubilc again.
now double click on the method name, it will take to you to write the code.
(method implementation)
just wirte between the method ---endmethod,
res = num1 + num2.
come back to methods tab, click on parameters button, to define exporting, importing etc.. paramters for your method,
define 'res' as an exporting parameter, 2 variables num1 and num2 as importing parameters.Activate the class.
now you have defined a class.
whenever you want the logic to sum 2 variables, in all those cases you can make use of the SUM method in this class. This is what Reusability is.A very imp. feature of OO ABAP.
So now comes Instantiation.
you can't directly access a class.
You have to create a reference variable of the type of the class, then create an object with the reference variable. (memory allocation).
This step is called Instantiation or Instantiating the class
For this go to se38, in which ever program you want to instatantiate the above class.
do as below.
data: obj type ref to zsow_cl1.
start-of-selection.
create object obj.
Now object of the above class is ready for you.
Now all the contents i.e either attributes or methods etc of the class can be accessed with this object
now you have to call the method 'sum' of the above class using the above object in your program for the sum functionalty.
for that click on Pattern button select 'Abap Object Patterns' press enter
select 'Call method' radio button, give your object name ('OBJ')
class name ( ZSOW_CL1)
give the method name (SUM)
class and method names can be selected from the F4
press enter.
you will get the below line in your program
CALL METHOD OBJ->SUM
EXPORTING
NUM1 =
NUM2 =
* IMPORTING
* RES =
now define 2 variables of type i to pass the inputs to the method and one more vairable to hold the output coming from the FM
on the whole code in your se38 is as follows.
DATA: OBJ TYPE REF TO ZSOW_CL1,
X TYPE I,
Y TYPE I,
Z TYPE I.
START-OF-SELECTION.
CREATE OBJECT OBJ.
X = 10.
Y = 10.
CALL METHOD OBJ->SUM
EXPORTING
NUM1 = X
NUM2 = Y
IMPORTING
RES = Z.
WRITE: Z.
so Z will give the output.
Next is Encapsulation
while defining the method i asked you to give the visibility as Public.
Visibility can be of 3 types:
Public
Protected
Private
public means as i said above the method or varaibles can be used outside the class also.as you did above outside the class you have created an object to the class and
accessed the method.
private means the attributes/methods that you define in the class can only be accessed in/by the method of the same class, they cannot be accessed anywhere else and outside.
change your 'a' parameter visibilty to private and try the below code in se38.
obj->b = 10.
obj->a = 10.
1st line doesn't give error, since 'b' is public attribte,
2nd line will give error since 'a' is now private.
you can use 'a' in the 'SUM' method if you want.
Protected means it can't be accessed outside of the class like with the help of object, but can be accessed in the child class if defined to the above class.
just post if you have any other doubts after trying this example.
Do reward points if it helps you.
Regards,
Sowjanya -
Hi! All
How to find Proportion of Fixed Cost and Full cost of a material. Is it possible to get it?
Thanks and Regards,
Kvfull cost is nothing but the sum of variable cost + fixed cost. Obviously the cost of material, labour, etc. are variable costs. Fixed costs are usually overheads which you define through cost sheets. In the cost component structure, you will have to define the items are fixed, variable or variable + fixed. thus when you analyze the cost component structure, you can get the required information.
-
Hi,
I have defined variable (inputVariable) based on complex message type.
I need create copy of this variable for making changes on it.
So I created new variable (inputCopyVariable) based on the same complex message type.
In assign activity I assign
<copy>
<from variable="inputVariable"/>
<to variable="inputCopyVariable"/>
</copy>
Then I assign new values to inputCopyVariable.
<copy>
<from variable="checkingVariable" part="checkingResponseElement" query="/ns3:checkingResponseElement/sum"/>
<to variable="inputCopyVariable" part="payload" query="/client:inputRequest/client:price"/>
</copy>
I was shocked when I discovered that inputVariable was changed too.
So I experiment and it is true, when I change any of this variables then BPEL makes a change to both variables.
I need independent variables, how to do this.
I can use transformation. There is everything all right.
Thanks.I think it is not a problem of displaying the variables in the BPELConsole.
I make experiment:
simple process with two vriables created with same message type.
1) variable1.note = 'new'
2) variable2 = variable1
3) variable1.note = 'change'
4) variable2.text = 'text'
5) <case condition="bpws:getVariableData('variable1','payload','/client:vars/client:note') = bpws:getVariableData('variable2','payload','/client:vars/client:note')">
if condition is true then process return 1 else return 0
Testing this I can see changing both variables and get comparing values by BPEL.
Result is: changing variable1 cause change variable2 and process return 1 (values of vriables are same). -
This is my first Java course. I have to create an array that stores 20 prices. I have
double[] prices = {2.34, 7.89, 1.34,5.00,5.89, 3.59, 4.83, 6.72, 1.89,
.89,2.00, 3.00, 6.53, 4.32, 1.66,10.99, 19.99,7.45, 25.95,.99};
Then we have to display the sum of all the prices and calculate the average price.
It sounds easy. I can do it in C++ but some how I do not know how to code it in java. Our text does not explain it well enough.
I suspect that I have to use a method. I know how to create methods but not for an array.
Can anyone help with an example?This is what you want?
import java.text.DecimalFormat;
class ArrayTest
public static void main(String args[]) //main method
DecimalFormat twoDigits = new DecimalFormat("0.00"); //two digits after the dot(.), adjust to your needs
double sum =0.0, average=0.0; //sum & average variables
double[] prices ={ 2.34, 7.89, 1.34, 5.00, 5.89, 3.59, 4.83,
6.72, 1.89, 0.89, 2.00, 3.00, 6.53, 4.32,
1.66, 10.99, 19.99, 7.45, 25.95, 0.99 };
for (int i=0; i<20; i++)
sum = sum + prices; //the sum
average = sum/20; //the average
System.out.println("The sum is: " + twoDigits.format(sum));
System.out.println("The average is: " + twoDigits.format(average));
Study it, Anything you don't understand let me know.
AA -
Would someone tell me something about multithread and multiprocessor
Hey, would you be so kind to tell me something about how to progrmme with using multithread in multiprocessro? and where can I find something about it? My problem is that
Assume that you have to write a computer program that will receive as input a single array
storing a large number of integers. The program has to compute the prefix sums of the
number sequence.
Given a sequence of numbers x1, x2, ..., xn, the prefix sums are the partial sums:
s1 = x1
s2 = x1 + x2
sn = x1 + x2 + ... + xn
�You have to be prepared to write a program for program should be able to use a variable, user-specified, number of processors. For
example, the user should be able to run the program using any number of processors P
between 1 and 16. The number of processors P can either be selected using a command
line argument or the program can prompt the user.
�Your program should be able to sum a variable, user-specified, number of integers. The
integers in the input sequence should be randomly generated inside your program. (That
is, the user will input n, and the program will then randomly generate n numbers.)
�Your program should print out (either to the standard output or to a file) in ascending
order the prefix sums computed: s1, s2, �, sn.
Can someone give me some help? I have no idea about how to do it?
thanks a lot ofI think perhaps you are asking about how to create threads in Java? I'm not sure, but I'll give you some background anyway. Basically all that you need to know is documented in the class java.lang.Thread. If you want a class to run on a separate thread then you can do one of two things:
(a) define a class that extends Thread.
(b) define a class that implements Runnable.
I prefer the latter, but it's up to you. So, for example, if I have some computationally expensive algorithm to execute I would define a class like this:
public class ImExpensive implements Runnable {
����public void run() {
��������<insert code here>
����}
Then when you want to run the algorithm you do this:
����ImExpensive o = new ImExpensive();
����new Thread(o).start();
The second line in this case constructs a thread that the object 'o' can run on (the start() method causes the run() method in the ImExpensive class to execute).
Now, as for running on multi-processors, I have never done this so I am not too sure. But all that you have to do is figure out a way of associating the thread that was created with a particular processor.
Also, be careful when using threads. Everything will be OK if your computations are mutually exclusive (ie: they aren't interdependent). If they aren't then you might run into what is sometimes called "the racehorse problem". This is a phenomenon that occurs because you can't guarantee which threads are going to finish first or indeed the order of interleaved operations. It's difficult to describe but this tutorial may help you out.
http://java.sun.com/docs/books/tutorial/essential/threads/
Hope that helps. :)
Ben
Maybe you are looking for
-
hi could anybody please check how it works in JS or AS - what do you get in XML structure - what is tagged - when you try to MarkUp character containing InLine graphic ? or Text object containing only one "character" - InLine graphics something like
-
Cannot add and Sync ringtones in Itunes
Hi, I have gotten a new 16GB Iphone and it works perfectly with Itunes 8.02.20 except the ringtones I added in itunes, it doesnt sync (or even show up in my Iphone Ringtones tab). I have tried many M4R but it still doesnt work. Those m4r shownin my L
-
I have run the TB using S_PLO_86000030 but my TB is not balancing: Can someone assist on how to identify what is causing the difference. Thanks. Dr $3,704,812,081 Cr $3,705,297,120
-
I'm writing a script in Adobe Story, but each of my pages has the same number on it, for example 1. How do I default back to having a new page number for each page? Thanks.
-
Creating file browser GUI using java swing tree
Hi all, I have some questions which i wish to clarify asap. I am working on a file browser project using java swing. I need to create 2 separate buttons. 1 of them will add a 'folder' while the other button will add a 'file' to the tree when the butt