Thursday, February 27, 2020

Default subinventory is not defined in the destination organization(Subinventory Transfer)

ERROR

Default subinventory is not defined in the destination organization

Solution

mtl_transactions_interface  -        Add  to_subinventory    column

Negative balances not allowed(Subinventory Material Transactions)

ERROR

Negative balances not allowed


Solution

Increase the on hand stock

Navigation

India Local Inventory - query the item -  check item quantity available to move

Tuesday, February 25, 2020

BOM Extract Query(Bill Of materials)

/* Formatted on 2020/02/25 16:49 (Formatter Plus v4.8.8) */
SELECT ood.organization_code, ood.organization_name, msi.segment1 bom_code,
       msi.description bom_desc, bic.item_num, bic.operation_seq_num,
       msi1.segment1 component_code, msi1.description component_desc,
       ml.meaning supply_type, bic.component_quantity, bic.effectivity_date,
       bic.disable_date, msi1.inventory_item_status_code,
       bic.supply_subinventory, bic.wip_supply_type
  FROM mtl_system_items_b msi,
       org_organization_definitions ood,
       bom_bill_of_materials bom,
       bom_inventory_components bic,
       mtl_system_items_b msi1,
       mfg_lookups ml
 WHERE bom.assembly_item_id = msi.inventory_item_id
   AND bom.bill_sequence_id = bic.bill_sequence_id
   AND msi.organization_id = ood.organization_id
   AND bom.organization_id = ood.organization_id
   -- AND msi1.inventory_item_status_code = 'Active'
   AND bic.component_item_id = msi1.inventory_item_id
   AND msi1.organization_id = ood.organization_id
   AND ml.lookup_code(+) = bic.wip_supply_type
   AND ml.lookup_type(+) = 'WIP_SUPPLY'

Saturday, February 22, 2020

Customer Address update(Postal Code)

CREATE TABLE xx_CUST_LOC_PIN_UPDATE_STG
(
  OPERATING_UNIT   VARCHAR2(500 BYTE),
  CUSTOMER_NAME    VARCHAR2(50 BYTE),
  CUSTOMER_NUMBER  VARCHAR2(30 BYTE),
  CUSTOMER_GROUP   VARCHAR2(500 BYTE),
  CUSTOMER_SITE    VARCHAR2(500 BYTE),
  PIN_CODE         VARCHAR2(60 BYTE),
  STATUS_FLAG      VARCHAR2(10 BYTE),
  STATUS_MESSAGE   VARCHAR2(2000 BYTE),
  PROCESS_FLAG     VARCHAR2(10 BYTE)
)

       CREATE OR REPLACE PROCEDURE APPS.xx_cust_loc_pin_update_prc
IS
---DECLARE
   p_location_rec            hz_location_v2pub.location_rec_type;
   p_object_version_number   NUMBER                              := 1;
   x_return_status           VARCHAR2 (2000);
   x_msg_count               NUMBER;
   x_msg_data                VARCHAR2 (2000);
   l_error_message           VARCHAR2 (2000);
   l_location_id             NUMBER;
   l_status_flag             VARCHAR2 (10);
   l_object_version_number   NUMBER                              := 1;

   CURSOR c1
   IS
      SELECT stg.ROWID, stg.*
        FROM xx_cust_loc_pin_update_stg stg ;-- where CUSTOMER_GROUP='ATITH FIBER PVT. LTD.';
BEGIN
   fnd_global.apps_initialize (user_id           => 1130,
                               resp_id           => 50855,
                               resp_appl_id      => 222
                              );
   DBMS_OUTPUT.ENABLE (buffer_size => NULL);
