Developing XML Publisher Report – Using Data Template as Data Source

Background: 
Developing XML Publisher Report – Using Data Template(.xml) as Data Source and Template(.rtf) as Layout.
Note that, we can use .rdf file as data source. But for this demo we are using Date XML Template.
Prerequisite for the below Example:

1. Create a table
CREATE TABLE demo_products
(  product_code   NUMBER,
   product_name   VARCHAR2 (100));

2. Insert Values
INSERT INTO demo_products
     VALUES (569, ‘Oracle Cost Management’);
3. Issue Commit

Step1: Define Data Template:

The data template is the method by which you communicate your request for data to the data engine.
The data template is an XML document that consists of four basic sections:  

  • Define parameters: In which parameters are declared in child <parameter> elements
  • Define triggers:
  • Define data query: In which the SQL queries are defined in child <sqlStatement> elements
  • Define data structure: In which the output XML structure is defined
 Create Data Template: (Save this file as XXDPDT.xml)
<?xml version=”1.0″ encoding=”UTF-8″?>
<dataTemplate name=”demoProductsDT” description=”Demo Products Details” version=”1.0″>
   <parameters>
     <parameter name=”p_product_id” datatype=”number”/>
   </parameters>
  <dataQuery>
    <sqlStatement name=”DQ”>
         <![CDATA[ SELECT product_code, product_name FROM demo_products 
                            WHERE product_code = NVL(:p_product_id,product_code) ]]>
    </sqlStatement>
  </dataQuery>
  <dataStructure>
    <group name=”G_DP” source=”DQ”>
      <element name=”PRODUCT_CODE” value=”product_code”/>
      <element name=”PRODUCT_NAME” value=”product_name”/>
    </group>
  </dataStructure>
</dataTemplate>
  • This Data Template selects the product details from the demo_products table. It uses a bind parameter to find the product name against the product code.
  • For each bind parameter in the query , we need to define a Parameter in the Concurrent Program

Step 2: Create Data Definition & Associate with Data Template
Navigation: XML Publisher Administrator -> Data Definitions -> Create Data Definition
Screen 1 : Create Data Definition
       Enter the data definition Details and click on Apply. Note down the Code. 
       The code should be used as the short name of the concurrent program.

Screen 2: Associate Data Template
       View Data Definition
Click on ‘Add File’ button to upload Data Template file that was created through step 1
Screen 3: Data Definiton
       Data Template is associated with Data Definition

Step 3: Define a Concurrent Program to generate the Data XML output. 
Note:
1. Output format should be XML
2. Short Name in the concurrent program and Code in the data definition should be same.
Screen 2: Concurrent Program – Parameters
For each parameter in the Data Template, define a parameter in the concurrent program.
The Data Template parameter name should match the concurrent program parameter token
Note:
Token is p_product_id. This is the bind parameter we have used in date template. For every bind parameter used in the data template, we have to define parameter in the concurrent program.
Screen 3: Associate the Concurrent Program to a request group.
Screen 4: Execute the concurrent program “Product Demo Report”and click on the output button get the Data XML. Save the XML file. We will use it to generate the RTF Template.
Screen 5: Concurrent Program Output
Note:
We are getting the output in xml because we didn’t define template & associated yet.

Step 4: Define the RTF Template using the Generated Data XML

Pre-requisite : Install XML Publisher Desktop
After installation following Menus & Toolbars gets added to the MS Word.

Load XML Data generated by Concurrent Program
Data -> Load XML Data
Message after loading the data
Using the Table Wizard as below to create the ‘Table Report Format’ with the columns of demo_products.

Final Output layout look like this.

Save this file with .rtf extension
Step 5: Registering the Template with BI Publisher
Navigation: XML Publisher Administrator -> Templates -> Create Template

Step 6: Run the concurrent program to see the output

Note:

As already mentioned output format can be anything. Here it is pdf. We can select format that we want at the runtime.

