Showing posts with label Inventory_Details. Show all posts
Showing posts with label Inventory_Details. Show all posts

Tuesday, 9 May 2017

Inventory out bound interface

CREATE OR REPLACE PROCEDURE xx_INV_Out1 (Errbuf       OUT varchar2,
                                         Retcode      OUT varchar2,
                                         f_id      IN     number,
                                         t_id      IN     varchar2)
AS
   CURSOR c1
   IS
      SELECT   msi.segment1 item,
               msi.inventory_item_id Itemid,
               msi.description itemdesc,
               msi.primary_uom_code Uom,
               ood.organization_name name,
               ood.organization_id id,
               mc.segment1 || ',' || mc.segment2 Category
        FROM   mtl_system_items_b msi,
               org_organization_definitions ood,
               mtl_item_categories mic,
               mtl_categories mc
       WHERE       msi.organization_id = ood.organization_id
               AND msi.inventory_item_id = mic.inventory_item_id
               AND msi.organization_id = mic.organization_id
               AND mic.category_id = mc.category_id
               AND msi.purchasing_item_flag = 'Y'
               AND msi.organization_id BETWEEN f_id AND t_id;

   x_id      UTL_FILE.file_type;
   l_count   number (5) DEFAULT 0 ;
BEGIN
   x_id :=
      UTL_FILE.fopen ('d:\oracle\proddb\8.1.7\plsql\temp',
                      'invoutdata.dat',
                      'W');

   --select * from v$parameter where name like '%utl_file%'
   FOR x1 IN c1
   LOOP
      l_count := l_count + 1;
      UTL_FILE.put_line (
         x_id,
            x1.item
         || '-'
         || x1.itemid
         || '-'
         || x1.itemdesc
         || '-'
         || x1.uom
         || '-'
         || x1.name
         || '-'
         || x1.id
         || '-'
         || x1.category
      );
   END LOOP;

   UTL_FILE.fclose (x_id);
   Fnd_file.Put_line (
      Fnd_file.output,
      'No of Records transfered to the data file :' || l_count
   );
   Fnd_File.Put_line (fnd_File.Output, ' ');
   Fnd_File.Put_line (
      fnd_File.Output,
      'Submitted User name  ' || Fnd_Profile.VALUE ('USERNAME')
   );
   Fnd_File.Put_line (fnd_File.Output, ' ');
   Fnd_File.Put_line (
      fnd_File.Output,
      'Submitted Responsibility name ' || Fnd_profile.VALUE ('RESP_NAME')
   );
   Fnd_File.Put_line (fnd_File.Output, ' ');
   Fnd_File.Put_line (fnd_File.Output, 'Submission Date :' || SYSDATE);
EXCEPTION
   WHEN UTL_FILE.invalid_operation
   THEN
      fnd_file.put_line (fnd_File.LOG, 'invalid operation');
      UTL_FILE.fclose_all;
   WHEN UTL_FILE.invalid_path
   THEN
      fnd_file.put_line (fnd_File.LOG, 'invalid path');
      UTL_FILE.fclose_all;
   WHEN UTL_FILE.invalid_mode
   THEN
      fnd_file.put_line (fnd_File.LOG, 'invalid mode');
      UTL_FILE.fclose_all;
   WHEN UTL_FILE.invalid_filehandle
   THEN
      fnd_file.put_line (fnd_File.LOG, 'invalid filehandle');
      UTL_FILE.fclose_all;
   WHEN UTL_FILE.read_error
   THEN
      fnd_file.put_line (fnd_File.LOG, 'read error');
      UTL_FILE.fclose_all;
   WHEN UTL_FILE.internal_error
   THEN
      fnd_file.put_line (fnd_File.LOG, 'internal error');
      UTL_FILE.fclose_all;
   WHEN OTHERS
   THEN
      fnd_file.put_line (fnd_File.LOG, 'other error');
      UTL_FILE.fclose_all;
END xx_INV_Out1;
/

Friday, 18 November 2016

Retroactive billing report in oracle order management:-

/* Formatted on 11/18/2016 3:59:06 PM (QP5 v5.114.809.3010) */
SELECT   DECODE (:p_sort_by, 'O', orig_head.order_number)
            sort_by_order_number,
         DECODE (
            :p_sort_by,
            'T',
            oe_retrobill_pvt.invoice_number (orig_head.order_number,
                                             orig_lin.line_id,
                                             orig_head.order_type_id),
            NULL
         )
            sort_by_invoice_no,
         DECODE (
            SUBSTR (UPPER (:p_item_display), 1, 1),
            'P',
            NVL (orig_lin.user_item_description, item_info.item_description),
            'D',
            NVL (orig_lin.user_item_description, si_tl.description),
            'O',
            item_info.item,
            'F',
            item_info.inventory_item,
            'C',
            item_info.item || ' - '
            || NVL (orig_lin.user_item_description,
                    item_info.item_description),
            'I',
               item_info.inventory_item
            || ' - '
            || NVL (orig_lin.user_item_description, si_tl.description),
            NVL (orig_lin.user_item_description, item_info.item_description)
         )
            item_name,
         oe_order_misc_pub.get_concat_line_number (orig_lin.line_id) line_no,
         party.party_name customer_name,
         site.location invoice_to_name,
         orig_head.order_number,
         orig_head.ordered_date ordered_date,
         orig_head.transactional_curr_code currency,
         orig_lin.ordered_quantity Ordered,
         orig_lin.shipped_quantity Shipped,
         orig_lin.invoiced_quantity Invoiced,
         TO_CHAR (orig_lin.line_id) line_id,
         TO_CHAR (orig_lin.header_id) header_id,
         orig_lin.unit_selling_price orig_price,
         orig_head.order_type_id,
         orig_head.org_id,
         orig_lin.inventory_item_id
  FROM   oe_order_lines_all orig_lin,
         oe_order_lines_all retro_lin,
         hz_cust_accounts cust_info,
         hz_parties party,
         oe_items_v item_info,
         mtl_system_items_tl si_tl,
         oe_order_headers_all orig_head,
         hz_cust_site_uses_all site,
         hz_cust_acct_sites_all acct_site,
         oe_order_headers_all retro_head
 WHERE       orig_head.header_id = orig_lin.header_id
         AND NVL (orig_head.org_id, 0) = NVL (:p_organization_id, 0)
         AND retro_lin.order_source_id = 27
         AND retro_lin.orig_sys_line_ref = orig_lin.line_id
         AND retro_head.header_id = retro_lin.header_id
         AND retro_head.order_source_id = 27
         AND retro_head.orig_sys_document_ref = TO_CHAR (:p_request_id)
         AND retro_lin.retrobill_request_id = :p_request_id
         AND orig_lin.invoiced_quantity > 0
         AND cust_info.cust_account_id = orig_head.sold_to_org_id
         AND cust_info.party_id = party.party_id
         AND orig_lin.inventory_item_id = item_info.inventory_item_id
         AND NVL (orig_lin.ordered_item, '-99') =
               DECODE (orig_lin.item_identifier_type,
                       'INT', NVL (orig_lin.ordered_item, '-99'),
                       'CUST', NVL (orig_lin.ordered_item, '-99'),
                       item_info.item)
         AND NVL (orig_lin.sold_to_org_id, -99) =
               NVL (item_info.sold_to_org_id,
                    NVL (orig_lin.sold_to_org_id, -99))
         AND NVL (orig_lin.item_identifier_type, 'INT') =
               item_info.item_identifier_type
         AND NVL (orig_lin.ordered_item_id, -99) =
               NVL (item_info.item_id, -99)
         AND si_tl.inventory_item_id = item_info.inventory_item_id
         AND si_tl.organization_id = item_info.organization_id
         AND si_tl.language = USERENV ('LANG')
         AND site.site_use_code = 'BILL_TO'
         AND site.site_use_id = orig_lin.invoice_to_org_id
         AND acct_site.cust_account_id = cust_info.cust_account_id
         AND site.cust_acct_site_id = acct_site.cust_acct_site_id;

