Powered By Blogger

Monday, September 17, 2012

Account Alias Issue Code

What is Account Alias Issue?

Account Alias as the name suggests is a Simplified Name for Account Combinations setup in GL.

Now normally in organizations, you need to throw materials away from the inventory in case material is unused or scrapped. So for this you use the Account Alias Issue Transactions.

Using Account Alias Issue transaction, you normally throw away materials and hence this reduces the stock.
The opposite of Account Alias issue is Miscellaneous receipt which you often use to increase material stock in Inventory.




Account Alias Setup is present in Inventory > Setup > Account Aliases


Our Requirement was the following :- 

The business created a Specific subinventory = INVADJ to which they will first do a subinventory transfer from any specific inventory from which they want to reduce the stock or throw away material.

Hence they would first do a Subinventory Transfer. Actually to be particular, we needed e-Signatures to sign-off the scrap amounts to throw away from the stock. Hence this step. You may directly reduce stock from any subinventory you like to.

You can easily achieve the Account Alias Transaction from Application. For those who need the code, it is here. Now remember, the ultimate destination for the transaction is MTL_MATERIAL_TRANSACTIONS.

Account Alias Issue Code

-- Get the Interface Transaction ID

SELECT mtl_material_transactions_s.NEXTVAL
     INTO l_transaction_interface_id
     FROM DUAL;

-- Get the Transaction type ID
SELECT transaction_type_id
     INTO l_trx_type_id
     FROM mtl_transaction_types
    WHERE transaction_type_name = 'Account alias issue';

-- Check if item is Lot Controlled / Serial Number Controlled

SELECT lot_control_code
         ,serial_number_control_code
     INTO l_lot_control_code
         ,l_serial_number_control_code
     FROM mtl_system_items_b
    WHERE inventory_item_id = l_inventory_item_id
      AND organization_id = l_organization_id;

INSERT INTO mtl_transactions_interface
               (transaction_header_id
               ,transaction_interface_id
               ,transaction_type_id
               ,transaction_uom
               ,transaction_date
               ,organization_id
               ,transaction_quantity
               ,last_update_date
               ,last_updated_by
               ,creation_date
               ,created_by
               ,transaction_mode
               ,process_flag
               ,source_header_id
               ,source_line_id
               ,source_code
               ,transaction_source_id
               --,transaction_source_name
   ,            lock_flag
               ,flow_schedule
               ,scheduled_flag
               ,inventory_item_id
               ,subinventory_code
               ,distribution_account_id
               --,transaction_cost
   ,            cost_type_id
               ,locator_id
               )
        VALUES (l_transaction_interface_id              -- transaction_header_id
               ,l_transaction_interface_id           -- transaction_interface_id
               ,l_trx_type_id                             -- transaction_type_id
               ,'EA'                             -- transaction_uom
               ,SYSDATE                           -- transaction_date
               ,225                             -- organization_id
               ,- 4              /* -- transaction_quantity // Please Note this has to be -ve as you are reducing qty from stock */ 
               ,SYSDATE                                      -- last_update_date
               ,1752                       -- last_updated_by = Niladri Banerjee
               ,SYSDATE                                         -- creation_date
               ,1752                            -- created_by = Niladri Banerjee
               ,3                    -- transaction_mode = BACKGROUND PROCESSING
               ,1                                                -- process_flag
               ,l_transaction_interface_id                   -- source_header_id
               ,l_transaction_interface_id                     -- source_line_id
               ,'SCRAP'                                           -- source_code
               ,60                                      -- transaction_source_id
               --,'SCRAP'                                -- transaction_source_name
   ,            2                                                   -- Lock_flag
               ,'Y'                                             -- flow_schedule
               ,2                                              -- scheduled_flag
               ,1701                         -- inventory_item_id
               ,'STORES'                         -- subinventory_code
   ,            1                                                /*-- cost_type_id // For Standard Costs. Check cst_cost_types for your cost you want*/
               ,929                                       -- locator_id // Get the inventory_location_id from mtl_item_locations_kfv where concatenated_segements = << Your Specific Locator>>
               );

