Wednesday, 19 November 2014

TCA Architecture

  • HZ Parties - Stores basic information about parties and their relationship. Party ID is the primary key. Party id, Party Number, Party Name and Party Type are key columns. Establishes the Business Relationships.
  • HZ Locations - Stores delivery or postal address. Location ID is the primary key. Not to be used for modeling party hierarchical relationships (use party relationships). Identifies the Party and its Account. Location can cross Parties and a Party can have multiple Locations. Account (beneath the Party) inherits the Locations defined for the Party.
  • HZ Party Sites - Table that links HZ Parties with HZ Locations. Party Site ID is the primary key.
  • HZ Cust Accounts - Different instances of Business Relationships (Selling, etc). Multiple Accounts can exist for a Party. Cust Account ID is the primary key.
  • HZ Cust Acct Sites All - Site reference to the Account . Partitioned by Org Id. Primary Key is Cust Acct Site Id.
  • HZ Cust Site Uses All - Stores business purpose usage (Bill To, Ship To, etc) for the Customer Account. Site Use Id is the Primary Key. Integrated with HZ Cust Acct Sites All.
  • HZ Customer Profiles - Stores credit characteristics of Party, Account, Site.
  • HZ Party Relationships - Stores relationships between parties.
  • HZ Cust Profile Classes - Stores credit characteristics that is common across a group of Accounts


Monday, 17 November 2014

HowTo: Run the .sh File Shell Script In Linux / UNIX

sh file is nothing but the shell script to install given application or to perform other tasks under UNIX like operating systems. The easiest way to run .sh shell script in Linux or UNIX is to type the following commands. Open the terminal (your shell prompt) and type the command:
sh file.sh
OR
bash file.sh

.sh File As Root User

Sometime you need to install application which requires root level privalage
Some time you need root access to install application; without root, you won't have the necessary permissions to install application or make system level modifications. Root access is disabled by default on many Linux and UNIX like systems. Simply use sudo or su as follows:
sudo bash filename.sh
Type your password. Another option is to use the su command as follows to become superuser:
su -
Type root user password and finally run your script:
bash filename.sh

chmod Command: Run Shell Script In Linux

Another recommend option is to set an executable permission using the chmod command as follows:
chmod +x file.sh
Now your can run your .sh file as follows
./file.sh

Unix Commands

Basic Shell Script Commands


# Create Directory
mkdir <dirname>

# Remove Directory
rmdir <dirname>

#remove folder with files
rm -r -f <dirname>

# Change Directory
cd <newpath>

# Create new file
vi <newfile.ext>

#insert data into file
vi <openfilename.ext>
esc i <make changes>

#Save file
esc :wq enter

# exit without saving changes
esc :q! enter

# open existing file
vi <existingfilename.ext>

#remove file
rm <filename.ext>

# copy file with same name
cp <sourcedir>/<sourcefilename.ext> <destinationdir>

# copy file with new name
cp <sourcedir>/<sourcefilename.ext> <destinationdir>/<newfilename.ext>

# Move file with same name
mv <sourcedir>/<sourcefilename.ext> <destinationdir>

# move file with data appended to filename in the front
mv <sourcedir>/<sourcefilename.ext> <destinationdir>/`date+%H%M%d%m%y`<filename.ext>

#print line
echo “your text here to print”

#print date
echo `date`

#To See Lines

tail <File Name> Lines

#All Rights


chmod 777 <File Name> 

Friday, 14 November 2014

Using Parallel Execution

https://docs.oracle.com/cd/B10501_01/server.920/a96520/tuningpe.htm


Types of Parallelism

The following types of parallelism are discussed in this section:


Example 21-4 Parallelizing INSERT ... SELECT

Add the new employees who were hired after the acquisition of ACME.

INSERT /*+ PARALLEL(EMP) */ INTO employees
SELECT /*+ PARALLEL(ACME_EMP) */ * 
FROM ACME_EMP;

Example 1 Parallelizing UPDATE and DELETE
Give a 10 percent salary raise to all clerks in Dallas.
UPDATE /*+ PARALLEL(EMP) */ employees
SET SAL=SAL * 1.1
  WHERE JOB='CLERK' AND DEPTNO IN
  (SELECT DEPTNO FROM DEPT WHERE LOCATION='DALLAS');

The PARALLEL hint is applied to the UPDATE operation as well as to the scan.
Example 2 Parallelizing UPDATE and DELETE
Remove all products in the grocery category because the grocery business line was recently spun off into a separate company.
DELETE /*+ PARALLEL(PRODUCTS) */ FROM PRODUCTS
WHERE PRODUCT_CATEGORY ='GROCERY';


Again, the parallelism is applied to the scan as well as UPDATE operation on table employees.