Tuesday, 15 November 2016

Inventory Replenishment Oracle Apps

In any business involved in the sale of goods , the business needs to keep a track of its inventory and replenish the inventory when needed. The business can use different methods to replenish their inventory.

The Inventory replenishment methods provided by Oracle include


  1. Min-Max Planning
  2. Reorder Point Planning
  3. Kanban Replenishment Planning
  4. Replenishment Counting
When Placing an order for replenishing the inventory , the business needs to answer certain quetions
  1. What should be ordered
  2. How much should be ordered
  3. When should it be ordered
  4. Which planning method should be used to decide the order
Lets see the answer to these questions:
  1. What should be ordered : The business needs to decide what products/goods it needs to buy
  2. How much should be ordered : When deciding on this the business needs to consider the carrying cost of the goods and the expected demand
  3. When should it be ordered: This will be answered by the replenishment method used
  4. Which planning method should be used to decide the order : It is decided by the business depending on Oracles offering of each mechanism
Of the replenishment methods listed above , some can be performed at Organization/warehouse level and some at sub-inventory level
Now we will look at the different replenishment methods :
Re-Order Point Planning : is an inventory replenishment mechanism in which the inventory is replenished when the inventory levels fall below a certain pre-defined level. The amount of order placed is equal to EOQ (Economic Order Quantity) . This mechanism is suggested for in-expensive items.
Re-Order Point : Safety stock + Forecasted demand during the lead time , lead time is the time in which the business expects the goods to be delivered
This mechanism can be used in cases of:
  • replenishment at Org level is done
  • for inexpensive items
  • item demand is independent of others
 Min-Max Planning: Min Max Planning is another simple method of inventory planning with the below features
  • User  defines the minimum and maximum inventory levels of the item
  • Inventory is replenished to the maximum level when the level reaches the minimum level
  • Can be applied to any number of items
This mechanism can be used in cases of:: 
  • Inventory replenishment is planned at Org or sub-inventory level
  • the items do not require strict inventory monitoring
Kanban Replenishment : Kanban Replenishment Planning is a replenishment mechanism which depends on visual cues for inventory replenishment. This mechanism is applicable for items which require shorter lead times,having a constant demand and medium to high production demand
Kanban uses replenishment signals which are easily indicative and visible : in means of color coding scheme, color cards or empty bins.
Depending on the mechanism used once the inventory needs to be replenished as per the signals business will have the replenishment.
The inventory replenishment in Kanban can be on the type of replenishment chosen:
  1. Inter Org: In this case an internal requisition is created
  2. Intra Org: In this case goods are transferred from one sub-inventory of the warehouse to the other
  3. Production : Creation or release of a production job is done
  4. Supplier: A purchase requisition is created
Replenishment Counting: Replenishment counting is used for items for which inventory tracking is not maintained. In this mechanism the counters will physically count the inventory on a periodic basis and replenish the inventory as and when required.

Inventory Planning and Replenishment Oracle apps

In a business maintaining inventory of goods , the business needs to replenish the stock of the sold goods to maintain the required inventory for normal business operations
 
The Inventory replenishment is determined by the inventory replenishment method employed by the business
 
      1.       Min-Max Planning
      2.       Kanban Replenishment Planning
      3.       Replenishment Palnning
      4.       Re-Order Point Planning
 
The Re-Order of Inventory raises a lot of questions which need to be answered
 
      1.       What should be ordered
      2.       How much should be ordered
      3.       When should the goods be ordered
      4.       Which planning method to use
 
How Much to Order : This depends on the relation between the supply and demand and the inventory replenishment lead time.
 
Inventory Forecasting: Inventory forecasting is the process of extrapolating the expected demand of the goods over an expected number of periods
 
Inventory Replenishment methods
      1.       Min-Max Planning
      2.       Kanban Replenishment Planning
      3.       Replenishment Planning
      4.       Re-Order Point Planning
 
Re Order Point Planning
As the name suggests this method of replenishment will replenish the inventory when the inventory level falls below a certain decided point.
The goods ordered are equal to the EOQ (Economic Order Quantity)
This mechanism is recommended for the items which are not very expensive
Re-Order point planning steps
1.       Enter item planning attributes
2.       Forecast item demands
3.       Define safety stock
4.       Run Re-Order point report
 
