Wednesday, 7 May 2014

Multiple Error Messages in OAF

Requirement – How to raise multiple error messages as multiline on OAF pages. 

Solution –  1) Create and initialize new ArrayList object
       2) Define the error messages in array list
       3) Raise bundled eception method  

Example - 
    ArrayList  errMsg = new ArrayList();                 
 
    errMsg.add(new OAException("Who is Lucifer")); 
    errMsg.add(new OAException("Ra-One will kill Lucifer"));
    errMsg.add(new OAException("G-One is protector"));       
    
   OAException.raiseBundledOAException(errMsg);    

Output – 
1.       Who is Lucifer
2.       Ra-One will kill Lucifer
3.       G-One is protector
------------------------------------------------------------------------------------------------------
Exception -  If above method is being implemented inside a try/catch block, It might not throw expected error message.So either implement above outside Try/catch block or use below steps to handle this inside try/catch.       
             
1)      Create array list object at global level
      ArrayList  errMsg = new ArrayList();     
            
2)      Define the messages inside the try block and raise exception with custom message
 try {
    errMsg.add(new OAException("Who is Lucifer")); 
    errMsg.add(new OAException("Ra-One will kill Lucifer"));
    errMsg.add(new OAException("G-One is protector"));      
    throw new OAException("Sandeep");   
     }           

3)      Handle this implementation inside the catch block
catch(Exception e) 
  {
  String a="oracle.apps.fnd.framework.OAException: Sandeep";
  if (a.equals(e.toString()))
  {   OAException.raiseBundledOAException(errMsg);    }
  else
  {   throw new OAException("Exception Has been found in code :" +e, OAException.INFORMATION); 
 }

Tuesday, 29 April 2014

Determine the current version of Oracle XML Publisher on an Oracle E-Business Suite environment.

Based upon an output file generated by XML Publisher
  • PDF Output
    1. Open the PDF document in Adobe Reader
    2. Open the menu File
    3. Select Document Properties
    4. Click on the tab Description
          ==> The property named PDF Producer will show e.g. Oracle XML Publisher 5.6.3.
  • RTF Output
    1. Open the RTF document in Microsoft Word
    2. Open the menu File
    3. Select Properties
    4. Click on the tab Summary
         ==> The property named Comments will show .e.g. Generated by Oracle XML Publisher 5.6.3
  • HTML and Excel output
    1. Open the document in Notepad (or any other plain text editor)
          ==> line 4 or 5 will show e.g. Generated by Oracle XML Publisher 5.6.1
With R12 – version is : 5.6.3



 How to obtain the OPP debug log files

Responsibility : System Administrator
Concurrent Manager Administration
Select the Output Post Processor
Click on the Processes button
Select the process that was active during the time  frame that your request ran. Select Manager Log

How to Debug – XML Publisher Report – Log

The Concurrent Request ends with Phase ‘Completed’ and Status ‘Warning’ which indicates that the Output Post Processor (OPP) failed to generate an output file. In such cases the request log file shows a generic error message indicating the the post-processing action has failed:

    +————- 1) PUBLISH ————-+
    Beginning post-processing of request 3181529 on node PBREUGEL at 11-APR-2008 11:41:30.
    Post-processing of request 3181529 failed at 11-APR-2008 11:41:31 with the error message:
    One or more post-processing actions failed. Consult the OPP service log for details.
    +————————————–+

The actual error returned by the XML Publisher Core engine is captured in the OPP log file. There are three possible ways to obtain the OPP log file:

    Directly from the file system based after identifying the corresponding OPP log file name using the following SQL statement:

    SELECT fcpp.concurrent_request_id req_id, fcp.node_name, fcp.logfile_name
      FROM fnd_conc_pp_actions fcpp, fnd_concurrent_processes fcp
    WHERE fcpp.processor_id = fcp.concurrent_process_id
       AND fcpp.action_type = 6
       AND fcpp.concurrent_request_id = &&request_id

    Via the Forms application:

    Login to the application as SYSADMIN
    Responsibility: System Administrator
    Function: Concurrent –> Manager –> Administration
    Select the Output Post Processor
    Click on the Processes button
    Select the Concurrent Process which was active during the time that the request ran
    Click on the Manager Log button to open the Output Post Processor log file

    Via the Oracle Application Manager (OAM)

    Login to the application as SYSADMIN
    Responsibility: System Administration
    Function: Oracle Applications Manager –> Concurrent Managers
    Select the Output Post Processor Service and click on View Details
    Click on View Processes
    Select the Concurrent Process which was active during the time that the request ran
    Click on the Log button to open the Output Post Processor log file

Delivery channels – How does the Oracle XML Publisher Core engine gets invoked?