References:
http://www.oracle.com/technology/products/xml-publisher/index.htm
http://www.oracle.com/technetwork/middleware/bi-publisher/overview/index.html
http://xdo.us.oracle.com
Oracle® XML Publisher Administration and Developer’s Guide

FAQ:
What is XDODTEXE used in the Executable section of Concurrent Program?

XDODTEXE is a BI Publisher Data Template Executable. The purpose of this executable is to identify data template file (.xml) and execute the data template to generate the raw xml data, that later can be used by BI Publisher formatting engine to format as as per the layout (RTF, PDF etc).
This executable will be used by all the BI Publisher reports (Concurrent Program) which are using Data Template to generate the xml data. 

Oracle App Using Flash Message in Forms Personalization
Responsibility: Application Developer
Navigation: Application > Messages
Create new message
Name: XX_TEST
Current Text Message: This is a test message for &USER_NAME
Save and close form.
Generate the message
Responsibility: Application Developer
Click on View > Requests in the menu to execute a concurrent program. Select Generate Messages program.

Click on Help > Diagnostics > Custom Code > Personalize
Create a new Personalization
Click on Actions
Sequence 10
Type: Builtin
Description: Retrieve the msg
Builtin Type: Execute a procedure
Argument: FND_MESSAGE.SET_NAME(‘XXCUST’, ‘XX_TEST’)
Sequence 11
Type: Builtin
Description: Set the USER token
Builtin Type: Execute a Procedure
Argument: fnd_message.set_token (‘USERNAME’, fnd_profile.value(‘USERNAME’))
Sequence 12
Type: Builtin
Description: Set the ORG token
Builtin Type: Execute a Procedure
Argument: fnd_message.set_token (‘ORG_ID’, fnd_profile.value(‘ORG_ID’))
Sequence 13
Type: Message
Description: Display the msg
Message Type: Show
Message Text: =FND_MESSAGE.GET

Recipe Header Uploading can be done using the following steps:

1. First Create a staging table say “MJIL_RCP_HDR_UPL_TBL” as shown below.