Min-Max Planning
The items are planned depending on the user defined Minimum and Maximum quantity.The items are replenished to the Maximum level once it falls below the Minimum Level. It is generally applied to low cost items which do not require strict monitoring
 
Kanban Planning:
Kanban is a pull replenishment system whose aims is zero stockouts, shorter lead times, and reduced inventory with minimal manual supervision. Instead of waiting for an MRP plan to release materials down the supply chain, with kanban each operation pulls the materials it needs from its source when it needs them, signaling with a replenishment signal or a kanban that it needs to do so.
Kanban
 
The term kanban refers to a visual replenishment signal such as a card or an empty bin for an item. In a kanban system, each work center has several bins, each containing a certain number of the same item. When a bin becomes empty, the work center starts the process of replenishing the empty bin by sending the replenishment signal, or a kanban. Meanwhile, the work center can continue using the other (stocked) bins.
 
Types of Kanban Replenishment:
Inter Org: Replenishes by creating Internal Requisition
Intra Org: Triggers Material movement from a subinventory in the same Organization.
Production: Creates or releases a Production Job
Supplier: Creates a Purchase Requisition.
Kanban Elements:
Pull Sequence is a group of information that defines a Kanban location, source information, and planning parameters for an Item.
 Kanban chain is a series of Pull Sequences, which defines the replenishment network. E.g.: Assembly to Stores.
Kanban Cards are created for Item, Subinventory and Locator (optional) and uniquely identified by a Kanban number
 Replenishable Cards can be created automatically through Pull Sequence or manually through „Kanban Cards‟ window.
Replenishment Counting
• Replenishment Counting is a method of ordering Items for non-Tracked Subinventory.
• Non-Tracked subinventories are expense subinventory, for which On-hand balances are not maintained.
• Whenever an Item is moved into Expense Subinventory, the Expense account is charged and the quantity is discarded.
• Items are replenished in Non-Tracked Subinventory by periodically counting the items physically.

Inventory Transactions Process

Transactions in the inventory are classified depending on the flow
 
Material Flow:-
 
         1.       Receive Goods
         2.       Move Goods
         3.       Issue Goods
 
Business Flow:-
 
         1.       WIP à Inventory
         2.       Purchasing à Inventory
         3.       Order Management à Inventory
         4.       Services à Inventory
 
Different types of Inventory Transactions:-
 
         1.       Miscellaneous issue
         2.       Miscellaneous receipt
         3.       Sub inventory transfer
         4.       Inter org transfer
Miscellaneous Issue:-
 
Users can use miscellaneous transactions to issue material from general ledger accounts in your current organization. Items are issued from the inventory without any documentation
 
Miscellaneous Receipt:-
 
Users can use miscellaneous transactions to receive material to general ledger accounts in your current organization. Items are issued from the inventory without any documentation
 
Sub Inventory Transfer:-
 
Users  use sub inventory transfers to transfer material within your current organization between sub inventories, or between two locators within the same sub inventorys
 
Inter Org Transfer:-
 
Users  use direct inter-organization transfers to move inventory directly from shipping organization to a destination organization
Managing Inventory Receipts:-
 
Users can receive both internally and externally sourced shipments and deliver material directly to inventory, the shop floor, and you can deliver to inventory, shop floor, and expense destinations
 
Types of Inventory Receipts:-
 
Direct Shipment:  A direct Shipment enables the users to receive and deliver the goods to the inventory by a single inventory transaction
 
Standard Receipt: This is a2 step of performing the receipt of goods. The process enables the users to receive the goods in one inventory organization and deliver in another organization
 
Inspected Receipt: This is a 3 step of performing the receipt of goods. The process enables the users to receive the goods in one inventory organization, inspect the goods and deliver in another 
organization.
 
Move Order:-
 
A move Order is a document which enables the movement of goods within a single organization. Move Order document keep track of the intra org transfer of the materials. The move order document Is created when a sales order is pick released. The move order document is used by the warehouse personell for performing picking.
 
There are 3 activities in Move Orders:
 
Move Order Creation: Creation of the move order documents
Move Order Allocation: Allocation of the goods to the move order
Move Order Transaction: Transfer of the goods within the organization as specified on the move order

Tuesday, 28 June 2016

R12: Create, Allocate and Transact a Move Order using APIs

                                    Move Orders in Oracle provide good functionality for approval based movement of material with in an inventory organization. Move Order Approvals use a workflow (INV: Move Order Approval) for approvals and hence provide flexibility to extend it for approvals.
Move Orders can be created from different sources. These move orders are identified by Move order type at the header level. Different types of move orders are:
Move Order Requisitions: These are created from the move order form. Based on the setup at the organization and item level, move orders require approval before they can be allocated and transacted. These requisitions can be created to charge an account or move the material from one subinventory to another.
Replenishment Move Orders: These are auto-created with pre approved status. Depending on the planning type you can replenish the quantity in a subinventory for an item. Three types of replenishment plans (in relation to move orders) are available:
  1. Min-max Replenishment Planning
  2. Kanban Replenishment Planning
  3. Replenishing Count planning
Based on these sources, when appropriate programs are run, move orders are automatically created.
Pick Wave Move Order Requisitions: These move orders are specifically for the sales order picking process. When Pick Releasing program is run move orders are created as preapproved and allocated. Pick Confirm process transacts these pick wave move orders.
Move orders contain headers and lines. All types of approved move orders have to be allocated (basically reserved) before they can be transacted. Depending on the item transaction controls (Subinventory, Locator, Revision, Lot or Serial number) move order creation and allocation gets complex.
The process is simple. Create and approve Move orders, allocate move order lines and transact them.
In this article let us review creating, allocating, and transacting a move order requisition of first type (requisitions) using APIs. These move orders will be created in pre approved status and hence do not use workflow. Move Order Issue transaction type is used in this example. An account is chosen while creating this move order. When successfully transacted, this account gets debited, crediting inventory account of the subinventory. From the user interface, to create Move orders, Move Orders window is used.
The lines are allocated when allocation step is performed. In this example the logic for allocation and transaction is borrowed from pick confirmation code. To allocate and transact same form is used: Transact Move Orders.
If the item is lot and serial number controlled (as in this example), you have to pass the lot number and serial number information into the move order lines table parameter. And also make sure to pass another parameter (p_suggess_serial) as true. This will automatically take care of allocating the lot and serial numbers into the appropriate table as mentioned in the process flow. Also when we allocate the move order from the user interface, the records in the form are created in the mtl_material_transactions_temp table with transaction_status as 2, which allows the user to change the values from user interface. But in order to perform transaction from SQL, you have to change this value to 3 so that the transaction manager can pick these records up. You find that logic in the allocating code.
The tables affected in each process step are mentioned in the process flow. Code for each step as well as complete code to create, allocate and transact can be downloaded as seen here.
 Create Move Order:-