-- If Item is Lot Controlled
IF  l_lot_control_code  = 2
THEN
INSERT INTO mtl_transaction_lots_interface
                  (transaction_interface_id
                  ,lot_number
                  ,transaction_quantity
                  ,last_update_date
                  ,last_updated_by
                  ,creation_date
                  ,created_by
                  ,product_transaction_id
                  ,primary_quantity
                  ,lot_expiration_date
                  )
           VALUES (
                   l_transaction_interface_id        -- transaction_interface_id
                  ,'L2345'                                    /* lot_number // Get the Lot Number from MTL_LOT_NUMBERS as per your requirement */
                  ,- (4)            -- transaction_quantity // Remember this has to be -ve 
                  ,SYSDATE                                   -- last_update_date
                  ,1752                    -- last_updated_by = Niladri Banerjee
                  ,SYSDATE                                      -- creation_date
                  ,1752                         -- created_by = Niladri Banerjee
                  ,l_transaction_interface_id          -- product_transaction_id
                  ,- 4               -- primary_quantity
                  ,l_lot_expiration_date                  /*-- lot_expiration_date // Get the Lot Expiry Date from MTL_LOT_NUMBERS as per your requirement*/
                  );
END IF;
-- Please note that an item can be both Lot and Serial Controlled together at the same time.
-- If item is Serial Controlled
IF l_serial_number_control_code > 1
THEN
INSERT INTO mtl_serial_numbers_interface
                            (transaction_interface_id
                           , last_update_date
                           , last_updated_by
                           , creation_date
                           , created_by
                           , fm_serial_number
                           , to_serial_number
                            )
                     VALUES (l_transaction_interface_id
                           , SYSDATE
                           , 1752 
                           , SYSDATE
                           , 1752
                           , 'SERIAL-123'
                           , 'SERIAL-123'
                            );
END IF;
COMMIT;

Now remember the Material Transaction Processor Runs in the Background to pick the transaction. In case you want to Invoke it from backend for the specific Interface Transaction ID, here is the code.

Declare the following variables 
   l_return_status               VARCHAR2 (10);
   l_errorcode                   NUMBER;
   l_msg_count                   NUMBER;
   l_msg_data                    VARCHAR2 (2000);
   l_trans_count                 NUMBER;

and use the following code to invoke transaction manager

l_return_value   :=
   inv_txn_manager_pub.process_transactions
                                   (p_api_version       => 1.0
                                   ,x_return_status     => l_return_status
                                   ,x_msg_count         => l_msg_count
                                   ,x_msg_data          => l_msg_data
                                   ,x_trans_count       => l_trans_count
                                   ,p_table             => 1
                                   ,p_header_id         => l_transaction_interface_id
                                   );
If l_return_status = 'E'
THEN
  -- Error
ELSE
  -- Success !!!
END IF;

From Application the inventory transaction processor can run in the following way

Go to Inventory > Setup > Transactions > Interface Managers and then Highlight "Material Transaction"



In case you successfully entered the data into interface tables but the transaction has not appeared in MTL_MATERIAL_TRANSACTIONS, then check for errors

SELECT error_explanation FROM MTL_TRANSACTIONS_INTERFACE WHERE transaction_interface_id = << Your Transaction Interface ID >>

This Completes the Account Alias Issue Transaction !!! Hope this helps !! Please write to me for any queries in the same blog post.


Wednesday, March 3, 2010

All About FNDLOAD

Sample Script Code for these Objects :
1 - Printer Styles
FNDLOAD apps/apps@seed115 O Y DOWNLOAD $FND_TOP/patch/115/import/afcppstl.lct file_name.ldt STYLE PRINTER_STYLE_NAME="printer style name"

2 - Lookups

FNDLOAD apps/apps@seed115 O Y DOWNLOAD $FND_TOP/patch/115/import/aflvmlu.lct file_name.ldt FND_LOOKUP_TYPE APPLICATION_SHORT_NAME="prod" LOOKUP_TYPE="lookup name"