CREATE TABLE MJIL_RCP_HDR_UPL_TBL
(
   RECIPE_ID                  NUMBER (15),
   RECIPE_DESCRIPTION         VARCHAR2 (70 BYTE),
   RECIPE_NO                  VARCHAR2 (32 BYTE),
   RECIPE_VERSION             NUMBER (5),
   USER_ID                    NUMBER (15),
   USER_NAME                  VARCHAR2 (70 BYTE),
   OWNER_ORGN_CODE            VARCHAR2 (4 BYTE),
   CREATION_ORGN_CODE         VARCHAR2 (4 BYTE),
   OWNER_ORGANIZATION_ID      NUMBER,
   CREATION_ORGANIZATION_ID   NUMBER,
   FORMULA_ID                 NUMBER (15),
   FORMULA_NO                 VARCHAR2 (32 BYTE),
   FORMULA_VERS               NUMBER,
   ROUTING_ID                 NUMBER,
   ROUTING_NO                 VARCHAR2 (32 BYTE),
   ROUTING_VERS               NUMBER (5),
   PROJECT_ID                 NUMBER (15),
   RECIPE_STATUS              VARCHAR2 (30 BYTE),
   PLANNED_PROCESS_LOSS       NUMBER,
   TEXT_CODE                  NUMBER (10),
   DELETE_MARK                NUMBER (5),
   CONTIGUOUS_IND             NUMBER,
   ENHANCED_PI_IND            VARCHAR2 (1 BYTE),
   RECIPE_TYPE                NUMBER,
   CREATION_DATE              DATE,
   CREATED_BY                 NUMBER (15),
   LAST_UPDATED_BY            NUMBER (15),
   LAST_UPDATE_DATE           DATE,
   LAST_UPDATE_LOGIN          NUMBER (15),
   OWNER_ID                   NUMBER (15),
   OWNER_LAB_TYPE             VARCHAR2 (4 BYTE),
   CALCULATE_STEP_QUANTITY    NUMBER (5),
   FIXED_PROCESS_LOSS         NUMBER,
   FIXED_PROCESS_LOSS_UOM     VARCHAR2 (3 BYTE),
   ATTRIBUTE_CATEGORY         VARCHAR2 (30 BYTE),
   ATTRIBUTE1                 VARCHAR2 (240 BYTE),
   ATTRIBUTE2                 VARCHAR2 (240 BYTE),
   ATTRIBUTE3                 VARCHAR2 (240 BYTE),
   ATTRIBUTE4                 VARCHAR2 (240 BYTE),
   ATTRIBUTE5                 VARCHAR2 (240 BYTE),
   ATTRIBUTE6                 VARCHAR2 (240 BYTE),
   ATTRIBUTE7                 VARCHAR2 (240 BYTE),
   ATTRIBUTE8                 VARCHAR2 (240 BYTE),
   ATTRIBUTE9                 VARCHAR2 (240 BYTE),
   ATTRIBUTE10                VARCHAR2 (240 BYTE),
   ATTRIBUTE11                VARCHAR2 (240 BYTE),
   ATTRIBUTE12                VARCHAR2 (240 BYTE),
   ATTRIBUTE13                VARCHAR2 (240 BYTE),
   ATTRIBUTE14                VARCHAR2 (240 BYTE),
   ATTRIBUTE15                VARCHAR2 (240 BYTE),
   ATTRIBUTE16                VARCHAR2 (240 BYTE),
   ATTRIBUTE17                VARCHAR2 (240 BYTE),
   ATTRIBUTE18                VARCHAR2 (240 BYTE),
   ATTRIBUTE19                VARCHAR2 (240 BYTE),
   ATTRIBUTE20                VARCHAR2 (240 BYTE),
   ATTRIBUTE21                VARCHAR2 (240 BYTE),
   ATTRIBUTE22                VARCHAR2 (240 BYTE),
   ATTRIBUTE23                VARCHAR2 (240 BYTE),
   ATTRIBUTE24                VARCHAR2 (240 BYTE),
   ATTRIBUTE25                VARCHAR2 (240 BYTE),
   ATTRIBUTE26                VARCHAR2 (240 BYTE),
   ATTRIBUTE27                VARCHAR2 (240 BYTE),
   ATTRIBUTE28                VARCHAR2 (240 BYTE),
   ATTRIBUTE29                VARCHAR2 (240 BYTE),
   ATTRIBUTE30                VARCHAR2 (240 BYTE)
);

2. Next create a procedure using the script as shown below.

CREATE OR REPLACE PROCEDURE CONA_RECIPE_UPLOAD_PD (ERRBUF    OUT VARCHAR2,
                                                   RETCODE   OUT NUMBER)
IS
   /******************************************************************************
   NAME: APPS.CONA_RECIPE_UPLOAD_PD
   PURPOSE: Recipe Header Uploading
   REVISIONS:
   Ver Date Author Description
   ——— ———- ————— ————————————
   1.0 8/16/2013 1. Oracle User Created this procedure.

   NOTES:

   Automatically available Auto Replace Keywords:
   Object Name: APPS.CONA_RECIPE_UPLOAD_PD
   ******************************************************************************/

   mjil_rcp_hdr_tbl          gmd_recipe_header.recipe_tbl;
   mjil_rcp_hdr_flex_tbl     gmd_recipe_header.recipe_flex;
   X_status                  VARCHAR2 (1);
   X_msg_cnt                 NUMBER;
   X_msg_dat                 VARCHAR2 (1000);
   X_row                     NUMBER := 1;
   l_user_id                 NUMBER := 1114;
   l_responsibility_id       NUMBER := 22883;
   l_out_index               NUMBER;
   l_responsibility_app_id   NUMBER;

   CURSOR c1
   IS
      SELECT * FROM mjil_rcp_hdr_upl_tbl;