DECLARE
   PROCEDURE create_move_order
   IS
l_hdr_rec         inv_move_order_pub.trohdr_rec_type              := inv_move_order_pub.g_miss_trohdr_rec;
l_line_tbl        inv_move_order_pub.trolin_tbl_type              := inv_move_order_pub.g_miss_trolin_tbl;
x_return_status   VARCHAR2 (1);
x_msg_count       NUMBER;
x_msg_data        VARCHAR2 (4000);
x_hdr_rec         inv_move_order_pub.trohdr_rec_type              := inv_move_order_pub.g_miss_trohdr_rec;
x_hdr_val_rec     inv_move_order_pub.trohdr_val_rec_type;
x_line_tbl        inv_move_order_pub.trolin_tbl_type;
x_line_val_tbl    inv_move_order_pub.trolin_val_tbl_type;
v_msg_index_out   NUMBER;
l_rsr_type        inv_reservation_global.mtl_reservation_tbl_type;

BEGIN
   l_line_tbl.DELETE;
   x_line_tbl.DELETE;
   mo_global.set_policy_context ('S', 204);
   inv_globals.set_org_id (207);
   fnd_global.apps_initialize (1005902, 50583, 401);
   l_hdr_rec.date_required := SYSDATE;
   l_hdr_rec.header_status := inv_globals.g_to_status_preapproved;
   l_hdr_rec.organization_id := 207;
   l_hdr_rec.status_date := SYSDATE;
   l_hdr_rec.transaction_type_id := inv_globals.g_type_transfer_order_issue;
   l_hdr_rec.move_order_type := inv_globals.g_move_order_requisition;
   l_hdr_rec.db_flag := fnd_api.g_true;
   l_hdr_rec.operation := inv_globals.g_opr_create;
   l_hdr_rec.description := 'Test Move Order';
   l_hdr_rec.to_account_id := 12831;
   l_hdr_rec.from_subinventory_code := 'FGI';
   l_line_tbl (1).date_required := SYSDATE;
   l_line_tbl (1).inventory_item_id := 167742;
   l_line_tbl (1).line_id := fnd_api.g_miss_num;
   l_line_tbl (1).line_number := 1;
   l_line_tbl (1).line_status := inv_globals.g_to_status_preapproved;
   l_line_tbl (1).transaction_type_id :=
      inv_globals.g_type_transfer_order_issue;
   l_line_tbl (1).organization_id := 207;
   l_line_tbl (1).quantity := 1;
   l_line_tbl (1).status_date := SYSDATE;
   l_line_tbl (1).uom_code := 'Ea';
   l_line_tbl (1).db_flag := fnd_api.g_true;
   l_line_tbl (1).operation := inv_globals.g_opr_create;
   l_line_tbl (1).from_subinventory_code := 'FGI';
   l_line_tbl (1).to_account_id := 12831;
   l_line_tbl (1).lot_number := 'A01';         --If the item is lot controlled
   l_line_tbl (1).serial_number_start := 'A01-0031'; --If the item is serial number controlled
   l_line_tbl (1).serial_number_end := 'A01-0031'; --If the item is serial number controlled
   inv_move_order_pub.process_move_order (
      p_api_version_number   => 1.0,
      p_init_msg_list        => fnd_api.g_false,
      p_return_values        => fnd_api.g_false,
      p_commit               => fnd_api.g_false,
      x_return_status        => x_return_status,
      x_msg_count            => x_msg_count,
      x_msg_data             => x_msg_data,
      p_trohdr_rec           => l_hdr_rec,
      p_trolin_tbl           => l_line_tbl,
      x_trohdr_rec           => x_hdr_rec,
      x_trohdr_val_rec       => x_hdr_val_rec,
      x_trolin_tbl           => x_line_tbl,
      x_trolin_val_tbl       => x_line_val_tbl
   );
   DBMS_OUTPUT.put_line ('Return Status is :' || x_return_status);
   DBMS_OUTPUT.put_line ('Message Count is :' || x_msg_count);
   DBMS_OUTPUT.put_line (
      'Move Order Number is :' || x_hdr_rec.request_number
   );
   DBMS_OUTPUT.put_line ('Number of Lines Created are :' || x_line_tbl.COUNT);

   IF x_return_status = 'S'
   THEN
      COMMIT;
   ELSE
      ROLLBACK;
   END IF;

   IF x_msg_count > 0
   THEN
      FOR v_index IN 1 .. x_msg_count
      LOOP
         fnd_msg_pub.get (p_msg_index       => v_index,
                          p_encoded         => 'F',
                          p_data            => x_msg_data,
                          p_msg_index_out   => v_msg_index_out);
         x_msg_data := SUBSTR (x_msg_data, 1, 200);
         DBMS_OUTPUT.put_line (x_msg_data);
         DBMS_OUTPUT.put_line (
            '============================================================'
         );
      END LOOP;
   END IF;
END;

BEGIN
   create_move_order;
END;
 
Allocate Move Order:
 
