Can XSLT calc sum(QTY * COST) ?

Given an xml doc like:
<ORDER>
<ITEM>
<QTY>10</QTY>
<COST>55</COST>
</ITEM>
<ITEM>
<QTY>20</QTY>
<COST>77</COST>
</ITEM>
</ORDER>
can XSLT be used to create <TOTAL_COST>, where TOTAL_COST = sum(QTY * COST) ?
The xpath sum() function requires a node-list as an argument, but the multiple operator "*"
returns a number, so they are not compatible. Is there any other way to do this?

Cannot be done using XPath 1.0 as is.
You'd need to use a recursive template.
See this link into the XSLT FAQ for an example:
http://www.dpawson.co.uk/xsl/N5121.html#N26919
The XSL WG is planning to make this easier in XPath 2.0

Similar Messages

  • Expandable Table Need to Sum Different Cost Centers

    I am trying to complete a mileage reimbursement form. I think I have a good design (?) but I am missing a critical efficiency within the form. I want the form to be able to calculate the cost centers across the expandable table within the subform. I have a dropdown that has different cost centers. How would I be able to sum like cost centers within the expandable table? Can I populate another table with just the totals for a particular cost center by calculation? I would need this for all cost centers This would help out the accounting department as the mulitple cost centers would be added.
    My first page is expandable to accomodate multiple rows and has a page total and a grand total that floats if more rows are needed. My second page is more or less just for accounting I have a seperate table that right now is manually completed. The clerk has to printout the form and then manually add each cost center and then add it to the table on the second page.
    I have tried to just use a numeric field on the second page attempting to get the calculations based of the test entry in the cost center of Edit. It only places the data of the first entry and does not cycle through and capture all cost centers in the expandable table that are Edit. Any help in the code and ideas on how to present the total in a new table would be greatly appreciated.I am a beginner at this and am trying to learn and complete this on my own but I am not sure what to do. Attached is my form.
    http://aaa9.org/Updated%20Employee%20Mileage%20Expense%20Form.pdf

    The following JavaScript will loop through the table and total up according to what is selected in the dropdown list. Put it on the Calculate event of a numeric field.
    You'll need a separate field for each category and you'll need to update the rawValue test to the appropriate number for each field (I started with 2 because your first entry, which is 1 is blank). Depending where you put the fields you'll need to update the path to "Table1".
    var nTotal = 0;
    for (var i=0; i < Table1._Item.count; i++){
         if (xfa.resolveNode("Table1.Item[" + i + "].DropDownList2").rawValue == 2){
              nTotal ++;
    this.rawValue = nTotal;
    Couple of tips:
    You've got an extra subform on your "page 3", you've wrapped one subform with another which isn't needed.
    It's important to name your subforms, especially when scripting.

  • Can not confirm the qty in schedule line in MTO case

    Hi All,
    I used item category ZTAN for Make-to-order purpose when I create the sales order. I set the KEVV for ZTAN in requirement assignment and requirement class 060 is assigned to KEVV.In 060 I set the availiablity is false, requirement transfer is true and Allocation Indicator = 3.
    Then I do below transaction in SAP:
    1/Create sales order
    2/Run MRP
    3/Generate the production order
    4/GR against production order
    5/Create delivery note
    By the way, the strategy group for the my finished goods is 40.
    But in the step 5, the system tell me that not confirmed qty in the order schedule line so that I can not create the Delivery. I go back to sales order and check the schedule line, but and press the button of Item Availiablity, the system can not confirmed the qty for the schedule line. Do any one know what probelm in my setting or oerations?? I will appreciate if any feedback. Thank you in advance.
    Joe

    Hi Friends,
    Any comments please? It is quite urgent.
    BR
    Joe

  • My company have purchased one I Creative cloud for one years. But now, always my company want to buy also anthers n°3 Photoshop application from use always in our office below our comfy. Can we have a privilege cost for the company or we need to buy this

    My company have purchased one I Creative cloud for one years (It's the first time for us) Of course we have pay this product with a price of company but there are new clients adobe. But now, always my company want to buy also anthers n°3 Photoshop application from use always in our office below our account already created. Can we have a privilege cost forecast for company or we need to buy this product as if it is the first time and pay the maximum price for one years?
    Thanks

    Cloud License allows 2 activations http://www.adobe.com/legal/licenses-terms.html
    -Install on a 2nd computer http://forums.adobe.com/thread/1452292?tstart=0
    -Windows or Mac does not matter... 2 on the same operating system, or 1 on each
    -Both subscriptions MAY be in use at the same time https://forums.adobe.com/thread/1683787

  • How can i use SUM aggregate in select query?

    HI,
    GURUS,
    How can i use SUM function in Select Query and i want to store that value into itab.
    for ex:
    TABLES: vbap.
    types: begin of ty_vbap,
           incluse type vbap,
           sum type string,
          end of ty_vbap.
    data: i_vbap type TABLE OF ty_vbap,
          w_vbap type ty_vbap.
    SELECT sum(posnr) FROM vbap into table i_vbap up to 5 rows.
                            (or)
    SELECT sum(posnr) FROM vbap into table i_vbap group by vbeln.
      loop at i_vbap into w_vbap
    " which variable have to use to display summed value.
      endloop.
    if above code is not understandable pleas give ome sample code on  above query.
    Thank u,
    shabeer ahmed.

    Hi,
    Check this sample code.
    TABLES SBOOK.
    DATA:  COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F.
    DATA:  CONNID LIKE SBOOK-CONNID.
    SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT )
           INTO (CONNID, COUNT, SUM, AVG)
           FROM SBOOK
           WHERE
             CARRID   = 'LH '      AND
             FLDATE   = '19950228'
           GROUP BY CONNID.
      WRITE: / CONNID, COUNT, SUM, AVG.
    ENDSELECT.
    Regards,
    Sravanthi

  • Why can't I change qty of Transfer Order

    hi,guys
    I had allow partially delivery goods in order, but when I created Transfer Order from delivery order, I found that I can not change pick qty in transfer order, I used LT03 to create transfer order, so, why can't I change pick qty in transfer order, it is gery!!!

    Hi there,
    If you want to process only a partial quantity, then you have to create delivery only for a partial quantity.
    In a transfer order TO you have to pick the entire delivery quantity. Partial picking is not allowed in TO. Quantity field is blank in TO.
    For eg if you have 100 items in a sales order, but you want to process only 50 now. So create a delivery for 50 items & process TO. If you create delivery for 100 items, do picking in TO for all the 100 items. Just processing TO for 50 items is not permitted. This means that all quantities in delivery has to be picked to PGI.
    Regards,
    Sivanand

  • Which ERP scenarios can be performed with overhead cost orders?...

    Hello SAP-team!
    Which ERP scenarios can be performed with overhead cost orders?
    - Material cost estimates with BOM and task lists
    - Overhead cost collectors that post overhead costs to cost centers
    - Accrued costs in CO
    - Settlement to a G/L account if FI-AA is not being used
    - Investment orders that post to fixed assets
    ps: thanks to SAP-community!
    Eugene

    Hi,
    Which ERP scenarios can be performed with overhead cost orders?
    - Material cost estimates with BOM and task lists- False
    - Overhead cost collectors that post overhead costs to cost centers- True
    - Accrued costs in CO-True
    - Settlement to a G/L account if FI-AA is not being used-True
    - Investment orders that post to fixed assets- True
    Regards
    Sudhakar Reddy

  • Can you upgrade the wifi card and if you can how much will it cost

    hi i just got a macbook not the pro its the white one and i find it has  a hard time grabbing my wifi and i know its the wifi card because i have 2 iphones and ipod touch and 2 laptops not including my macbook and all of them have no trouble holding the wifi connection so if anyone can help me out i just want to know can i upgrade the wifi card and if i can how much will it cost
    ps i cant do any of take it apart my self and install it i just wan to know how much it will cost going through apple
    thanks

    Why do people think they are postiing in a notebook forum when if you look around, this is clearly something else.
    If you really want a new Mac you have to buy one. That is part of the fun of owning laptops, they are not upgradeable.

  • As I can use my iphone in Costa Rica if you buy from apple miami and is locked to AT

    As I can use my iphone in Costa Rica if you buy from apple miami and is locked to AT & T??

    There is nothing you can do.
    There is nothing AT&amp;T can do.
    There is nothing Apple can do.
    If you wanted to use the phone internationally, you should have gotten an unlocked phone. You are stuck with AT&amp;T.

  • My daughter is traveling to Italy from Canada with her iphone 5, I am in Canada and also have an iphone 5, can we communicate with out costing us

    My daughter is traveling to Italy from Canada with her iphone 5,
    I am in Canada and also have an iphone 5,
    can we communicate with out costing us extra?

    That adaptor should work.

  • Can we make two shipment cost for one outbound delivery

    Hi team,
    Can we make two shipment cost for one outbound delivery?
    Need your suggesstions.
    Regards
    Venkat Ramana

    Hi
    I do not think that you will get a reply now as it has been too long.
    Maybe the answer is not known.
    However as the forum is growing and it takes so much time to get through all of the pages it would be nice to keep it current so could you please close your thread and either re-open a new one (this might help as people are more likely to look at curret ones) or try another forum.
    This will make life easier for everyone
    Regards
    Frenchy.

  • How can we change the item cost at time of Inventory Transfer, thru SDK?

    Hi All,
    How can we change the item cost at time of Inventory Transfer, thru SDK?
    My client wants some items to be transferred from A warehouse to B warehouse. When they transfer , they have to pay some octroi charges. This octroi charges they want to include in item cost at time of Inventory Transfer.
    How do we give this additional cost effect in item cost at the time of Inventory transfer? Please help .
    regrds,
    Binita

    Binita,
    This question was posted earlier and was replied.  If you want to do this through SDK please post the question to the SDK Forum.
    Which ever route you take (SDK or manual within the system), you still have to follow the process steps involved.
    Step 1: Transfer the goods
    Step 2: Revaluate the Goods on WH B to reflect Octroi
    Suda

  • Can't get the plan cost in the service order!

    Dear experts,
    I create a service order from a service Notification,in the service order , I assign a work center, activity type and work to Operations,however I can't get the plan cost in the Costs tab, when I use the T-code:IW42 confirm the service order, It can get this actual cost! I have maintain the activity type,I don't know why can't get the plan cost?
    thanks
    Lance

    Hello,
    Have you maintianed the activity pricing? I think the transaction is KP26.
    Prase

  • How can I check  the current cost and budget in SAP?

    Dear experts,
         How can I check  the current cost and budget in SAP for the PR approval?
    Table:COEP, COBK, COSS COSP can not find below information:Tender_budget,Working_budget,reconciliation,Additional,Adjustment,variation
    Best regards,
    Merry

    Dear expert,
         I need below information:Project_id,Cost_code,Nature_code,Section_code,Work_type,Work_code,Cost_type,Suffix,item_desc,Tender_budget,Working_budget,reconciliation,Additional,Adjustment,variation
    Can you tell me which table and filed can find them?
    Many thanks.
    best regards,
    Merry

  • I can not get apps that cost money.  I can get the free ones but not any that cost $.  I have an iTunes account funded but still can't.  Any ideas?

    I can not get apps that cost $.  I can get songs and free aps but not those that cost $.  I have funded iTunes account.  When I try to buy an app it refers me to this chat/community site.  Can anyone help.

    Does it refere you to this site, or iTunes store support? I would think you need to contact iTunes store support, not other users in this user-to-user forum. Click the Contact Us link at the bottom right on this page.

Maybe you are looking for