BEGIN
   FND_GLOBAL.
    APPS_INITIALIZE (l_user_id, l_responsibility_id, l_responsibility_app_id);

   FOR i IN c1
   LOOP
      mjil_rcp_hdr_tbl (X_row).recipe_no := i.recipe_no;
      mjil_rcp_hdr_tbl (X_row).recipe_version := i.recipe_version;
      mjil_rcp_hdr_tbl (X_row).recipe_description := i.recipe_description;
      mjil_rcp_hdr_tbl (X_row).RECIPE_STATUS := i.RECIPE_STATUS;
      mjil_rcp_hdr_tbl (X_row).RECIPE_TYPE := i.RECIPE_TYPE;
      mjil_rcp_hdr_tbl (X_row).formula_no := i.formula_no;
      mjil_rcp_hdr_tbl (X_row).formula_vers := i.formula_vers;
      mjil_rcp_hdr_tbl (X_row).routing_no := i.routing_no;
      mjil_rcp_hdr_tbl (X_row).routing_vers := i.routing_vers;

      mjil_rcp_hdr_tbl (X_row).delete_mark := i.delete_mark;
      mjil_rcp_hdr_tbl (X_row).creation_date := SYSDATE;
      mjil_rcp_hdr_tbl (X_row).created_by := i.created_by;
      mjil_rcp_hdr_tbl (X_row).last_updated_by := i.last_updated_by;
      mjil_rcp_hdr_tbl (X_row).last_update_date := SYSDATE;
      mjil_rcp_hdr_tbl (X_row).last_update_login := 1114;

      mjil_rcp_hdr_tbl (X_row).user_name := i.user_name;
      mjil_rcp_hdr_tbl (X_row).owner_orgn_code := i.owner_orgn_code;
      mjil_rcp_hdr_tbl (X_row).OWNER_ORGANIZATION_ID :=
         i.owner_organization_id;
      mjil_rcp_hdr_tbl (X_row).creation_orgn_code := i.creation_orgn_code;
      mjil_rcp_hdr_tbl (X_row).owner_id := i.owner_id;

      mjil_rcp_hdr_flex_tbl (X_row).attribute1 := ‘FLEX1’;

      X_row := X_row + 1;
   END LOOP;

   gmd_recipe_header.
    create_recipe_header (p_api_version          => 1,
                          p_init_msg_list        => FND_API.G_TRUE,
                          p_commit               => FND_API.G_TRUE,
                          p_called_from_forms    => ‘NO’,
                          x_return_status        => X_status,
                          x_msg_count            => X_msg_cnt,
                          x_msg_data             => X_msg_dat,
                          p_recipe_header_tbl    => mjil_rcp_hdr_tbl,
                          p_recipe_header_flex   => mjil_rcp_hdr_flex_tbl);

   DBMS_OUTPUT.put_line (‘Return status – ‘ || X_status);
   DBMS_OUTPUT.put_line (‘Message count – ‘ || X_msg_cnt);

   FOR i IN 1 .. X_msg_cnt
   LOOP
      FND_MSG_PUB.get (p_msg_index       => i,
                       p_encoded         => ‘F’,
                       p_data            => X_msg_dat,
                       P_MSG_INDEX_OUT   => l_out_index);
      DBMS_OUTPUT.PUT_LINE (‘Message Text ‘ || X_msg_dat);
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line (‘Return status – ‘ || X_status);
      DBMS_OUTPUT.put_line (‘Message count – ‘ || X_msg_cnt);

      FOR i IN 1 .. X_msg_cnt
      LOOP
         FND_MSG_PUB.get (p_msg_index       => i,
                          p_encoded         => ‘F’,
                          p_data            => X_msg_dat,
                          P_MSG_INDEX_OUT   => l_out_index);
         DBMS_OUTPUT.PUT_LINE (‘Message Text ‘ || X_msg_dat);
      END LOOP;
END;
/

3. Finally register the procedure and run it.

Module GMD R12.GMD.A.6 (UNP Product Development; Process Manufacturing Product Development)
The procedure for adding an ingredient in the formula