/* Formatted on 6/28/2016 2:51:21 PM (QP5 v5.114.809.3010) */
DECLARE
   x_return_status   VARCHAR2 (1);
   x_msg_data        VARCHAR2 (4000);
   x_msg_count       NUMBER;
   l_line_tbl        inv_move_order_pub.trolin_tbl_type;

   PROCEDURE allocate_move_order (
      p_line_tbl        IN     inv_move_order_pub.trolin_tbl_type,
      x_return_status      OUT VARCHAR2,
      x_msg_data           OUT VARCHAR2,
      x_msg_count          OUT NUMBER
   )
   IS
      x_line_tbl        inv_move_order_pub.trolin_tbl_type;
      l_trolin_tbl      inv_move_order_pub.trolin_tbl_type;
      l_mold_tbl        inv_mo_line_detail_util.g_mmtt_tbl_type;
      l_qty_detailed    NUMBER;
      l_qty_delivered   NUMBER;
      l_return_status   VARCHAR2 (1);
      v_msg_index_out   NUMBER;
      l_rsr_type        inv_reservation_global.mtl_reservation_tbl_type;
      i                 INTEGER;
      l_trolin_rec      inv_move_order_pub.trolin_rec_type;
   BEGIN
      x_line_tbl := p_line_tbl;

      IF x_line_tbl.COUNT > 0
      THEN
         FOR j IN x_line_tbl.FIRST .. x_line_tbl.LAST
         LOOP
            DBMS_OUTPUT.put_line (x_line_tbl (j).line_id);

            BEGIN
               inv_ppengine_pvt.create_suggestions (
                  p_api_version           => 1.0,
                  p_init_msg_list         => fnd_api.g_false,
                  p_commit                => fnd_api.g_false,
                  p_validation_level      => fnd_api.g_valid_level_none,
                  x_return_status         => x_return_status,
                  x_msg_count             => x_msg_count,
                  x_msg_data              => x_msg_data,
                  p_transaction_temp_id   => x_line_tbl (j).line_id,
                  p_reservations          => l_rsr_type,
                  p_suggest_serial        => fnd_api.g_true,
                  p_plan_tasks            => FALSE,
                  p_quick_pick_flag       => 'N',
                  p_organization_id       => 207
               );
               DBMS_OUTPUT.put_line ('Return Status is :' || x_return_status);
               DBMS_OUTPUT.put_line ('Message Count is :' || x_msg_count);

               IF x_return_status = 'S'
               THEN
                  BEGIN
                     l_trolin_tbl := x_line_tbl;

                     IF (l_trolin_tbl.COUNT <> 0)
                     THEN
                        i := l_trolin_tbl.FIRST;

                        WHILE i IS NOT NULL
                        LOOP
                           IF (l_trolin_tbl (i).return_status <>
                                  fnd_api.g_ret_sts_unexp_error
                               AND l_trolin_tbl (i).return_status <>
                                     fnd_api.g_ret_sts_error)
                           THEN
                              l_trolin_rec :=
                                 inv_trolin_util.query_row (
                                    l_trolin_tbl (i).line_id
                                 );
                              l_trolin_tbl (i) := l_trolin_rec;
                              l_qty_detailed :=
                                 l_trolin_tbl (i).quantity_detailed;
                              l_qty_delivered :=
                                 NVL (l_trolin_tbl (i).quantity_delivered, 0);

                              IF NVL (l_qty_detailed, 0) = 0
                              THEN
                                 l_mold_tbl :=
                                    inv_mo_line_detail_util.query_rows (
                                       p_line_id   => l_trolin_tbl (i).line_id
                                    );

                                 FOR j IN 1 .. l_mold_tbl.COUNT
                                 LOOP
                                    l_mold_tbl (j).transaction_status := 3;
                                    l_mold_tbl (j).transaction_mode := 1;
                                    l_mold_tbl (j).source_line_id :=
                                       l_trolin_tbl (i).line_id;
                                    inv_mo_line_detail_util.update_row (
                                       l_return_status,
                                       l_mold_tbl (j)
                                    );
                                 END LOOP;

                                 SELECT   transaction_header_id,
                                          transaction_quantity
                                   INTO   l_trolin_tbl (
                                             i
                                          ).transaction_header_id,
                                          l_trolin_tbl (i).quantity_detailed
                                   FROM   mtl_material_transactions_temp
                                  WHERE   move_order_line_id =
                                             l_trolin_tbl (i).line_id;

                                 l_trolin_tbl (i).last_update_date := SYSDATE;
                                 l_trolin_tbl (i).last_update_login :=
                                    fnd_global.login_id;

                                 IF l_trolin_tbl (i).last_update_login = -1
                                 THEN
                                    l_trolin_tbl (i).last_update_login :=
                                       fnd_global.conc_login_id;
                                 END IF;

                                 l_trolin_tbl (i).last_updated_by :=
                                    fnd_global.user_id;
                                 l_trolin_tbl (i).program_id :=
                                    fnd_global.conc_program_id;
                                 l_trolin_tbl (i).program_update_date :=
                                    SYSDATE;
                                 l_trolin_tbl (i).request_id :=
                                    fnd_global.conc_request_id;
                                 l_trolin_tbl (i).program_application_id :=
                                    fnd_global.prog_appl_id;
                                 inv_trolin_util.update_row (
                                    l_trolin_tbl (i)
                                 );
                              END IF;
                           END IF;

                           i := l_trolin_tbl.NEXT (i);
                        END LOOP;
                     END IF;
                  END;
               ELSE
                  ROLLBACK;
               END IF;

               IF x_msg_count > 0
               THEN
                  FOR v_index IN 1 .. x_msg_count
                  LOOP
                     fnd_msg_pub.get (p_msg_index       => v_index,
                                      p_encoded         => 'F',
                                      p_data            => x_msg_data,
                                      p_msg_index_out   => v_msg_index_out);
                     x_msg_data := SUBSTR (x_msg_data, 1, 200);
                     DBMS_OUTPUT.put_line (x_msg_data);
                     DBMS_OUTPUT.put_line('============================================================');
                  END LOOP;
               END IF;
            END;
         END LOOP;
      END IF;
   END;
BEGIN
   l_line_tbl (1).line_id := 3929705;
   allocate_move_order (l_line_tbl,
                        x_return_status,
                        x_msg_data,
                        x_msg_count);
   COMMIT;