-- Initializing the Mandatory API parameters
   FOR i IN c1
   LOOP
      IF c1%NOTFOUND
      THEN
         COMMIT;
         CONTINUE;
      END IF;

      l_error_message := NULL;
      l_status_flag := NULL;
      DBMS_OUTPUT.put_line ('Looop started..');

      BEGIN
         SELECT DISTINCT hps.location_id
                    INTO l_location_id
                    FROM apps.hz_parties hp,
                         apps.hz_cust_accounts hca,
                         apps.hz_party_sites hps,
                         apps.hz_locations hl,
                         apps.hz_cust_acct_sites_all hcasa1,
                         hr_operating_units ood,
                         hz_cust_site_uses_all hsu
                   WHERE 1 = 1
                     AND hp.party_id = hca.party_id
                     AND hp.party_id = hps.party_id
                     AND nvl(party_site_name,hp.province)=i.customer_site                                                           
                     AND hps.location_id = hl.location_id
                     AND hcasa1.party_site_id = hps.party_site_id
                     AND ood.NAME = i.operating_unit
                     AND ood.organization_id = hcasa1.org_id
                     AND account_number = i.customer_number
                     AND hsu.cust_acct_site_id = hcasa1.cust_acct_site_id;

         DBMS_OUTPUT.put_line ('location ' || l_location_id);
      EXCEPTION
         WHEN NO_DATA_FOUND
         THEN
            l_status_flag := 'E';

            UPDATE xx_cust_loc_pin_update_stg
               SET status_flag = 'E',
                   status_message = 'Customer Site not found',
                   process_flag = 'I'
             WHERE ROWID = i.ROWID;

            DBMS_OUTPUT.put_line ('Customer Site not found '
                                  || i.customer_site
                                 );
            COMMIT;
            CONTINUE;
         WHEN TOO_MANY_ROWS
         THEN
            l_status_flag := 'E';

            UPDATE xx_cust_loc_pin_update_stg
               SET status_flag = 'E',
                   status_message = 'Customer Site not found-too many rows',
                   process_flag = 'I'
             WHERE ROWID = i.ROWID;

            DBMS_OUTPUT.put_line (   'Customer Site not found too many'
                                  || i.customer_site
                                 );
            COMMIT;
            CONTINUE;
      END;

      IF l_location_id IS NOT NULL
      THEN
         SELECT object_version_number
           INTO l_object_version_number
           FROM hz_locations
          WHERE location_id = l_location_id;
      END IF;

      DBMS_OUTPUT.put_line ('before process ' || l_location_id);
      DBMS_OUTPUT.put_line ('l_status_flag ' || l_status_flag);

      IF l_status_flag IS NULL
      THEN
         DBMS_OUTPUT.put_line ('Validated ' || l_location_id);
         p_location_rec.location_id := l_location_id;   
         p_location_rec.postal_code := i.pin_code;
         p_object_version_number := l_object_version_number;
         DBMS_OUTPUT.put_line
                         ('Calling the API hz_location_v2pub.update_location');
         hz_location_v2pub.update_location
                         (p_init_msg_list              => fnd_api.g_true,
                          p_location_rec               => p_location_rec,
                          p_object_version_number      => p_object_version_number,
                          x_return_status              => x_return_status,
                          x_msg_count                  => x_msg_count,
                          x_msg_data                   => x_msg_data
                         );
         COMMIT;
         DBMS_OUTPUT.put_line ('x_return_status' || x_return_status);

         IF x_return_status = fnd_api.g_ret_sts_success
         THEN
            -- COMMIT;
            DBMS_OUTPUT.put_line ('Creation of Location is Successful ');
            DBMS_OUTPUT.put_line ('Output information ....');
            DBMS_OUTPUT.put_line ('New Address1: ' || p_location_rec.address1);
            DBMS_OUTPUT.put_line (   'p_object_version_number = '
                                  || p_object_version_number
                                 );

            UPDATE xx_cust_loc_pin_update_stg
               SET status_flag = 'S',
                   status_message = 'Sucess',
                   process_flag = 'C'
             WHERE ROWID = i.ROWID;

            COMMIT;
            CONTINUE;
            DBMS_OUTPUT.put_line ('sucess  ' || x_return_status);
         ELSE
            DBMS_OUTPUT.put_line ('Creation of Location failed:' || x_msg_data
                                 );
            ROLLBACK;

            FOR i IN 1 .. x_msg_count
            LOOP
               x_msg_data :=
                          oe_msg_pub.get (p_msg_index      => i,
                                          p_encoded        => 'F');
               DBMS_OUTPUT.put_line (i || ') ' || x_msg_data);
            END LOOP;

            l_error_message := SQLCODE || SQLERRM || x_msg_data;
            DBMS_OUTPUT.put_line ('error-2 ' || l_error_message);

            UPDATE xx_cust_loc_pin_update_stg
               SET status_flag = 'E',
                   status_message = l_error_message,
                   process_flag = 'I';

            DBMS_OUTPUT.put_line ('error-2 ' || l_error_message);
            COMMIT;
            CONTINUE;
         END IF;

         DBMS_OUTPUT.put_line ('Completion of API');
      END IF;
   END LOOP;