Two step publishing method

        Submit a concurrent program of which the Output Format is set to XML
        Submit the XML Report Publisher concurrent request to produce the final output. At submission time, specify the request ID from step 1, choose the desired template and the Output Format (PDF, RTF,…).

   One step publishing method

        Submit a Concurrent Program with the Output Format is set to XML. At submission time select the desired template and the Output Format (PDF, RTF,…). In the background the Output Post Processor (OPP) automatically applies the layout template to the generated XML data file and creates the output file. This method is the most common usage of XML Publisher.

   All other situations

        These delivery channels do not use the concurrent managers but they are web or forms based, where the XML Publisher Core API’s are called directly in JAVA code. No concurrent request is involved and only the XML Publisher Core engine is used. Examples of such situations are the following:
            Pick Slip
            Dunning Letters
            Blanket Agreement (Preview and Print)

How to Modify Existing Seeded Templates Using XML Publisher

Seeded templates cannot be updated or deleted. The Update and Delete icons for these templates are disabled. If you wish to modify a seeded template, duplicate it, then modify the template file of the duplicated entry. You can then End Date the seeded template if you do not wish it to be available to your users.

Copying a Template:
Use the Search region to find the template you wish to copy. From the search results table, select the Duplicate icon for the template to launch the Copy Template page.
Code – Assign a template Code using the product short name and a descriptive ending. (The Code assigned must have the same prefix in the name as the seeded templates’ code.)
Name – Enter a user-friendly name for your template.
Application – Select the report’s application from the LOV.
Source Template Name – (Not updateable) Displays the name of the template you are duplicating.

Use the following steps:

You must remove any incorrect duplicates of the template/report that you are trying to copy by end dating them on the same day they where created.
1. Go to XML Publisher Responsibility > Templates.
2. Use the search engine to find the template you wish to copy.
3. Click on the link for the copy previously created.
4. Click the Update button and enter an end date into the End Date field. (Use the creation date to completely remove the incorrect copy.)
5. Repeat this for every incorrect copy that may exist.
If you have previously end dated the seeded template, remove the end date.
1. Go to XML Publisher Responsibility > Templates.
2. Use the search engine to find the template and change the Active field to "No".
3. Click on the link for the seeded report.
4. Click the Update button and remove the end date.

After making your modifications by downloading a copy of the seeded template or creating a new file, create a duplicate of the seeded template.

1. Use the search engine to find the template you wish to copy.  The seeded report should now display.
2. Click the "Duplicate" icon next to the seeded report.
3. Change the required Code field from Copy of XXXX to XXXX2. For example, if your seeded templates’ code was ‘BENSSCNF’, then for the duplicate template, one of the possible codes could be ‘BENSSCNF2′ (basically any code prefixed with ‘BENSSCNF’). Also, note that these codes are non-updateable, so make sure to rename them while duplicating the template itself.
4. Change the required Name field and click the Apply button.
5. Click the Add File button and upload the new or customized replacement file.
6. Click the Update button and change the Default file, if necessary.
7. Alter the copy start date, if necessary. This date will coincide with the date used to end date the seeded template.
8. Go back to Templates and find the seeded report you have duplicated.
9. Click the link for the seeded template and click the Update button.
10. End date the seeded template.
11. Generate the report in the application. The generated report should reflect your duplicate.

Monday, 24 March 2014

API - Inventory Item Creation

DECLARE
   X_INVENTORY_ITEM_ID   NUMBER;
   X_ORGANIZATION_ID     NUMBER;
   X_RETURN_STATUS       VARCHAR2 (4000);
   X_MSG_DATA            VARCHAR2 (4000);
   X_MSG_COUNT           NUMBER;
   LX_MSG_INDEX_OUT      NUMBER;
BEGIN
   FND_GLOBAL.
   APPS_INITIALIZE (USER_ID => 1832, RESP_ID => NULL, RESP_APPL_ID => NULL);

   ego_item_pub.
   process_item (p_api_version                  => 1.0,
                 p_init_msg_list                => 'T',
                 p_commit                       => 'T',
                 p_Transaction_Type             => 'CREATE' -- UPDATE FOR Updating item
                                                           ,
                 p_segment1                     => 'XYZABC'      --  ITEM CODE
                                                           ,
                 p_description                  => 'CREATED BY API' --  ITEM DESCRIPTION
                                                                   ,
                 p_long_description             => 'CREATED FOR LONG' --  ITEM LONG DESCRIPTION
                                                                     ,
                 p_organization_id              => 755 --  WAREHOUSE ORGANIZATION ID
                                                      --, P_TEMPLATE_ID                => 2
                 ,
                 p_Inventory_Item_Status_Code   => 'Active',
                 p_approval_status              => 'A',
                 x_inventory_item_id            => x_inventory_item_id,
                 x_organization_id              => x_organization_id,
                 x_return_status                => x_return_status,
                 x_msg_count                    => x_msg_count,
                 x_msg_data                     => x_msg_data);

   DBMS_OUTPUT.put_line (x_msg_data);

   FOR j IN 1 .. x_msg_count
   LOOP
      FND_MSG_PUB.Get (p_msg_index       => j,
                       p_encoded         => 'F',
                       p_data            => x_msg_data,
                       p_msg_index_out   => lx_msg_index_out);
      DBMS_OUTPUT.put_line (x_msg_data);
   END LOOP;

   IF x_return_status = 'S'
   THEN
      DBMS_OUTPUT.put_line ('ITEM CREATION SUCCESSFUL');
   END IF;