END;
Transact Move Order:
/* Formatted on 6/28/2016 2:52:14 PM (QP5 v5.114.809.3010) */ DECLARE x_return_status VARCHAR2 (1); PROCEDURE transact_move_order (p_move_order_id IN NUMBER, x_return_status OUT VARCHAR2) IS l_header_id NUMBER; l_program VARCHAR2 (100); l_func VARCHAR2 (100); l_args VARCHAR2 (100); p_timeout NUMBER; l_old_tm_success BOOLEAN; l_rc_field NUMBER; CURSOR c1 (p_header_id IN NUMBER) IS SELECT transaction_header_id FROM mtl_material_transactions_temp WHERE transaction_source_id = p_header_id; BEGIN mo_global.set_policy_context ('S', 204); inv_globals.set_org_id (207); fnd_global.apps_initialize (1005902, 50583, 401); FOR i IN c1 (p_move_order_id) LOOP l_program := 'INXTPU'; l_func := l_program; l_args := l_program || ' ' || 'TRANS_HEADER_ID=' || TO_CHAR (i.transaction_header_id); p_timeout := 500; COMMIT; l_old_tm_success := inv_pick_wave_pick_confirm_pub.inv_tm_launch ( program => l_program, args => l_args, TIMEOUT => p_timeout, rtval => l_rc_field ); IF l_old_tm_success THEN x_return_status := 'S'; DBMS_OUTPUT.put_line ('Result is :' || 'Success'); ELSE x_return_status := 'E'; DBMS_OUTPUT.put_line ('Result is :' || 'Failed'); END IF; IF x_return_status = 'S' THEN COMMIT; ELSE ROLLBACK; END IF; END LOOP; END; BEGIN transact_move_order (2055447, x_return_status); COMMIT; END;
Move Order Composite:
DECLARE
   l_header_rec      inv_move_order_pub.trohdr_rec_type;
   l_line_tbl        inv_move_order_pub.trolin_tbl_type;
   x_return_status   VARCHAR2 (1);
   x_msg_data        VARCHAR2 (4000);
   x_msg_count       NUMBER;

   PROCEDURE create_move_order (
      x_hdr_rec         OUT   inv_move_order_pub.trohdr_rec_type
    , x_line_tbl        OUT   inv_move_order_pub.trolin_tbl_type
    , x_return_status   OUT   VARCHAR2
    , x_msg_data        OUT   VARCHAR2
    , x_msg_count       OUT   NUMBER
   )
   IS
      l_hdr_rec         inv_move_order_pub.trohdr_rec_type              :=
      inv_move_order_pub.g_miss_trohdr_rec;
      l_line_tbl        inv_move_order_pub.trolin_tbl_type              :=
      inv_move_order_pub.g_miss_trolin_tbl;
      x_hdr_val_rec     inv_move_order_pub.trohdr_val_rec_type;
      x_line_val_tbl    inv_move_order_pub.trolin_val_tbl_type;
      v_msg_index_out   NUMBER;
      l_rsr_type        inv_reservation_global.mtl_reservation_tbl_type;
   BEGIN
      l_line_tbl.DELETE;
      x_line_tbl.DELETE;
      l_hdr_rec.date_required := SYSDATE;
      l_hdr_rec.header_status := inv_globals.g_to_status_preapproved;
      l_hdr_rec.organization_id := 207;
      l_hdr_rec.status_date := SYSDATE;
      l_hdr_rec.transaction_type_id := inv_globals.g_type_transfer_order_issue
      ;
      l_hdr_rec.move_order_type := inv_globals.g_move_order_requisition;
      l_hdr_rec.db_flag := fnd_api.g_true;
      l_hdr_rec.operation := inv_globals.g_opr_create;
      l_hdr_rec.description := 'Test Move Order';
      l_hdr_rec.to_account_id := 12831;
      l_hdr_rec.from_subinventory_code := 'FGI';
      l_line_tbl (1).date_required := SYSDATE;
      l_line_tbl (1).inventory_item_id := 167742;
      l_line_tbl (1).line_id := fnd_api.g_miss_num;
      l_line_tbl (1).line_number := 1;
      l_line_tbl (1).line_status := inv_globals.g_to_status_preapproved;
      l_line_tbl (1).transaction_type_id := inv_globals.
      g_type_transfer_order_issue;
      l_line_tbl (1).organization_id := 207;
      l_line_tbl (1).quantity := 1;
      l_line_tbl (1).status_date := SYSDATE;
      l_line_tbl (1).uom_code := 'Ea';
      l_line_tbl (1).db_flag := fnd_api.g_true;
      l_line_tbl (1).operation := inv_globals.g_opr_create;
      l_line_tbl (1).from_subinventory_code := 'FGI';
      l_line_tbl (1).to_account_id := 12831;
      l_line_tbl (1).lot_number := 'A01';
      --If the item is lot controlled
      l_line_tbl (1).serial_number_start := 'A01-0039';
      --If the item is serial number controlled
      l_line_tbl (1).serial_number_end := 'A01-0039';
      --If the item is serial number controlled
      inv_move_order_pub.process_move_order (p_api_version_number      => 1.0
                                           , p_init_msg_list           =>
      fnd_api.g_false
                                           , p_return_values           =>
      fnd_api.g_false
                                           , p_commit                  =>
      fnd_api.g_false
                                           , x_return_status           =>
      x_return_status
                                           , x_msg_count               =>
      x_msg_count
                                           , x_msg_data                =>
      x_msg_data
                                           , p_trohdr_rec              =>
      l_hdr_rec
                                           , p_trolin_tbl              =>
      l_line_tbl
                                           , x_trohdr_rec              =>
      x_hdr_rec
                                           , x_trohdr_val_rec          =>
      x_hdr_val_rec
                                           , x_trolin_tbl              =>
      x_line_tbl
                                           , x_trolin_val_tbl          =>
      x_line_val_tbl
                                            );
      DBMS_OUTPUT.put_line ('Return Status is :' || x_return_status);
      DBMS_OUTPUT.put_line ('Message Count is :' || x_msg_count);
      DBMS_OUTPUT.put_line ('Move Order Number is :' || x_hdr_rec.
      request_number);
      DBMS_OUTPUT.put_line ('Move Order ID is :' || x_hdr_rec.header_id);
      DBMS_OUTPUT.put_line ('Number of Lines Created are :' || x_line_tbl.
      COUNT);

      IF x_return_status = 'S'
      THEN
         COMMIT;
      ELSE
         ROLLBACK;
      END IF;

      IF x_msg_count > 0
      THEN
         FOR v_index IN 1 .. x_msg_count
         LOOP
            fnd_msg_pub.get (p_msg_index => v_index, p_encoded => 'F', p_data
      => x_msg_data, p_msg_index_out => v_msg_index_out);
            x_msg_data := SUBSTR (x_msg_data, 1, 200);
            DBMS_OUTPUT.put_line (x_msg_data);
            DBMS_OUTPUT.put_line (
      '============================================================');
         END LOOP;
      END IF;
   END;
 
 
 