END;
/

Tuesday, February 18, 2020

0ORA-0000: normal, successful completion -API error

Error : 

error-2 0ORA-0000: normal, successful completion

Scnario:

when updating customer sites using  hz_location_v2pub.update_location

Solution

 SELECT object_version_number
           INTO l_object_version_number
           FROM hz_locations
          WHERE location_id = l_location_id;

Monday, February 17, 2020

PLSQL Error

Error:

ORA-20000: ORU-10027: buffer overflow, limit of 20000 bytes
ORA-06512: at "SYS.DBMS_OUTPUT", line 32
ORA-06512: at "SYS.DBMS_OUTPUT", line 97
ORA-06512: at "SYS.DBMS_OUTPUT", line 112

Solution

 DBMS_OUTPUT.ENABLE(1000000);

Starting with Oracle release 10g, it is possible to use the following unlimited buffer settings:


DBMS_OUTPUT.ENABLE (buffer_size => NULL);

Sunday, January 26, 2020

how to remove table lock


 
STEP 1:  get  the SID for the table which have lock.
select
   session_id
from
   dba_dml_locks
where
   name = 'table';


output


SID
----
450


STEP 2:  find the Serial# for the table row lock :


select
   sid,
   serial#
from
   v$session
where
   sid in (
   select
      session_id
   from
      dba_dml_locks
   where
      name = 'table');


Output :
SID SERIAL#
---- -------
 450 18341


STEP 3:  Finally "alter system" command to kill the session that is holding the table lock:


alter system kill session 'SID,SERIALl#';
  alter system kill session '450,18341'

Saturday, January 18, 2020

item on hand qty query

/* Formatted on 2020/01/18 15:54 (Formatter Plus v4.8.8) */
SELECT   subinventory_code, item.segment1 item_code,
         item.description item_description, SUM (on_hand.on_hand) on_hand
    FROM apps.mtl_system_items_b item, apps.mtl_onhand_total_mwb_v on_hand
   WHERE item.organization_id = 130                                   --ORG ID
     AND item.inventory_item_id = on_hand.inventory_item_id
     --AND on_hand.subinventory_code = 'zzz'  --sub inventory
     AND item.segment1 IN
                         ('TCPGPGBG00025032', 'TCPGPGBG00500046') ---item name
GROUP BY item.segment1, item.description, subinventory_code;

sale order back to back query