PROCEDURE insert_formuladetail(
    p_formula_id    NUMBER ,
    p_ingredient_id NUMBER ,
    p_new_qty       NUMBER ,
    p_uom           VARCHAR2 DEFAULT NULL,
    p_return_status OUT VARCHAR2 ,
    p_message OUT VARCHAR2 )
IS
  l_api_version       CONSTANT NUMBER := 1.0;
  l_init_msg_list     VARCHAR2 (1)    := FND_API.G_TRUE ;
  l_commit            VARCHAR2 (1)    := FND_API.G_FALSE;
  l_called_from_forms VARCHAR2 (10)   := ‘NO’;
  l_return_status     VARCHAR2 (1);
  l_msg_count         NUMBER ;
  l_msg_data          VARCHAR2 (400);
  L_FORMULA_DETAIL_TBL GMD_FORMULA_DETAIL_PUB.FORMULA_INSERT_DTL_TBL_TYPE;
  — l_formula_head fm_form_mst_b%rowtype;
  L_LINE_NO NUMBER ;
  — i pls_ integer := 1;
  no_proc_finish EXCEPTION ;
BEGIN
  IF (p_formula_id IS NULL) THEN
    p_message      := ‘P_formula_id parameter can not be empty ‘;
    raise no_proc_finish;
  END IF ;
  BEGIN
    SELECT *
    INTO l_formula_head
    FROM fm_form_mst_b fm
    WHERE fm.formula_id = p_formula_id;
  EXCEPTION
  WHEN OTHERS THEN
    p_message := ‘ Could not managed to find a formula ‘;
    raise no_proc_finish;
  END ;
  BEGIN
    SELECT MAX (fm.line_no)
    INTO l_line_no
    FROM fm_matl_dtl fm
    WHERE fm.FORMULA_ID = p_formula_id
    AND fm.line_type    = -1;
  EXCEPTION
  WHEN OTHERS THEN
    p_message := ‘ Could not find a string formula ‘;
    raise no_proc_finish;
  END ;
  gme_common_pvt.set_who;
  l_formula_detail_tbl(i).formula_id        := p_formula_id;
  l_formula_detail_tbl(i).formula_no        := l_formula_head.formula_no;
  l_formula_detail_tbl(i).formula_vers      := l_formula_head.formula_vers;
  l_formula_detail_tbl(i).line_type         :=           -1;
  l_formula_detail_tbl(i).line_no           := l_line_no + 1;
  l_formula_detail_tbl(i).inventory_item_id := p_ingredient_id;
  l_formula_detail_tbl(i).QTY               := p_new_qty;
  L_FORMULA_DETAIL_TBL(I).RELEASE_TYPE      := 1; — manually
  IF (p_uom                                 IS NOT NULL) THEN
    l_formula_detail_tbl(i).DETAIL_UOM      := p_uom;
  END IF ;
  gmd_formula_detail_pub.insert_formuladetail( p_api_version => l_api_version ,p_init_msg_list => l_init_msg_list ,p_commit => l_commit ,p_called_from_forms => l_called_from_forms ,x_return_status => l_return_status ,x_msg_count => l_msg_count ,x_msg_data => l_msg_data ,p_formula_detail_tbl => l_formula_detail_tbl );
  IF l_return_status <> FND_API.g_ret_sts_success THEN
    IF l_msg_count    = 1 THEN
      p_message      := FND_MSG_PUB.get(1,’F’);
      RAISE no_proc_finish;
    ELSE
      FOR l IN 1..l_msg_count
      LOOP
        FND_MSG_PUB.get (p_msg_index => l ,p_encoded => ‘ F ‘ ,p_data => p_message ,p_msg_index_out => l_msg_count);
      END LOOP ;
      RAISE no_proc_finish;
    END IF ;
  END IF ;
  p_return_status := ‘ S ‘;
EXCEPTION
WHEN no_proc_finish THEN
  p_return_status := ‘ E ‘;