***********************************************************************
 
PROCEDURE allocate_move_order (
      p_line_tbl        IN       inv_move_order_pub.trolin_tbl_type
    , x_return_status   OUT      VARCHAR2
    , x_msg_data        OUT      VARCHAR2
    , x_msg_count       OUT      NUMBER
   )
   IS
      x_line_tbl        inv_move_order_pub.trolin_tbl_type;
      l_trolin_tbl      inv_move_order_pub.trolin_tbl_type;
      l_mold_tbl        inv_mo_line_detail_util.g_mmtt_tbl_type;
      l_qty_detailed    NUMBER;
      l_qty_delivered   NUMBER;
      l_return_status   VARCHAR2 (1);
      v_msg_index_out   NUMBER;
      l_rsr_type        inv_reservation_global.mtl_reservation_tbl_type;
      i                 INTEGER;
      l_trolin_rec      inv_move_order_pub.trolin_rec_type;
   BEGIN
      x_line_tbl := p_line_tbl;

      IF x_line_tbl.COUNT > 0
      THEN
         FOR j IN x_line_tbl.FIRST .. x_line_tbl.LAST
         LOOP
            DBMS_OUTPUT.put_line (x_line_tbl (j).line_id);

            BEGIN
               inv_ppengine_pvt.create_suggestions (p_api_version
      => 1.0
                                                  , p_init_msg_list
      => fnd_api.g_false
                                                  , p_commit
      => fnd_api.g_false
                                                  , p_validation_level
      => fnd_api.g_valid_level_none
                                                  , x_return_status
      => x_return_status
                                                  , x_msg_count
      => x_msg_count
                                                  , x_msg_data
      => x_msg_data
                                                  , p_transaction_temp_id
      => x_line_tbl (j).line_id
                                                  , p_reservations
      => l_rsr_type
                                                  , p_suggest_serial
      => fnd_api.g_true
                                                  , p_plan_tasks
      => FALSE
                                                  , p_quick_pick_flag
      => 'N'
                                                  , p_organization_id
      => 207
                                                   );
               DBMS_OUTPUT.put_line ('Return Status is :' || x_return_status);
               DBMS_OUTPUT.put_line ('Message Count is :' || x_msg_count);

               IF x_return_status = 'S'
               THEN
                  BEGIN
                     l_trolin_tbl := x_line_tbl;

                     IF (l_trolin_tbl.COUNT <> 0)
                     THEN
                        i := l_trolin_tbl.FIRST;

                        WHILE i IS NOT NULL
                        LOOP
                           IF (    l_trolin_tbl (i).return_status <> fnd_api.
      g_ret_sts_unexp_error
                               AND l_trolin_tbl (i).return_status <> fnd_api.
      g_ret_sts_error
                              )
                           THEN
                              l_trolin_rec := inv_trolin_util.query_row (
      l_trolin_tbl (i).line_id);
                              l_trolin_tbl (i) := l_trolin_rec;
                              l_qty_detailed := l_trolin_tbl (i).
      quantity_detailed;
                              l_qty_delivered := NVL (l_trolin_tbl (i).
      quantity_delivered, 0);

                              IF NVL (l_qty_detailed, 0) = 0
                              THEN
                                 l_mold_tbl := inv_mo_line_detail_util.
      query_rows (p_line_id => l_trolin_tbl (i).line_id);

                                 FOR j IN 1 .. l_mold_tbl.COUNT
                                 LOOP
                                    l_mold_tbl (j).transaction_status := 3;
                                    l_mold_tbl (j).transaction_mode := 1;
                                    l_mold_tbl (j).source_line_id :=
      l_trolin_tbl (i).line_id;
                                    inv_mo_line_detail_util.update_row (
      l_return_status, l_mold_tbl (j));
                                 END LOOP;

                                 SELECT transaction_header_id,
      transaction_quantity
                                   INTO l_trolin_tbl (i).transaction_header_id
      , l_trolin_tbl (i).quantity_detailed
                                   FROM mtl_material_transactions_temp
                                  WHERE move_order_line_id = l_trolin_tbl (i).
      line_id;

                                 l_trolin_tbl (i).last_update_date := SYSDATE;
                                 l_trolin_tbl (i).last_update_login :=
      fnd_global.login_id;

                                 IF l_trolin_tbl (i).last_update_login = -1
                                 THEN
                                    l_trolin_tbl (i).last_update_login :=
      fnd_global.conc_login_id;
                                 END IF;

                                 l_trolin_tbl (i).last_updated_by :=
      fnd_global.user_id;
                                 l_trolin_tbl (i).program_id := fnd_global.
      conc_program_id;
                                 l_trolin_tbl (i).program_update_date :=
      SYSDATE;
                                 l_trolin_tbl (i).request_id := fnd_global.
      conc_request_id;
                                 l_trolin_tbl (i).program_application_id :=
      fnd_global.prog_appl_id;
                                 inv_trolin_util.update_row (l_trolin_tbl (i))
      ;
                              END IF;
                           END IF;

                           i := l_trolin_tbl.NEXT (i);
                        END LOOP;
                     END IF;
                  END;
               ELSE
                  ROLLBACK;
               END IF;

               IF x_msg_count > 0
               THEN
                  FOR v_index IN 1 .. x_msg_count
                  LOOP
                     fnd_msg_pub.get (p_msg_index          => v_index
                                    , p_encoded            => 'F'
                                    , p_data               => x_msg_data
                                    , p_msg_index_out      => v_msg_index_out
                                     );
                     x_msg_data := SUBSTR (x_msg_data, 1, 200);
                     DBMS_OUTPUT.put_line (x_msg_data);
                     DBMS_OUTPUT.put_line (
      '============================================================');
                  END LOOP;
               END IF;
            END;
         END LOOP;
      END IF;
   END;
 