SELECT   hou.NAME ORGANIZATION, hp_ship.party_name customer,
         oh.cust_po_number customer_number, hca.account_number,
         oh.order_number so_no, ot.NAME order_type, oh.ordered_date so_date,
         oh.flow_status_code status, msib.segment1 item, msib.description,
         ordered_quantity, ship_to.LOCATION ship_to_location,
         ship_loc.address1 ship_to_address1,
         ship_loc.address2 ship_to_address2,
         ship_loc.address3 ship_to_address3,
         ship_loc.address4 ship_to_address4,
            DECODE (ship_loc.city,
                    NULL, NULL,
                    ship_loc.city || ', '
                   )
         || DECODE (ship_loc.state,
                    NULL, ship_loc.province || ', ',
                    ship_loc.state || ', '
                   )
         || DECODE (ship_loc.postal_code,
                    NULL, NULL,
                    ship_loc.postal_code || ', '
                   )
         || DECODE (ship_loc.country, NULL, NULL, ship_loc.country)
                                                             ship_to_address5,
         ship_to.LOCATION bill_to_location,
         bill_loc.address1 bill_to_address1,
         bill_loc.address2 bill_to_address2,
         bill_loc.address3 bill_to_address3,
         bill_loc.address4 bill_to_address4,
            DECODE (bill_loc.city,
                    NULL, NULL,
                    bill_loc.city || ', '
                   )
         || DECODE (bill_loc.state,
                    NULL, bill_loc.province || ', ',
                    bill_loc.state || ', '
                   )
         || DECODE (bill_loc.postal_code,
                    NULL, NULL,
                    bill_loc.postal_code || ', '
                   )
         || DECODE (bill_loc.country, NULL, NULL, bill_loc.country)
                                                             bill_to_address5,
         bill_to.LOCATION bill_to_location,
         ship_loc.address1 bill_to_address1,
         ship_loc.address2 bill_to_address2,
         ship_loc.address3 bill_to_address3,
         ship_loc.address4 bill_to_address4,
            DECODE (ship_loc.city,
                    NULL, NULL,
                    ship_loc.city || ', '
                   )
         || DECODE (ship_loc.state,
                    NULL, ship_loc.province || ', ',
                    ship_loc.state || ', '
                   )
         || DECODE (ship_loc.postal_code,
                    NULL, NULL,
                    ship_loc.postal_code || ', '
                   )
         || DECODE (ship_loc.country, NULL, NULL, ship_loc.country)
                                                             bill_to_address5,
         bill_to.LOCATION bill_to_location,
         bill_loc.address1 bill_to_address1,
         bill_loc.address2 bill_to_address2,
         bill_loc.address3 bill_to_address3,
         bill_loc.address4 bill_to_address4,
            DECODE (bill_loc.city,
                    NULL, NULL,
                    bill_loc.city || ', '
                   )
         || DECODE (bill_loc.state,
                    NULL, bill_loc.province || ', ',
                    bill_loc.state || ', '
                   )
         || DECODE (bill_loc.postal_code,
                    NULL, NULL,
                    bill_loc.postal_code || ', '
                   )
         || DECODE (bill_loc.country, NULL, NULL, bill_loc.country)
                                                             bill_to_address5
    FROM apps.oe_order_headers_all oh,
         apps.oe_order_lines_all ol,
         apps.hr_operating_units hou,
         apps.oe_transaction_types_tl ot,
         apps.mtl_system_items_b msib,
         apps.hz_cust_accounts_all hca,                                      --
         apps.hz_parties hp_ship,
         apps.hz_cust_site_uses_all ship_to,
         apps.hz_cust_acct_sites_all ship_cu,
         apps.hz_party_sites ship_ps,
         apps.hz_locations ship_loc,
         apps.hz_parties hp_bill,
         apps.hz_cust_site_uses_all bill_to,
         apps.hz_cust_acct_sites_all bill_cu,
         apps.hz_party_sites bill_ps,
         apps.hz_locations bill_loc
   WHERE 1 = 1
     AND source_type_code = 'EXTERNAL'
     AND oh.header_id = ol.header_id
     AND hou.organization_id = oh.org_id
     AND oh.sold_to_org_id = hca.cust_account_id
     AND hca.party_id = hp_ship.party_id
     AND ship_to.site_use_id = oh.ship_to_org_id
     AND ship_to.site_use_code = 'SHIP_TO'
     AND ship_to.cust_acct_site_id = ship_cu.cust_acct_site_id
     AND ship_ps.party_site_id = ship_cu.party_site_id
     AND ship_loc.location_id = ship_ps.location_id
     AND ot.transaction_type_id = oh.order_type_id
     AND ol.ordered_item = msib.segment1
     AND oh.ship_from_org_id = msib.organization_id
     -------
     AND hca.party_id = hp_bill.party_id
     AND bill_to.site_use_id = oh.invoice_to_org_id
     AND bill_to.site_use_code = 'BILL_TO'
     AND bill_to.cust_acct_site_id = bill_cu.cust_acct_site_id
     AND bill_ps.party_site_id = bill_cu.party_site_id
     AND bill_loc.location_id = bill_ps.location_id
ORDER BY oh.ordered_date DESC

finding location of rdf in server



