Tuesday, August 22, 2017

XML publisher’Reports (RTF) Check printing


I have a customer who wants to convert their 40+ Oracle Apps reports to ‘XML publisher’ Reports. These reports are fall in categories of AR invoice report, check printing report and PO print report which they are printing on pre-printed (pre-defined) stationary.
Just a little background of pre-printed stationary report’s layout where there is a fix Header section and fix Detail Section Table. Detail section table should always have fix table height, in the sense it should always have fix number of rows in the table no matter how many rows returned by actual report run. For example Invoice stationary has fix 30 rows in line detail table, and Actual report run is returning only 5 rows then rest 25 blank rows should be generatedprogrammatically.


So far there are solutions available which are talking about fixing table height for the 1st pages onwards not for the first page itself, i.e. where actual report run is returning lines which are less than lines_fixed_per_page.
 For example Invoice run is returning only 5 rows where as pre-printed stationary has fixed 30 lines per page.I struggled a lot to get this solution and now I got this and sharing it in this whitepaper.

So far it has not been discovered because of the limitation of for-loop in XSL-FO (XML Technology).Limitation I mean is ,we can not write loop like ‘ for (i=10;i<15 em="" i="" in="" xml.="" xml="">for’
 loop will always iterate till it gets data, if we want to go beyond that then we can not go. I mean we can write for loop based on data value.
To overcome this problem, I have used Sub-template concept which I am calling recursively.


Detail Solution
 I am giving this solution for Standard Check Printing Report. Tree structure of data (Sample XML data is as follow).
      -- Top Most root -- Header
      21897
      2205
      
         -- Inner loop - Line Section
          1
          ERS-20-SEP-06-243
        
         -- Inner loop - Line Section
          2
          ERS-20-SEP-06-244
        
      
    

Below is the step-step guide which I follow.

1) Open the Outermost for loop --  G_CHECKS

2) Declare Global Variable called ‘no_of_lines_per_page’  -- In this case I have fixed 40 lines per page.

3) Declare incontext variable for inner group (G_INVOICES), variable is called ‘inner_group’

4) Open the Inner Loop
   

5) Before putting any elements with the help of current record pointer 'position()’, I am checking if the current position is modulizing with the no_of_lines_per_page equals zero or not. If it reaches the first record after modulizing then I will create local variable 'first_rec' and initialize it with '0'.

Note : -- Above 3 steps ( 3,4,5) are created under ‘V_inner_group_And_V_First_rec’ form-field. Here there is limitation of Microsoft-word. We can enter upto 138 characters only in ‘Status’ field of ‘Add help text’ button.If you want to add more , you can do this by clicking on ‘Help Key’  which is adjacent to ‘Status’ tab.

6) If above condition holds true then we will iterate the inner loop.

7) I will check with the help of current record pointer 'position()' that the current record position is either greater than 'first_rec' i.e. the first record or less the 'no_of_lines_per_page' value set up earlier. If it is then show the record otherwise not otherwise it will not go in loop.
   =$first_rec and position()<$first_rec+$no_of_lines_per_page?>

8) Here I am closing the inner for loop and if condition
   

9) Here I am checking if no_of_lines of invoice is modulizing with the no_of_lines_per_page equals to zero or not ,and the same time I am checking if $first_rec+$no_of_lines_per_page is greater than no_of_lines of invoice or not. This is important step for filling the blank rows.
count($inner_group))?>


10) Now I am calling sub-template recursively for filling the blank rows. While calling this template I am passing one parameter which is having value of no_of_rows to fill. Sub-template will have just one row table.

11) Sub-template declaration
   
   
   name="countdown">  
   
   

12) I have created page break after the fixed number of rows have been displayed.
   
      page
   

13) Finally closing outer if and inner for loop and outer for loop.
   

If you want more information then please contact me

Monday, August 21, 2017

RTF Template : Working with variables

Define Constant Variable
This variable remains constant for entire file


Assigning Group/Repeating Frame to Variable

Here DocumentPayable is a Group which is assigned to variable inner_group. So we can loop through this variable as below

Here you can also get total records in a group anytime using count($inner_group)

Incrementing Variable in Loop
Declare variable before loop and increment it inside loop as below



However, this variable is not referenced using $ symbol

Printing Variable ValueThe "xsl:value-of" element can be used to select the value of an XML element and add it to the output