********************************************************************************* 
 
 
 /* Formatted on 6/28/2016 2:54:58 PM (QP5 v5.114.809.3010) */
PROCEDURE transact_move_order (p_move_order_id   IN     NUMBER,
                               x_return_status      OUT VARCHAR2)
IS
   l_header_id        NUMBER;
   l_program          VARCHAR2 (100);
   l_func             VARCHAR2 (100);
   l_args             VARCHAR2 (100);
   p_timeout          NUMBER;
   l_old_tm_success   BOOLEAN;
   l_rc_field         NUMBER;

   CURSOR c1 (p_header_id IN NUMBER)
   IS
      SELECT   transaction_header_id
        FROM   mtl_material_transactions_temp
       WHERE   transaction_source_id = p_header_id;
BEGIN
   FOR i IN c1 (p_move_order_id)
   LOOP
      l_program := 'INXTPU';
      l_func := l_program;
      l_args :=
            l_program
         || ' '
         || 'TRANS_HEADER_ID='
         || TO_CHAR (i.transaction_header_id);
      p_timeout := 500;
      COMMIT;
      l_old_tm_success :=
         inv_pick_wave_pick_confirm_pub.inv_tm_launch (
            program   => l_program,
            args      => l_args,
            TIMEOUT   => p_timeout,
            rtval     => l_rc_field
         );

      IF l_old_tm_success
      THEN
         x_return_status := 'S';
         DBMS_OUTPUT.put_line ('Result is :' || 'Success');
      ELSE
         x_return_status := 'E';
         DBMS_OUTPUT.put_line ('Result is :' || 'Failed');
      END IF;

      IF x_return_status = 'S'
      THEN
         COMMIT;
      ELSE
         ROLLBACK;
      END IF;
   END LOOP;
END;

BEGIN
   mo_global.set_policy_context ('S', 204);
   inv_globals.set_org_id (207);
   fnd_global.apps_initialize (1005902, 50583, 401);
   DBMS_OUTPUT.put_line ('Creating Move Order');
   create_move_order (l_header_rec,
                      l_line_tbl,
                      x_return_status,
                      x_msg_data,
                      x_msg_count);

   IF x_return_status = 'S'
   THEN
      COMMIT;
      DBMS_OUTPUT.put_line ('Move Order Created');

      IF l_line_tbl.COUNT > 0
      THEN
         x_return_status := NULL;
         x_msg_data := NULL;
         x_msg_count := NULL;
         DBMS_OUTPUT.put_line ('Allocating Move Order');
         allocate_move_order (l_line_tbl,
                              x_return_status,
                              x_msg_data,
                              x_msg_count);

         IF x_return_status = 'S'
         THEN
            COMMIT;
            DBMS_OUTPUT.put_line ('Move Order Allocated');
            x_return_status := NULL;
            DBMS_OUTPUT.put_line ('Transacting Move Order');
            DBMS_OUTPUT.put_line (
               'l_header_rec.header_id :' || l_header_rec.header_id
            );
            transact_move_order (l_header_rec.header_id, x_return_status);

            IF x_return_status = 'S'
            THEN
               COMMIT;
               DBMS_OUTPUT.put_line ('Move Order Transacted');
            END IF;
         END IF;
      END IF;
   END IF;
END;

Wednesday, 19 August 2015

Inventory to GL link in R12

/* Formatted on 8/19/2015 6:31:42 PM (QP5 v5.240.12305.39446) */
SELECT DISTINCT glh.*
  FROM xla_transaction_entities_upg xte,
       xla_events xe,
       xla_distribution_links xdl,
       mtl_transaction_accounts mta,
       xla_ae_headers xah,
       xla_ae_lines xal,
       gl_import_references gir,
       gl_je_headers glh
 WHERE     1 = 1
       AND xte.source_id_int_1 = &transaction_id
       AND xte.entity_id = xe.entity_id
       AND mta.transaction_id = xte.source_id_int_1
       AND xdl.source_distribution_type = 'MTL_TRANSACTION_ACCOUNTS'
       AND xdl.source_distribution_id_num_1 = mta.inv_sub_ledger_id
       AND xdl.ae_header_id = xah.ae_header_id
       AND xal.ae_header_id = xdl.ae_header_id
       AND xal.ae_header_id = xah.ae_header_id
       AND gir.gl_sl_link_table = 'XLAJEL'
       AND gir.gl_sl_link_id = xal.gl_sl_link_id
       AND gir.je_header_id = glh.je_header_id;

Wednesday, 15 July 2015

Oracle Inventory: Defining Item (Item Master) in R12

Defining an Item (Item Master):

Navigate to the Inventory Super User responsibility
Items à Master Items window
Choose the Org (master)
This is the window where you need to enter all attributes of the item.
Enter the Item and Description field and Save your work.
You can manually assign the attributes navigating to all the tabs like Main, Inventory, Bills of Materials, etc.
Also you can apply a predefined item template on this item as per your business need.
So for copying the attribute
Go to, Tools à Copy From
In this case, I am copying the attributes from the Finished Good template.
Then click on Apply and then Done.
Now the new Item acquired all attributes as per the Finished Good template.
You can go to individual tabs and check and modify the attributes as per your need.

Main:

 

Inventory:

Check whether following attributes are checked or not
Inventory Item, Stockable, Transactable, Reservable

 

Bill of Materials:

 

Asset Management:

 

Costing:

 

Purchasing:

 

Receiving:

 

Physical Attribute:

 

General Planning:

 

MPS/MRP Planning:

 

Lead Time:

 

Work in Process:

 

Order Management:

 

Invoicing:

 

Process Manufacturing:

 

Services:

 

Web Option:

Check and modify the attributes and Save your work.