SELECT APPLICATION_NAME,'$'||BASEPATH||'/'||'reports/US' Reports_Path,EXECUTION_FILE_NAME FROM APPS.FND_EXECUTABLES_VL A, APPS.FND_APPLICATION_VL B WHERE EXECUTION_METHOD_CODE='P' AND A.APPLICATION_ID=B.APPLICATION_ID AND EXECUTION_FILE_NAME like '%&RDF_NAME%'

Friday, January 17, 2020

Query to list all Form Personalizations oracle apps


 SELECT ffv.form_id                 ,
  ffv.form_name                     ,
  ffv.user_form_name                ,
  ffv.description "Form Description",
  ffcr.sequence                     ,
  ffcr.description "Personalization Rule Name"
   FROM fnd_form_vl ffv,
  fnd_form_custom_rules ffcr
  WHERE ffv.form_name = ffcr.form_name
ORDER BY ffv.form_name,
  ffcr.sequence;
 
 
 SELECT * FROM fnd_form_custom_rules;

Thursday, January 16, 2020

Oracle E-Business Form Not Launching(EBS Form Not Opening)


Oracle E-Business Form Not Launching(EBS Form Not Opening)

Download the latest Java JRE File

Download Link :




If You Get the following problems when opening the form
Oracle Forms – The application’s digital signature has an error – Your forms application is Frozen

https://oracleformsinfo.files.wordpress.com/2012/02/warning.jpg?w=300

Solution:
Go into the control panel and right-click on the java icon.

Go to ‘Advanced’  tab then open the ‘JAVA plugin’ branch on the tree
UNCHECK   ‘Enable the next-generation Java Plug-in(requires browser restart)’
Click Apply
Then click OK.
Then make sure ALL browser windows have been closed. You should also check in the control panel that no extra iexplore.exe processes are open and kill the program or “ORACLE FUSION FORMS … ”  if it exists. Then when you run the forms again your browser will reload this page and popup the warning message again, this time you should be able to select the checkbox and accept the security warning. Once accepted the warning should

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgL26qsU6o37HcW6L-XTSONwJHfhylzSzTNhb0Rf3jH6KhjXcYmPYbZ4ocJfy3QxfolVKE9zCv1Xdg1rQsz83ROgOWgNtWpDMeiPYsssERNc3NMYU0Jnt15c0TXTFUR8dJlEmSCESGcROWm/s320/veri.jpg


Monday, January 13, 2020

Bom Components end date api (BOM Update)

CREATE TABLE PURE_BOM_UPDATE_STG
(
  ORGANIZATION_NAME      VARCHAR2(100 BYTE),
  BOM_CODE               VARCHAR2(200 BYTE),
  BOM_DESCRIPTION        VARCHAR2(500 BYTE),
  ALTERNATIVE_BOM        VARCHAR2(100 BYTE),
  COMPONENT_CODE         VARCHAR2(250 BYTE),
  COMPONENT_DESCRIPTION  VARCHAR2(500 BYTE),
  OPERATION_SEQ_NUM      NUMBER,
  ITEM_SEQUENCE          NUMBER,
  COMPONENT_QUANTITY     NUMBER,
  SUPPLY_SUBINVENTORY    VARCHAR2(500 BYTE),
  STATUS_MESSAGE         VARCHAR2(3000 BYTE),
  STATUS_FLAG            VARCHAR2(10 BYTE),
  PROCESS_FLAG           VARCHAR2(10 BYTE)
)


