Search This Blog

Tuesday 5 February 2013

Running Totals


                                               Running Totals

Here we are using same RTF which we had used in IF CONDITION which is shown below.
Here we are going to calculate Running total.
Now we can see step by step process.
Our basic RTF looks


This example uses the following XML:


To create the Running Total field, define a variable to track the total and initialize it to 0.
First we have to declare or set a variable for that we have to take one field and in that field we are going to set a variable which should take before starting of main group i.e. Vendor Name as shown below.




Now add one more column to the RTF for displaying running totals as shown below.
Place the cursor in Inv_Amt column Right click to create one more column.
Click ok.
Do the same step to create one more cell .
Give the name of the column and take one form field which is shown below
Give double click on the field and Provide proper default text and in Add Help Text and in that we are going to write below command.
<?xdoxslt:set_variable($_XDOCTX,'RUNTOT',xdoxslt:get_variable($_XDOCTX,'RUNTOT')+UNIT_PRICE)?>
<?xdoxslt:get_variable($_XDOCTX,'RUNTOT')?>

Click ok.
Now our RTF looks

Now we have to publish the report

Click on Template Builder => Preview => HTML/PDF/Excel/RTF (any format).
We can get below output



From the above output we can say that Inv Amt is adding one by one where we can say it in Run total











Re - Grouping input XML before applying to template


Re - Grouping input XML before applying to template


In this lesson we are going to construct an RDF with out any grouping but we can regroup it in the RTF which is shown below.

Now we have to construct an RDF by using below Query

SELECT pha.segment1 po_number, 
              pha.creation_date po_date,
              pha.type_lookup_code, 
              pv.segment1 vendor_number,
              pv.vendor_name,
              pla.line_num, 
              pla.unit_price unit_price, 
              pla.quantity quantity
  FROM po_headers_all pha,
               po_vendors pv,
               po_lines_all pla,
               po_line_locations_all plla,
               mtl_system_items_b msi
 WHERE pha.vendor_id = pv.vendor_id
   AND    pha.po_header_id = pla.po_header_id
   AND    pla.po_line_id = plla.po_line_id
   AND    pla.item_id = msi.inventory_item_id
   AND    plla.ship_to_location_id = msi.organization_id
   AND    ROWNUM < 101

Our RDF looks

Now we have to generate XML .
Our XML looks


Now we have to construct RTF.
Out RTF looks

In the Add Help Text we have to write below command for each field



 

Now we have to publish the report

Click on Template Builder => Preview => HTML/PDF/Excel/RTF (any format).
We can get below output