Incremental Data Loading in Parallel

Parallel DML combined with the updatable join views facility provides an efficient solution for refreshing the tables of a data warehouse system. To refresh tables is to update them with the differential data generated from the OLTP production system.
In the following example, assume that you want to refresh a table named customer that has columns c_keyc_name, and c_addr. The differential data contains either new rows or rows that have been updated since the last refresh of the data warehouse. In this example, the updated data is shipped from the production system to the data warehouse system by means of ASCII files. These files must be loaded into a temporary table, named diff_customer, before starting the refresh process. You can use SQL*Loader with both the parallel and direct options to efficiently perform this task. You can use the APPEND hint when loading in parallel as well.
Once diff_customer is loaded, the refresh process can be started. It can be performed in two phases or by merging in parallel, as demonstrated in the following:

Updating the Table in Parallel

The following statement is a straightforward SQL implementation of the update using subqueries:
UPDATE customers
SET(c_name, c_addr) = 
  (SELECT c_name, c_addr
   FROM diff_customer
   WHERE diff_customer.c_key = customer.c_key)
   WHERE c_key IN(SELECT c_key FROM diff_customer);

Unfortunately, the two subqueries in this statement affect performance.
An alternative is to rewrite this query using updatable join views. To do this, you must first add a primary key constraint to the diff_customer table to ensure that the modified columns map to a key-preserved table:
CREATE UNIQUE INDEX diff_pkey_ind ON diff_customer(c_key)
  PARALLEL NOLOGGING;
ALTER TABLE diff_customer ADD PRIMARY KEY (c_key);

You can then update the customers table with the following SQL statement:
UPDATE /*+ PARALLEL(cust_joinview) */
(SELECT /*+ PARALLEL(customers) PARALLEL(diff_customer) */
CUSTOMER.c_name AS c_name
CUSTOMER.c_addr AS c_addr,
diff_customer.c_name AS c_newname, diff_customer.c_addr AS c_newaddr
   WHERE customers.c_key = diff_customer.c_key) cust_joinview
   SET c_name = c_newname, c_addr = c_newaddr;

The base scans feeding the join view cust_joinview are done in parallel. You can then parallelize the update to further improve performance, but only if the customer table is partitioned.

Inserting the New Rows into the Table in Parallel

The last phase of the refresh process consists of inserting the new rows from the diff_customer temporary table to the customer table. Unlike the update case, you cannot avoid having a subquery in the INSERT statement:
INSERT /*+PARALLEL(customers)*/ INTO customers
SELECT * FROM diff_customer
s);

However, you can guarantee that the subquery is transformed into an anti-hash join by using the HASH_AJ hint. Doing so enables you to use parallel INSERT to execute the preceding statement efficiently. Parallel INSERT is applicable even if the table is not partitioned.

Merging in Parallel

In Oracle9i, you combine the previous updates and inserts into one statement, commonly known as a merge. The following statement achieves the same result as all of the statements in "Updating the Table in Parallel" and "Inserting the New Rows into the Table in Parallel":
MERGE INTO customers USING diff_customer
ON (diff_customer.c_key = customer.c_key)
WHEN MATCHED THEN
  UPDATE SET (c_name, c_addr) = (SELECT c_name, c_addr 
  FROM diff_customer
  WHERE diff_customer.c_key = customers.c_key) 
WHEN NOT MATCHED THEN
  INSERT VALUES (diff_customer.c_key,diff_customer.c_data);

FIRST_ROWS(n) Hint

Starting with Oracle9i, a hint called FIRST_ROWS(n), where n is a positive integer was added. This hint enables the optimizer to use a new optimization mode to optimize the query to return n rows in the shortest amount of time. Oracle Corporation recommends that you use this new hint in place of the old FIRST_ROWS hint for online queries because the new optimization mode may improve the response time compared to the old optimization mode.
Use the FIRST_ROWS(n) hint in cases where you want the first n number of rows in the shortest possible time. For example, to obtain the first 10 rows in the shortest possible time, use the hint as follows:
SELECT /*+ FIRST_ROWS(10) */ article_id
FROM articles_tab
WHERE CONTAINS(article, 'Oracle')>0
ORDER BY pub_date DESC;

Tuesday, 11 November 2014

Sql Script for Running from Back end Scripts

Set serveroutput on;
Set timing on;
Set echo on;
Set feedback on;

spool  xxx.lst

.
.
.

COMMIT;

spool off;
exit;

Unix Nohup: Run a Command or Shell-Script Even after You Logout

Unix Nohup: Run a Command or Shell-Script Even after You Logout


When you execute a Unix job in the background ( using &, bg command), and logout from the session, your process will get killed. You can avoid this using several methods — executing the job with nohup, or making it as batch job using at, batch or cron command.