CREATE OR REPLACE PROCEDURE pure_bom_update_api
IS
---DECLARE
   l_bom_header_rec             bom_bo_pub.bom_head_rec_type
                                          := bom_bo_pub.g_miss_bom_header_rec;
   l_bom_revision_tbl           bom_bo_pub.bom_revision_tbl_type
                                        := bom_bo_pub.g_miss_bom_revision_tbl;
   l_bom_component_tbl          bom_bo_pub.bom_comps_tbl_type
                                       := bom_bo_pub.g_miss_bom_component_tbl;
   l_bom_ref_designator_tbl     bom_bo_pub.bom_ref_designator_tbl_type
                                  := bom_bo_pub.g_miss_bom_ref_designator_tbl;
   l_bom_sub_component_tbl      bom_bo_pub.bom_sub_component_tbl_type
                                   := bom_bo_pub.g_miss_bom_sub_component_tbl;
   l_error_message_list         error_handler.error_tbl_type;
   l_x_bom_header_rec           bom_bo_pub.bom_head_rec_type;
   l_x_bom_revision_tbl         bom_bo_pub.bom_revision_tbl_type;
   l_x_bom_component_tbl        bom_bo_pub.bom_comps_tbl_type;
   l_x_bom_ref_designator_tbl   bom_bo_pub.bom_ref_designator_tbl_type;
   l_x_bom_sub_component_tbl    bom_bo_pub.bom_sub_component_tbl_type;
   l_x_return_status            VARCHAR2 (2000);
   l_x_msg_count                NUMBER;
   i                            NUMBER                                 := 1;
   l_count                      NUMBER;
   l_status_flag                VARCHAR2 (10)                         := NULL;
   l_error_message              VARCHAR2 (20000)                      := NULL;
   l_process_flag               VARCHAR2 (10);
   l_organization_id            NUMBER;
   l_start_eff_date             DATE;
   l_user_id                    NUMBER                                 := -1;
   l_resp_id                    NUMBER                                 := -1;
   l_application_id             NUMBER                                 := -1;
   l_user_name                  VARCHAR2 (1000)                     := 'PURE';
   l_resp_name                  VARCHAR2 (1000)                 := 'PURE_BOM';
   l_error_table                error_handler.error_tbl_type;
   l_return_status              VARCHAR2 (10)                         := NULL;
   l_msg_count                  NUMBER                                 := 0;
   l_assembly_item_id           NUMBER                                := NULL;
   l_organization_code          VARCHAR2 (100)                        := NULL;
   l_component_item_id          NUMBER                                := NULL;
   l_wip_supply_type            VARCHAR2 (50)                         := NULL;
   ---NUMBER;
   l_dis_date                   DATE;
   l_bill_sequence_id           NUMBER                                := NULL;

   CURSOR c_process
   IS
      SELECT   cust.process_flag, ood.organization_code,
               ood.organization_name, ood.organization_id,
               bom.assembly_item_id, msi.segment1 bom_code, msi.description,
               bic.item_num, bic.operation_seq_num, bic.component_item_id,
               msi1.segment1 component_code, ml.meaning supply_type,
               bic.wip_supply_type, bic.effectivity_date, bic.disable_date,
               cust.alternative_bom
          FROM mtl_system_items_b msi,
               org_organization_definitions ood,
               bom_bill_of_materials bom,
               bom_inventory_components bic,
               mtl_system_items_b msi1,
               mfg_lookups ml,
               pure_bom_update_stg cust
         WHERE bom.assembly_item_id = msi.inventory_item_id
           AND bom.bill_sequence_id = bic.bill_sequence_id
           AND msi.organization_id = ood.organization_id
           AND bom.organization_id = ood.organization_id
           AND msi1.inventory_item_status_code = 'Active'
           AND bic.component_item_id = msi1.inventory_item_id
           AND msi1.organization_id = ood.organization_id
           AND ml.lookup_code(+) = bic.wip_supply_type
           AND ml.lookup_type(+) = 'WIP_SUPPLY'
           AND ood.organization_name = cust.organization_name
           AND msi.segment1 = cust.bom_code
           AND msi1.segment1 = cust.component_code
           AND bic.operation_seq_num = cust.operation_seq_num
           AND item_sequence = item_num
           AND NVL (bom.alternate_bom_designator, 'x') =
                                               NVL (cust.alternative_bom, 'x')
           ---AND cust.status_flag <> 'C'
           AND cust.bom_code IN
                ('MGCRHDBR00200020', 'MGCRHDBR00200045', 'MGCRHDCN00001008')
      ORDER BY bom_code ASC;