END;

---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

 OR

 --------------------------------------------------------------------------------------------
API EGO_ITEM_PUB.Process_Items can be used to create or Update Items.
---------------------------------------------------------------------------------------------

In this we will see how to create a new Item 'NEWITEM' using an API.

Below code can be used to create it.

/* Formatted on 3/24/2014 10:23:27 PM (QP5 v5.139.911.3011) */
SET SERVEROUTPUT ON

DECLARE
   l_item_table      EGO_Item_PUB.Item_Tbl_Type;
   x_item_table      EGO_Item_PUB.Item_Tbl_Type;
   x_return_status   VARCHAR2 (1);
   x_msg_count       NUMBER (10);
   x_msg_data        VARCHAR2 (1000);
   x_message_list    Error_Handler.Error_Tbl_Type;
BEGIN
   --Apps Initialization

   FND_GLOBAL.
   APPS_INITIALIZE (USER_ID        => &userid,
                    RESP_ID        => &RESP_ID,
                    RESP_APPL_ID   => &RESP_APPL_ID);

   --FIRST Item definition
   l_item_table (1).Transaction_Type := 'CREATE'; -- Replace this with 'UPDATE' for update transaction.
   l_item_table (1).Segment1 := 'NEWITEM';
   l_item_table (1).Description := 'NEWITEM';
   l_item_table (1).Organization_Code := '&masterorg';
   l_item_table (1).Template_Name := '&template';

   DBMS_OUTPUT.PUT_LINE ('Calling API to Create Item');

   EGO_ITEM_PUB.Process_Items (p_api_version     => 1.0,
                               p_init_msg_list   => FND_API.g_TRUE,
                               p_commit          => FND_API.g_TRUE,
                               p_Item_Tbl        => l_item_table,
                               x_Item_Tbl        => x_item_table,
                               x_return_status   => x_return_status,
                               x_msg_count       => x_msg_count);


   DBMS_OUTPUT.PUT_LINE ('Return Status ==>' || x_return_status);

   IF (x_return_status = FND_API.G_RET_STS_SUCCESS)
   THEN
      FOR i IN 1 .. x_item_table.COUNT
      LOOP
         DBMS_OUTPUT.
         PUT_LINE (
            'Inventory Item Id Created:'
            || TO_CHAR (x_item_table (i).Inventory_Item_Id));
         DBMS_OUTPUT.
         PUT_LINE (
            'Organization Id :' || TO_CHAR (x_item_table (i).Organization_Id));
      END LOOP;
   ELSE
      DBMS_OUTPUT.PUT_LINE ('Error Messages :');
      Error_Handler.GET_MESSAGE_LIST (x_message_list => x_message_list);

      FOR i IN 1 .. x_message_list.COUNT
      LOOP
         DBMS_OUTPUT.PUT_LINE (x_message_list (i).MESSAGE_TEXT);
      END LOOP;
   END IF;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.
      PUT_LINE (
         'Error has Occured and error is ' || SUBSTR (SQLERRM, 1, 200));
END;

Debugging Errors
---------------------------

Suppose if any error has occured during the process, we can check the details of the error using Mtl_system_items_interface and Mtl_interace_errors table.

If any error occured, then Process_flag value of the record in the Mtl_system_items_interface will be 3. Also for this record transaction_id will be populated.

Using the transaction_id we can check the error in Mtl_interface_error table and get the exact error_mesage on which the record is failing.

Use the below script to debug error in case item 'NEWITEM' is not created.


SELECT msii.segment1,
       msii.description,
       msii.process_flag,
       msii.transaction_id,
       mie.error_message
  FROM mtl_system_items_interface msii, mtl_interface_errors mie
 WHERE     msii.transaction_id = mie.transaction_id
       AND msii.process_flag = 3
       AND msii.segment1 = 'NEWITEM';

Monday, 10 February 2014

OPM Production Batch GME and INV tables relate together for a given batch


Oracle Process Manufacturing Process Execution 


OPM Production Batch GME and INV tables relate together for a given batch

The following SQL*Plus queries show how the GME and INV tables relate together for a given batch.

In each statement, please replace the value '12345' with the required Batch Number, and 'PR1' with the relevant Plant Code or Organization.