WHEN OTHERS THEN
  p_message       := SQLERRM ;
  p_return_status := ‘ E ‘;
END ;

Formula Upload can be done using the following steps:

1. Create a staging table say “MJIL_FORMULA_UPLOAD” whose structure is given below.

CREATE TABLE MJIL_FORMULA_UPLOAD
(
   RECORD_TYPE               VARCHAR2 (1 BYTE),
   FORMULA_NO                VARCHAR2 (32 BYTE),
   FORMULA_VERS              NUMBER,
   FORMULA_TYPE              NUMBER,
   FORMULA_DESC1             VARCHAR2 (70 BYTE),
   FORMULA_DESC2             VARCHAR2 (70 BYTE),
   FORMULA_CLASS             VARCHAR2 (32 BYTE),
   FMCONTROL_CLASS           VARCHAR2 (32 BYTE),
   INACTIVE_IND              NUMBER,
   OWNER_ORGANIZATION_ID     NUMBER,
   TOTAL_INPUT_QTY           NUMBER,
   TOTAL_OUTPUT_QTY          NUMBER,
   YIELD_UOM                 VARCHAR2 (3 BYTE),
   FORMULA_STATUS            VARCHAR2 (30 BYTE),
   OWNER_ID                  NUMBER (15),
   FORMULA_ID                NUMBER,
   FORMULALINE_ID            NUMBER,
   LINE_TYPE                 NUMBER,
   LINE_NO                   NUMBER,
   ITEM_NO                   VARCHAR2 (2000 BYTE),
   INVENTORY_ITEM_ID         NUMBER,
   REVISION                  VARCHAR2 (3 BYTE),
   QTY                       NUMBER,
   DETAIL_UOM                VARCHAR2 (3 BYTE),
   MASTER_FORMULA_ID         NUMBER,
   RELEASE_TYPE              NUMBER,
   SCRAP_FACTOR              NUMBER,
   SCALE_TYPE_HDR            NUMBER,
   SCALE_TYPE_DTL            NUMBER,
   COST_ALLOC                NUMBER,
   PHANTOM_TYPE              NUMBER,
   REWORK_TYPE               NUMBER,
   BUFFER_IND                NUMBER,
   BY_PRODUCT_TYPE           VARCHAR2 (1 BYTE),
   INGREDIENT_END_DATE       DATE,
   ATTRIBUTE1                VARCHAR2 (240 BYTE),
   ATTRIBUTE2                VARCHAR2 (240 BYTE),
   ATTRIBUTE3                VARCHAR2 (240 BYTE),
   ATTRIBUTE4                VARCHAR2 (240 BYTE),
   ATTRIBUTE5                VARCHAR2 (240 BYTE),
   ATTRIBUTE6                VARCHAR2 (240 BYTE),
   ATTRIBUTE7                VARCHAR2 (240 BYTE),
   ATTRIBUTE8                VARCHAR2 (240 BYTE),
   ATTRIBUTE9                VARCHAR2 (240 BYTE),
   ATTRIBUTE10               VARCHAR2 (240 BYTE),
   ATTRIBUTE11               VARCHAR2 (240 BYTE),
   ATTRIBUTE12               VARCHAR2 (240 BYTE),
   ATTRIBUTE13               VARCHAR2 (240 BYTE),
   ATTRIBUTE14               VARCHAR2 (240 BYTE),
   ATTRIBUTE15               VARCHAR2 (240 BYTE),
   ATTRIBUTE16               VARCHAR2 (240 BYTE),
   ATTRIBUTE17               VARCHAR2 (240 BYTE),
   ATTRIBUTE18               VARCHAR2 (240 BYTE),
   ATTRIBUTE19               VARCHAR2 (240 BYTE),
   ATTRIBUTE20               VARCHAR2 (240 BYTE),
   ATTRIBUTE21               VARCHAR2 (240 BYTE),
   ATTRIBUTE22               VARCHAR2 (240 BYTE),
   ATTRIBUTE23               VARCHAR2 (240 BYTE),
   ATTRIBUTE24               VARCHAR2 (240 BYTE),
   ATTRIBUTE25               VARCHAR2 (240 BYTE),
   ATTRIBUTE26               VARCHAR2 (240 BYTE),
   ATTRIBUTE27               VARCHAR2 (240 BYTE),
   ATTRIBUTE28               VARCHAR2 (240 BYTE),
   ATTRIBUTE29               VARCHAR2 (240 BYTE),
   ATTRIBUTE30               VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE1            VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE2            VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE3            VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE4            VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE5            VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE6            VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE7            VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE8            VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE9            VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE10           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE11           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE12           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE13           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE14           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE15           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE16           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE17           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE18           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE19           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE20           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE21           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE22           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE23           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE24           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE25           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE26           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE27           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE28           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE29           VARCHAR2 (240 BYTE),
   DTL_ATTRIBUTE30           VARCHAR2 (240 BYTE),
   ATTRIBUTE_CATEGORY        VARCHAR2 (30 BYTE),
   DTL_ATTRIBUTE_CATEGORY    VARCHAR2 (30 BYTE),
   TPFORMULA_ID              NUMBER,
   IAFORMULA_ID              NUMBER,
   SCALE_MULTIPLE            NUMBER,
   CONTRIBUTE_YIELD_IND      VARCHAR2 (1 BYTE),
   SCALE_UOM                 VARCHAR2 (4 BYTE),
   CONTRIBUTE_STEP_QTY_IND   VARCHAR2 (1 BYTE),
   SCALE_ROUNDING_VARIANCE   NUMBER,
   ROUNDING_DIRECTION        NUMBER,
   TEXT_CODE_HDR             NUMBER,
   TEXT_CODE_DTL             NUMBER,
   USER_ID                   NUMBER,
   CREATION_DATE             DATE,
   CREATED_BY                NUMBER (15),
   LAST_UPDATED_BY           NUMBER (15),
   LAST_UPDATE_DATE          DATE,
   LAST_UPDATE_LOGIN         NUMBER (15),
   USER_NAME                 VARCHAR2 (100 BYTE),
   DELETE_MARK               NUMBER DEFAULT 0,
   AUTO_PRODUCT_CALC         VARCHAR2 (1 BYTE),
   PROD_PERCENT              NUMBER
);