-- AND process_flag NOT IN ('C', NULL);
BEGIN
   DBMS_OUTPUT.ENABLE (1000000);

   SELECT user_id
     INTO l_user_id
     FROM fnd_user
    WHERE user_name = l_user_name;

   -- Get the application_id and responsibility_id
   SELECT application_id, responsibility_id
     INTO l_application_id, l_resp_id
     FROM fnd_responsibility
    WHERE responsibility_key = l_resp_name;

   -- intiialize applications information
   fnd_global.apps_initialize (l_user_id, l_resp_id, l_application_id);
  --- i := 0;

   FOR j IN c_process
   LOOP
      i := 1;
      l_error_message := NULL;                           --- startt C_PROCESS

      IF j.disable_date IS NOT NULL
      THEN
         UPDATE pure_bom_update_stg
            SET status_flag = 'C',                       ---l_x_return_status,
                status_message = 'Already end dated ',
                process_flag = 'C'
          WHERE organization_name = j.organization_name
            AND bom_code = j.bom_code
            AND component_code = j.component_code
            AND operation_seq_num = j.operation_seq_num
            AND item_sequence = j.item_num;

         ---dbms_output.put_line(disabled component )||;
         COMMIT;
      END IF;

--      BEGIN
--         SELECT COUNT (*)
--           INTO l_count
--           FROM bom_inventory_components
--          WHERE component_item_id = j.component_item_id
--            ---and ORGANIZATION_ID=j.ORGANIZATION_ID
--            AND item_num = j.item_num
--            AND operation_seq_num = j.operation_seq_num;

      --         IF l_count =0
--         THEN
--            UPDATE pure_bom_update_stg
--               SET status_flag = 'E',                    ---l_x_return_status,
--                   status_message = 'Component doesnot exist ',
--                   process_flag = 'I'
--             WHERE organization_name = j.organization_name
--               AND bom_code = j.bom_code
--               AND component_code = j.component_code
--               AND operation_seq_num = j.operation_seq_num
--               AND item_sequence = j.item_num;

      --            COMMIT;
--         END IF;
--      END;
      DBMS_OUTPUT.put_line ('l_start_eff_date ' || l_start_eff_date);
      DBMS_OUTPUT.put_line ('j.wip_supply_type ' || l_wip_supply_type);
      l_bom_component_tbl (i) := bom_bo_pub.g_miss_bom_component_rec;
      l_bom_component_tbl (i).transaction_type := 'UPDATE';
      l_bom_component_tbl (i).organization_code := j.organization_code;
      l_bom_component_tbl (i).assembly_item_name := j.bom_code;
      l_bom_component_tbl (i).start_effective_date := j.effectivity_date;
      --- TO_DATE (j.effectivity_date, 'DD-MON-YYYY HH24:MI:SS');
      l_bom_component_tbl (i).disable_date := SYSDATE;
      --- TO_DATE (SYSDATE, 'DD-MON-YYYY HH24:MI:SS');
      l_bom_component_tbl (i).component_item_name := j.component_code;
      l_bom_component_tbl (i).item_sequence_number := j.item_num;
      l_bom_component_tbl (i).operation_sequence_number := j.operation_seq_num;
      l_bom_component_tbl (i).return_status := NULL;
      l_bom_component_tbl (i).wip_supply_type := j.wip_supply_type;
      --- j.supply_type;
      l_bom_component_tbl (i).alternate_bom_code :=
                                                 NVL (j.alternative_bom, NULL);

      IF j.disable_date IS NULL
      THEN
         BEGIN
            DBMS_OUTPUT.put_line ('Calling API...');
            DBMS_OUTPUT.put_line (' j.organization_code'
                                  || l_organization_code
                                 );
            DBMS_OUTPUT.put_line (' j.bom_code' || j.bom_code);
            DBMS_OUTPUT.put_line (' l_start_eff_date' || j.effectivity_date);
            DBMS_OUTPUT.put_line (' j.component_code ' || j.component_code);
            DBMS_OUTPUT.put_line (' j.item_sequence' || j.item_num);
            DBMS_OUTPUT.put_line (' j.operation_seq_num'
                                  || j.operation_seq_num
                                 );
            DBMS_OUTPUT.put_line (' wip_supply_type' || j.wip_supply_type);
        --- IF j.disable_date IS NOT NULL
      ---THEN