This quick tip is for beginners. If you’ve been using nohup for a while, leave us a comment and tell us under what situations you use nohup.
In this quick tip, let us review how to make your process running even after you logout, using nohup.
Nohup stands for no hang up, which can be executed as shown below.
nohup syntax:
# nohup command-with-options &
Nohup is very helpful when you have to execute a shell-script or command that take a long time to finish. In that case, you don’t want to be connected to the shell and waiting for the command to complete. Instead, execute it with nohup, exit the shell and continue with your other work.

Explanation about nohup.out file

By default, the standard output will be redirected to nohup.out file in the current directory. And the standard error will be redirected to stdout, thus it will also go to nohup.out. So, your nohup.out will contain both standard output and error messages from the script that you’ve executed using nohup command.
Instead of using nohup.out, you can also redirect the output to a file using the normal shell redirections.

Example: Printing lines to both standard output & standard error

while(true)
do
echo "standard output"
echo "standard error" 1>&2 
sleep 1;
done

Execute the script without redirection

$ nohup sh custom-script.sh &
[1] 12034
$ nohup: ignoring input and appending output to `nohup.out'

$ tail -f nohup.out
standard output
standard error
standard output
standard error
..

Execute the script with redirection

$ nohup sh custom-script.sh > custom-out.log &
[1] 11069
$ nohup: ignoring input and redirecting stderr to stdout

$ tail -f custom-out.log
standard output
standard error
standard output
standard error
..
If you log-out of the shell and login again, you’ll still see the custom-script.sh running in the background.
$ ps aux | grep sathiya 
sathiya  12034  0.0  0.1   4912  1080 pts/2    S    14:10   0:00 sh custom-script.sh

Parallel Hint

 SELECT  /*+parallel(X,10)*/                                            
         COUNT(*)
     FROM OE_ORDER_HEADERS_ALL X
    WHERE org_id = 100
 AND creation_date >= '01-DEC-2001'

Parallel SQL enables a SQL statement to be processed by multiple threads or processes simultaneously.

Understanding Parallel SQL
In a serial—nonparallel—execution environment, a single process or thread undertakes the operations required to process your SQL statement, and each action must complete before the succeeding action can commence. The single Oracle process might only leverage the power of a single CPU and read from a single disk at any given instant. Because most modern hardware platforms include more than a single CPU and because Oracle data is often spread across multiple disks, serial SQL execution cannot take advantage of all the available processing power.
For instance, consider the following SQL statement:
SELECT *
FROM sh.customers
ORDER BY cust_first_name, cust_last_name, cust_year_of_birth
If executing without the parallel query option, a single process would be responsible for fetching all the rows in the CUSTOMERS table. The same process would be responsible for sorting the rows to satisfy the ORDER BY clause. Figure 13-1 illustrates the workflow.
We can request that Oracle execute this statement in parallel by using the PARALLEL hint:
SELECT /*+ parallel(c,2) */ *
FROM sh.customers c
ORDER BY cust_first_name, cust_last_name, cust_year_of_birth
If parallel processing is available, the CUSTOMERS table will be scanned by two processes in parallel. A further two processes will be employed to sort the resulting rows. A final process—the session that issued the SQL in the first place—combines the rows and returns the result set. The process that requests and coordinates the parallel processing stream is the Query coordinator. Figure 13-2 illustrates this sequence of events.
Serial SQL statement
Figure 13-1 Serial execution of a SQL statement.
Oracle supports parallel processing for a wide range of operations, including queries, DDL, and DML:

  • Queries that involve table or index range scans
  • Bulk insert, update, or delete operations
  • Table and index creation
  • The collection of object statistics using DBMS_STATS (see Chapter 7, "Optimizing the Optimizer")
  • Backup and recovery operations using Recovery Manager (RMAN)

The Degree of Parallelism (DOP) defines the number of parallel streams of execution that will be created. In the simplest case, this translates to the number of parallel slave processes enlisted to support your SQL's execution. However, the number of parallel processes is more often twice the DOP. This is because each step in a nontrivial execution plan needs to feed data into the subsequent step, so two sets of processes are required to maintain the parallel stream of processing.
Executing parallel SQL statement with Oracle parallel hint
Figure 13-2 Parallel Execution.
For instance, if the statement includes a full table scan, an ORDER BY and a GROUP BY, three sets of parallel processes are required: one to scan, one to sort, and one go group. Because Oracle reuses the first set of parallel processes (those that performed the scan) to perform the third operation (the GROUP BY), only two sets of processes are required. As a result of this approach, the number of parallel slaves allocated should never be more than twice the DOP.
Figure 13-3 shows how parallel slaves are allocated for a DOP of 2.
Parallel slave pool
The Oracle server maintains a pool of parallel slave processes available for parallel operations. The database configuration parameters PARALLEL_MIN_ SERVERS
Oracle parallel process allocation
Figure 13-3 Parallel process allocation for a DOP of 2.
and PARALLEL_MAX_SERVERS determine the initial and maximum size of the pool. If insufficient slaves are currently active but the pool has not reached its maximum value, Oracle will create more slaves. After a configurable period of inactivity, slave processes will shut down until the pool is again at its minimum size.
If there are insufficient query processes to satisfy the DOP requested by your statement, one of the following outcomes results:
  • If there are some parallel query slaves available, but less than requested by your SQL statement, your statement might run at a reduced DOP.
  • If there are no parallel query slaves available, your statement might run serially.
  • Under specific circumstances, you might get an error. This will only occur if the database parameter PARALLEL_MIN_PERCENT has been set to a value that is higher than the percentage of required slaves that are available.
  • In Oracle 11g Release 2 and forward, your SQL execution might be delayed until sufficient parallel servers are available.
See the "Parallel Configuration Parameters" section later in this chapter for more information on how to configure these outcomes.
Parallel Query IO
We discussed in Chapter 2, "Oracle Architecture and Concepts," and elsewhere, how the Oracle buffer cache helps reduce disk IO by buffering frequently accessed data blocks in shared memory. Oracle has an alternate IO mechanism, direct path IO, which it can use if it determines that it would be faster to bypass the buffer cache and perform the IO directly. For instance, Oracle uses direct IO when reading and writing temporary segments for sorting and intermediate result sets. In Oracle 11g onward, Oracle sometimes uses direct path IO in preference to the normal buffered IO for serial table access as well.
When performing Parallel query operations, Oracle normally uses direct path IO. By using direct path IO, Oracle avoids creating contention for the buffer cache and allows IO to be more optimally distributed between slaves. Furthermore, for parallel operations that perform full table scans the chance of finding matching data in the buffer cache is fairly low, so the buffer cache adds little value.
In Oracle 10g and earlier, parallel query always uses direct path IO, and serial query will always use buffered IO. In 11g, Oracle can use buffered IO for parallel query (from 11g release 2 forward), and serial queries might use direct path IO. However, it remains true that parallel queries are less likely to use buffered IO and might, therefore, have a higher IO cost than serial queries. The higher IO cost will, of course, be shared amongst all the parallel processes so the overall performance might still be superior.
Direct path and buffered IO are discussed in more detail within Chapter 21, "Disk IO Tuning Fundamentals."
Parallel performance gains
The performance improvements that you can expect to obtain from parallel SQL depend on the suitability of your host computer, Oracle configuration, and the SQL statement. If all the conditions for parallel processing are met, you can expect to get substantial performance improvements in proportion to the DOP employed.
On many systems, the limit of effective parallelism will be determined by segment spread, not by hardware configuration. For instance, if you have 32 CPUs and 64 independent disk devices, you might hope for effective parallelism up to at least a DOP of 32 or maybe even 64. However, if the table you are querying is spread over only 6 disks, you are likely to see performance improvements reduce as you increase the DOP beyond 6 or so.
Figure 13-4 illustrates the improvements gained when increasing the DOP for a SQL statement that performs a table scan and GROUP BY of a single table.
Increasing DOP for a SQL statement
Figure 13-4 Improvement gains for various DOPs on various host configurations.
The host configurations shown are
  • An Amazon CPU-intensive Extra Large EC2 image. This is a virtual server running in Amazon's AWS cloud that has the equivalent of 8 _ 2.5-GHz CPUs and has storage on a widely striped SAN.
  • An Amazon CPU-intensive Medium EC2 image. This is similar to the extra large image, but has only 2 CPUs.
  • A Dell 6800 4 CPU server with disk storage on a widely striped SAN using ASM.
  • A Dell latitude D830 laptop (my laptop). It is dual core, but all data files are on a single disk.
In each case, the parallel SQL was the only SQL running.
These examples show that for suitably configured systems, performance gains were greater the more CPUs that were available. However, attempting to use parallel on a host that is unsuitable (as in my laptop) is futile at best and counter-productive at worst.
The performance gains achieved through parallal processing are most dependent on the hardware configuration of the host. To get benefits from parallel processing, the host should possess multiple CPUs and data should be spread across multiple disk devices.


Oracle hints

Tuning with hints
 

There are many hints for every possible step within execution plans:
Global hints:   rule, first_rows, first_rows_n all_rows, driving_site

Table join hints:  use_nl, use_hash

Index hints:  Specifies an index name

Table access hints:  parallel, full, cardinality
 
Table join hints:  ordered
 
You can tune Oracle with hints by placing them after the SELECT statements, but Oracle hints can also be used in subqueries:
 
SELECT
a.Author_last_name, a.author_first_name
FROM author a
WHERE author_key in
(select /*+ FULL(a) FULL(b) */ b.author_key
from sales a, book_author b
Where a.book_key=b.book_key);
 

Tips for tuning with Oracle hints


Carefully check the hint syntax. It is always a good idea to use the full-comment syntax for a hint. For example, the /+* hint */ syntax is generally preferred to the ? ?+ hint syntax.

Use the table alias Whenever you have a query that specifies an alias for a table, you cannot use the table name. Instead, you must specify the table alias name. For example, the following query will invoke the index hint because the emp table is aliased with ?e?:
select /*+ index(e,dept_idx) */ * from emp e;

Never reference the schema name in a hint Hints will be ignored when the schema owner is specified in the hint. For example, the following hint will be ignored:
select /*+ index(scott.emp,dept_idx) */ * from emp;
 

Inappropriate Oracle hints

 
First, please read this link to understand why Oracle SQL can ignore hints.
 
Some Oracle hints are contradictory and invalid, and a hint will be ignored if it assumes an access path that is not available. For example,
  • Specifying an index hint on a table that has no indexes
  • Specifying a parallel hint for an index range scan
You need to be especially careful with validation of hints because it is not always obvious that a hint is contradictory with the query. For example, consider the following query in the emp table with no index on the ename column.
select /*+ first_rows */ * from emp order by ename;

The following hint is invalid because first_rows access and parallel access are mutually exclusive. That is because parallel access always assumes a full-table scan and first_rows favors index access.
-- An invalid hint
select /*+ index (emp emp_idx) parallel(emp,8)*/
  emp_name
from
  emp
where
  emp_type = 'SALARIED';

Some Oracle professionals will place hints together to reinforce their wishes. For example, if there is a SMP server with eight or more CPUs, one may want to use Oracle Parallel Query to speed up legitimate full-table scans.
Spelling - If table name or index name is spelled incorrectly, then the hint will not be used. Here we see a query with a misspelled table name:
select /*+ index(erp, dept_idx) */ * from emp;


Table Name - The table name is mandatory in the hint. For example, the following hint will be ignored because the table name is not specified in the query:
select /*+ index(dept_idx) */ * from emp;
 

Other Oracle hints tips:

Here are guidelines for using Oracle hints for tuning:
  • Because hints are placed inside comments, they will be ignored if the hint is incompatible with the existing execution plan or when the hint is formatted improperly.
     
  • When using the RBO, hints can be used to change specific queries to use the CBO. Always remember to analyze all table and indexes that participate in the query.
     
  • When using the CBO, you can start tuning a suspect SQL statement by adding the rule or first_rows hint.
     
  • Hints can be applied to subqueries, but a hint in the outer query will not carry over into the subquery.
     

Tuning with the parallel hint


When using parallel query, one should seldom turn on parallelism at the table level, alter table customer parallel 35, because the setting of parallelism for a table influences the optimizer. This causes the optimizer to see that the full-table scan is inexpensive. Hence, most Oracle professionals specify parallel query on a query-by-query basis, combining the full hint with the parallel hint to ensure a fast parallel full-table scan:
-- A valid hint
select /*+ full parallel(emp,35)*/
   emp_name
from
   emp
order by
   ename;


Lets take a look at one of the most important hints for Oracle tuning.

The 
ordered hint determines the driving table for the query execution and also specifies the order that tables are joined together. The ordered hint requests that the tables should be joined in the order that they are specified in the from clause, with the first table in the from clause specifying the driving table.
 
Using the ordered hint can save a huge amount of parse time and speed SQL execution because the optimizer is given the best order to join the tables.
 

Tuning with the cardinality hint

The use of the cardinality hint compensates for the optimizers inability to estimate the inter-table join result set.  This is NOT a problem with the optimizer, as no amount of metadata will help when joining tables with complex, multi-column where clauses.
The cardinality hint is used in two general cases, complex joins and dynamically created tables like global temporary tables (and possibly using materializations using the WITH clause):
select /*+ cardinality( gtt 500 ) */
stuff
from global_temp_table;

The dynamic sampling hint

The use of the 10g dynamic_sampling hint is very useful for highly volatile tables and global temporary tables.
In 10g, you can use the dynamic_sampling hint to direct Oracle to estimate the cardinality of highly volatile tables.
The dynamic sampling hint is also useful for estimating the size of dynamically created objects such as global temporary tables (GTT?s)

select /*+ dynamic_sampling(customer 4) */ pol_no, sales_id, sum_assured, premium
from customer;
 
 
Here are my related notes on Oracle hints:

Monday, 13 October 2014

RTF Template - Word Features

Q. How to repeat table header on each page?
Ans: Right click on first row of table header and Go to table properties and click on Row Tab. Here check the second option checkbox- Repeat as header row at the top of each page. For rest of the rows uncheck this checkbox and check first option- Allow row to break across pages

Q. How to insert tag in header/footer portion of RTF template?
Ans. Usually we are not allowed to insert tag in header/footer. But we can insert text of the tag directly in header/footer, it indirectly work as a tag in template. Eg: (?CountryName?)
Q. Not able to print tag value even after opening the loop?
Ans. Sometimes we are not able to print tag value even after properly opening and closing the loop. In such case, provide complete path for tag in form field help text.
Eg: (?/OutboundPaymentInstruction/OutboundPayment/Payee/SupplierNumber?)
Q. How to remove line border between records of a table?
Ans. To manage line border between records of a table in loop, use outside border option in Formatting Menu of Word. If it still doesnt work, then create a table in excel by formatting cells and paste it in RTF template.

Note: Replace symbol '(' with '<' and ')' with '>' in all above xml/xsl syntax

RTF Template - IF Condition

You can use IF condition directly or using xdofx in RTF Template. Below are few examples
(?xdofx:if LENGTH(/XXBRPRPOP/LIST_G_INIT_INFO/G_INIT_INFO/LIST_G_HEADERS/G_HEADERS/POH_CUSTOMER)=0 THEN 'DELIVER TO:'POD_REQUESTOR_NAME'('POD_QUANTITY_ORDERED')' END IF?)


(?xdofx:if LENGTH(/XXBRPRPOP/LIST_G_INIT_INFO/G_INIT_INFO/LIST_G_HEADERS/G_HEADERS/POH_CUSTOMER) !=0 AND(/XXBRPRPOP/LIST_G_INIT_INFO/G_INIT_INFO/LIST_G_HEADERS/G_HEADERS/POH_CUSTOMER)!=POD_REQUESTOR_NAME THEN 'DELIVER TO:'POD_REQUESTOR_NAME'('POD_QUANTITY_ORDERED')' END IF?)


(?if:string-length(/XXBRPRPOP/LIST_G_INIT_INFO/G_INIT_INFO/LIST_G_HEADERS/G_HEADERS/LIST_G_CANCEL_RELEASE/CANCEL_RELEASE_DATE)!=0?)


(?xdofx:if AMOUNT > 1000 then ’Higher’
else
if AMOUNT < 1000 then ’Lower’
else
’Equal’
end if?>


Note: Replace symbol '(' with '<' and ')' with '>' for starting and ending Tags above

RTF Template - Page Break

nsert definite space in RTF templateUse below syntax in Tag to insert space before or after in your template. As point increases, space also get increased.
(xsl:attribute name='space-before')100pt(/xsl:attribute)
(xsl:attribute name='space-after')100pt(/xsl:attribute)


Inserting pagebreak
1) Below is the simple syntax to add pagebreak
(?split-by-page-break:?)

2) We can also use below syntax for before and after
(xsl:attribute name="break-before")page(/xsl:attribute)
(xsl:attribute name="break-after")page(/xsl:attribute)
3) Conditional pagebreak, use below syntax. Here we are inserting page-break if value of variable no_of_lines_per_page is equal to total records in loop inner_group. Variable is always referred by $ in XSL
(xsl:if xdofo:ctx="inblock" test="$no_of_lines_per_page=count($inner_group)")(xsl:attribute name="break-before")page(/xsl:attribute) (/xsl:if)Note: Replace symbol '(' with '<' and ')' with '>' in all above xml/xsl syntax

RTF Template Signature Printing

Fixed SignatureIf you have fixed logo or signature to print in RTF template, then perform below steps
1) Copy file in .gif format to $OA_MEDIA path at Application Server
2) Insert picture in RTF template and add below text in Web Tab
url:{'${OA_MEDIA}/MAB_NEW.gif'}

Dynamic Signature
If you want to print signature based on Tag value in RTF template, then perform below steps
1) Copy file in .gif format to $OA_MEDIA path at Application Server
2) File name must be same as Tag value. For example, if tag value is Amit, then your file name should be Amit.gif
3) Finally, Insert picture in RTF template and add below text in Web Tab
url:{concat('$[OA_MEDIA]/',.//PO_NUMBER)}

RTF Template Variable

Define Constant Variable
This variable remains constant for entire file
(xsl:variable name="no_of_lines_per_page" select="number(15)"/)

Assigning Group/Repeating Frame to Variable
(xsl:variable xdofo:ctx="incontext" name="inner_group" select=".//DocumentPayable"/)
Here DocumentPayable is a Group which is assigned to variable inner_group. So we can loop through this variable as below
(?for-each:$inner_group?)
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
(?xdoxslt:set_variable($_XDOCTX, ‘counter’, 0)?)
(?for-each:G_LINES?)
(?xdoxslt:set_variable($_XDOCTX, ‘counter’, xdoxslt:get_variable($_XDOCTX, ‘counter’) + 1)?)
(?xdoxslt:get_variable($_XDOCTX, ‘counter’)?)
(?end for-each?)

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
(xsl:value-of select=”$var1”/)

Note: Replace symbol '(' with '<' and ')' with '>' for starting and ending Tags above

XML Creation Thru PLSQL

CREATE OR REPLACE PROCEDURE gl_inter_company_trans 
(retcode OUT VARCHAR2,
errbuf OUT VARCHAR2,
p_period VARCHAR2,
p_operating_unit VARCHAR2,
p_status1 VARCHAR2)
IS

CURSOR gl_detail 
(p_status IN VARCHAR2,
p_period VARCHAR2,
p_operating_unit VARCHAR2)
IS
SELECT receiver, sender, transaction_number, period, entered_date,
description, note, amount, NAME, attribute10, status, gl_date,
sendor_gl_transfer, receiver_gl_transfer, CONTEXT
FROM (SELECT rsub.NAME receiver, ssub.NAME sender,
gl_.transaction_number, gl_.sender_period_name period,
gl_.entered_date, gl_.description, gl_.note,
( NVL (gl_.sender_running_total_dr, 0)
- NVL (gl_.sender_running_total_cr, 0)
) amount,
REPLACE (typ.NAME, '&', '') NAME, gl_.attribute10,
DECODE (gl_.status, 'R', 'Review', 'Approved') status,
gl_.gl_date,
DECODE (gl_.sender_transfer_flag, 'Y', 'Yes', 'No') sendor_gl_transfer,
DECODE (gl_.receiver_transfer_flag, 'Y', 'Yes', 'No') receiver_gl_transfer,
gl_.CONTEXT
FROM gl.gl_iea_transactions gl_,
gl.gl_iea_transaction_types typ,
gl.gl_iea_subsidiaries ssub,
gl.gl_iea_subsidiaries rsub
WHERE typ.transaction_type_id = gl_.transaction_type_id
AND ssub.subsidiary_id = gl_.sending_subsidiary_id
AND rsub.subsidiary_id = gl_.receiving_subsidiary_id
AND gl_.status = 'R'
AND gl_.status = NVL (p_status, gl_.status)
AND gl_.sender_period_name = NVL (p_period, gl_.sender_period_name)
AND ( ssub.NAME = NVL (p_operating_unit, ssub.NAME)
OR rsub.NAME = NVL (p_operating_unit, rsub.NAME)));

p_status VARCHAR2 (100);
v_transaction_num_prev VARCHAR2 (50) := '00000';
v_transaction_num_curr VARCHAR2 (50) := '11111';

BEGIN

BEGIN
IF p_status1 = 'Approved'
THEN
p_status := 'A';
ELSIF p_status1 = 'Review'
THEN
p_status := 'R';
ELSIF p_status1 = 'ALL'
THEN
p_status := NULL;
END IF;
END;

fnd_file.put_line (fnd_file.output, '(?xml version="1.0" encoding="UTF-8"?)');
fnd_file.put_line (fnd_file.output, '(Pending_Transac)'); -- Main Tag
fnd_file.put_line (fnd_file.output, '(PERIOD)' || p_period || '');
fnd_file.put_line (fnd_file.output, '(OPERATING_UNIT)' || p_operating_unit || '(/OPERATING_UNIT)');
fnd_file.put_line (fnd_file.output, '(STATUS)' || p_status1 || '(/STATUS)');

FOR rec_gl_detail IN gl_detail (p_status, p_period, p_operating_unit)
LOOP
v_transaction_num_curr := rec_gl_detail.transaction_number;
IF p_operating_unit IS NOT NULL
THEN
fnd_file.put_line (fnd_file.output, '(G_GL_DETAIL)'); -- Masters tag
fnd_file.put_line (fnd_file.output, '(STATUS)' || rec_gl_detail.status || '(/STATUS)');
fnd_file.put_line (fnd_file.output, '(TRANSACTION_NUMBER)' || rec_gl_detail.transaction_number
'(/TRANSACTION_NUMBER)
');
fnd_file.put_line (fnd_file.output, '(ENTERED_DATE)' || rec_gl_detail.entered_date ||
'(/ENTERED_DATE)
');
fnd_file.put_line (fnd_file.output, '(GL_DATE)' || rec_gl_detail.gl_date || '(/GL_DATE)');
fnd_file.put_line (fnd_file.output, '(PERIOD)' || rec_gl_detail.period || '(/PERIOD)');
fnd_file.put_line (fnd_file.output, '(NAME)' || rec_gl_detail.NAME || '(/NAME)');
fnd_file.put_line (fnd_file.output, '(SENDER)'  || rec_gl_detail.sender || '(/SENDER)');
fnd_file.put_line (fnd_file.output, '(SENDOR_GL_TRANSFER)' || rec_gl_detail.sendor_gl_transfer ||
'(/SENDOR_GL_TRANSFER)
');
fnd_file.put_line (fnd_file.output, '(RECEIVER)' || rec_gl_detail.receiver || '(/RECEIVER)');
fnd_file.put_line (fnd_file.output, '(RECEIVER_GL_TRANSFER)' || rec_gl_detail.receiver_gl_transfer ||
'(/RECEIVER_GL_TRANSFER)
');
fnd_file.put_line (fnd_file.output, '(AMOUNT)' || rec_gl_detail.amount || '(/AMOUNT)');
fnd_file.put_line (fnd_file.output, '(DESCRIPTION)' || rec_gl_detail.description || '(/DESCRIPTION)');
fnd_file.put_line (fnd_file.output, '(NOTE)' || rec_gl_detail.note || '(/NOTE)');
fnd_file.put_line (fnd_file.output, '(ATTRIBUTE10)' || rec_gl_detail.attribute10 || '(/ATTRIBUTE10)');
fnd_file.put_line (fnd_file.output, '(CONTEXT)' || rec_gl_detail.CONTEXT || '(/CONTEXT)');
fnd_file.put_line (fnd_file.output, '(/G_GL_DETAIL)
');

ELSIF p_operating_unit IS NULL
THEN

IF ( ( v_transaction_num_curr <> v_transaction_num_prev
AND rec_gl_detail.status = 'Approved')
OR rec_gl_detail.status = 'Review')
THEN
fnd_file.put_line (fnd_file.output, '(G_GL_DETAIL)'); -- Masters tag
fnd_file.put_line (fnd_file.output, '(STATUS)' || rec_gl_detail.status || '(/STATUS)');
fnd_file.put_line (fnd_file.output, '(TRANSACTION_NUMBER)' || rec_gl_detail.transaction_number ||
'(/TRANSACTION_NUMBER)');
fnd_file.put_line (fnd_file.output, '(ENTERED_DATE)' || rec_gl_detail.entered_date ||
'(/ENTERED_DATE)');
fnd_file.put_line (fnd_file.output, '(GL_DATE)' || rec_gl_detail.gl_date || '(/GL_DATE)');
fnd_file.put_line (fnd_file.output, '(PERIOD)' || rec_gl_detail.period || '(/PERIOD)');
fnd_file.put_line (fnd_file.output, '(NAME)' || rec_gl_detail.NAME || '(/NAME)');
fnd_file.put_line (fnd_file.output, '(SENDER)' || rec_gl_detail.sender || '(/SENDER)');
fnd_file.put_line (fnd_file.output, '(SENDOR_GL_TRANSFER)' || rec_gl_detail.sendor_gl_transfer ||
'(/SENDOR_GL_TRANSFER)');
fnd_file.put_line (fnd_file.output, '(RECEIVER)' || rec_gl_detail.receiver || '(/RECEIVER)');
fnd_file.put_line (fnd_file.output, '(RECEIVER_GL_TRANSFER)' || rec_gl_detail.receiver_gl_transfer ||
'(/RECEIVER_GL_TRANSFER)');
fnd_file.put_line (fnd_file.output, '(AMOUNT)' || rec_gl_detail.amount || '(/AMOUNT)');
fnd_file.put_line (fnd_file.output, '(DESCRIPTION)' || rec_gl_detail.description || '(/DESCRIPTION)');
fnd_file.put_line (fnd_file.output, '(NOTE)' || rec_gl_detail.note || '(/NOTE)');
fnd_file.put_line (fnd_file.output, '(ATTRIBUTE10)' || rec_gl_detail.attribute10 || '(/ATTRIBUTE10)');
fnd_file.put_line (fnd_file.output, '(CONTEXT)' || rec_gl_detail.CONTEXT || '(/CONTEXT)');
fnd_file.put_line (fnd_file.output, '(/G_GL_DETAIL)');
END IF;

v_transaction_num_prev := v_transaction_num_curr;

END IF;
END LOOP;

fnd_file.put_line (fnd_file.output, '(/Pending_Transac)
'); -- End Main Tag

EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (fnd_file.LOG, 'Entered into Exception');
END gl_inter_company_trans;