2. Next create a procedure similar to the one given below.

CREATE OR REPLACE PROCEDURE APPS.CONA_FML_UPLOAD_PD (ERRBUF    OUT VARCHAR2,
                                                     RETCODE   OUT NUMBER)
IS
   /******************************************************************************
   NAME: CONA_FML_UPLOAD_PD
   PURPOSE: Formula Uploading
   REVISIONS:
   Ver Date Author Description
   ——— ———- ————— ————————————
   1.0 8/16/2013 1. Oracle User Created this procedure.
   NOTES:
   Automatically available Auto Replace Keywords:
   Object Name: CONA_FML_UPLOAD_PD
   ******************************************************************************/
   mjil_fml_tabtype          apps.gmd_formula_pub.formula_insert_hdr_tbl_type;

   CURSOR c1
   IS
      SELECT *
        FROM MJIL_FORMULA_UPLOAD
       WHERE formula_no NOT IN (SELECT formula_no FROM fm_form_mst);

   cnt                       NUMBER;
   l_return_status           VARCHAR2 (1);
   l_msg_count               NUMBER;
   l_msg_data                VARCHAR2 (1000);
   l_out_index               NUMBER := 0;
   l_user_id                 NUMBER := 1114;
   l_responsibility_id       NUMBER := 22883;
   l_responsibility_app_id   NUMBER;