1) Batch


select gbh.* from gme_batch_header gbh
where gbh.batch_no = '12345'
and gbh.organization_id =
  (select organization_id from org_organization_definitions ood
    where ood.organization_code = 'PR1');   

2) Batch Material Details 



select ood.organization_code, gbh.batch_no, gbh.batch_id, gmd.*
from gme_material_details gmd, gme_batch_header gbh,
 org_organization_definitions ood
where gmd.batch_id = gbh.batch_id
and gbh.batch_no = '12345'
and gbh.organization_id = ood.organization_id
and ood.organization_code = 'PR1'
order by gbh.batch_id, gmd.material_detail_i;


3) Batch Material Transactions Temp



select ood.organization_code, gbh.batch_no, gbh.batch_id, gmd.line_no,
  gmd.material_detail_id, gmd.line_type, mmtt.*
from mtl_material_transactions_temp mmtt, gme_material_details gmd,
   gme_batch_header gbh, org_organization_definitions ood
where mmtt.transaction_source_type_id = 5
and mmtt.trx_source_line_id = gmd.material_detail_id
and mmtt.transaction_source_id = gbh.batch_id
and gmd.batch_id = gbh.batch_id
and gbh.batch_no = '12345'
and gbh.organization_id = ood.organization_id
and ood.organization_code = 'PR1'
order by gbh.batch_id, gmd.line_type, gmd.material_detail_id,
  mmtt.transaction_temp_id;


4) Batch Material Transactions 



select ood.organization_code, gbh.batch_no, gbh.batch_id, gmd.line_no,
gmd.material_detail_id, gmd.line_type, mmt.*
from mtl_material_transactions mmt, gme_material_details gmd, gme_batch_header gbh, org_organization_definitions ood
where mmt.transaction_source_type_id = 5
and mmt.trx_source_line_id = gmd.material_detail_id
and mmt.transaction_source_id = gbh.batch_id
and gmd.batch_id = gbh.batch_id
and gbh.batch_no = '12345'
and gbh.organization_id = ood.organization_id
and ood.organization_code = 'PR1'
order by gbh.batch_id, gmd.line_type, gmd.material_detail_id, mmt.transaction_id;


5) Lot Numbers 



select ood.organization_code, gbh.batch_no, gbh.batch_id, gmd.line_no,
gmd.material_detail_id, gmd.line_type, mtln.*
from mtl_transaction_lot_numbers mtln, mtl_material_transactions mmt,
  gme_material_details gmd, gme_batch_header gbh,
  org_organization_definitions ood
where mtln.transaction_id= mmt.transaction_id
and mmt.transaction_source_type_id = 5
and mmt.trx_source_line_id = gmd.material_detail_id
and gmd.batch_id = gbh.batch_id
and gbh.batch_no = '12345'
and gbh.organization_id = ood.organization_id
and ood.organization_code = 'PR1'
order by gbh.batch_id, gmd.line_type, gmd.material_detail_id, gmd.line_type,
  mmt.transaction_id;


6) Reservations 



select ood.organization_code, gbh.batch_no, gbh.batch_id, gmd.line_no,
  gmd.material_detail_id, gmd.line_type, mr.*
from mtl_reservations mr, gme_material_details gmd, gme_batch_header gbh,
 org_organization_definitions ood
where mr.demand_source_type_id = 5
and mr.demand_source_line_id = gmd.material_detail_id
and gmd.batch_id = gbh.batch_id
and gbh.batch_no = '12345'
and gbh.organization_id = ood.organization_id
and ood.organization_code = 'PR1'
order by gbh.batch_id, gmd.line_type, gmd.material_detail_id, gmd.line_type;


7) Pending Product Lots 


select ood.organization_code, gbh.batch_no, gbh.batch_id, gmd.line_no,
  gmd.material_detail_id, gmd.line_type, gppl.*
from gme_pending_product_lots gppl, gme_material_details gmd, gme_batch_header gbh, org_organization_definitions ood
where gppl.material_detail_id = gmd.material_detail_id
and gmd.batch_id = gbh.batch_id
and gbh.batch_no = '12345'
and gbh.organization_id = ood.organization_id
and ood.organization_code = 'PR1'
order by gbh.batch_id, gmd.line_type, gmd.material_detail_id, gmd.line_type;


8) Requirements 


select ood.organization_code, gbh.batch_no, gbh.batch_id, gbr.*
from gmf_batch_requirements gbr, gme_batch_header gbh,
  org_organization_definitions ood
where gbr.batch_id = gbh.batch_id
and gbh.batch_no = '12345'
and gbh.organization_id = ood.organization_id
and ood.organization_code = 'PR1'
order by gbr.requirement_id;
 
 
 
Ref: http://ebsmodule.blogspot.in/2013/05/opm-production-batch-gme-and-inv-tables.html