---bms_output.put_line(' j.bom_code' || j.bom_code);
            DBMS_OUTPUT.put_line ('Line count....' || i || j.bom_code);
            error_handler.initialize;
            bom_bo_pub.process_bom
                      (p_bo_identifier               => 'BOM',
                       p_api_version_number          => 1.0,
                       p_init_msg_list               => TRUE,
                       p_bom_header_rec              => l_bom_header_rec,
                       p_bom_revision_tbl            => l_bom_revision_tbl,
                       p_bom_component_tbl           => l_bom_component_tbl,
                       p_bom_ref_designator_tbl      => l_bom_ref_designator_tbl,
                       p_bom_sub_component_tbl       => l_bom_sub_component_tbl,
                       x_bom_header_rec              => l_x_bom_header_rec,
                       x_bom_revision_tbl            => l_x_bom_revision_tbl,
                       x_bom_component_tbl           => l_x_bom_component_tbl,
                       x_bom_ref_designator_tbl      => l_x_bom_ref_designator_tbl,
                       x_bom_sub_component_tbl       => l_x_bom_sub_component_tbl,
                       x_return_status               => l_x_return_status,
                       x_msg_count                   => l_x_msg_count,
                       p_debug                       => 'N',
                       p_output_dir                  => '',
                       p_debug_filename              => ''
                      );
            COMMIT;
         EXCEPTION
            WHEN OTHERS
            THEN
               l_error_message :=
                      l_error_message || 'Error after processing ' || SQLERRM;

               ----- DBMS_OUTPUT.put_line ('1' || l_error_message);
               UPDATE pure_bom_update_stg
                  SET status_flag = 'E',                 ---l_x_return_status,
                      status_message = l_error_message,
                      process_flag = 'I'
                WHERE organization_name = j.organization_name
                  AND bom_code = j.bom_code
                  AND component_code = j.component_code
                  AND operation_seq_num = j.operation_seq_num
                  AND item_sequence = j.item_num;

               --AND ROWID = j.ROWID;
               COMMIT;
         END;
      END IF;

      error_handler.get_message_list (l_error_message_list);
 
      DBMS_OUTPUT.put_line ('Return Status = ' || l_x_return_status);
      DBMS_OUTPUT.put_line ('Message Count = ' || l_x_msg_count);

      IF l_x_return_status <> 'S'
      THEN
         ----DBMS_OUTPUT.put_line ('3' || l_error_message);
         FOR k IN 1 .. l_x_msg_count
         LOOP
            ----- DBMS_OUTPUT.put_line ('4' || l_error_message);
            DBMS_OUTPUT.put_line
                               (   TO_CHAR (k)
                                || ' MESSAGE TEXT '
                                || SUBSTR
                                        (l_error_message_list (k).MESSAGE_TEXT,
                                         1,
                                         250
                                        )
                               );
            DBMS_OUTPUT.put_line (   TO_CHAR (k)
                                  || ' MESSAGE TYPE '
                                  || l_error_message_list (k).MESSAGE_TYPE
                                 );
            l_error_message :=
                  l_error_message
               || TO_CHAR (k)
               || ' MESSAGE TEXT '
               || SUBSTR (l_error_message_list (k).MESSAGE_TEXT, 1, 250);
            ROLLBACK;

            UPDATE pure_bom_update_stg
               SET status_flag = l_x_return_status,
                   status_message = l_error_message,
                   process_flag = 'I'
             WHERE organization_name = j.organization_name
               AND bom_code = j.bom_code
               AND component_code = j.component_code
               AND operation_seq_num = j.operation_seq_num
               AND item_sequence = j.item_num;

            COMMIT;
         END LOOP;

         DBMS_OUTPUT.put_line (l_error_message);
      ELSE
         IF l_x_return_status = 'S'
         THEN
            UPDATE pure_bom_update_stg
               SET status_flag = 'C',                   ----l_x_return_status,
                   status_message = 'END DATED',
                   process_flag = 'C'
             WHERE organization_name = j.organization_name
               AND bom_code = j.bom_code
               AND component_code = j.component_code
               AND operation_seq_num = j.operation_seq_num
               AND item_sequence = j.item_num;
            COMMIT;
         END IF;
      END IF;

   END LOOP;                                                  ---END C_PROCESS
END;

SELECT 1
  FROM DUAL