BEGIN
   FND_GLOBAL.
    APPS_INITIALIZE (l_user_id, l_responsibility_id, l_responsibility_app_id);
   cnt := 0;

   FOR i IN c1
   LOOP
      cnt := cnt + 1;
      mjil_fml_tabtype (cnt).record_type := i.record_type;
      mjil_fml_tabtype (cnt).FORMULA_NO := TRIM (i.FORMULA_NO);
      mjil_fml_tabtype (cnt).FORMULA_VERS := i.formula_vers;
      mjil_fml_tabtype (cnt).formula_type := i.formula_type;
      mjil_fml_tabtype (cnt).formula_desc1 := i.formula_desc1;
      mjil_fml_tabtype (cnt).formula_desc2 := i.formula_desc2;
      mjil_fml_tabtype (cnt).inactive_ind := i.inactive_ind;
      mjil_fml_tabtype (cnt).OWNER_ORGANIZATION_ID := i.owner_organization_id;
      mjil_fml_tabtype (cnt).total_input_qty := i.total_input_qty;
      mjil_fml_tabtype (cnt).total_output_qty := i.total_output_qty;
      mjil_fml_tabtype (cnt).formula_status := i.formula_status;
      mjil_fml_tabtype (cnt).line_no := i.line_no;
      mjil_fml_tabtype (cnt).line_type := i.line_type;
      mjil_fml_tabtype (cnt).item_no := i.item_no;
      mjil_fml_tabtype (cnt).qty := i.qty;
      mjil_fml_tabtype (cnt).detail_uom := i.detail_uom;
      mjil_fml_tabtype (cnt).release_type := i.release_Type;
      mjil_fml_tabtype (cnt).scrap_factor := i.scrap_factor;
      mjil_fml_tabtype (cnt).scale_type_hdr := i.scale_type_hdr;
      mjil_fml_tabtype (cnt).scale_type_dtl := i.scale_type_dtl;
      mjil_fml_tabtype (cnt).cost_alloc := i.cost_alloc;
      mjil_fml_tabtype (cnt).phantom_type := i.phantom_type;
      mjil_fml_tabtype (cnt).rework_type := i.rework_type;
      mjil_fml_tabtype (cnt).buffer_ind := i.buffer_ind;
      mjil_fml_tabtype (cnt).contribute_yield_ind := i.contribute_yield_ind;
      mjil_fml_tabtype (cnt).contribute_step_qty_ind :=
         i.contribute_step_qty_ind;
      mjil_fml_tabtype (cnt).delete_mark := i.delete_mark;
   END LOOP;

   GMD_FORMULA_PUB.Insert_Formula (p_api_version          => 1,
                                   p_init_msg_list        => FND_API.G_TRUE,
                                   p_commit               => FND_API.G_TRUE,
                                   p_called_from_forms    => ‘NO’,
                                   x_return_status        => l_return_status,
                                   x_msg_count            => l_msg_count,
                                   x_msg_data             => l_msg_data,
                                   p_formula_header_tbl   => mjil_fml_tabtype);
   DBMS_OUTPUT.put_line (‘Return status – ‘ || l_return_status);
   DBMS_OUTPUT.put_line (‘Message count – ‘ || l_msg_count);

   FOR i IN 1 .. l_msg_count
   LOOP
      FND_MSG_PUB.get (p_msg_index       => i,
                       p_encoded         => ‘F’,
                       p_data            => l_msg_data,
                       P_MSG_INDEX_OUT   => l_out_index);
      DBMS_OUTPUT.PUT_LINE (‘Message Text ‘ || l_msg_data);
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line (‘Return status – ‘ || l_return_status);
      DBMS_OUTPUT.put_line (‘Message count – ‘ || l_msg_count);

      FOR i IN 1 .. l_msg_count
      LOOP
         FND_MSG_PUB.get (p_msg_index       => i,
                          p_encoded         => ‘F’,
                          p_data            => l_msg_data,
                          P_MSG_INDEX_OUT   => l_out_index);
         DBMS_OUTPUT.PUT_LINE (‘Message Text ‘ || l_msg_data);
      END LOOP;
END;

3. Register and run the procedure in Oracle Apps.