3 - Descriptive Flexfield with all of specific Contexts

FNDLOAD apps/apps@seed115 O Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct file_name.ldt DESC_FLEX P_LEVEL=?COL_ALL:REF_ALL:CTX_ONE:SEG_ALL? APPLICATION_SHORT_NAME="prod" DESCRIPTIVE_FLEXFIELD_NAME="desc flex name" P_CONTEXT_CODE="context name"

4 - Key Flexfield Structures

FNDLOAD apps/apps@seed115 O Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct file_name.ldt KEY_FLEX P_LEVEL=?COL_ALL:FQL_ALL:SQL_ALL:STR_ONE:WFP_ALL:SHA_ALL:CVR_ALL:SEG_ALL? APPLICATION_SHORT_NAME="prod" ID_FLEX_CODE="key flex code" P_STRUCTURE_CODE="structure name"

5 - Concurrent Programs

FNDLOAD apps/apps@seed115 O Y DOWNLOAD $FND_TOP/patch/115/import/afcpprog.lct file_name.ldt PROGRAM APPLICATION_SHORT_NAME="prod" CONCURRENT_PROGRAM_NAME="concurrent name"

6 - Value Sets

FNDLOAD apps/apps@seed115 O Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct file_name.ldt VALUE_SET FLEX_VALUE_SET_NAME="value set name"

7 - Value Sets with values

FNDLOAD apps/apps@seed115 O Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct file_name.ldt VALUE_SET_VALUE FLEX_VALUE_SET_NAME="value set name"

8 - Profile Options

FNDLOAD apps/apps@seed115 O Y DOWNLOAD $FND_TOP/patch/115/import/afscprof.lct file_name.ldt PROFILE PROFILE_NAME="profile option" APPLICATION_SHORT_NAME="prod"

9 - Requset Group

FNDLOAD apps/apps@seed115 O Y DOWNLOAD $FND_TOP/patch/115/import/afcpreqg.lct file_name.ldt REQUEST_GROUP REQUEST_GROUP_NAME="request group" APPLICATION_SHORT_NAME="prod"

Request Group for one program

FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afcpreqg.lct wgt_wip_reports_rg.ldt REQUEST_GROUP REQUEST_GROUP_NAME="All GUI Reports" APPLICATION_SHORT_NAME="WIP" REQUEST_GROUP_UNIT UNIT_TYPE="P" UNIT_APP="WGT" UNIT_NAME="WGTSCRAPDR"

10 - Request Sets

FNDLOAD apps/apps@seed115 O Y DOWNLOAD $FND_TOP/patch/115/import/afcprset.lct file_name.ldt REQ_SET APPLICATION_SHORT_NAME="prod" REQUEST_SET_NAME="request set"

11 - Responsibilities

FNDLOAD apps/apps@seed115 O Y DOWNLOAD $FND_TOP/patch/115/import/afscursp.lct file_name.ldt FND_RESPONSIBILITY RESP_KEY="responsibility

12 - Menus

FNDLOAD apps/apps@seed115 O Y DOWNLOAD $FND_TOP/patch/115/import/afsload.lct file_name.ldt MENU MENU_NAME="menu_name"

13 Forms/Functions

FNDLOAD apps/apps@seed115 0 Y DOWNLOAD $FND_TOP/patch/115/import/affrmcus.lct file_name.ldt FND_FORM_CUSTOM_RULES The Upload syntax for all styles: FNDLOAD apps/apps@seed115 0 Y UPLOAD $FND_TOP/patch/115/import/affrmcus.lct file_name.ldt

14. User/Responsibilities

FNDLOAD apps/apps@seed115 0 Y DOWNLOAD @FND:patch/115/import/afscursp.lct file_name.ldt FND_USER Then UPLOAD FNDLOAD apps/apps@seed115 0 Y UPLOAD [UPLOAD_PARTIAL] @FND:patch/115/import/afscursp.lct file_name.ldt FND_USER []

For UPLOAD use UPLOAD_MODE = REPLACE and CUSTOM_MODE = FORCE