Quantcast
Channel: Oracle Maniacs' Notes » Modules
Viewing all 68 articles
Browse latest View live

Receivables Invoice Interface/Conversion

$
0
0

This article illustrates how to populate the Invoice interface tables and invoke Autoinvoice for importing customer invoices into Oracle Apps.

Tables used

ra_interface_lines_all

ra_customers

hz_customers_profiles

hz_party_sites

ra_cust_trx_types_all

ra_terms_tl

fnd_user

ra_addresses_all

gl_sets_of_books

Steps to run autoinvoce

  1. Populate the table ra_interface_lines with data as per script given elsewhere in this document
  2. In the interface option choose autoinvoice
  3. From auto invoice choose autoinvoice master program.
  4. No. of instances =1
  5. Invoice source = Batch source name
  6. Default date: Current date may be entered

One request id is generated and the request is executed. Check the report for any errors.

Query in the transaction options to ensure invoice has been entered

Navigation: Transactions > Transactions

Click on Line Items button

Close this screen to go back to the Transaction form. Click on Distributions button


2) The setup steps for AutoInvoice process is given in this article.

4) Check column user_id in the table FND_USER for created_by and last_updated_by fields.

Query for retrieving data from the back end regarding customer number, id, etc.

SELECT   ra_customers.party_id, ra_customers.customer_name, ra_customers.customer_number, hz_party_sites.party_site_number,
         ra_customers.customer_id, ra_addresses_all.address_id, ra_addresses_all.address1, ra_addresses_all.address2,
         ra_addresses_all.address3, ra_addresses_all.city, ra_addresses_all.postal_code, ra_addresses_all.state
    FROM ra_customers, hz_party_sites, ra_addresses_all
   WHERE ra_customers.party_id = hz_party_sites.party_id
     AND ra_addresses_all.party_location_id = hz_party_sites.location_id
     AND ra_addresses_all.org_id = 141
ORDER BY ra_customers.customer_number, ra_customers.customer_id, ra_customers.party_id, hz_party_sites.party_site_number

  
Insert script

The following fields should be populated  by the script.

INSERT INTO ra_interface_lines_all
            (amount,
             batch_source_name,
             conversion_date,
             conversion_rate,
             conversion_type,
             currency_code,
             cust_trx_type_id,
             description,
             interface_line_attribute1,
             interface_line_context,
             line_type,
             orig_system_bill_address_id,   --PARTY SITE ID
             orig_system_bill_customer_id,   --CUSTOMER ID
             term_id,
             trx_date,
             gl_date,
             created_by,
             creation_date,
             last_update_date,
             last_updated_by,
             trx_number,
             set_of_books_id
            )
     VALUES (20000,
             'Intercompany',
             TO_DATE ('06-SEP-06', 'DD-MON-RR'),
             1,
             'Corporate',
             'INR',
             1,
             'Invoice number',
             'Invoice number',
             'DFF name',
             'Line ',
             1124,
             7045,
             1001,
             4,
             TO_DATE ('30-JUN-06', 'DD-MON-RR'),
             TO_DATE ('30-JUN-06', 'DD-MON-RR'),
             0,
             TO_DATE ('06-SEP-06', 'DD-MON-RR'),
             TO_DATE ('06-SEP-06', 'DD-MON-RR'),
             0,
             'Invoice number',
             1001
            );

A sample interface program is given below

DECLARE
   /******************************************************************************

      Note:
      To Import Customer Open Balances follow this steps:-
      1.Create a DFF in the descriptive Segments 'Line Transaction Flexfield',
      set context as 'TEST' ,also select INTERFACE_LINE_ATTRIBUTE1 for pass the reference number.
      For that pass the 'TEST' value in the INTERFACE_LINE_CONTEXT and reference number
      in the INTERFACE_LINE_ATTRIBUTE1.This is mendatory because grouping rules.

      2.Create a Source(AR->SETUP>TRANSACTIONS->SOURCES), 'PROJECTS INOVOICE',
        type should be 'IMPORTED'

      3.Create a Transaction Types(AR->SETUP>TRANSACTIONS->TRANSACION TYPES), 'OPEN INVOICE''
        attach receivable and revenue account. Then attch this Transaction types in the Source.'

      Run the Auto Invoice Master Program which call the Auto Invoice Import and after both
      successfull request it send the data.

      *******************************************************************************/
   CURSOR c1
   IS
      SELECT customer_name, customer_number, bill_no, bill_date, bill_amt, description, rate, revenue_account, rev_ccid,
             receivable_account, rec_ccid
        FROM xx_cust_open_inv
       WHERE status IS NULL;

   p_error                       NUMBER;
   p_err_msg                     VARCHAR2 (200);
   p_amount                      NUMBER         := 0;
   i                             NUMBER         := 1;   --used as a counter
   p_interface_line_context      VARCHAR2 (100);
   p_interface_line_attribute8   VARCHAR2 (100);   --used as a grouping rule
   p_interface_line_attribute9   VARCHAR2 (100);   --used as a grouping rule
   p_party_id                    NUMBER;
   p_cust_account_id             NUMBER;
   p_bill_to_address             VARCHAR2 (200);
   p_ship_to_address             VARCHAR2 (200);
   p_bill_to_address_id          NUMBER;
   p_ship_to_address_id          NUMBER;
   RESULT                        BOOLEAN;
   p_item_id                     NUMBER;
   p_uom_code                    VARCHAR2 (150);
   p_unit_of_measure             VARCHAR2 (150);
   p_item_description            VARCHAR2 (240);
   v_seq                         NUMBER;
   p_party_name                  VARCHAR2 (240);
   p_message1                    VARCHAR2 (20);
   p_message                     VARCHAR2 (200);
BEGIN
   FOR c1_rec IN c1
   LOOP
      p_error := 0;

      BEGIN
         p_message1 := 'CUSTOMER ERROR';

         SELECT party_id
           INTO p_party_id
           FROM hz_parties
          WHERE UPPER (party_name) = UPPER (c1_rec.customer_name);

         p_message1 := 'CUST ACCOUNT ERROR';

         SELECT cust_account_id
           INTO p_cust_account_id
           FROM hz_cust_accounts
          WHERE party_id = p_party_id;

         p_message1 := 'BILL REF ERROR';

         SELECT orig_system_reference, cust_acct_site_id
           INTO p_bill_to_address, p_bill_to_address_id
           FROM hz_cust_acct_sites_all
          WHERE cust_account_id = p_cust_account_id AND bill_to_flag = 'P';

         p_message1 := 'SHIP REF ERROR';

         SELECT orig_system_reference
           INTO p_ship_to_address
           FROM hz_cust_acct_sites_all
          WHERE cust_account_id = p_cust_account_id AND ship_to_flag = 'P';
      EXCEPTION
         WHEN OTHERS
         THEN
            p_message := SUBSTR (SQLERRM,
                                 1,
                                 180
                                );

            UPDATE xx_cust_open_inv
               SET status = 'N',
                   error_meggage = p_message1 || p_message
             WHERE bill_no = c1_rec.bill_no;

            p_error := 1;
      END;   -- The specific record is left out and looped into the next record

      p_item_description := 'OPEN INVOICE';

      BEGIN
         p_message1 := 'HEADER ERROR';

         INSERT INTO ra_interface_lines_all
                     (interface_line_id,
                      description,
                      interface_line_context,
                      interface_line_attribute1,
                      interface_line_attribute2,
                      interface_line_attribute3,
                      interface_line_attribute4,
                      interface_line_attribute5,
                      interface_line_attribute6,
                      interface_line_attribute7,
                      interface_line_attribute8,
                      batch_source_name,
                      set_of_books_id,
                      line_type,
                      currency_code,
                      amount,
                      cust_trx_type_id,
                      term_id,
                      orig_system_bill_customer_id,
                      orig_system_bill_address_id,
                      orig_system_bill_address_ref,
                      orig_system_ship_address_id,
                      orig_system_ship_customer_id,
                      conversion_type,
                      conversion_rate,
                      trx_date,
                      gl_date,
                      quantity,
                      unit_selling_price,
                      acctd_amount,
                      interface_line_attribute9,
                      line_number,
                      comments,
                      created_by,
                      creation_date,
                      last_updated_by,
                      last_update_date,
                      last_update_login,
                      org_id
                     )
              VALUES (ra_customer_trx_lines_s.NEXTVAL,
                      p_item_description,
                      'TEST',
                      xx_open_cust_invoice_num.NEXTVAL,   --project number,
                      'DRAFT',   -- Draft Invoice Number
                      'AGREEMENT',   -- Agreement Number
                      'ORG',   -- Project Organization Number
                      'ABCD',   -- Project Manager
                      v_counter,   -- Line Number
                      'Type',   -- Type
                      'Line',   -- Line Type
                      'PROJECTS INVOICE',   -- Transaction Source Name
                      3004,   -- GL Set Of Books Id
                      'LINE',
                      'INR',
                      c1_rec.bill_amt,
                      1300,   -- Transaction Type Id
                      5,   -- Payment Terms Id
                      p_cust_account_id,
                      p_bill_to_address_id,
                      p_bill_to_address,
                      p_bill_to_address_id,
                      p_cust_account_id,
                      'User',   -- Exchange Rate Type
                      1,   -- Exchange Rate
                      SYSDATE,   -- Transaction Date
                      SYSDATE,   -- GL Date
                      1,
                      c1_rec.rate,
                      c1_rec.bill_amt,
                      c1_rec.bill_no,
                      1,
                      'INVOICES',   -- Comments Line--
                      0,
                      SYSDATE,
                      0,
                      SYSDATE,
                      -1,
                      123   -- Operating Unit Id
                     );

         p_message1 := 'REV ERROR';

         INSERT INTO ra_interface_distributions_all
                     (interface_distribution_id,
                      interface_line_id,
                      interface_line_context,
                      account_class,
                      amount,
                      code_combination_id,
                      acctd_amount,
                      interface_line_attribute9,
                      interface_line_attribute10,
                      created_by,
                      creation_date,
                      last_update_date,
                      last_updated_by,
                      last_update_login,
                      org_id
                     )
              VALUES (ra_cust_trx_line_gl_dist_s.NEXTVAL,
                      ra_customer_trx_lines_s.CURRVAL,
                      'Test',   -- Used as a grouping rule
                      'REV',
                      c1_rec.bill_amt,
                      c1_rec.rev_ccid,
                      c1_rec.bill_amt,
                      c1_rec.bill_no,
                      234,
                      0,
                      SYSDATE,
                      SYSDATE,
                      0,
                      -1,
                      123   -- Operating Unit Id
                     );

         p_message1 := 'REC ERROR';

         INSERT INTO ra_interface_distributions_all
                     (interface_distribution_id, interface_line_id, interface_line_context, account_class, amount, PERCENT,
                      code_combination_id, acctd_amount, interface_line_attribute9, interface_line_attribute10, created_by, creation_date,
                      last_update_date, last_updated_by, last_update_login, org_id
                     )
              VALUES (ra_cust_trx_line_gl_dist_s.NEXTVAL, ra_customer_trx_lines_s.CURRVAL, 'Test', 'REC', c1_rec.bill_amt, 100,
                      c1_rec.rec_ccid, c1_rec.bill_amt, c1_rec.bill_no, 234,   -- User Id
                                                                            0, SYSDATE,
                      SYSDATE, 0, -1, 123
                     );
      EXCEPTION
         WHEN OTHERS
         THEN
            p_message := SUBSTR (SQLERRM,
                                 1,
                                 180
                                );

            UPDATE xx_cust_open_inv
               SET status = 'N',
                   error_meggage = p_message1 || p_message
             WHERE bill_no = c1_rec.bill_no;
      END;

      fnd_global.apps_initialize (user_id                       => 234,
                                  resp_id                       => 50237,
                                  resp_appl_id                  => 222
                                 );

     -- Execute the Invoice import program
      reqno :=
         fnd_request.submit_request (application                   => 'SQLAR',
                                     program                       => 'RAXMTR',
                                     start_time                    => SYSDATE,
                                     argument1                     => '1',
                                     argument2                     => 'TESTSCP',
                                     argument3                     => '30-Sep-2005'
                                    );
   END LOOP;
END;

Cheers!



AR Receipts Interface/Conversion

$
0
0

Sample interface code

Create Receipt

-- Create a receipt
DECLARE
   p_return_status   VARCHAR2 (1000);
   x_return_status   VARCHAR2 (4000);
   x_message_count   NUMBER;
   x_msg_data        VARCHAR2 (4000);
   p_cr_id           NUMBER;
BEGIN
   fnd_global.apps_initialize (user_id                       => 1097,
                               resp_id                       => 50239,
                               resp_appl_id                  => 222
                              );

   -- Create the receipt
   ar_receipt_api_pub.create_cash (
                                   -- Standard API parameters.
                                   p_api_version                 => 1,
                                   x_return_status               => x_return_status,
                                   x_msg_count                   => x_message_count,
                                   x_msg_data                    => x_msg_data,
                                    -- Receipt info. parameters
                                   -- p_usr_currency_code       IN  VARCHAR2 DEFAULT NULL, --the translated currency code
                                   p_currency_code               => 'INR',
                                   -- p_usr_exchange_rate_type  IN  VARCHAR2 DEFAULT NULL,
                                   -- p_exchange_rate_type      IN  VARCHAR2 DEFAULT NULL,
                                   -- p_exchange_rate           IN  NUMBER   DEFAULT NULL,
                                   -- p_exchange_rate_date      IN  DATE     DEFAULT NULL,
                                   p_amount                      => 50000,
                                   --p_factor_discount_amount  IN  NUMBER   DEFAULT NULL,
                                   p_receipt_number              => 'PDC/1',
                                   p_receipt_date                => SYSDATE,
                                   p_gl_date                     => SYSDATE,
                                   --p_maturity_date           IN  DATE     DEFAULT NULL,
                                   --p_postmark_date           IN  DATE     DEFAULT NULL,
                                   p_customer_id                 => 2046,
                                   -- p_customer_name           IN  VARCHAR2 DEFAULT NULL,
                                   -- p_customer_number         IN VARCHAR2  DEFAULT NULL,
                                   -- p_customer_bank_account_id IN NUMBER   DEFAULT NULL,
                                   -- p_customer_bank_account_num   IN  VARCHAR2  DEFAULT NULL,
                                   -- p_customer_bank_account_name  IN  VARCHAR2  DEFAULT NULL,
                                   -- p_location                 IN  VARCHAR2 DEFAULT NULL,
                                   p_customer_site_use_id        => 1072,
                                   -- p_customer_receipt_reference IN  VARCHAR2  DEFAULT NULL,
                                   -- p_override_remit_account_flag IN  VARCHAR2 DEFAULT NULL,
                                   -- p_remittance_bank_account_id  IN  NUMBER  DEFAULT NULL,
                                   -- p_remittance_bank_account_num  IN VARCHAR2 DEFAULT NULL,
                                   -- p_remittance_bank_account_name IN VARCHAR2 DEFAULT NULL,
                                   p_deposit_date                => SYSDATE,
                                   p_receipt_method_id           => 1000,
                                   -- p_receipt_method_name      IN  VARCHAR2 DEFAULT NULL,
                                   -- p_doc_sequence_value       IN  NUMBER   DEFAULT NULL,
                                   -- p_ussgl_transaction_code   IN  VARCHAR2 DEFAULT NULL,
                                   -- p_anticipated_clearing_date IN DATE     DEFAULT NULL,
                                   -- p_called_from               IN VARCHAR2 DEFAULT NULL,
                                   -- p_attribute_rec         IN  attribute_rec_type DEFAULT attribute_rec_const,
                                   -- ******* Global Flexfield parameters *******
                                   -- p_global_attribute_rec  IN global_attribute_rec_type DEFAULT global_attribute_rec_const,
                                   -- p_comments             IN VARCHAR2 DEFAULT NULL,
                                   --   ***  Notes Receivable Additional Information  ***
                                   -- p_issuer_name                  IN VARCHAR2  DEFAULT NULL,
                                   -- p_issue_date                   IN DATE   DEFAULT NULL,
                                   -- p_issuer_bank_branch_id        IN NUMBER  DEFAULT NULL,
                                   -- ** OUT NOCOPY variables
                                   p_cr_id                       => p_cr_id
                                  );
   DBMS_OUTPUT.put_line (x_return_status || CHR (10) || x_msg_data);
END;

Reverse a receipt

-- Reverse a receipt

DECLARE
   p_return_status   VARCHAR2 (1000);
   x_return_status   VARCHAR2 (4000);
   x_message_count   NUMBER;
   x_msg_data        VARCHAR2 (4000);
   p_cr_id           NUMBER;

   CURSOR c1
   IS
      SELECT receipt_number, cash_receipt_id, customer_id, customer_site_use_id, attribute1, attribute2, amount
        FROM ar_cash_receipts_v
       WHERE payment_method_dsp = 'PDC'
         AND receipt_status <> 'REV'
         AND attribute1 IS NOT NULL
         AND attribute2 IS NOT NULL
         AND TO_DATE (attribute2) <= TRUNC (SYSDATE) + 3;   -- Should Be Sysdate Only
BEGIN
   fnd_global.apps_initialize (user_id                       => 1097,
                               resp_id                       => 50239,
                               resp_appl_id                  => 222
                              );

   FOR c1_rec IN c1
   LOOP
      ar_receipt_api_pub.REVERSE (
                                  -- Standard API parameters.
                                  p_api_version                 => 1,
                                  x_return_status               => x_return_status,
                                  x_msg_count                   => x_message_count,
                                  x_msg_data                    => x_msg_data,
                                  -- Receipt reversal related parameters
                                  p_cash_receipt_id             => c1_rec.cash_receipt_id,
                                  p_receipt_number              => c1_rec.receipt_number,
                                  p_reversal_category_code      => 'REV',
                                  --      p_reversal_category_name  IN ar_lookups.meaning%TYPE DEFAULT NULL,
                                  p_reversal_gl_date            => TO_DATE (c1_rec.attribute2),
                                  p_reversal_date               => TO_DATE (c1_rec.attribute2),
                                  p_reversal_reason_code        => 'PDC',
                                  --p_reversal_reason_name    IN ar_lookups.meaning%TYPE DEFAULT NULL,
                                  p_reversal_comments           => 'Test',
                                  --      p_called_from             IN VARCHAR2 DEFAULT NULL,
                                  --      p_attribute_rec           IN attribute_rec_type DEFAULT attribute_rec_const,
                                  --p_global_attribute_rec    IN global_attribute_rec_type_upd DEFAULT global_attribute_rec_upd_cons
                                  --      p_global_attribute_rec    IN global_attribute_rec_type DEFAULT global_attribute_rec_const,
                                  p_cancel_claims_flag          => 'Y'
                                 );

      IF x_return_status = 'S'
      THEN
         -- Call Create API
         ar_receipt_api_pub.create_cash (
                                         -- Standard API parameters.
                                         p_api_version                 => 1,
                                         x_return_status               => x_return_status,
                                         x_msg_count                   => x_message_count,
                                         x_msg_data                    => x_msg_data,
                                         -- Receipt info. parameters
                                         -- p_usr_currency_code       IN  VARCHAR2 DEFAULT NULL, --the translated currency code
                                         p_currency_code               => 'INR',
                                         -- p_usr_exchange_rate_type  IN  VARCHAR2 DEFAULT NULL,
                                         -- p_exchange_rate_type      IN  VARCHAR2 DEFAULT NULL,
                                         -- p_exchange_rate           IN  NUMBER   DEFAULT NULL,
                                         -- p_exchange_rate_date      IN  DATE     DEFAULT NULL,
                                         p_amount                      => c1_rec.amount,
                                         --p_factor_discount_amount  IN  NUMBER   DEFAULT NULL,
                                         p_receipt_number              => c1_rec.receipt_number,
                                         p_receipt_date                => TO_DATE (c1_rec.attribute2),
                                         p_gl_date                     => TO_DATE (c1_rec.attribute2),
                                         --p_maturity_date           IN  DATE     DEFAULT NULL,
                                         --p_postmark_date           IN  DATE     DEFAULT NULL,
                                         p_customer_id                 => c1_rec.customer_id,
                                         -- p_customer_name           IN  VARCHAR2 DEFAULT NULL,
                                         -- p_customer_number         IN VARCHAR2  DEFAULT NULL,
                                         -- p_customer_bank_account_id IN NUMBER   DEFAULT NULL,
                                         -- p_customer_bank_account_num   IN  VARCHAR2  DEFAULT NULL,
                                         -- p_customer_bank_account_name  IN  VARCHAR2  DEFAULT NULL,
                                         -- p_location                 IN  VARCHAR2 DEFAULT NULL,
                                         p_customer_site_use_id        => c1_rec.customer_site_use_id,
                                         -- p_customer_receipt_reference IN  VARCHAR2  DEFAULT NULL,
                                         -- p_override_remit_account_flag IN  VARCHAR2 DEFAULT NULL,
                                         -- p_remittance_bank_account_id  IN  NUMBER  DEFAULT NULL,
                                         -- p_remittance_bank_account_num  IN VARCHAR2 DEFAULT NULL,
                                         -- p_remittance_bank_account_name IN VARCHAR2 DEFAULT NULL,
                                         p_deposit_date                => TO_DATE (c1_rec.attribute2),
                                         p_receipt_method_id           => c1_rec.attribute1,
                                         -- p_receipt_method_name      IN  VARCHAR2 DEFAULT NULL,
                                         -- p_doc_sequence_value       IN  NUMBER   DEFAULT NULL,
                                         -- p_ussgl_transaction_code   IN  VARCHAR2 DEFAULT NULL,
                                         -- p_anticipated_clearing_date IN DATE     DEFAULT NULL,
                                         -- p_called_from               IN VARCHAR2 DEFAULT NULL,
                                         -- p_attribute_rec         IN  attribute_rec_type DEFAULT attribute_rec_const,
                                         -- ******* Global Flexfield parameters *******
                                         -- p_global_attribute_rec  IN global_attribute_rec_type DEFAULT global_attribute_rec_const,
                                         -- p_comments             IN VARCHAR2 DEFAULT NULL,
                                         --   ***  Notes Receivable Additional Information  ***
                                         -- p_issuer_name                  IN VARCHAR2  DEFAULT NULL,
                                         -- p_issue_date                   IN DATE   DEFAULT NULL,
                                         -- p_issuer_bank_branch_id        IN NUMBER  DEFAULT NULL,
                                         --   ** OUT NOCOPY variables
                                         p_cr_id                       => p_cr_id
                                        );
      END IF;
   END LOOP;
END;

Cancel a receipt

-- Cancel a receipt

DECLARE
   p_return_status   VARCHAR2 (1000);
   x_return_status   VARCHAR2 (4000);
   x_message_count   NUMBER;
   x_msg_data        VARCHAR2 (4000);
BEGIN
   fnd_global.apps_initialize (user_id => 1097,
                               resp_id => 50239,
                               resp_appl_id => 222
                              );
   ar_receipt_api_pub.REVERSE (
                               -- Standard API parameters.
                               p_api_version                 => 1,
                               x_return_status               => x_return_status,
                               x_msg_count                   => x_message_count,
                               x_msg_data                    => x_msg_data,
                               -- Receipt reversal related parameters
                               p_cash_receipt_id             => 1129,
                               p_receipt_number              => 'PDC/1',
                               p_reversal_category_code      => 'REV',
                               -- p_reversal_category_name  IN ar_lookups.meaning%TYPE DEFAULT NULL,
                               p_reversal_gl_date            => SYSDATE,
                               p_reversal_date               => SYSDATE,
                               p_reversal_reason_code        => 'PDC',
                               -- p_reversal_reason_name    IN ar_lookups.meaning%TYPE DEFAULT NULL,
                               p_reversal_comments           => 'Test',
                               -- p_called_from             IN VARCHAR2 DEFAULT NULL,
                               -- p_attribute_rec           IN attribute_rec_type DEFAULT attribute_rec_const,
                               -- p_global_attribute_rec    IN global_attribute_rec_type_upd DEFAULT global_attribute_rec_upd_cons
                               -- p_global_attribute_rec    IN global_attribute_rec_type DEFAULT global_attribute_rec_const,
                               p_cancel_claims_flag          => 'Y'
                              );
   DBMS_OUTPUT.put_line (x_return_status || CHR (10) || x_msg_data);
END;

Cheers!


Customer Interface/Conversion

$
0
0

Sample interface or conversion code for customers:

DECLARE
   l_orig_system_address_ref     VARCHAR2 (240);
   l_site_use_code               VARCHAR2 (20);
   l_primary_site_use_flag       VARCHAR2 (1);
   l_count                       NUMBER;
   l_category_code               VARCHAR2 (30);
   l_class_code                  VARCHAR2 (30);
   l_organization_id             NUMBER;
   l_country                     VARCHAR (2);
   l_by                          NUMBER;
   l_orig_system_telephone_ref   VARCHAR2 (240);
   l_bill_to_orig_address_ref    VARCHAR2 (240);
   process_next_record           EXCEPTION;
   l_error_count                 NUMBER;
   l_load_count                  NUMBER;
   l_error_code                  NUMBER;
   l_error_name                  VARCHAR2 (50);
   l_error_desc                  VARCHAR2 (200);
   l_site_use_bill               VARCHAR2 (25);
   l_site_use_ship               VARCHAR2 (25);
   l_customer_number             VARCHAR2 (20);
   l_cust_num                    NUMBER;
   l_los                         VARCHAR2 (25);
   l_los2                        VARCHAR2 (25);

   CURSOR c1
   IS
      SELECT DISTINCT los,
					  entity,
					  region,
					  inter_territory,
					  customer_number,
					  customer_name,
					  client_type,
					  service_partner,
					  addr_line1,
                      addr_line2,
					  city,
					  state,
					  country,
					  postalcode,
                      -- Orig_system_Reference orig_system_customer_ref,
                      customer_name || '-11111' orig_system_customer_ref,
                      --customer_name orig_system_customer_ref,
                      --customer_name||'-'||los||'-'||region||'-'||addr_line1||'99999' orig_system_address_ref,
                      customer_name || '-22222-' || addr_line1 orig_system_address_ref, contact_first_name, contact_last_name,
                      contact_designation,
					  SUBSTR (contact_telephone,
                                                   1,
                                                   25
                                                  ) contact_telephone,
					  contact_mobile,
					  contact_fax,
					  contact_pager,
					  contact_email,
                      customer_name || '-' || addr_line1 || '-' || contact_first_name || '-' || contact_last_name orig_system_contact_ref,
                      org_id
                 FROM xx_customer_master
                WHERE interface_flag IS NULL;

   FUNCTION get_country_code (p_country IN VARCHAR2)
      RETURN VARCHAR2
   IS
   BEGIN
      SELECT territory_code
        INTO l_country
        FROM fnd_territories_vl
       WHERE territory_short_name = p_country;

      RETURN l_country;
   EXCEPTION
      WHEN NO_DATA_FOUND
      THEN
         l_country := NULL;
         l_error_code := SQLCODE;
         l_error_name := 'get_country_code -' || p_country;
         l_error_desc := SQLERRM;
         RAISE process_next_record;
      WHEN OTHERS
      THEN
         l_country := NULL;
         l_error_code := SQLCODE;
         l_error_name := 'get_country_code -' || p_country;
         l_error_desc := SQLERRM;
         RAISE process_next_record;
   END;
BEGIN
   l_error_count := 0;
   l_load_count := 0;
   l_by := fnd_global.user_id;

   FOR r_cust IN c1
   LOOP
      BEGIN
         l_count := 0;
         l_primary_site_use_flag := 'Y';
         l_country := get_country_code (r_cust.country);
         --l_country := 'IN';
         l_organization_id := 82;

         BEGIN
            l_error_code := 0;
            l_error_name := NULL;
            l_error_desc := NULL;
            l_site_use_code := 'BILL_TO';

            INSERT INTO ra_customers_interface_all
                        (orig_system_customer_ref,
						 orig_system_address_ref,
						 site_use_code,
						 primary_site_use_flag,
						 insert_update_flag,
                         customer_name,
						 customer_status,
						 customer_type,
                         address1,
						 address2,
						 city,
						 state,
						 postal_code,
						 country,
						 last_updated_by,
						 last_update_date,
                         created_by,
						 creation_date,
						 org_id,
						 customer_attribute_category,
						 customer_attribute1,
						 customer_attribute2,
                         customer_attribute3,
						 customer_attribute4,
						 LOCATION
                        )
                 VALUES (r_cust.orig_system_customer_ref,
						 r_cust.orig_system_address_ref,
						 l_site_use_code,
						 'Y',   -- l_primary_site_use_flag
                         'I',
                         SUBSTR (r_cust.customer_name,
                                 1,
                                 50
                                ),
						'A',
						DECODE (r_cust.client_type,
                                                'Domestic', 'D',
                                                'Foreign', 'F',
                                                NULL
                                               ),
                        r_cust.addr_line1,
						r_cust.addr_line2,
						r_cust.city,
						r_cust.state,
						r_cust.postalcode,
						l_country,
						l_by,
						SYSDATE,
                        l_by,
						SYSDATE,
						l_organization_id,
						'Addl Customer Information',
						r_cust.entity,
						r_cust.region,
                        DECODE (r_cust.inter_territory,
                                 'Yes', 'Y',
                                 'No', 'N',
                                 NULL
                                ),
						r_cust.service_partner,
						l_site_use_bill
                        );

            COMMIT;
         EXCEPTION
            WHEN OTHERS
            THEN
               l_error_code := SQLCODE;
               l_error_name := 'Insert into ra_customers_interface_all - BILL_TO';
               l_error_desc := SUBSTR (SQLERRM,
                                       1,
                                       150
                                      );

               UPDATE xx_customer_master
                  SET status = l_error_name || '-' || l_error_desc
                WHERE customer_number = r_cust.customer_number;
         END;

         l_site_use_code := 'SHIP_TO';

         BEGIN
            l_error_code := 0;
            l_error_name := NULL;
            l_error_desc := NULL;

            INSERT INTO ra_customers_interface_all
                        (orig_system_customer_ref,
						 orig_system_address_ref,
						 bill_to_orig_address_ref,
						 site_use_code,
                         primary_site_use_flag,
						 insert_update_flag,
						 customer_name,
						 customer_status,
                         customer_type,
						 address1,
						 address2,
                         city,
						 state,
						 postal_code,
						 country,
						 last_updated_by,
						 last_update_date,
						 created_by,
						 creation_date,
						 org_id,
                         customer_attribute_category,
						 customer_attribute1,
						 customer_attribute2,
                         customer_attribute3,
						 customer_attribute4
                        )
                 VALUES (r_cust.orig_system_customer_ref,
						 r_cust.orig_system_address_ref,
						 r_cust.orig_system_address_ref,
						 l_site_use_code,
                         'Y',   --l_primary_site_use_flag,
                         'I',
						 SUBSTR (r_cust.customer_name,
                                          1,
                                          50
                                         ),
						 'A',
                         DECODE (r_cust.client_type,
                                 'Domestic', 'D',
                                 'Foreign', 'F',
                                 NULL
                                ),
						 r_cust.addr_line1,
						 r_cust.addr_line2,
                         r_cust.city,
						 r_cust.state,
						 r_cust.postalcode,
						 l_country,
						 l_by,
						 SYSDATE,
						 l_by,
						 SYSDATE,
						 l_organization_id,
                         'Addl Customer Information',
						 r_cust.entity,
						 r_cust.region,
                         DECODE (r_cust.inter_territory,
                                 'Yes', 'Y',
                                 'No', 'N',
                                 NULL
                                ),
						 r_cust.service_partner
                        );

            COMMIT;
         EXCEPTION
            WHEN OTHERS
            THEN
               l_error_code := SQLCODE;
               l_error_name := 'Insert into ra_customers_interface_all - SHIP_TO';
               l_error_desc := SUBSTR (SQLERRM,
                                       1,
                                       150
                                      );

               UPDATE xx_customer_master
                  SET status = l_error_name || '-' || l_error_desc
                WHERE customer_number = r_cust.customer_number;
         END;

         BEGIN
            l_error_code := 0;
            l_error_name := NULL;
            l_error_desc := NULL;
            l_orig_system_telephone_ref := r_cust.customer_name || r_cust.addr_line1 || '-' || r_cust.contact_telephone || 'PHONE';

            /*

            RA_CONTACT_PHONES_INTERFACE IS A VIEW, THOUGH IT IS INSERTING DATA IN
            THAT TABLE BUT DATA CAN NOT BE SEEN IN THAT TABLE, DATA ACTUALLY
            POPULATED IN THE 'RA_CONTACT_PHONES_INT_ALL' TABLE, WHERE THE DATA
            CAN BE SEEN.

            TELEPHONE TYPE AND DESIGNATION SHOULD BE DEFINED IN THE LOOK_UP TABLE
            */
            INSERT INTO ra_contact_phones_interface
                        (orig_system_address_ref,
						 orig_system_customer_ref,
						 orig_system_telephone_ref,
                         orig_system_contact_ref,
						 insert_update_flag,
						 telephone,
						 telephone_type,
                         contact_first_name,
						 contact_last_name,
                         contact_job_title,
						 email_address,
						 last_updated_by,
						 last_update_date,
						 created_by,
						 creation_date,
						 org_id
                        )
                 VALUES (r_cust.orig_system_address_ref,
						 r_cust.orig_system_customer_ref,
						 l_orig_system_telephone_ref,
                         r_cust.orig_system_contact_ref,
						 'I',
						 SUBSTR (r_cust.contact_telephone, 1, 25),
						 'GEN',
                         NVL (SUBSTR (r_cust.contact_first_name,
                                      1,
                                      40
                                     ), 'XX'),
						 NVL (SUBSTR (r_cust.contact_last_name,
                                                            1,
                                                            50
                                                           ), 'YY'),
                         SUBSTR (r_cust.contact_designation,
                                 1,
                                 50
                                ),
						 r_cust.contact_email,
						 l_by,
						 SYSDATE,
						 l_by,
						 SYSDATE,
						 l_organization_id
                        );

            COMMIT;
         EXCEPTION
            WHEN OTHERS
            THEN
               l_error_code := SQLCODE;
               l_error_name := 'Telephone insert';
               l_error_desc :=
                     r_cust.contact_telephone
                  || '-'
                  || r_cust.contact_first_name
                  || '-'
                  || r_cust.contact_last_name
                  || '-'
                  || r_cust.contact_designation
                  || '-'
                  || r_cust.contact_email;

               UPDATE xx_customer_master
                  SET status = l_error_name || '-' || l_error_desc
                WHERE customer_number = r_cust.customer_number;
         END;

         IF r_cust.contact_mobile IS NOT NULL
         THEN
            DBMS_OUTPUT.put_line ('Mobile : begin');
            l_orig_system_telephone_ref :=
                  r_cust.customer_name
               || '-'
               || r_cust.los
               || '-'
               || r_cust.region
               || '-'
               || r_cust.addr_line1
               || '-'
               || r_cust.contact_first_name
               || '-'
               || r_cust.contact_last_name
               || '-'
               || r_cust.contact_mobile
               || 'MOBILE';

            INSERT INTO ra_contact_phones_interface
                        (orig_system_customer_ref,
						 orig_system_telephone_ref,
						 orig_system_contact_ref,
						 insert_update_flag,
                         telephone,
						 telephone_type,
						 contact_first_name,
                         contact_last_name,
						 contact_job_title,
                         email_address,
						 last_updated_by,
						 last_update_date,
						 created_by,
						 creation_date,
						 org_id
                        )
                 VALUES (r_cust.orig_system_customer_ref,
						 l_orig_system_telephone_ref,
						 r_cust.orig_system_contact_ref,
						 'I',
                         SUBSTR (r_cust.contact_mobile,
                                 1,
                                 25
                                ),
						 'MOBILE',
						 NVL (SUBSTR (r_cust.contact_first_name,
                                                          1,
                                                          40
                                                         ), 'XX'),
                         NVL (SUBSTR (r_cust.contact_last_name,
                                      1,
                                      50
                                     ), 'YY'),
						 SUBSTR (r_cust.contact_designation,
                                                       1,
                                                       50
                                                      ),
                         r_cust.contact_email,
						 l_by,
						 SYSDATE,
						 l_by,
						 SYSDATE,
						 l_organization_id
                        );

            DBMS_OUTPUT.put_line ('Mobile : end');
         END IF;

         IF r_cust.contact_fax IS NOT NULL
         THEN
            DBMS_OUTPUT.put_line ('Fax : begin');
            l_orig_system_telephone_ref :=
                  r_cust.customer_name
               || '-'
               || r_cust.los
               || '-'
               || r_cust.region
               || '-'
               || r_cust.addr_line1
               || '-'
               || r_cust.contact_first_name
               || '-'
               || r_cust.contact_last_name
               || '-'
               || r_cust.contact_fax
               || 'FAXX';

            INSERT INTO ra_contact_phones_interface
                        (orig_system_customer_ref,
						 orig_system_telephone_ref,
						 orig_system_contact_ref,
						 insert_update_flag,
                         telephone,
						 telephone_type,
						 contact_first_name,
                         contact_last_name,
						 contact_job_title,
                         email_address,
						 last_updated_by,
						 last_update_date,
						 created_by,
						 creation_date,
						 org_id
                        )
                 VALUES (r_cust.orig_system_customer_ref,
						 l_orig_system_telephone_ref,
						 r_cust.orig_system_contact_ref,
						 'I',
                         SUBSTR (r_cust.contact_fax,
                                 1,
                                 25
                                ),
						 'FAX',
						 NVL (SUBSTR (r_cust.contact_first_name,
                                                       1,
                                                       40
                                                      ), 'XX'),
                         NVL (SUBSTR (r_cust.contact_last_name,
                                      1,
                                      50
                                     ), 'YY'),
						 SUBSTR (r_cust.contact_designation,
                                                       1,
                                                       50
                                                      ),
                         r_cust.contact_email,
						 l_by,
						 SYSDATE,
						 l_by,
						 SYSDATE,
						 l_organization_id
                        );

            DBMS_OUTPUT.put_line ('Fax : end');
         END IF;
      EXCEPTION
         WHEN OTHERS
         THEN
            l_error_code := SQLCODE;
            l_error_name := 'Insert into ra_contact_phones_interface';
            l_error_desc := SUBSTR (SQLERRM,
                                    1,
                                    200
                                   );
            RAISE process_next_record;
      END;

      l_count := l_count + 1;

      BEGIN
         l_error_code := 0;
         l_error_name := NULL;
         l_error_desc := NULL;

         INSERT INTO ra_customer_profiles_interface
                     (orig_system_customer_ref,
                      -- ORIG_SYSTEM_ADDRESS_REF,
                      insert_update_flag,
					  customer_profile_class_name,
					  credit_hold,
					  last_updated_by,
                      last_update_date,
					  created_by,
					  creation_date
                     )
              VALUES (r_cust.orig_system_customer_ref,
                      -- r_cust.orig_system_address_ref,
                      'I',
					  'DEFAULT',
					  'N',
					  l_by,
                      SYSDATE,
					  l_by,
					  SYSDATE
                     );

         COMMIT;
         l_load_count := l_load_count + 1;
      EXCEPTION
         WHEN OTHERS
         THEN
            l_error_code := SQLCODE;
            l_error_name := 'Insert into ra_customer_profiles_interface';
            l_error_desc := SUBSTR (SQLERRM,
                                    1,
                                    150
                                   );

            UPDATE xx_customer_master
               SET status = l_error_name || '-' || l_error_desc
             WHERE customer_number = r_cust.customer_number;

            COMMIT;
      END;

      BEGIN
         l_error_code := 0;
         l_error_name := NULL;
         l_error_desc := NULL;

         INSERT INTO ra_customer_banks_interface
                     (orig_system_customer_ref,
					  orig_system_address_ref,
					  primary_flag,
					  start_date,
					  last_updated_by,
					  last_update_date,
                      created_by,
					  creation_date,
					  bank_account_name,
					  bank_account_currency_code,
					  bank_account_num,
					  bank_name,
                      bank_branch_name
                     )
              VALUES (r_cust.orig_system_customer_ref,
					  r_cust.orig_system_address_ref,
					  'Y',
					  SYSDATE,
					  0,
					  SYSDATE,
                      0,
					  SYSDATE,
					  'Dummy-account',
					  'INR',
					  'Dummy-number',
					  'Dummy-Bank',
                      'Dummy-Branch'
                     );

         COMMIT;
         l_load_count := l_load_count + 1;

         UPDATE xx_customer_master
            SET status = 'SUCCESFUL'
          WHERE customer_number = r_cust.customer_number;
      EXCEPTION
         WHEN OTHERS
         THEN
            l_error_code := SQLCODE;
            l_error_name := 'Insert into RA_CUSTOMER_BANKS_INTERFACE';
            l_error_desc := SUBSTR (SQLERRM,
                                    1,
                                    150
                                   );

            UPDATE xx_customer_master
               SET status = l_error_name || '-' || l_error_desc
             WHERE customer_number = r_cust.customer_number;

            COMMIT;
      END;
   END LOOP;
END;

Cheers!


Item Interface/Conversion

$
0
0

Sample item conversion interface and/or conversion code

PROCEDURE PWC_INV_ITEM_UPLOAD_WITHORG IS

CURSOR C1 IS
SELECT     SEGMENT1,
           --SEGMENT2,
           --SEGMENT3,
           --SEGMENT4,
           --SEGMENT5,
           DESCRIPTION,
           UOM, -- UNIT OF MEASURE
           INV_CATEGORY_SET,
           PO_CATEGORY_SET,
           MODVAT_FLAG,
           EXCISE_FLAG,
           ITEM_CLASS,
           SU1_ORG,
           SU2_ORG,
           DGPP_ORG,
           PRODUCT_CATEGORY,
           EXCISE_CATEGORY,
           OLD_ITEM_CODE,
           ROWID           ROWXX
FROM   XX_ITEM_MASTER_TEMP
WHERE  STATUS IS NULL
AND    SEGMENT1 NOT IN (
           SELECT SEGMENT1
           FROM   MTL_SYSTEM_ITEMS
                            )
           AND    SEGMENT1 NOT IN
                      (
                   SELECT SEGMENT1
                   FROM   PWC_ITEM_MASTER_TEMP
                   HAVING COUNT(*) > 1
                   GROUP BY SEGMENT1
                   );

PL_UOM_CODE     MTL_UNITS_OF_MEASURE.UNIT_OF_MEASURE%TYPE;
PL_INSERT         BOOLEAN;
PL_MESSAGE     VARCHAR2(200);
P_COUNT NUMBER:=4;
P_ORG_CODE VARCHAR2(10);

BEGIN
FOR C1_REC IN C1
LOOP

        PL_MESSAGE:='RECORD INSERTED';

        BEGIN
                 SELECT     UNIT_OF_MEASURE
                 INTO       PL_UOM_CODE
                 FROM       MTL_UNITS_OF_MEASURE
                 WHERE      UOM_CODE = C1_REC.UOM
                 AND        DISABLE_DATE IS NULL;

                 PL_INSERT:=TRUE;

        EXCEPTION
            WHEN OTHERS
                THEN
                        PL_INSERT:=FALSE;
                        PL_MESSAGE:='ERROR : CHECK THE UOM';
        END;

IF PL_INSERT
THEN
 BEGIN
     --- insert into item master org -----

        INSERT INTO MTL_SYSTEM_ITEMS_INTERFACE(
                   LAST_UPDATE_DATE,
                   CREATION_DATE,
                   ORGANIZATION_CODE,
                   LAST_UPDATED_BY,
                   CREATED_BY,
                   LIST_PRICE_PER_UNIT,
                   DAYS_EARLY_RECEIPT_ALLOWED,
                   DAYS_LATE_RECEIPT_ALLOWED,
                   RECEIVING_ROUTING_ID,          --1--
                   LOCATION_CONTROL_CODE,
                   SERIAL_NUMBER_CONTROL_CODE,
                   EXPENSE_ACCOUNT,
                   PURCHASING_ITEM_FLAG,
                   PURCHASING_ENABLED_FLAG,
                   SHIPPABLE_ITEM_FLAG,
                   CUSTOMER_ORDER_FLAG,
                   INTERNAL_ORDER_FLAG,
                   SERVICE_ITEM_FLAG,
                   INVENTORY_ITEM_FLAG,
                   ENG_ITEM_FLAG,
                   INVENTORY_ASSET_FLAG,
                   CUSTOMER_ORDER_ENABLED_FLAG,
                   INTERNAL_ORDER_ENABLED_FLAG,
                   SO_TRANSACTIONS_FLAG,
                   MTL_TRANSACTIONS_ENABLED_FLAG,
                   STOCK_ENABLED_FLAG,
                   BOM_ENABLED_FLAG,
                   BUILD_IN_WIP_FLAG,
                   CATALOG_STATUS_FLAG,
                   TAXABLE_FLAG,
                   ALLOW_ITEM_DESC_UPDATE_FLAG,
                   INSPECTION_REQUIRED_FLAG,        -- N --
                   RECEIPT_REQUIRED_FLAG,
                   RFQ_REQUIRED_FLAG,
                   ALLOW_SUBSTITUTE_RECEIPTS_FLAG, ---Y-
                   ALLOW_UNORDERED_RECEIPTS_FLAG,   --y---
                   ALLOW_EXPRESS_DELIVERY_FLAG,
                   END_ASSEMBLY_PEGGING_FLAG,
                   REPETITIVE_PLANNING_FLAG,
                   PICK_COMPONENTS_FLAG,
                   REPLENISH_TO_ORDER_FLAG,
                   ATP_COMPONENTS_FLAG,
                   ATP_FLAG,
                   INVENTORY_ITEM_STATUS_CODE,
                   ITEM_TYPE,
                   DESCRIPTION,
                   PRIMARY_UNIT_OF_MEASURE,
                   PRIMARY_UOM_CODE,
                   SEGMENT1,
                   --SEGMENT2,
                   --SEGMENT3,
                   --SEGMENT4,
                   --SEGMENT5,
                   VENDOR_WARRANTY_FLAG,
                   SERVICEABLE_PRODUCT_FLAG,
                   INVOICEABLE_ITEM_FLAG,
                   INVOICE_ENABLED_FLAG,
                   MUST_USE_APPROVED_VENDOR_FLAG,
                   OUTSIDE_OPERATION_FLAG,
                   COSTING_ENABLED_FLAG,
                   CYCLE_COUNT_ENABLED_FLAG,
                   AUTO_CREATED_CONFIG_FLAG,
                   TRANSACTION_TYPE,
                   PROCESS_FLAG,
                   RECEIPT_DAYS_EXCEPTION_CODE,
                   QTY_RCV_EXCEPTION_CODE,
                   ATTRIBUTE_CATEGORY,
                   REVISION_QTY_CONTROL_CODE,
                   DEFAULT_INCLUDE_IN_ROLLUP_FLAG,
                   ATTRIBUTE1,
                   ATTRIBUTE2,
                   ATTRIBUTE3,
                   ATTRIBUTE11,
                   ATTRIBUTE15,
                   ATTRIBUTE12,
                   ATTRIBUTE13,
                   ATTRIBUTE10,
                   Set_process_id,
                   LONG_DESCRIPTION
                   )
        VALUES(
                   SYSDATE,
                   SYSDATE,
                   'IMT',                    --ORGANIZATION_CODE,  --***   NEED TO CHANGE ***---
                   FND_GLOBAL.USER_ID,
                   FND_GLOBAL.USER_ID,
                   NULL,                     --LIST_PRICE_PER_UNIT,
                   5,
                   5,
                   '',
                   2,
                   1,                        -- SERIAL NUMBER CONTROL CODE
                   1021,                     -- EXPENSET ACCOUNT  ID --***   NEED TO CHANGE ***---
                   'Y',
                   'Y',
                   'N',
                   'N',
                   'N',
                   'N',
                   'Y',
                   'N',
                   'Y',
                   'N',
                   'N',
                   'Y',
                   'Y',
                   'Y',
                   'Y',
                   'Y',
                   'N',
                   '',
                   'Y',
                   '',--
                   'Y',
                   '',
                   'Y',
                   'Y',
                   'Y',
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'Active',
                   'P',                      --ITEM_TYPE ---- --***   NEED TO CHANGE ***--- SEE TYPE IN LOOKUP --
                   C1_REC.DESCRIPTION,       -- DESCRIPTION
                   PL_UOM_CODE,               --PRIMARY_UNIT_OF_MEASURE,
                   C1_REC.UOM,              --PRIMARY_UOM_CODE,
                   C1_REC.SEGMENT1,          --SEGMENT1,
                   --C1_REC.SEGMENT2,        --SEGMENT2,
                  -- C1_REC.SEGMENT3,        --SEGMENT3,
                   --C1_REC.SEGMENT4,        --SEGMENT4,
                   --C1_REC.SEGMENT5,        --SEGMENT5,
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'Y',
                   'N',
                   'N',
                   'CREATE',                --TRANSACTION_TYPE,
                   1,                       --PROCESS_FLAG,
                   'WARNING',               --RECEIPT_DAYS_EXCEPTION_CODE,
                   'WARNING',               --QTY_RCV_EXCEPTION_CODE
                   'India Items',           --ATTRIBUTE CATEGORY
                   1,
                   'Y',
                   C1_REC.MODVAT_FLAG,      --'Y',    -- NOD VAT FLAG INDIA LOCALIZATION
                   C1_REC.EXCISE_FLAG,      ---'Y',                 -- EXCISE FLAG INDIA LOCALIZATION
                   C1_REC.ITEM_CLASS,       --'RMIN', --DEFAULT---        -- INDIA LOCALIZATION
                   C1_REC.UOM,              -- INDIA LOCALIZATION
                   'N',                     -- INDIA LOCALIZATION
                   UPPER(C1_REC.UOM),
                   UPPER(C1_REC.UOM),
                   'DISCITEM',
                   2,
                   'Old Material Code:=>'||C1_REC.OLD_ITEM_CODE
                   );

                 INSERT INTO MTL_ITEM_CATEGORIES_INTERFACE
                (
                    LAST_UPDATE_DATE,
                    LAST_UPDATED_BY,
                    CREATION_DATE,
                    CREATED_BY,
                    PROCESS_FLAG,
                    CATEGORY_SET_NAME,
                    CATEGORY_NAME,
                    ORGANIZATION_CODE,
                    ITEM_NUMBER,
                    TRANSACTION_TYPE,
                    OLD_CATEGORY_NAME,
                    SET_PROCESS_ID
                    )
   VALUES(
                   SYSDATE,
                   FND_GLOBAL.USER_ID,
                   SYSDATE,
                   FND_GLOBAL.USER_ID,
                   1,
                   'Inventory',
                   C1_REC.INV_CATEGORY_SET,
                   'IMT',                           --ORGANIZATION_CODE, -----***   NEED TO CHANGE ***---
                   C1_REC.SEGMENT1,
                   'UPDATE',
                   'MISC' ,          ---- OLD CATEGORY NAME WHICH WILL BE UPDATED BY THAT ---
                    2
                    );

                    INSERT INTO MTL_ITEM_CATEGORIES_INTERFACE (
                    LAST_UPDATE_DATE,
                    LAST_UPDATED_BY,
                    CREATION_DATE,
                    CREATED_BY,
                    PROCESS_FLAG,
                    CATEGORY_SET_NAME,
                    CATEGORY_NAME,
                    ORGANIZATION_CODE,
                    ITEM_NUMBER,
                    TRANSACTION_TYPE,
                    SET_PROCESS_ID
                   )
   VALUES(
                   SYSDATE,
                   FND_GLOBAL.USER_ID,
                   SYSDATE,
                   FND_GLOBAL.USER_ID,
                   1,
                   'Purchasing',
                   C1_REC.PO_CATEGORY_SET,
                   'IMT',                    --ORGANIZATION_CODE, -----***   NEED TO CHANGE ***---
                   C1_REC.SEGMENT1,
                   'CREATE',
                   2
                   );

                   INSERT INTO MTL_ITEM_CATEGORIES_INTERFACE (
                    LAST_UPDATE_DATE,
                    LAST_UPDATED_BY,
                    CREATION_DATE,
                    CREATED_BY,
                    PROCESS_FLAG,
                    CATEGORY_SET_NAME,
                    CATEGORY_NAME,
                    ORGANIZATION_CODE,
                    ITEM_NUMBER,
                    TRANSACTION_TYPE,
                    SET_PROCESS_ID
                   )
   VALUES(
                   SYSDATE,
                   FND_GLOBAL.USER_ID,
                   SYSDATE,
                   FND_GLOBAL.USER_ID,
                   1,
                   'Product_Type',
                   C1_REC.PRODUCT_CATEGORY,
                   'IMT',                    --ORGANIZATION_CODE, -----***   NEED TO CHANGE ***---
                   C1_REC.SEGMENT1,
                   'CREATE',
                   2
                   );

                   INSERT INTO MTL_ITEM_CATEGORIES_INTERFACE (
                    LAST_UPDATE_DATE,
                    LAST_UPDATED_BY,
                    CREATION_DATE,
                    CREATED_BY,
                    PROCESS_FLAG,
                    CATEGORY_SET_NAME,
                    CATEGORY_NAME,
                    ORGANIZATION_CODE,
                    ITEM_NUMBER,
                    TRANSACTION_TYPE,
                    SET_PROCESS_ID
                   )
   VALUES(
                   SYSDATE,
                   FND_GLOBAL.USER_ID,
                   SYSDATE,
                   FND_GLOBAL.USER_ID,
                   1,
                   'Excise_Categories',
                   C1_REC.EXCISE_CATEGORY,
                   'IMT',                    --ORGANIZATION_CODE, -----***   NEED TO CHANGE ***---
                   C1_REC.SEGMENT1,
                   'CREATE',
                   2
                   );
    COMMIT;

   EXCEPTION
          WHEN OTHERS
          THEN
          PL_MESSAGE:= SUBSTR(SQLERRM, 1, 200);
   END;

   --- **ATTACHMENT TO ORG ***---

    IF C1_REC.SU1_ORG='Y' THEN
       BEGIN
         -- insert into SU1 org master ---
         P_ORG_CODE:='SU1';

            INSERT INTO MTL_SYSTEM_ITEMS_INTERFACE(
                   LAST_UPDATE_DATE,
                   CREATION_DATE,
                   ORGANIZATION_CODE,
                   LAST_UPDATED_BY,
                   CREATED_BY,
                   LIST_PRICE_PER_UNIT,
                   DAYS_EARLY_RECEIPT_ALLOWED,
                   DAYS_LATE_RECEIPT_ALLOWED,
                   RECEIVING_ROUTING_ID,          --1--
                   LOCATION_CONTROL_CODE,
                   SERIAL_NUMBER_CONTROL_CODE,
                   EXPENSE_ACCOUNT,
                   PURCHASING_ITEM_FLAG,
                   PURCHASING_ENABLED_FLAG,
                   SHIPPABLE_ITEM_FLAG,
                   CUSTOMER_ORDER_FLAG,
                   INTERNAL_ORDER_FLAG,
                   SERVICE_ITEM_FLAG,
                   INVENTORY_ITEM_FLAG,
                   ENG_ITEM_FLAG,
                   INVENTORY_ASSET_FLAG,
                   CUSTOMER_ORDER_ENABLED_FLAG,
                   INTERNAL_ORDER_ENABLED_FLAG,
                   SO_TRANSACTIONS_FLAG,
                   MTL_TRANSACTIONS_ENABLED_FLAG,
                   STOCK_ENABLED_FLAG,
                   BOM_ENABLED_FLAG,
                   BUILD_IN_WIP_FLAG,
                   CATALOG_STATUS_FLAG,
                   TAXABLE_FLAG,
                   ALLOW_ITEM_DESC_UPDATE_FLAG,
                   INSPECTION_REQUIRED_FLAG,        -- N --
                   RECEIPT_REQUIRED_FLAG,
                   RFQ_REQUIRED_FLAG,
                   ALLOW_SUBSTITUTE_RECEIPTS_FLAG, ---Y-
                   ALLOW_UNORDERED_RECEIPTS_FLAG,   --y---
                   ALLOW_EXPRESS_DELIVERY_FLAG,
                   END_ASSEMBLY_PEGGING_FLAG,
                   REPETITIVE_PLANNING_FLAG,
                   PICK_COMPONENTS_FLAG,
                   REPLENISH_TO_ORDER_FLAG,
                   ATP_COMPONENTS_FLAG,
                   ATP_FLAG,
                   INVENTORY_ITEM_STATUS_CODE,
                   ITEM_TYPE,
                   DESCRIPTION,
                   PRIMARY_UNIT_OF_MEASURE,
                   PRIMARY_UOM_CODE,
                   SEGMENT1,
                   --SEGMENT2,
                   --SEGMENT3,
                   --SEGMENT4,
                   --SEGMENT5,
                   VENDOR_WARRANTY_FLAG,
                   SERVICEABLE_PRODUCT_FLAG,
                   INVOICEABLE_ITEM_FLAG,
                   INVOICE_ENABLED_FLAG,
                   MUST_USE_APPROVED_VENDOR_FLAG,
                   OUTSIDE_OPERATION_FLAG,
                   COSTING_ENABLED_FLAG,
                   CYCLE_COUNT_ENABLED_FLAG,
                   AUTO_CREATED_CONFIG_FLAG,
                   TRANSACTION_TYPE,
                   PROCESS_FLAG,
                   RECEIPT_DAYS_EXCEPTION_CODE,
                   QTY_RCV_EXCEPTION_CODE,
                   ATTRIBUTE_CATEGORY,
                   REVISION_QTY_CONTROL_CODE,
                   DEFAULT_INCLUDE_IN_ROLLUP_FLAG,
                   ATTRIBUTE1,
                   ATTRIBUTE2,
                   ATTRIBUTE3,
                   ATTRIBUTE11,
                   ATTRIBUTE15,
                   ATTRIBUTE12,
                   ATTRIBUTE13,
                   Set_process_id,
                   LONG_DESCRIPTION
                   )
        VALUES(
                   SYSDATE,
                   SYSDATE,
                   P_ORG_CODE,                    --ORGANIZATION_CODE,  --***   NEED TO CHANGE ***---
                   FND_GLOBAL.USER_ID,
                   FND_GLOBAL.USER_ID,
                   NULL,                     --LIST_PRICE_PER_UNIT,
                   5,
                   5,
                   '',
                   2,
                   1,                        -- SERIAL NUMBER CONTROL CODE
                   1021,                     -- EXPENSET ACCOUNT  ID --***   NEED TO CHANGE ***---
                   'Y',
                   'Y',
                   'N',
                   'N',
                   'N',
                   'N',
                   'Y',
                   'N',
                   'Y',
                   'N',
                   'N',
                   'Y',
                   'Y',
                   'Y',
                   'Y',
                   'Y',
                   'N',
                   '',
                   'Y',
                   '',--
                   'Y',
                   '',
                   'Y',
                   'Y',
                   'Y',
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'Active',
                   'P',                      --ITEM_TYPE ---- --***   NEED TO CHANGE ***--- SEE TYPE IN LOOKUP --
                   C1_REC.DESCRIPTION,       -- DESCRIPTION
                   PL_UOM_CODE,               --PRIMARY_UNIT_OF_MEASURE,
                   C1_REC.UOM,              --PRIMARY_UOM_CODE,
                   C1_REC.SEGMENT1,          --SEGMENT1,
                   --C1_REC.SEGMENT2,        --SEGMENT2,
                  -- C1_REC.SEGMENT3,        --SEGMENT3,
                   --C1_REC.SEGMENT4,        --SEGMENT4,
                   --C1_REC.SEGMENT5,        --SEGMENT5,
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'Y',
                   'N',
                   'N',
                   'CREATE',                --TRANSACTION_TYPE,
                   1,                       --PROCESS_FLAG,
                   'WARNING',               --RECEIPT_DAYS_EXCEPTION_CODE,
                   'WARNING',               --QTY_RCV_EXCEPTION_CODE
                   'India Items',           --ATTRIBUTE CATEGORY
                   1,
                   'Y',
                   C1_REC.MODVAT_FLAG,      --'Y',    -- NOD VAT FLAG INDIA LOCALIZATION
                   C1_REC.EXCISE_FLAG,      ---'Y',                 -- EXCISE FLAG INDIA LOCALIZATION
                   C1_REC.ITEM_CLASS,       --'RMIN', --DEFAULT---        -- INDIA LOCALIZATION
                   C1_REC.UOM,              -- INDIA LOCALIZATION
                   'N',                     -- INDIA LOCALIZATION
                   UPPER(C1_REC.UOM),
                   UPPER(C1_REC.UOM),
                   2,
                   'Old Material Code:=>'||C1_REC.OLD_ITEM_CODE
                   );

    COMMIT;

       EXCEPTION
          WHEN OTHERS
          THEN
       PL_MESSAGE:= SUBSTR(SQLERRM, 1, 200);
       END;

    END IF;

    IF C1_REC.SU2_ORG='Y' THEN
       BEGIN
        -- insert into SU2 org master ---
        P_ORG_CODE:='SU2';

          INSERT INTO MTL_SYSTEM_ITEMS_INTERFACE(
                   LAST_UPDATE_DATE,
                   CREATION_DATE,
                   ORGANIZATION_CODE,
                   LAST_UPDATED_BY,
                   CREATED_BY,
                   LIST_PRICE_PER_UNIT,
                   DAYS_EARLY_RECEIPT_ALLOWED,
                   DAYS_LATE_RECEIPT_ALLOWED,
                   RECEIVING_ROUTING_ID,          --1--
                   LOCATION_CONTROL_CODE,
                   SERIAL_NUMBER_CONTROL_CODE,
                   EXPENSE_ACCOUNT,
                   PURCHASING_ITEM_FLAG,
                   PURCHASING_ENABLED_FLAG,
                   SHIPPABLE_ITEM_FLAG,
                   CUSTOMER_ORDER_FLAG,
                   INTERNAL_ORDER_FLAG,
                   SERVICE_ITEM_FLAG,
                   INVENTORY_ITEM_FLAG,
                   ENG_ITEM_FLAG,
                   INVENTORY_ASSET_FLAG,
                   CUSTOMER_ORDER_ENABLED_FLAG,
                   INTERNAL_ORDER_ENABLED_FLAG,
                   SO_TRANSACTIONS_FLAG,
                   MTL_TRANSACTIONS_ENABLED_FLAG,
                   STOCK_ENABLED_FLAG,
                   BOM_ENABLED_FLAG,
                   BUILD_IN_WIP_FLAG,
                   CATALOG_STATUS_FLAG,
                   TAXABLE_FLAG,
                   ALLOW_ITEM_DESC_UPDATE_FLAG,
                   INSPECTION_REQUIRED_FLAG,        -- N --
                   RECEIPT_REQUIRED_FLAG,
                   RFQ_REQUIRED_FLAG,
                   ALLOW_SUBSTITUTE_RECEIPTS_FLAG, ---Y-
                   ALLOW_UNORDERED_RECEIPTS_FLAG,   --y---
                   ALLOW_EXPRESS_DELIVERY_FLAG,
                   END_ASSEMBLY_PEGGING_FLAG,
                   REPETITIVE_PLANNING_FLAG,
                   PICK_COMPONENTS_FLAG,
                   REPLENISH_TO_ORDER_FLAG,
                   ATP_COMPONENTS_FLAG,
                   ATP_FLAG,
                   INVENTORY_ITEM_STATUS_CODE,
                   ITEM_TYPE,
                   DESCRIPTION,
                   PRIMARY_UNIT_OF_MEASURE,
                   PRIMARY_UOM_CODE,
                   SEGMENT1,
                   --SEGMENT2,
                   --SEGMENT3,
                   --SEGMENT4,
                   --SEGMENT5,
                   VENDOR_WARRANTY_FLAG,
                   SERVICEABLE_PRODUCT_FLAG,
                   INVOICEABLE_ITEM_FLAG,
                   INVOICE_ENABLED_FLAG,
                   MUST_USE_APPROVED_VENDOR_FLAG,
                   OUTSIDE_OPERATION_FLAG,
                   COSTING_ENABLED_FLAG,
                   CYCLE_COUNT_ENABLED_FLAG,
                   AUTO_CREATED_CONFIG_FLAG,
                   TRANSACTION_TYPE,
                   PROCESS_FLAG,
                   RECEIPT_DAYS_EXCEPTION_CODE,
                   QTY_RCV_EXCEPTION_CODE,
                   ATTRIBUTE_CATEGORY,
                   REVISION_QTY_CONTROL_CODE,
                   DEFAULT_INCLUDE_IN_ROLLUP_FLAG,
                   ATTRIBUTE1,
                   ATTRIBUTE2,
                   ATTRIBUTE3,
                   ATTRIBUTE11,
                   ATTRIBUTE15,
                   ATTRIBUTE12,
                   ATTRIBUTE13,
                   Set_process_id,
                   LONG_DESCRIPTION
                   )
        VALUES(
                   SYSDATE,
                   SYSDATE,
                   P_ORG_CODE,                    --ORGANIZATION_CODE,  --***   NEED TO CHANGE ***---
                   FND_GLOBAL.USER_ID,
                   FND_GLOBAL.USER_ID,
                   NULL,                     --LIST_PRICE_PER_UNIT,
                   5,
                   5,
                   '',
                   2,
                   1,                        -- SERIAL NUMBER CONTROL CODE
                   1021,                     -- EXPENSET ACCOUNT  ID --***   NEED TO CHANGE ***---
                   'Y',
                   'Y',
                   'N',
                   'N',
                   'N',
                   'N',
                   'Y',
                   'N',
                   'Y',
                   'N',
                   'N',
                   'Y',
                   'Y',
                   'Y',
                   'Y',
                   'Y',
                   'N',
                   '',
                   'Y',
                   '',--
                   'Y',
                   '',
                   'Y',
                   'Y',
                   'Y',
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'Active',
                   'P',                      --ITEM_TYPE ---- --***   NEED TO CHANGE ***--- SEE TYPE IN LOOKUP --
                   C1_REC.DESCRIPTION,       -- DESCRIPTION
                   PL_UOM_CODE,               --PRIMARY_UNIT_OF_MEASURE,
                   C1_REC.UOM,              --PRIMARY_UOM_CODE,
                   C1_REC.SEGMENT1,          --SEGMENT1,
                   --C1_REC.SEGMENT2,        --SEGMENT2,
                  -- C1_REC.SEGMENT3,        --SEGMENT3,
                   --C1_REC.SEGMENT4,        --SEGMENT4,
                   --C1_REC.SEGMENT5,        --SEGMENT5,
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'Y',
                   'N',
                   'N',
                   'CREATE',                --TRANSACTION_TYPE,
                   1,                       --PROCESS_FLAG,
                   'WARNING',               --RECEIPT_DAYS_EXCEPTION_CODE,
                   'WARNING',               --QTY_RCV_EXCEPTION_CODE
                   'India Items',           --ATTRIBUTE CATEGORY
                   1,
                   'Y',
                   C1_REC.MODVAT_FLAG,      --'Y',    -- NOD VAT FLAG INDIA LOCALIZATION
                   C1_REC.EXCISE_FLAG,      ---'Y',                 -- EXCISE FLAG INDIA LOCALIZATION
                   C1_REC.ITEM_CLASS,       --'RMIN', --DEFAULT---        -- INDIA LOCALIZATION
                   C1_REC.UOM,              -- INDIA LOCALIZATION
                   'N',                     -- INDIA LOCALIZATION
                   UPPER(C1_REC.UOM),
                   UPPER(C1_REC.UOM),
                   2,
                   'Old Material Code:=>'||C1_REC.OLD_ITEM_CODE
                   );

                COMMIT;

       EXCEPTION
          WHEN OTHERS
          THEN
       PL_MESSAGE:= SUBSTR(SQLERRM, 1, 200);
       END;

    END IF;

    IF C1_REC.DGPP_ORG='Y' THEN
       BEGIN
        -- insert into dgpp org master ---
        P_ORG_CODE:='DGS';

             INSERT INTO MTL_SYSTEM_ITEMS_INTERFACE(
                   LAST_UPDATE_DATE,
                   CREATION_DATE,
                   ORGANIZATION_CODE,
                   LAST_UPDATED_BY,
                   CREATED_BY,
                   LIST_PRICE_PER_UNIT,
                   DAYS_EARLY_RECEIPT_ALLOWED,
                   DAYS_LATE_RECEIPT_ALLOWED,
                   RECEIVING_ROUTING_ID,          --1--
                   LOCATION_CONTROL_CODE,
                   SERIAL_NUMBER_CONTROL_CODE,
                   EXPENSE_ACCOUNT,
                   PURCHASING_ITEM_FLAG,
                   PURCHASING_ENABLED_FLAG,
                   SHIPPABLE_ITEM_FLAG,
                   CUSTOMER_ORDER_FLAG,
                   INTERNAL_ORDER_FLAG,
                   SERVICE_ITEM_FLAG,
                   INVENTORY_ITEM_FLAG,
                   ENG_ITEM_FLAG,
                   INVENTORY_ASSET_FLAG,
                   CUSTOMER_ORDER_ENABLED_FLAG,
                   INTERNAL_ORDER_ENABLED_FLAG,
                   SO_TRANSACTIONS_FLAG,
                   MTL_TRANSACTIONS_ENABLED_FLAG,
                   STOCK_ENABLED_FLAG,
                   BOM_ENABLED_FLAG,
                   BUILD_IN_WIP_FLAG,
                   CATALOG_STATUS_FLAG,
                   TAXABLE_FLAG,
                   ALLOW_ITEM_DESC_UPDATE_FLAG,
                   INSPECTION_REQUIRED_FLAG,        -- N --
                   RECEIPT_REQUIRED_FLAG,
                   RFQ_REQUIRED_FLAG,
                   ALLOW_SUBSTITUTE_RECEIPTS_FLAG, ---Y-
                   ALLOW_UNORDERED_RECEIPTS_FLAG,   --y---
                   ALLOW_EXPRESS_DELIVERY_FLAG,
                   END_ASSEMBLY_PEGGING_FLAG,
                   REPETITIVE_PLANNING_FLAG,
                   PICK_COMPONENTS_FLAG,
                   REPLENISH_TO_ORDER_FLAG,
                   ATP_COMPONENTS_FLAG,
                   ATP_FLAG,
                   INVENTORY_ITEM_STATUS_CODE,
                   ITEM_TYPE,
                   DESCRIPTION,
                   PRIMARY_UNIT_OF_MEASURE,
                   PRIMARY_UOM_CODE,
                   SEGMENT1,
                   --SEGMENT2,
                   --SEGMENT3,
                   --SEGMENT4,
                   --SEGMENT5,
                   VENDOR_WARRANTY_FLAG,
                   SERVICEABLE_PRODUCT_FLAG,
                   INVOICEABLE_ITEM_FLAG,
                   INVOICE_ENABLED_FLAG,
                   MUST_USE_APPROVED_VENDOR_FLAG,
                   OUTSIDE_OPERATION_FLAG,
                   COSTING_ENABLED_FLAG,
                   CYCLE_COUNT_ENABLED_FLAG,
                   AUTO_CREATED_CONFIG_FLAG,
                   TRANSACTION_TYPE,
                   PROCESS_FLAG,
                   RECEIPT_DAYS_EXCEPTION_CODE,
                   QTY_RCV_EXCEPTION_CODE,
                   ATTRIBUTE_CATEGORY,
                   REVISION_QTY_CONTROL_CODE,
                   DEFAULT_INCLUDE_IN_ROLLUP_FLAG,
                   ATTRIBUTE1,
                   ATTRIBUTE2,
                   ATTRIBUTE3,
                   ATTRIBUTE11,
                   ATTRIBUTE15,
                   ATTRIBUTE12,
                   ATTRIBUTE13,
                   Set_process_id,
                   LONG_DESCRIPTION
                   )
        VALUES(
                   SYSDATE,
                   SYSDATE,
                   P_ORG_CODE,                    --ORGANIZATION_CODE,  --***   NEED TO CHANGE ***---
                   FND_GLOBAL.USER_ID,
                   FND_GLOBAL.USER_ID,
                   NULL,                     --LIST_PRICE_PER_UNIT,
                   5,
                   5,
                   '',
                   2,
                   1,                        -- SERIAL NUMBER CONTROL CODE
                   1021,                     -- EXPENSET ACCOUNT  ID --***   NEED TO CHANGE ***---
                   'Y',
                   'Y',
                   'N',
                   'N',
                   'N',
                   'N',
                   'Y',
                   'N',
                   'Y',
                   'N',
                   'N',
                   'Y',
                   'Y',
                   'Y',
                   'Y',
                   'Y',
                   'N',
                   '',
                   'Y',
                   '',--
                   'Y',
                   '',
                   'Y',
                   'Y',
                   'Y',
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'Active',
                   'P',                      --ITEM_TYPE ---- --***   NEED TO CHANGE ***--- SEE TYPE IN LOOKUP --
                   C1_REC.DESCRIPTION,       -- DESCRIPTION
                   PL_UOM_CODE,               --PRIMARY_UNIT_OF_MEASURE,
                   C1_REC.UOM,              --PRIMARY_UOM_CODE,
                   C1_REC.SEGMENT1,          --SEGMENT1,
                   --C1_REC.SEGMENT2,        --SEGMENT2,
                  -- C1_REC.SEGMENT3,        --SEGMENT3,
                   --C1_REC.SEGMENT4,        --SEGMENT4,
                   --C1_REC.SEGMENT5,        --SEGMENT5,
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'N',
                   'Y',
                   'N',
                   'N',
                   'CREATE',                --TRANSACTION_TYPE,
                   1,                       --PROCESS_FLAG,
                   'WARNING',               --RECEIPT_DAYS_EXCEPTION_CODE,
                   'WARNING',               --QTY_RCV_EXCEPTION_CODE
                   'India Items',           --ATTRIBUTE CATEGORY
                   1,
                   'Y',
                   C1_REC.MODVAT_FLAG,      --'Y',    -- NOD VAT FLAG INDIA LOCALIZATION
                   C1_REC.EXCISE_FLAG,      ---'Y',                 -- EXCISE FLAG INDIA LOCALIZATION
                   C1_REC.ITEM_CLASS,       --'RMIN', --DEFAULT---        -- INDIA LOCALIZATION
                   C1_REC.UOM,              -- INDIA LOCALIZATION
                   'N',                     -- INDIA LOCALIZATION
                   UPPER(C1_REC.UOM),
                   UPPER(C1_REC.UOM),
                   2,
                   'Old Material Code:=>'||C1_REC.OLD_ITEM_CODE
                   );

    COMMIT;

       EXCEPTION
          WHEN OTHERS
          THEN
       PL_MESSAGE:= SUBSTR(SQLERRM, 1, 200);
       END;

    END IF;

END IF;

UPDATE XX_ITEM_MASTER_TEMP SET STATUS = PL_MESSAGE WHERE ROWID=C1_REC.ROWXX;

END LOOP;
END;

Cheers!


Sales Orders Interface/Conversion

$
0
0

Sample code for sales order interface/conversion is given below

DECLARE
   v_order_type_id        NUMBER;
   v_payment_term_id      NUMBER        := 4;
   v_sold_to_org_id       NUMBER;
   v_booked_flag          VARCHAR2 (1);
   v_closed_flag          VARCHAR2 (1);
   v_cancelled_flag       VARCHAR2 (1);
   v_accounting_rule_id   NUMBER        := 1;
   v_tax                  VARCHAR2 (50);
   v_tax_code             VARCHAR2 (50);
   v_tax_point            VARCHAR2 (80);
   v_tax_value            NUMBER;
   v_price_list_id        NUMBER;
   v_org_id               NUMBER;
   v_ship_from_org_id     NUMBER;
   v_header_id            NUMBER;
   v_line_id              NUMBER;
   v_ship_to_org_id       NUMBER;
   v_invoice_to_org_id    NUMBER;
   v_customer_id          NUMBER;
   v_payment_terms_id     NUMBER;
   v_order_source_id      NUMBER        := 9;
   v_banker1              NUMBER;
   v_banker2              NUMBER;
   v_inventory_item_id    NUMBER;
   v_tax_amount           NUMBER;
   v_line_no              NUMBER;
   v_tax_line_no          NUMBER;
   v_tax_id               NUMBER;

   CURSOR c_header
   IS
      SELECT order_type,
             --orig_sys_document_ref,
             order_number,
             customer_po_number,   -- customer po
             ordered_date,   -- ordered date
             order_status,   -- status
             customer_name,   -- customer
             customer_id,   -- customer number
             end_customer_contact,   -- customer contact
             ship_to_org,   -- consignee
             invoice_to_org,   -- buyer
             price_list,   -- price list
             transactional_curr_code,   -- currency
             payment_terms,   -- payment_terms
             org_id,
             attribute1,   -- L/C Number
             attribute2,   -- L/C Opening Date
             attribute3,   -- Last Shipment Date
             attribute4,   -- Advance Date
             attribute5,   -- Negotiation Days
             attribute6,   -- Partial Shipment
             attribute7,   -- Trans Shipment
             attribute8,   -- Carriage By
             attribute9,   -- Weight Basis
             attribute10,   -- Banker 1
             attribute11,   -- Banker2
             attribute12,   -- Terms of delivery (1)
             attribute13,   -- Terms of delivery (2)
             attribute14,   -- Port of loading
             attribute15,   -- Port of discharge
             attribute16,   -- Country of Desitnation
             attribute17   -- Final destination
        FROM xx_order_headers_iface;

   CURSOR c_lines (p_orig_sys_document_ref VARCHAR2)
   IS
      SELECT orig_sys_document_ref,
             line_id,   -- line no
             inventory_item,   -- ordered item
             grade,   -- Grade
             ordered_quantity,   -- Qty
             order_quantity_uom,   -- UOM
             ordered_quantity2,   -- Sec_qty
             ordered_quantity_uom2,   -- Sec UOM
             ship_from_org_id,   -- Warehouse
             selling_price,   -- unit selling price
             request_date,   -- Request date
             schedule_ship_date,   -- schedule ship date
             order_status,   -- status
             shipping_instructions,   -- Production Instructions
             packing_instructions,   -- Shipping/Packing Instructions
             industry_attribute1,   -- Product Description
             industry_attribute2,   -- Drawing No (CCL)
             industry_attribute3,   -- SkinPass &TL
             industry_attribute4,   -- Passivation
             industry_attribute5,   -- Spangle
             industry_attribute6,   -- Finish
             industry_attribute7,   -- PKG TCT/BMT
             industry_attribute8,   -- Zinc Coating
             industry_attribute9,   -- Bundle/Coil Wt. (Min)
             industry_attribute10,   -- Bundle/Coil Wt. (Max)
             industry_attribute11,   -- Packing Weight
             industry_attribute12,   -- Coil position
             industry_attribute13,   -- COIL ID
             industry_attribute14,   -- Coil Winding Method
             industry_attribute15,   -- End Use
             industry_attribute16,   -- Shipping Mark
             industry_attribute17,   -- Shipping Colour Code
             industry_attribute18,   -- Logo Marking
             industry_attribute19,   -- Packing Standard
             industry_attribute20,   -- Thickness (Pkg Std)
             industry_attribute21,   -- Width (Pkg Std)
             industry_attribute22,   -- Length (Pkg Std)
             industry_attribute23,   -- Auction ID
             industry_attribute24
        FROM xx_order_lines_iface
       WHERE orig_sys_document_ref = p_orig_sys_document_ref;

   CURSOR c_tax (p_order_number VARCHAR2)
   IS
      SELECT tax_line_no, tax_name, tax_type, precedence_1, precedence_2, precedence_3, precedence_4, precedence_5, tax_rate, tax_amount,
             tax_id
        FROM pwc_in_ra_interface_tax_lines
       WHERE order_number = p_order_number;
BEGIN
   DELETE FROM xx_ja_tax;   -- Clearing all header, line mapping data if there is any

   FOR rec_header IN c_header
   LOOP
      SELECT oe_order_headers_s.NEXTVAL
        INTO v_header_id
        FROM DUAL;

      /* Setting order status flag */
      IF rec_header.order_status = 'BOOKED'
      THEN
         v_booked_flag := 'Y';
      ELSIF rec_header.order_status = 'CLOSED'
      THEN
         v_closed_flag := 'Y';
      ELSIF rec_header.order_status = 'CANCELLED'
      THEN
         v_cancelled_flag := 'Y';
      END IF;

      /* Setting the order type id */
      SELECT order_type_id
        INTO v_order_type_id
        FROM oe_order_types_115_all
       WHERE NAME = rec_header.order_type;

      /* Setting the order status flag */
      v_booked_flag := '';
      v_closed_flag := '';
      v_cancelled_flag := '';

      /* Getting the price list */
      SELECT list_header_id
        INTO v_price_list_id
        FROM qp_list_headers_tl
       WHERE NAME = rec_header.price_list;

      SELECT order_type_id
        INTO v_order_type_id
        FROM oe_order_types_115_all
       WHERE NAME = rec_header.order_type;

      /* Get the payment term id */
      BEGIN
         SELECT term_id
           INTO v_payment_terms_id
           FROM ra_terms_tl
          WHERE NAME = rec_header.payment_terms;
      EXCEPTION
         WHEN OTHERS
         THEN
            v_payment_terms_id := 4;
      END;

      /* Getting the customer sold_to org_id */
      IF rec_header.customer_id IS NOT NULL
      THEN
         SELECT cust_account_id
           INTO v_sold_to_org_id
           FROM hz_cust_accounts
          WHERE account_number = rec_header.customer_id;
      ELSE
         SELECT cust_account_id
           INTO v_sold_to_org_id   -- sold_to_org_id
           FROM hz_cust_accounts
          WHERE party_id = (SELECT party_id
                              FROM hz_parties
                             WHERE party_name = rec_header.customer_name);

         SELECT customer_number
           INTO v_customer_id   -- Customer id
           FROM ra_customers
          WHERE customer_name = rec_header.customer_name;
      END IF;

      /* Getting the ship_to_org_id */
      SELECT site_use_id
        INTO v_ship_to_org_id
        FROM hz_cust_site_uses_all
       WHERE cust_acct_site_id =
                (SELECT cust_acct_site_id
                   FROM hz_cust_acct_sites_all
                  WHERE cust_account_id = (SELECT cust_account_id
                                             FROM hz_cust_accounts
                                            WHERE party_id = (SELECT party_id
                                                                FROM hz_parties
                                                               WHERE party_name = rec_header.ship_to_org))
                    AND ship_to_flag = 'P'
                    AND org_id = rec_header.org_id)
         AND site_use_code = 'SHIP_TO'
         AND status = 'A';

      /* Getting the bill_to_org_id */
      SELECT site_use_id
        INTO v_invoice_to_org_id
        FROM hz_cust_site_uses_all
       WHERE cust_acct_site_id =
                (SELECT cust_acct_site_id
                   FROM hz_cust_acct_sites_all
                  WHERE cust_account_id = (SELECT cust_account_id
                                             FROM hz_cust_accounts
                                            WHERE party_id = (SELECT party_id
                                                                FROM hz_parties
                                                               WHERE party_name = rec_header.invoice_to_org))
                    AND bill_to_flag = 'P'
                    AND org_id = rec_header.org_id)
         AND site_use_code = 'BILL_TO'
         AND status = 'A';

      /* Getting the bank branch id for DFFs attribute16 and attribute17 */
      SELECT bank_branch_id
        INTO v_banker1
        FROM ap_bank_branches
       WHERE bank_name = rec_header.attribute16;

      SELECT bank_branch_id
        INTO v_banker2
        FROM ap_bank_branches
       WHERE bank_name = rec_header.attribute17;

      BEGIN
         INSERT INTO oe_headers_iface_all
                     (order_source_id,
                      order_type_id,
                      orig_sys_document_ref,
                      order_number,
                      customer_po_number,   -- customer po
                      ordered_date,   -- ordered date
                      customer_id,   -- customer number
                      end_customer_contact,   -- customer contact
                      sold_to_org_id,
                      ship_to_org_id,   -- consignee
                      invoice_to_org_id,   -- buyer
                      transactional_curr_code,   -- currency
                      payment_term_id,   -- payment_terms
                      CONTEXT,
                      attribute1,   -- L/C Number
                      attribute2,   -- L/C Opening Date
                      attribute3,   -- Last Shipment Date
                      attribute4,   -- Advance Date
                      attribute5,   -- Negotiation Days
                      attribute6,   -- Partial Shipment
                      attribute7,   -- Trans Shipment
                      attribute8,   -- Carriage By
                      attribute9,   -- Weight Basis
                      attribute10,   -- Banker 1
                      attribute11,   -- Banker2
                      attribute12,   -- Terms of delivery (1)
                      attribute13,   -- Terms of delivery (2)
                      attribute14,   -- Port of loading
                      attribute15,   -- Port of discharge
                      attribute16,   -- Country of Desitnation
                      attribute17,   -- Final destination
                      price_list_id,
                      booked_flag,
                      closed_flag,
                      cancelled_flag,
                      header_id,
                      org_id,
                      operation_code,
                      created_by,
                      creation_date,
                      last_updated_by,
                      last_update_date
                     )
              VALUES (v_order_source_id,   -- order source id
                      v_order_type_id,
                      rec_header.order_number || v_header_id,   -- orig_sys_document_ref
                      rec_header.order_number,   -- order number
                      rec_header.customer_po_number,   -- customer po
                      TO_DATE (rec_header.ordered_date, 'DD-MON-YYYY HH24:MI:SS'),   -- ordered date
                      rec_header.customer_id,   -- customer number
                      rec_header.end_customer_contact,   -- customer contact
                      v_sold_to_org_id, v_ship_to_org_id,   -- consignee
                      v_invoice_to_org_id,   -- buyer
                      rec_header.transactional_curr_code,   -- currency
                      v_payment_term_id,   -- payment_terms
                      rec_header.order_type, rec_header.attribute1,   -- L/C Number
                      rec_header.attribute2,   -- L/C Opening Date
                      rec_header.attribute3,   -- Last Shipment Date
                      rec_header.attribute4,   -- Advance Date
                      rec_header.attribute5,   -- Negotiation Days
                      rec_header.attribute6,   -- Partial Shipment
                      rec_header.attribute7,   -- Trans Shipment
                      rec_header.attribute8,   -- Carriage By
                      rec_header.attribute9,   -- Weight Basis
                      rec_header.attribute10,   -- Banker 1
                      rec_header.attribute11,   -- Banker2
                      rec_header.attribute12,   -- Terms of delivery (1)
                      rec_header.attribute13,   -- Terms of delivery (2)
                      rec_header.attribute14,   -- Port of loading
                      rec_header.attribute15,   -- Port of discharge
                      v_banker1,   -- Country of Desitnation
                      v_banker2,   -- Final destination
                      v_price_list_id,
                      v_booked_flag,
                      v_closed_flag,
                      v_cancelled_flag,
                      v_header_id,
                      rec_header.org_id,
                      'INSERT',
                      0,
                      SYSDATE,
                      0,
                      SYSDATE
                     );

         v_line_no := 1;   -- Restting the order line number to 1

         FOR rec_lines IN c_lines (rec_header.order_number)
         LOOP
            SELECT oe_order_lines_s.NEXTVAL
              INTO v_line_id
              FROM DUAL;

            SELECT organization_id
              INTO v_ship_from_org_id
              FROM org_organization_definitions
             WHERE operating_unit = rec_header.org_id AND organization_code = rec_lines.ship_from_org_id;

            SELECT inventory_item_id
              INTO v_inventory_item_id
              FROM mtl_system_items_b
             WHERE segment1 = rec_lines.inventory_item AND organization_id = v_ship_from_org_id;

            IF rec_lines.order_quantity_uom = 'Each'
            THEN
               rec_lines.order_quantity_uom := 'EA';
            ELSIF rec_lines.ordered_quantity_uom2 = 'Each'
            THEN
               rec_lines.ordered_quantity_uom2 := 'EA';
            END IF;

            INSERT INTO oe_lines_iface_all
                        (order_source_id,
                         orig_sys_line_ref,
                         orig_sys_document_ref,   -- order number
                         line_id,   -- line no
                         --  line_number,
                         inventory_item_id,   -- ordered item
                         -- Grade,
                         ordered_quantity,   -- Qty
                         order_quantity_uom,   -- UOM
                         ordered_quantity2,   -- Sec_qty
                         ordered_quantity_uom2,   -- Sec UOM
                         ship_from_org_id,   -- Warehouse
                         -- selling_price,            -- unit selling price
                         request_date,   -- Request date
                         schedule_ship_date,   -- schedule ship date
                         -- order_status,            -- status
                         shipping_instructions,   -- Production Instructions
                         packing_instructions,   -- Shipping/Packing Instructions
                         industry_attribute1,   -- Product Description
                         industry_attribute2,   -- Drawing No (CCL)
                         industry_attribute3,   -- SkinPass &TL
                         industry_attribute4,   -- Passivation
                         industry_attribute5,   -- Spangle
                         industry_attribute6,   -- Finish
                         industry_attribute7,   -- PKG TCT/BMT
                         industry_attribute8,   -- Zinc Coating
                         industry_attribute9,   -- Bundle/Coil Wt. (Min)
                         industry_attribute10,   -- Bundle/Coil Wt. (Max)
                         industry_attribute11,   -- Packing Weight
                         industry_attribute12,   -- Coil position
                         industry_attribute13,   -- COIL ID
                         industry_attribute14,   -- Coil Winding Method
                         industry_attribute15,
                         industry_attribute16,   -- End Use
                         industry_attribute17,   -- Shipping Mark
                         industry_attribute18,   -- Shipping Colour Code
                         industry_attribute19,   -- Logo Marking
                         industry_attribute20,   -- Packing Standard
                         industry_attribute21,   -- Thickness (Pkg Std)
                         industry_attribute22,   -- Width (Pkg Std)
                         industry_attribute23,   -- Length (Pkg Std)
                         industry_attribute24,   -- Auction ID
                         created_by,
                         creation_date,
                         last_updated_by,
                         last_update_date
                        )
                 VALUES (v_order_source_id,
                         rec_header.order_number || '_line_ref' || v_line_id,
                         rec_lines.orig_sys_document_ref || v_header_id,   -- order number
                         v_line_id,   -- line id
                         -- v_line_no, -- line number
                         v_inventory_item_id,   -- ordered item
                         -- rec_lines.Grade,                    -- Grade
                         rec_lines.ordered_quantity,   -- Qty
                         rec_lines.order_quantity_uom,   -- UOM
                         rec_lines.ordered_quantity2,   -- Sec_qty
                         rec_lines.ordered_quantity_uom2,   -- Sec UOM
                         v_ship_from_org_id,   -- Warehouse
                         -- rec_lines.selling_price,        -- unit selling price
                         rec_lines.request_date,   -- Request date
                         rec_lines.schedule_ship_date,   -- schedule ship date
                         -- rec_lines.order_status, -- status
                         rec_lines.shipping_instructions,   -- Production Instructions
                         rec_lines.packing_instructions,   -- Shipping/Packing Instructions
                         rec_lines.industry_attribute1,   -- Product Description
                         rec_lines.industry_attribute2,   -- Drawing No (CCL)
                         rec_lines.industry_attribute3,   -- SkinPass &TL
                         rec_lines.industry_attribute4,   -- Passivation
                         rec_lines.industry_attribute5,   -- Spangle
                         rec_lines.industry_attribute6,   -- Finish
                         rec_lines.industry_attribute7,   -- PKG TCT/BMT
                         rec_lines.industry_attribute8,   -- Zinc Coating
                         rec_lines.industry_attribute9,   -- Bundle/Coil Wt. (Min)
                         rec_lines.industry_attribute10,   -- Bundle/Coil Wt. (Max)
                         rec_lines.industry_attribute11,   -- Packing Weight
                         rec_lines.industry_attribute12,   -- Coil position
                         rec_lines.industry_attribute13,   -- COIL ID
                         rec_lines.industry_attribute14,   -- Coil Winding Method
                         rec_lines.industry_attribute15,
                         rec_lines.industry_attribute16,   -- End Use
                         rec_lines.industry_attribute17,   -- Shipping Mark
                         rec_lines.industry_attribute18,   -- Shipping Colour Code
                         rec_lines.industry_attribute19,   -- Logo Marking
                         rec_lines.industry_attribute20,   -- Packing Standard
                         rec_lines.industry_attribute21,   -- Thickness (Pkg Std)
                         rec_lines.industry_attribute22,   -- Width (Pkg Std)
                         rec_lines.industry_attribute23,   -- Length (Pkg Std)
                         rec_lines.industry_attribute24,   -- Auction ID
                         0,
                         SYSDATE,
                         0,
                         SYSDATE
                        );

            -- This portion is for India Localization
            /* Calculate total tax for an order line */
            SELECT SUM (tax_amount)
              INTO v_tax_amount
              FROM pwc_in_ra_interface_tax_lines
             WHERE order_number = rec_header.order_number;

            INSERT INTO ja_in_so_lines
                        (line_number,
                         line_id,
                         header_id,
                         -- shipment_schedule_line_id,
                         inventory_item_id,
                         unit_code,
                         quantity,
                         --tax_category_id,
                         selling_price, line_amount,
                         -- assessable_value,
                         tax_amount,
                         line_tot_amount,
                         -- shipment_schedule_flag,
                         -- shipment_line_number,
                         creation_date,
                         created_by,
                         last_update_date,
                         last_updated_by
                         -- last_update_login,
                         -- ato_flag,
                         -- excise_exempt_type,
                         -- excise_exempt_refno,
                         -- excise_exempt_date,
                         -- split_from_line_id,
                         -- lc_flag,
                         -- vat_exemption_flag,
                         -- vat_exemption_type,
                         -- vat_exemption_date,
                         -- vat_exemption_refno,
                         -- vat_assessable_value
                        )
                 VALUES (v_line_no,   -- line_number
                         v_line_id,   -- line_id
                         v_header_id,   -- header_id
                         -- shipment_schedule_line_id
                         v_inventory_item_id,   -- inventory_item_id
                         rec_lines.order_quantity_uom,   -- unit_code
                         rec_lines.ordered_quantity,   -- quantity
                         -- tax_category_id
                         rec_lines.selling_price,   -- selling_price
                         rec_lines.ordered_quantity * rec_lines.selling_price,   -- line_amount
                         -- assessable_value
                         v_tax_amount,   -- tax_amount
                         v_tax_amount,   -- line_tot_amount
                         -- shipment_schedule_flag
                         -- shipment_line_number
                         SYSDATE,   -- creation_date
                         0,   -- created_by
                         SYSDATE,   -- last_update_date
                         0   -- last_updated_by
                         -- last_update_login
                         -- ato_flag
                         -- excise_exempt_type
                         -- excise_exempt_refno
                         -- excise_exempt_date
                         -- split_from_line_id
                         -- lc_flag
                         -- vat_exemption_flag
                         -- vat_exemption_type
                         -- vat_exemption_date
                         -- vat_exemption_refno
                         -- vat_assessable_value
                        );

            v_tax_line_no := 1;   -- Resetting the tax line no.

            FOR rec_tax IN c_tax (rec_header.order_number)
            LOOP
               SELECT tax_id
                 INTO v_tax_id
                 FROM ja_in_tax_codes
                WHERE tax_name = rec_tax.tax_name;

               INSERT INTO ja_in_so_tax_lines
                           (tax_line_no,
                            line_id,
                            header_id,
                            precedence_1,
                            precedence_2,
                            precedence_3,
                            precedence_4,
                            precedence_5,
                            tax_id,
                            tax_rate,
                            -- qty_rate,
                            -- uom,
                            tax_amount,
                            -- base_tax_amount,
                            -- func_tax_amount,
                            creation_date,
                            created_by,
                            last_update_date,
                            last_updated_by
                            -- last_update_login,
                            -- tax_category_id
                           )
                    VALUES (v_tax_line_no,   --tax_line_no,
                            v_line_id,   -- line_id,
                            v_header_id,   -- header_id,
                            rec_tax.precedence_1,
                            rec_tax.precedence_2,
                            rec_tax.precedence_3,
                            rec_tax.precedence_4,
                            rec_tax.precedence_5,
                            v_tax_id,   -- tax_id,
                            rec_tax.tax_rate,   -- tax_rate
                            -- qty_rate,
                            -- uom,
                            rec_tax.tax_amount,   -- tax_amount,
                            -- base_tax_amount,
                            -- func_tax_amount,
                            SYSDATE,   -- creation_date,
                            0,   -- created_by,
                            SYSDATE,   -- last_update_date,
                            0   -- last_updated_by,
                            -- last_update_login,
                            -- tax_category_id
                           );

               v_tax_line_no := v_tax_line_no + 1;

               INSERT INTO xx_ja_tax
                    VALUES (rec_header.order_number, v_header_id, v_line_id);
            END LOOP;   -- tax

            FOR rec_tax IN c_tax (rec_header.order_number)
            LOOP
               SELECT tax_id
                 INTO v_tax_line_no
                 FROM ja_in_tax_codes
                WHERE tax_name = rec_tax.order_number;

               INSERT INTO ja_in_ra_interface_tax_lines
                           (interface_line_id, interface_tax_line_id, tax_line_no, customer_trx_line_id, link_to_cust_trx_line_id,
                            precedence_1, precedence_2, precedence_3, precedence_4, precedence_5, tax_id, tax_name, tax_rate, qty_rate,
                            uom, tax_amount, func_tax_amount, base_tax_amount, creation_date, created_by, last_update_date,
                            last_updated_by, last_update_login
                           )
                    VALUES (2,   -- interface_line_id,
                            2,   -- interface_tax_line_id,
                            10,   --tax_line_no,
                            NULL,   -- customer_trx_line_id,
                            NULL,   -- link_to_cust_trx_line_id,
                            1,   -- precedence_1,
                            NULL,   -- precedence_2,
                            NULL,   -- precedence_3,
                            NULL,   -- precedence_4,
                            NULL,   -- precedence_5,
                            44,   -- tax_id,
                            NULL,   -- tax_name,
                            NULL,   -- tax_rate,
                            NULL,   -- qty_rate,
                            NULL,   -- uom,
                            100,   -- tax_amount,
                            NULL,   -- func_tax_amount,
                            NULL,   -- base_tax_amount,
                            SYSDATE,   -- creation_date,
                            0,   -- created_by,
                            SYSDATE,   -- last_update_date,
                            0,   -- last_updated_by,
                            NULL   -- last_update_login
                           );
            END LOOP;   -- tax

            v_line_no := v_line_no + 1;   -- incrementing line id for the next insert
         END LOOP;   -- lines
      EXCEPTION
         WHEN OTHERS
         THEN
            NULL;
      END;
   END LOOP;   -- header

   COMMIT;
END;

Cheers!


Asset addition interface

$
0
0

A sample asset addition interface is given below

-- FOR MEMBER ASSET

DECLARE
   l_trans_rec             fa_api_types.trans_rec_type;
   l_dist_trans_rec        fa_api_types.trans_rec_type;
   l_asset_hdr_rec         fa_api_types.asset_hdr_rec_type;
   l_asset_desc_rec        fa_api_types.asset_desc_rec_type;
   l_asset_cat_rec         fa_api_types.asset_cat_rec_type;
   l_asset_type_rec        fa_api_types.asset_type_rec_type;
   l_asset_hierarchy_rec   fa_api_types.asset_hierarchy_rec_type;
   l_asset_fin_rec         fa_api_types.asset_fin_rec_type;
   l_asset_deprn_rec       fa_api_types.asset_deprn_rec_type;
   l_asset_dist_rec        fa_api_types.asset_dist_rec_type;
   l_asset_dist_tbl        fa_api_types.asset_dist_tbl_type;
   l_inv_tbl               fa_api_types.inv_tbl_type;
   l_inv_rate_tbl          fa_api_types.inv_rate_tbl_type;
   l_return_status         VARCHAR2 (1);
   l_mesg_count            NUMBER                                := 0;
   l_mesg_len              NUMBER;
   l_mesg                  VARCHAR2 (4000);
BEGIN
   fnd_profile.put ('PRINT_DEBUG', 'Y');
   DBMS_OUTPUT.ENABLE (1000000);
   fa_srvr_msg.init_server_message;
   fa_debug_pkg.initialize;
   -- desc info
   l_asset_desc_rec.description := 'Member API Test';
   --l_asset_desc_rec.asset_key_ccid := null;

   -- cat info *** NEED TO CHANGE BASED ON CATEGORY SETUP FOR YOUR BOOK ***
   l_asset_cat_rec.category_id := 31;
   --type info
   l_asset_type_rec.asset_type := 'CAPITALIZED';
   -- fin info
   l_asset_fin_rec.COST := 50000;
   l_asset_fin_rec.date_placed_in_service := '&DPIS';
   l_asset_fin_rec.depreciate_flag := 'YES';
   l_asset_fin_rec.group_asset_id := 5671;
   --l_asset_fin_rec.recognize_gain_loss := 'YES';
   --l_asset_fin_rec.deprn_method_code := 'STL';
   --l_asset_fin_rec.life_in_months := 72;

   -- deprn info
   --l_asset_deprn_rec.ytd_deprn := 500;
   --l_asset_deprn_rec.deprn_reserve := 500;
   --l_asset_deprn_rec.bonus_ytd_deprn := 0;
   --l_asset_deprn_rec.bonus_deprn_reserve := 0;

   -- book / trans info
   l_asset_hdr_rec.book_type_code := '&book';
   l_trans_rec.transaction_date_entered := l_asset_fin_rec.date_placed_in_service;
   l_trans_rec.who_info.last_updated_by := fnd_global.user_id;
   -- distribution info
   l_asset_dist_rec.units_assigned := 1;
   l_asset_dist_rec.expense_ccid := 5699;
   l_asset_dist_rec.location_ccid := 1;
   l_asset_dist_rec.assigned_to := NULL;
   l_asset_dist_rec.transaction_units := l_asset_dist_rec.units_assigned;
   l_asset_dist_tbl (1) := l_asset_dist_rec;
   --l_asset_desc_rec.asset_number :=
   --l_asset_desc_rec.property_type_code := 'REAL';
   --l_asset_desc_rec.property_1245_1250_code := '1245';
   --l_asset_desc_rec.in_use_flag := 'YES';
   --l_asset_desc_rec.owned_leased := 'OWNED';
   --l_asset_desc_rec.new_used := 'NEW';
   --l_asset_desc_rec.inventorial := 'YES';
   --l_asset_desc_rec.manufacturer_name :=
   --l_asset_desc_rec.serial_number :=
   --l_asset_desc_rec.model_number :=
   --l_asset_desc_rec.tag_number :=
   --l_asset_desc_rec.parent_asset_id :=
   --l_asset_desc_rec.warranty_id :=
   --l_asset_desc_rec.lease_id :=

   -- For tax addition, will need existing asset_id
   --l_asset_hdr_rec.asset_id :=

   --l_asset_fin_rec.salvage_value :=
   --l_asset_fin_rec.unrevalued_cost :=
   --l_asset_fin_rec.short_fiscal_year_flag :=
   --l_asset_fin_rec.conversion_date :=
   --l_asset_fin_rec.orig_deprn_start_date :=
   --l_asset_fin_rec.unit_of_measure :=

   --l_asset_deprn_rec.reval_deprn_reserve :=
   --l_asset_deprn_rec.reval_amortization_basis :=

   -- Accept amort start date for amortize NBV additions
   -- l_trans_rec.amortization_start_date :=
   -- to_date('&amort_start_date', 'DD-MON-YYYY');

   -- call the api
   fa_addition_pub.do_addition (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_full,
                                x_return_status               => l_return_status,
                                x_msg_count                   => l_mesg_count,
                                x_msg_data                    => l_mesg,
                                p_calling_fn                  => NULL,
                                px_trans_rec                  => l_trans_rec,
                                px_dist_trans_rec             => l_dist_trans_rec,
                                px_asset_hdr_rec              => l_asset_hdr_rec,
                                px_asset_desc_rec             => l_asset_desc_rec,
                                px_asset_type_rec             => l_asset_type_rec,
                                px_asset_cat_rec              => l_asset_cat_rec,
                                px_asset_hierarchy_rec        => l_asset_hierarchy_rec,
                                px_asset_fin_rec              => l_asset_fin_rec,
                                px_asset_deprn_rec            => l_asset_deprn_rec,
                                px_asset_dist_tbl             => l_asset_dist_tbl,
                                px_inv_tbl                    => l_inv_tbl,
                                px_inv_rate_tbl               => l_inv_rate_tbl
                               );
   DBMS_OUTPUT.put_line (l_return_status);

   IF (l_return_status <> fnd_api.g_ret_sts_success)
   THEN
      DBMS_OUTPUT.put_line ('FAILED');
      -- dbms_output.put_line(to_char(sqlerr));
      DBMS_OUTPUT.put_line (SQLERRM);
      l_mesg_count := fnd_msg_pub.count_msg;

      IF l_mesg_count > 0
      THEN
         l_mesg := CHR (10) || SUBSTR (fnd_msg_pub.get (fnd_msg_pub.g_first, fnd_api.g_false),
                                       1,
                                       512
                                      );

         FOR i IN 1 .. 2
         LOOP   -- (l_mesg_count - 1) loop
            l_mesg := l_mesg || CHR (10) || SUBSTR (fnd_msg_pub.get (fnd_msg_pub.g_next, fnd_api.g_false),
                                                    1,
                                                    512
                                                   );
         END LOOP;

         fnd_msg_pub.delete_msg ();
         l_mesg_len := LENGTH (l_mesg);

         FOR i IN 1 .. CEIL (l_mesg_len / 255)
         LOOP
            DBMS_OUTPUT.put_line (SUBSTR (l_mesg,
                                          ((i * 255) - 254),
                                          255
                                         ));
         END LOOP;
      END IF;
   ELSE
      DBMS_OUTPUT.put_line ('SUCCESS');
      DBMS_OUTPUT.put_line ('THID' || TO_CHAR (l_trans_rec.transaction_header_id));
      DBMS_OUTPUT.put_line ('ASSET_ID' || TO_CHAR (l_asset_hdr_rec.asset_id));
      DBMS_OUTPUT.put_line ('ASSET_NUMBER' || l_asset_desc_rec.asset_number);
   END IF;
END;

Cheers!


Payables Invoice Interface/Conversion

$
0
0

Sample code for Payables Invoice interface and/or conversion:


DECLARE
   gn_user_id        NUMBER  := fnd_global.user_id;
   gn_resp_id        NUMBER  := fnd_global.resp_id;
   gn_resp_appl_id   NUMBER  := fnd_global.resp_appl_id;
   gn_req_id         NUMBER  := fnd_global.conc_request_id;
   gn_sob_id         NUMBER  := fnd_profile.VALUE ('GL_SET_OF_BKS_ID');
   gn_org_id         NUMBER  := fnd_profile.VALUE ('ORG_ID');
   v_boolean         BOOLEAN;
-- ....
-- Other declarations
-- ....
BEGIN
   -- ...
   -- Several lines of code to pick up the data to create the invoices
   -- ...

   -- Invoice header
   SELECT ap_invoices_interface_s.NEXTVAL
     INTO ln_ho_invoice_id
     FROM DUAL;

   -- Insert data for invoice header
   INSERT INTO ap_invoices_interface
               (invoice_id, invoice_num, invoice_date, description,
                invoice_type_lookup_code, invoice_amount, invoice_currency_code, exchange_rate_type, exchange_rate,
                exchange_date, vendor_id, vendor_site_id,
                org_id, terms_id, payment_method_lookup_code,
                gl_date, goods_received_date,
                invoice_received_date, terms_date, SOURCE,
                pay_group_lookup_code, request_id, creation_date, created_by, last_update_date, last_updated_by
               )
        VALUES (ln_ho_invoice_id, lcu_ap_int_hdr_rec.invoice_number, lcu_ap_int_hdr_rec.invoice_date, lcu_ap_int_hdr_rec.hdr_desc,
                'STANDARD', ln_inv_amount, lcu_ap_int_hdr_rec.invoice_currency_code, 'User', NVL (lcu_ap_int_hdr_rec.exchange_rate, 1),
                lcu_ap_int_hdr_rec.exchange_date, lcu_ap_int_hdr_rec.vendor_id, lcu_ap_int_hdr_rec.vendor_site_id,
                lcu_ap_int_hdr_rec.org_id, lcu_ap_int_hdr_rec.terms_id, lcu_ap_int_hdr_rec.payment_method_lookup_code,
                lcu_ap_int_hdr_rec.gl_date, lcu_ap_int_hdr_rec.goods_received_date   --lc_ho_goods_rec_date
                                                                                  ,
                lcu_ap_int_hdr_rec.invoice_received_date, lcu_ap_int_hdr_rec.terms_date, lcu_ap_int_hdr_rec.ost_source,
                lcu_ap_int_hdr_rec.pay_grp, gn_req_id, SYSDATE, gn_user_id, SYSDATE, gn_user_id
               );

   -- Insert data for invoice distributions
   SELECT ap_invoice_lines_interface_s.NEXTVAL
     INTO ln_ho_invoice_line_id
     FROM DUAL;

   ln_line_amount := - (lcu_ap_int_line_rec.line_amount);

   -- Insert into AP interface lines table for HO invoice'
   INSERT INTO ap_invoice_lines_interface
               (invoice_id, invoice_line_id, line_number, line_type_lookup_code,
                amount, dist_code_concatenated, org_id,
                description, accounting_date, creation_date, created_by, last_update_date, last_updated_by,
                attribute2
               )
        VALUES (ln_ho_invoice_id, ln_ho_invoice_line_id, lcu_ap_int_line_rec.line_number, lcu_ap_int_line_rec.line_type_lookup_code,
                ln_line_amount, NVL (lc_code_comb, lcu_ap_int_line_rec.concatenated_segments), lcu_ap_int_line_rec.org_id,
                lcu_ap_int_line_rec.line_desc, lcu_ap_int_line_rec.accounting_date, SYSDATE, gn_user_id, SYSDATE, gn_user_id,
                lcu_ap_int_hdr_rec.invoice_number
               );

   -- Set the profile
   fnd_global.apps_initialize (user_id                       => gn_user_id,
                               resp_id                       => ln_resp_id,
                               resp_appl_id                  => gn_resp_appl_id
                              );
   -- Execute AP Invoice import
   ln_conc_req_id :=
      fnd_request.submit_request (application                   => 'SQLAP',
                                  program                       => 'APXIIMPT',
                                  description                   => '',
                                  start_time                    => '',
                                  sub_request                   => FALSE,
                                  argument1                     => 'STNINV',
                                  argument2                     => '',
                                  argument3                     => 'N/A',
                                  argument4                     => '',
                                  argument5                     => '',
                                  argument6                     => '',
                                  argument7                     => 'N',
                                  argument8                     => '',
                                  argument9                     => '',
                                  argument10                    => 'N',
                                  argument11                    => '',
                                  argument12                    => '',
                                  argument13                    => ''
                                 );

   EXECUTE IMMEDIATE 'COMMIT';

   IF ln_conc_req_id <> 0
   THEN
      -- Waiting for the Payables Import program to end
      lb_flag :=
         fnd_concurrent.wait_for_request (request_id                    => ln_conc_req_id,
                                          INTERVAL                      => 5,
                                          phase                         => lc_phase,
                                          status                        => lc_status,
                                          dev_phase                     => lc_dev_phase,
                                          dev_status                    => lc_dev_status,
                                          MESSAGE                       => lc_message
                                         );
      -- Submit the Invoice validation program
      ln_inv_vald_req_id :=
         fnd_request.submit_request (application                   => 'SQLAP',
                                     program                       => 'APPRVL',
                                     start_time                    => SYSDATE,
                                     sub_request                   => FALSE,
                                     argument1                     => 'All',
                                     argument2                     => NULL,
                                     argument3                     => NULL,
                                     argument4                     => NULL,
                                     argument5                     => NULL,
                                     argument6                     => 'HOPG',
                                     argument7                     => NULL,
                                     argument8                     => NULL,
                                     argument9                     => gn_sob_id,
                                     argument10                    => 'N',
                                     argument11                    => gn_org_id,
                                     argument13                    => 1000
                                    );

      EXECUTE IMMEDIATE 'COMMIT';

      IF ln_inv_vald_req_id <> 0
      THEN
         lb_flag := NULL;
         -- Wait for Invoice validation program to complete
         lb_flag :=
            fnd_concurrent.wait_for_request (request_id                    => ln_inv_vald_req_id,
                                             INTERVAL                      => 5,
                                             phase                         => lc_phase,
                                             status                        => lc_status,
                                             dev_phase                     => lc_dev_phase,
                                             dev_status                    => lc_dev_status,
                                             MESSAGE                       => lc_message
                                            );
      END IF;
   END IF;

   -- To cancel an AP Invoice
   BEGIN
      fnd_global.apps_initialize (user_id                       => gn_user_id,
                                  resp_id                       => gn_resp_id,
                                  resp_appl_id                  => gn_resp_appl_id
                                 );
      v_boolean :=
         ap_cancel_pkg.ap_cancel_single_invoice (p_invoice_id                  => p_xx_invoice_id,
                                                 p_last_updated_by             => p_xx_last_updated_by,
                                                 p_last_update_login           => p_xx_last_update_login,
                                                 p_set_of_books_id             => p_xx_set_of_books_id,
                                                 p_accounting_date             => p_xx_accounting_date,
                                                 p_period_name                 => p_xx_period_name,
                                                 p_message_name                => v_message_name,
                                                 p_invoice_amount              => v_invoice_amount,
                                                 p_base_amount                 => v_base_amount,
                                                 p_tax_amount                  => v_tax_amount,
                                                 p_temp_cancelled_amount       => v_temp_cancelled_amount,
                                                 p_cancelled_by                => v_cancelled_by,
                                                 p_cancelled_amount            => v_cancelled_amount,
                                                 p_cancelled_date              => v_cancelled_date,
                                                 p_last_update_date            => v_last_update_date,
                                                 p_original_prepayment_amount  => v_orig_prepay_amt,
                                                 p_check_id                    => v_check_id,
                                                 p_pay_curr_invoice_amount     => v_pay_cur_inv_amt,
                                                 p_calling_sequence            => NULL
                                                );

      IF v_boolean
      THEN
         fnd_file.put_line (fnd_file.LOG, 'Successfully Cancelled the Invoice: ' || x_invoice_num);
         COMMIT;
      ELSE
         fnd_file.put_line (fnd_file.LOG, 'Failed to Cancel the Invoice:' || x_invoice_num || 'AS' || v_message_name);
         ROLLBACK;
      END IF;
   END;
END;

Cheers!


Upload Corporate Credit card transactions for Oracle iExpense

$
0
0

I have discussed about Oracle iExpense flow earlier. In that article we talked about entering credit card expenses in the expense report (Step 3b in the Oracle iExpense Flow).

Credit card expenses are essentially the expenses when an employee makes using the corporate credit card provided by his employer. These expenses are sent as a data file by the bank/credit card company, that has provided the card to the employee on behalf of the employer, to the employer.

The employer then loads the data file into Oracle and keeps the expense lines ready for the employee to log in to Oracle and create his/her expense report. The process of loading the expense report data file is given below.


Step 1: Create a staging table

We have created staging table to load the file sent from the credit card company. The table structure we have created is as follows.

CREATE TABLE APPS.XX_AP_CC_TRXNS_STG_TL
(
  ATTRIBUTE1     VARCHAR2(80 BYTE),
  ATTRIBUTE2     DATE,
  ATTRIBUTE3     DATE,
  ATTRIBUTE4     NUMBER,
  ATTRIBUTE5     NUMBER,
  ATTRIBUTE6     VARCHAR2(240 BYTE),
  ATTRIBUTE7     VARCHAR2(15 BYTE),
  ATTRIBUTE8     VARCHAR2(15 BYTE),
  ATTRIBUTE9     NUMBER,
  ATTRIBUTE10    VARCHAR2(80 BYTE),
  ATTRIBUTE11    VARCHAR2(240 BYTE),
  ATTRIBUTE12    DATE,
  RECORD_STATUS  VARCHAR2(1 BYTE),
  DATA_SOURCE    VARCHAR2(60 BYTE),
  LOAD_SEQUENCE  NUMBER,
  REQUEST_ID     NUMBER,
  ERR_MSG        VARCHAR2(1000 BYTE)
)


Step 2: Create a loader program to load the file into the staging table

We have created a HOST program to load the credit card files. The host program will do the following,

  1. Use SQL Loader to load the bank file into the staging table
  2. Move the data file into a processed folder once the file has been loaded

The HOST program will be executed as a concurrent program.

Program:

Executable:

The control file (XX_AP_CC_CTL.ctl) for SQL loader is given below,

LOAD DATA
INFILE *
APPEND INTO TABLE XX_AP_CC_TRXNS_STG_TL
FIELDS TERMINATED BY ','
 OPTIONALLY ENCLOSED BY "'" TRAILING NULLCOLS
  (
   ATTRIBUTE1               "TRIM(:ATTRIBUTE1)",        -- Credit Card No
   ATTRIBUTE2               DATE 'DD/MM/YYYY',          -- Trans Date
   ATTRIBUTE3               DATE 'DD/MM/YYYY',          -- Posted Date
   ATTRIBUTE4               "TRIM(:ATTRIBUTE4)",        -- Amount Foreign Curr
   ATTRIBUTE5               "TRIM(:ATTRIBUTE5)",        -- Converted Amount in USD
   ATTRIBUTE6               "TRIM(:ATTRIBUTE6)",        -- Trans Ref Number
   ATTRIBUTE7               "TRIM(:ATTRIBUTE8)",        -- Currency Code USD
   ATTRIBUTE8               "TRIM(:ATTRIBUTE7)",        -- Transaction Currency Code
   ATTRIBUTE9               "TRIM(:ATTRIBUTE9)",        -- Currency Conversion Rate
   ATTRIBUTE10              "TRIM(:ATTRIBUTE10)",       -- Supplier Name
   ATTRIBUTE11              "TRIM(:ATTRIBUTE11)",       -- Location
   ATTRIBUTE12              DATE 'DD/MM/YYYY',           -- Statement Date    Not Available
   Record_Status            CONSTANT 'N',
   DATA_SOURCE              CONSTANT 'AP_IEXPENSES_CC',
   LOAD_SEQUENCE            SEQUENCE(MAX,1)
  )

The code for the HOST program

# ******************************************************************************
# Usage:        XX_AP_CC_LOAD.prog
# Description:  This program processes Credit Card files for IExpenses
#               available in IEXPENSES_CC folder and calls associated Data Loader Program
#
#
# History:
#
# ******************************************************************************

#Initialize parameters
#By default these four parameters will be assigned.
p_userid_passwd=$1
p_appl_login=$2
p_user_name=$3
p_request_id=$4
p_support_user=$5

CONTROL_FILE=XX_AP_CC_CTL.ctl
BASE_DIR=$XXCUST_TOP
LOADER_DIR=$BASE_DIR/bin
LOADER=$LOADER_DIR/$CONTROL_FILE
DATA_DIR=$XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_unprocessed/
LOGIN_ID=`echo $1|cut -f3,3 -d=`
LOGIN_ID=`echo $LOGIN_ID|cut -f1 -d ' '`
LOGIN_ID=`echo $LOGIN_ID|tr -d '\042'`

#Initialise system variables (standard variables used for logging)
v_work_dir=$XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_unprocessed/
v_file_path_name=$XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_unprocessed/
v_processed_dir=$XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_processed/
v_error_dir=$XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_errors/
v_check_file=$XXCUST_TOP/log/"check_file_"$p_request_id.log

# --------------------
# SQL*Loader Variables
# --------------------

BAD_FILE=$XXCUST_TOP/IEXPENSES_CC/bad_files
LOG_FILE=$XXCUST_TOP/IEXPENSES_CC/log_files
DIS_FILE=$XXCUST_TOP/IEXPENSES_CC/discard_files

# -------------------
# Get Parameter value
# -------------------

RETCODE=$?
code_error=$RETCODE

cd $v_work_dir

echo "The List of Files in the Current Directory : "
echo " "

ls -1 *.*

if [ $? -ne 0 ]
then
   echo "There are no files to be processed "
   mailx -m -s "There are no files to be processed " $p_support_user
   exit 0
else
   #Main Loop
   for v_file_name in  `ls -1 *.*`
   do

   echo " \n----------------------------------------------------"
        echo " Process begin for data file  :  "$v_file_name
        echo " ----------------------------------------------------"

        v_log_file=`echo $v_file_name|cut -f1,1 -d.`
        v_bad_file=`echo $v_file_name|cut -f1,1 -d.`
        v_out_file=`echo $v_file_name|cut -f1,1 -d.`

   if [ -s $v_processed_dir$v_file_name ]
    then
     echo "The data file "$v_file_name" already exists"
     rm $v_file_name
   else
              # ----------------------------------------------------------------
              #  Count records in data file, if empty - abort.Echo to Log file
              # ----------------------------------------------------------------
              RECORD_CNT=`wc -l < $v_file_name`
              if [ "$RECORD_CNT" -eq 0 ]
              then
                 echo "Current Data File is empty, can not process...."
                 echo "The data file is moved to XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_errors folder with name: "$4"-"$v_file_name
                  mv $v_file_name $v_error_dir$4"-"$v_file_name
              else
                 # ------------------------------------------------------
                 #     SQL loader to import data into interim table
                 # ------------------------------------------------------
                 echo "LOADER is: $LOADER"
                 echo "FILENAME is: $DATA_DIR/$v_file_name"
                 echo "LOG FILE is: $LOG_FILE/$v_log_file.log"
                 echo "BAD FILE is: $BAD_FILE/$v_bad_file.bad\n"

                 sqlldr userid=$LOGIN_ID \
                        control=$LOADER \
                          data=$DATA_DIR/$v_file_name \
                          log=$LOG_FILE/$v_log_file.log \
                          bad=$BAD_FILE/$v_bad_file.bad \

                echo " SQLLDR COMPLETED"
                echo " Return Code is: $RETCODE"

                 if [ $? = 0 ]
                 then
                    echo "The following file has been processed and moved to XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_processed folder: "$v_file_name
                    uuencode $LOG_FILE/$v_log_file.log $v_log_file.log|mailx -m -s "AP Invoices Log File for IExpenses " $p_support_user
                    mv $v_file_name $v_processed_dir
                    if [ -s $BAD_FILE/$v_bad_file.bad ]
                      then
                        echo "The following data file has error records which are moved to XXCUST_TOP/IEXPENSES_CC/iexpenses_cc_errors folder with name: "$4"-"$v_bad_file.bad
                        uuencode $BAD_FILE/$v_bad_file.bad $v_bad_file.bad|mailx -m -s "AP Invoices Bad File for IExpenses" $p_support_user
                        mv $BAD_FILE/$v_bad_file.bad $v_error_dir$4"-"$v_bad_file.bad
                     fi
                 else
                    echo "SQL*Loader Failed for Current Data File \n"
                    mailx -m -s "SQL*Loader Failed for Current Data File" $p_support_user
                 fi
              fi
   fi
 done
fi
exit 0

Check the loaded records in the staging table by running the following query,

select * from xx_ap_cc_trxns_stg_tl


Step 3: Validate and load the credit card lines from the staging table to the base table

We have written a validation package to validate the credit card lines and to insert the valid records from the staging table, XX_AP_CC_TRXNS_STG_TL, into the base table, AP_CREDIT_CARD_TRXNS_ALL, table. This package will be called from a concurrent program.

Note: We can decide not validate the credit card lines and load the expense lines into AP_CREDIT_CARD_TRXNS_ALL table. In that case we need to call the seeded validation program,
Credit Card Transactions Validation Program
, to validate the data. This process is demonstrated in the appendix section below.

The concurrent program definition is as follows,

Program:

Executable:

The PL/SQL code is as follows,

CREATE OR REPLACE PACKAGE xx_ap_cc_iexpense_pkg
AS
--==============================================================================
--                            XXXXX
--                           YYYYYY
--==============================================================================
--
--
-- MODULE NAME : xx_ap_cc_iexpense_pkg.pkb
-- AUTHOR      :
-- DATE        :
-- DESCRIPTION : This Program Validates Credit Card data from Staging Table and
--               if there are no errors encountered then data is inserted into
--                 AP_CREDIT_CARD_TRXNS_ALL table. If errors then the program is
--                 aborted and logged
--
-- Change Record:
-- =============
-- VERSION    DATE             AUTHOR(S)           Remarks
-- ========   ============     ===============     ============
--
--
--==============================================================================
   gn_request_id   NUMBER;
   gn_user_id      NUMBER;
   gn_email_id     VARCHAR2 (30);

   PROCEDURE xx_ap_validate_cc_proc (errbuf OUT VARCHAR2, retcode OUT NUMBER);
END xx_ap_cc_iexpense_pkg;

CREATE OR REPLACE PACKAGE BODY xx_ap_cc_iexpense_pkg
AS
--==============================================================================
--                            XXXXX
--                           YYYYYY
--==============================================================================
--
--
-- MODULE NAME : xx_ap_cc_iexpense_pkg.pkb
-- AUTHOR      :
-- DATE        :
-- DESCRIPTION : This Program Validates Credit Card data from Staging Table and
--               if there are no errors encountered then data is inserted into
--                 AP_CREDIT_CARD_TRXMS_ALL table. If errors then the program is
--                 aborted and logged
--
-- Change Record:
-- =============
-- VERSION    DATE             AUTHOR(S)           Remarks
-- ========   ============     ===============     ============
--
--==============================================================================
   PROCEDURE xx_ap_validate_cc_proc (errbuf OUT VARCHAR2, retcode OUT NUMBER)
   AS
      lv_org_id             NUMBER;
      lv_card_prg_id        VARCHAR2 (80);
      lv_err_message        VARCHAR2 (1000);
      lv_err_flag           VARCHAR2 (1);
      lv_trx_id             NUMBER;
      lv_card_number        VARCHAR2 (80);
      ln_total_emp_count    NUMBER;
      ln_total_count        NUMBER;
      ln_processed_count    NUMBER;
      ln_total_emp_failed   NUMBER;
      ln_reject_count       NUMBER;
      lc_status             VARCHAR2 (50);
      lc_wf_status          VARCHAR2 (50);

      CURSOR trans_cur (lv_request_id NUMBER)
      IS
         SELECT   attribute1   -- credit card Number
             FROM xxeyap_cc_trxns_stg_tl
            WHERE record_status <> 'P' AND request_id = lv_request_id AND data_source = 'AP_IEXPENSES_CC'
         GROUP BY attribute1, data_source;

      CURSOR trans_details_cur (l_card_no VARCHAR2, ln_request_id NUMBER)
      IS
         SELECT attribute1,   -- Credit Card Number
                attribute2,   -- Trans Date
                attribute3,   -- Posted Date
                attribute4,   -- Amount Foreign Curr
                attribute5,   -- Converted Amount in USD
                attribute6,   -- Trans Ref Number
                attribute7,   -- Currency Code USD
                attribute8,   -- Transaction Currency Code
                attribute9,   -- Currency Conversion Rate
                attribute10,  -- Supplier Name
                attribute11,  -- Location
                attribute12,  -- Statement Date
                record_status,
				data_source,
				load_sequence,
				ROWID
           FROM xx_ap_cc_trxns_stg_tl
          WHERE record_status <> 'P' AND request_id = ln_request_id AND attribute1 = l_card_no AND data_source = 'AP_IEXPENSES_CC';

      CURSOR check_ceo_trans (c_card_number VARCHAR2)
      IS
         SELECT lookup_code
           FROM fnd_lookup_values
          WHERE lookup_type = 'EY_CC_CEO_EXCLUSION'
            AND TRIM (meaning) = c_card_number
            AND NVL (enabled_flag, 'N') = 'Y'
            AND TRUNC (SYSDATE) BETWEEN TRUNC (start_date_active) AND TRUNC (NVL (end_date_active, SYSDATE));

      CURSOR status_cur (p_request_id NUMBER)
      IS
         SELECT   attribute1,   -- Credit Card Number
                             err_msg
             FROM xxeyap_cc_trxns_stg_tl
            WHERE record_status = 'E' AND data_source = 'AP_IEXPENSES_CC'
         GROUP BY attribute1, err_msg, record_status, data_source
         ORDER BY attribute1;

      lcu_check_ceo_trans   check_ceo_trans%ROWTYPE;
   BEGIN
      gn_request_id := fnd_global.conc_request_id;
      gn_user_id := fnd_profile.VALUE ('USER_ID');
      ln_total_emp_count := 0;
      ln_total_emp_failed := 0;

---------------------------------------------------------------------------
-----update the Receipt staging table with WHO columns
---------------------------------------------------------------------------
      BEGIN
         --      fnd_file.put_line (fnd_file.output, 'Request Id' ||gn_request_id);
         UPDATE xxeyap_cc_trxns_stg_tl
            SET request_id = gn_request_id
          WHERE record_status <> 'P';

         COMMIT;
      EXCEPTION
         WHEN OTHERS
         THEN
            lv_err_flag := 'E';
            lv_err_message := 'Error while Updating the Staging Table' || 'with Request Id - ' || SQLERRM;
            fnd_file.put_line (fnd_file.LOG, ' ' || lv_err_message);
      END;

      FOR trans_rec IN trans_cur (gn_request_id)
      LOOP
         lv_err_flag := 'S';
         lcu_check_ceo_trans := NULL;
---------------------------------------------------------------------------
---  Validate the Credit Card Number
---------------------------------------------------------------------------
         ln_total_emp_count := ln_total_emp_count + 1;

         BEGIN
            --       fnd_file.put_line (fnd_file.output, 'Card Number ' || SUBSTR(trans_rec.attribute1,9,16));
            SELECT card_number
              INTO lv_card_number
              FROM ap_cards_all
             WHERE SUBSTR (card_number,
                           9,
                           16
                          ) = SUBSTR (trans_rec.attribute1,
                                      9,
                                      16
                                     ) AND inactive_date IS NULL;
         EXCEPTION
            WHEN OTHERS
            THEN
               lv_err_flag := 'E';
               lv_err_message := 'Credit Card Number Not Exists';
               fnd_file.put_line (fnd_file.LOG, lv_err_message);
         END;

---------------------------------------------------------------------------
---  Check the transaction Belongs to CEO (Ver 1.1 Starts Here)
---------------------------------------------------------------------------
         OPEN check_ceo_trans (trans_rec.attribute1);

         FETCH check_ceo_trans
          INTO lcu_check_ceo_trans;

         CLOSE check_ceo_trans;

         IF lcu_check_ceo_trans.lookup_code IS NOT NULL
         THEN
            lv_err_flag := 'E';
            lv_err_message := 'CEO Credit Card Transacation';
            fnd_file.put_line (fnd_file.LOG, lv_err_message);
         END IF;   --Ver 1.1 Ends Here

---------------------------------------------------------------------------
---  Fetch the Org_id and Card Program Id, Based on the Credit Card Number
---------------------------------------------------------------------------
         BEGIN
            SELECT org_id, card_program_id
              INTO lv_org_id, lv_card_prg_id
              FROM ap_cards_all
             WHERE SUBSTR (card_number,
                           9,
                           16
                          ) = SUBSTR (trans_rec.attribute1,
                                      9,
                                      16
                                     ) AND inactive_date IS NULL;
         EXCEPTION
            WHEN OTHERS
            THEN
               lv_err_flag := 'E';
               lv_err_message := 'Error while getting the details Based on Credit Card No';
               fnd_file.put_line (fnd_file.LOG, lv_err_message);
         END;

         IF lv_err_flag <> 'E'
         THEN
            FOR trans_details_rec IN trans_details_cur (trans_rec.attribute1, gn_request_id)
            LOOP
               --To Fetch the trx_id sequence numbering
               SELECT xxey_ap_cc_seq_s.NEXTVAL
                 INTO lv_trx_id
                 FROM DUAL;

               BEGIN
                  INSERT INTO ap_credit_card_trxns_all
                              (trx_id, validate_code, card_program_id, expensed_amount, card_number,
                               reference_number,
                                                --                            transaction_type,
                                                transaction_date,
                               transaction_amount, debit_flag,
                               billed_date, billed_amount, billed_currency_code,
                               posted_date, posted_amount, posted_currency_code,
                               currency_conversion_rate,
                                                        --                            sic_code,
                                                        --                            merchant_reference,
                                                        merchant_name1, merchant_city,
                                                                                      --                            merchant_country,
                                                                                      org_id,
                               last_update_date, last_updated_by, last_update_login, creation_date, created_by, payment_flag,
                               merchant_activity, CATEGORY, payment_due_from_code, request_id, trx_available_date
                              )
                       VALUES (lv_trx_id, 'N', lv_card_prg_id, 0, trans_details_rec.attribute1,   -- Credit Card Num
                               trans_details_rec.attribute6 || '_' || lv_trx_id,   -- Trx Ref Num
                                                                                --                             trans_details_rec.transaction_type,
                                                                                trans_details_rec.attribute2,   -- Trx Date
                               trans_details_rec.attribute4,   -- Amount Foreign Curr
                                                            DECODE (SIGN (trans_details_rec.attribute4),
                                                                    -1, 'F',
                                                                    'T'
                                                                   ),
                               trans_details_rec.attribute3,   -- Posted date
                                                            trans_details_rec.attribute5,   -- Amount Foreign Curr
                                                                                         trans_details_rec.attribute8,   -- Transaction Currency Code
                               trans_details_rec.attribute3,   -- Posted Date
                                                            trans_details_rec.attribute5,   -- Amount Foreign Curr
                                                                                         trans_details_rec.attribute7,   -- Currency Code USD
                               trans_details_rec.attribute9,   -- Currency Conversion Rate
                                                            --                             trans_details_rec.sic_code,
                                                            --                             trans_details_rec.merchant_reference,
                                                            trans_details_rec.attribute10,   -- Supplier Name
                                                                                          trans_details_rec.attribute11,   -- Location
                                                                                                                        --                             trans_details_rec.merchant_country,
                                                                                                                        lv_org_id,
                               SYSDATE, gn_user_id, gn_user_id, SYSDATE, gn_user_id, 'N',
                               'M', 'BUSINESS', 'COMPANY', gn_request_id, trans_details_rec.attribute12
                              );

                  UPDATE xxeyap_cc_trxns_stg_tl
                     SET record_status = 'P',
                         err_msg = 'Record Processed'
                   WHERE ROWID = trans_details_rec.ROWID AND data_source = 'AP_IEXPENSES_CC';

                  -- AND SUBSTR(card_number,9,16) = SUBSTR(trans_rec.card_number,9,16);
                  COMMIT;
               EXCEPTION
                  WHEN OTHERS
                  THEN
                     fnd_file.put_line (fnd_file.LOG, 'Error in inserting record Data :-' || SQLERRM);
               END;
            END LOOP;
         ELSE
            ln_total_emp_failed := ln_total_emp_failed + 1;

            UPDATE xxeyap_cc_trxns_stg_tl
               SET record_status = 'E',
                   err_msg = lv_err_message
             WHERE SUBSTR (attribute1,
                           9,
                           16
                          ) = SUBSTR (trans_rec.attribute1,
                                      9,
                                      16
                                     );
         --           fnd_file.put_line (fnd_file.output, 'In Else of If for Error') ;
         END IF;
      END LOOP;

      BEGIN
         SELECT COUNT (*)
           INTO ln_total_count
           FROM xxeyap_cc_trxns_stg_tl
          WHERE request_id = gn_request_id;
      EXCEPTION
         WHEN OTHERS
         THEN
            fnd_file.put_line (fnd_file.LOG, 'Error in Others Exception for Receipt Created Count');
      END;

      BEGIN
         SELECT COUNT (*)
           INTO ln_processed_count
           FROM xxeyap_cc_trxns_stg_tl
          WHERE record_status = 'P' AND request_id = gn_request_id;
      EXCEPTION
         WHEN OTHERS
         THEN
            fnd_file.put_line (fnd_file.LOG, 'Error in Others Exception for Receipt Processed Count');
      END;

      BEGIN
         SELECT COUNT (*)
           INTO ln_reject_count
           FROM xxeyap_cc_trxns_stg_tl
          WHERE record_status = 'E' AND request_id = gn_request_id;
      EXCEPTION
         WHEN OTHERS
         THEN
            fnd_file.put_line (fnd_file.LOG, 'Error in Others Exception for Receipt Reject Count');
      END;

      fnd_file.put_line (fnd_file.output, 'EY IExpenses Credit Card Validation Program To AP, Run ON ' || SYSDATE);
      fnd_file.put_line (fnd_file.output, 'Summary Of Run : ');
      fnd_file.put_line (fnd_file.output, ' ');
      fnd_file.put_line (fnd_file.output, ' ');
      fnd_file.put_line (fnd_file.output, RPAD ('*',
                                                90,
                                                '*'
                                               ));
      fnd_file.put_line (fnd_file.output, '    Result of EY IExpenses Credit Card Validation Program       ');
      fnd_file.put_line (fnd_file.output, RPAD ('*',
                                                90,
                                                '*'
                                               ));
      fnd_file.put_line (fnd_file.output, 'Total No. Of Records Avaliable in Staging Table       :- ' || ln_total_count);
      fnd_file.put_line (fnd_file.output, 'Total No. Of Employees Records Processed              :- ' || ln_processed_count);
      fnd_file.put_line (fnd_file.output, 'Total No. Of Employees Records to be Processed        :- ' || ln_total_emp_count);
      fnd_file.put_line (fnd_file.output, 'Total No. Of Employees Records Failed                 :- ' || ln_total_emp_failed);
      fnd_file.put_line (fnd_file.output, 'Total No. Of Records Failed                           :- ' || ln_reject_count);
      fnd_file.put_line (fnd_file.output, RPAD ('*',
                                                90,
                                                '*'
                                               ));
      fnd_file.put_line (fnd_file.output, ' ');

      IF (ln_reject_count > 0)
      THEN
         fnd_file.put_line (fnd_file.output, RPAD ('*',
                                                   90,
                                                   '*'
                                                  ));
         fnd_file.put_line (fnd_file.output, ' ');
         fnd_file.put_line (fnd_file.output, ' Failed Records Information');
         fnd_file.put_line (fnd_file.output, '*****************************');
         fnd_file.put_line (fnd_file.output, '  ');
         fnd_file.put_line (fnd_file.output, RPAD ('*',
                                                   90,
                                                   '*'
                                                  ));
         fnd_file.put_line (fnd_file.output, RPAD ('Card Number ',
                                                   25,
                                                   ' '
                                                  ) || RPAD ('Error Message',
                                                             65,
                                                             ' '
                                                            ));
         fnd_file.put_line (fnd_file.output, RPAD ('*',
                                                   90,
                                                   '*'
                                                  ));
         fnd_file.put_line (fnd_file.output, ' ');

         FOR i IN status_cur (gn_request_id)
         LOOP
            fnd_file.put_line (fnd_file.output, RPAD (i.attribute1, 25) || RPAD (i.err_msg, 65));
         END LOOP;
      END IF;

      fnd_file.put_line (fnd_file.output, ' ');
      fnd_file.put_line (fnd_file.output, ' ');
      fnd_file.put_line (fnd_file.output, 'Request Id : ' || gn_request_id);
      fnd_file.put_line (fnd_file.output,
                         '****** Please See the Log of Request Id for Errors and Exceptions occured during execution In-Detail');
      fnd_file.put_line (fnd_file.output, ' ');
      fnd_file.put_line (fnd_file.output, ' ');
      fnd_file.put_line (fnd_file.output, '***** End of the Report *****');

      /*
      BEGIN
       XXEY_CC_INT_PK.INIT_NOTY_PR(gn_request_id,lc_status);
      EXCEPTION
       WHEN OTHERS THEN
          fnd_file.put_line (fnd_file.log, 'Error while Initiate the Workflow :-'||SQLERRM ) ;
      END;
      */
      BEGIN
         xxey_cc_notify.init_wf (gn_request_id, lc_wf_status);
      EXCEPTION
         WHEN OTHERS
         THEN
            fnd_file.put_line (fnd_file.LOG, 'Error while Initiate the Workflow :-' || SQLERRM);
      END;
   EXCEPTION
      WHEN OTHERS
      THEN
         fnd_file.put_line (fnd_file.LOG, 'Error while Inserting data into Base Table :-' || SQLERRM);
   END xx_ap_validate_cc_proc;
END xx_ap_cc_iexpense_pkg;
/


Step 4: Check the records

Query the credit card transactions base table to view the loaded records,

select * from ap_credit_card_trxns_all


Step 5: Create request set for both programs

You can create a request set so that both programs are executed in sequence. The request set will be like the following,

Stages

Once the programs are executed the credit card lines are loaded into AP_CREDIT_CARD_TRXNS_ALL table. The users subsequently create their own expense report after logging in to Oracle iExpense as shown in Step 3a in this article.

Important:
Only when the expense report is submitted for Credit Card, the expense lines are created in AP_EXPENSE_REPORT_LINES_ALL table. If the expense report is created but saved for later the expense lines remain in the AP_CREDIT_CARD_TRXNS_ALL table.


Code to list pending credit card transactions

The following code lists the employees for whom there are pending credit card transactions that have to be submitted as expense reports.

SELECT   ppx.employee_number, ppx.full_name, accta.card_number, COUNT (accta.card_number) "Num of Transactions"
    FROM ap_cards_all aca, ap_credit_card_trxns_all accta, per_people_x ppx
   WHERE aca.card_number = accta.card_number AND aca.employee_id = ppx.person_id
GROUP BY ppx.employee_number, ppx.full_name, accta.card_number

Appendix

When the seeded validation program, , is used to validate the credit card expense lines the custom program in step 3 above, only needs to transfer the data from the custom table to the credit card table, AP_CREDIT_CARD_TRXNS_ALL.

Once the records are loaded in the table, execute the seeded program named, Credit Card Transactions Validation Program

Responsibility: Payables responsibility

Navigation: View > Requests

After the program completes you can check the credit card table, AP_CREDIT_CARD_TRXNS_ALL, table to view the transactions from the database.

Execute query

select * from ap_credit_card_trxns_all order by trx_id desc

The output

Note the column, VALIDATE_CODE. The value “Y” in this column indicates that the credit card data is valid. You can see some lines with “Y” and some lines with an error message, “INVALID_CARD_NUMBER“.

Now the iExpense credit card users can log in and create their expense reports for the valid credit card transactions in the database against their user names and credit cards (Step 3b in the Oracle iExpense Flow)

Cheers!



PO/Requisition hierarchy change – Error handling/prevention process

$
0
0

When an organization uses Oracle Purchasing, employees are assigned in the PO/Requisition hierarchy. Actually the position of an employee is assigned to the hierarchy. Certain issues can creep in if more than 1 employee is assigned to a position that is in the hierarchy or if an existing position in the hierarchy is end dated. The issues and my resolutions are discussed below.

To notify administrator of position changes

Query the PO hierarchy

You will notice that certain positions show up as No Holders. E.g. position 5440 in the diagram.

This is because the position 5440 was attached to an employee but the employee has been assigned a new position by the HR department. Therefore this position in the PO hierarchy remains in the hierarchy but does not have an employee. Now any PO that goes for approval to position 5440, the workflow stops with a message to the user saying “No Approver found“.

There can be a problem with multiple holders for a position as well. As shown in the diagram below the position 0065 has got 9 holders. This means when the PO approval is sent to this position for approval the workflow will end saying that there multiple holders for a single position and the PO will not be approved.

The requisition workflow behaves in the same manner if similar problems exist in the requisition hierarchy.

To avoid No Holders on a position we created a notification email process so that the administrator can make necessary changes manually, on the PO/Requisition hierarchy.

Step 1: Create a custom table to store the old positions

We have created a custom table, xxhr_position_in_heirarchy, to store the old positions, i.e. the old positions of an employee at the time of a position change of an employee.

Table definition

CREATE TABLE xxhr_position_in_heirarchy
(
person_id NUMBER,
full_name VARCHAR2(50 BYTE),
employee_number VARCHAR2(15 BYTE),
POSITION VARCHAR2(100 BYTE),
position_id NUMBER(15),
record_inserted_on DATE
)

 
Step 2: Write a procedure to identify and store the old positions

We have written a custom procedure, xxhr_pos_in_heirarchy, to identify the old positions for an employee.


CREATE OR REPLACE PROCEDURE apps.xxhr_pos_in_heirarchy (errbuf OUT VARCHAR2, retcode OUT NUMBER)
-- +======================================================================+
-- | XXXXX
-- | YYYYY
-- +======================================================================+
-- |
-- | $Id$
-- |
-- | MODULE NAME: xxey_generate_org_prc
-- | AUTHOR:
-- | DATE:
-- | DESCRIPTION: This procedure is used to store the old positions
-- |
-- |
-- |
-- | PARAMETERS :
-- |
-- |Change Record:
-- |=============
-- |Version Date Author Remarks
-- |======= ==== ====== =======
-- |
-- +======================================================================+
AS
   l_err_message    VARCHAR2 (1000);
   l_record_count   NUMBER          := 0;
BEGIN
   fnd_file.put_line (fnd_file.output, '=========================== Deleted Records =======================================');

   SELECT COUNT (*)
     INTO l_record_count
     FROM xxcust.xxhr_position_in_heirarchy;

   fnd_file.put_line (fnd_file.output, '=======================================================================');
   fnd_file.put_line (fnd_file.output, 'Records Deleted: ' || l_record_count);
   fnd_file.put_line (fnd_file.output, '=======================================================================');

   DELETE      xxcust.xxhr_position_in_heirarchy;

   COMMIT;

   BEGIN
      l_record_count := 0;
      fnd_file.put_line (fnd_file.output, '========= Upoad Position in Hierarchy in xxcust.xxhr_position_in_heirarchy Table =============');

      INSERT INTO xxcust.xxhr_position_in_heirarchy
                  (person_id, full_name, employee_number, POSITION, position_id, record_inserted_on)
         (SELECT papf.person_id, papf.full_name, papf.employee_number, pp.NAME, pp.position_id, SYSDATE record_inserted_on
            FROM per_positions pp, per_all_assignments_f paaf, per_all_people_f papf
           WHERE paaf.position_id = pp.position_id
             AND papf.person_id = paaf.person_id
             AND TRUNC (SYSDATE) BETWEEN paaf.effective_start_date AND paaf.effective_end_date
             AND TRUNC (SYSDATE) BETWEEN papf.effective_start_date AND papf.effective_end_date
             AND papf.current_employee_flag = 'Y'
             AND (   (pp.position_id IN (
                         SELECT ose.subordinate_position_id
                           FROM per_pos_structure_elements ose, per_position_structures pos, per_pos_structure_versions posv
                          WHERE posv.position_structure_id = pos.position_structure_id
                            AND ose.pos_structure_version_id = posv.pos_structure_version_id
                            AND posv.date_to IS NULL
                            AND UPPER (pos.NAME) LIKE UPPER ('EY PO Approval Hierarchy'))
                     )
                  OR (pp.position_id IN (
                         SELECT ose.subordinate_position_id
                           FROM per_pos_structure_elements ose, per_position_structures pos, per_pos_structure_versions posv
                          WHERE posv.position_structure_id = pos.position_structure_id
                            AND ose.pos_structure_version_id = posv.pos_structure_version_id
                            AND posv.date_to IS NULL
                            AND UPPER (pos.NAME) LIKE UPPER ('EY Requisition Hierarchy'))
                     )
                 ));

      COMMIT;

      SELECT COUNT (*)
        INTO l_record_count
        FROM xxcust.xxhr_position_in_heirarchy;

      fnd_file.put_line (fnd_file.output, '=======================================================================');
      fnd_file.put_line (fnd_file.output, 'Records Uploaded: ' || l_record_count);
   EXCEPTION
      WHEN OTHERS
      THEN
         fnd_file.put_line (fnd_file.LOG, SQLERRM);
   END;
EXCEPTION
   WHEN OTHERS
   THEN
      fnd_file.put_line (fnd_file.LOG, SQLERRM);
END xxhr_pos_in_heirarchy;
/

 
Step 3: Create a concurrent program for executing the procedure

We created a concurrent program to execute the procedure.

Concurrent program name: EY HR Load Positions in Hierarchy To Temp Table

Executable name: xxhr_pos_in_heirarchy

This concurrent program is scheduled to run every day so that the position changes for each day is noted in the custom table.

 
Step 4: Create an alert to send position change emails

We created an Oracle alert that will check the change in positions and send emails to the team that maintains the Purchasing and Requisition hierarchy. The email will contain the positions of employees whose old positions exist in either the Purchasing or Requisition hierarchy and their new positions. These positions are changed manually by the team that maintains the hierarchy.

Alert definition

SQL

SELECT papf.full_name, papf.employee_number, pp.NAME new_position, xph.POSITION old_position
INTO &name, &emp_no, &posi2, &posi1
FROM   per_all_assignments_f paaf, per_all_people_f papf, per_positions pp, xxcust.xxhr_position_in_heirarchy xph
 WHERE paaf.person_id = papf.person_id
   AND papf.person_id = xph.person_id
   AND pp.position_id = paaf.position_id
   AND paaf.position_id != xph.position_id
   AND SYSDATE BETWEEN paaf.effective_start_date AND paaf.effective_end_date
   AND SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date
   AND NOT EXISTS (
          SELECT 1
            /*
            v1.output_value
            ,v2.output_value old_position
            ,v3.output_value new_position
            */
          FROM   apps.alr_alert_history_view v1, apps.alr_alert_history_view v2, apps.alr_alert_history_view v3
           WHERE v1.alert_name = 'EY HR Position Change Alert New'
             AND v2.alert_name = 'EY HR Position Change Alert New'
             AND v3.alert_name = 'EY HR Position Change Alert New'
             AND v1.exception_sequence = v2.exception_sequence
             AND v2.exception_sequence = v3.exception_sequence
             AND v1.output_name = 'EMP_NO'
             AND v2.output_name = 'POSI1'
             AND v3.output_name = 'POSI2'
             AND v1.output_value = papf.employee_number
             AND v2.output_value = xph.POSITION
             AND v3.output_value = pp.NAME)

Action

Action Details

Message text

For the &name (Employee number &Emp_No) position has been changed with the following details.

Position Old :&Posi1

Position new :&posi2

This is for your information and necessary action.

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

The alert LDT file is given in the URL below for reference.

Alert LDT document

Once the alert is executed it sends the email. The email that will be delivered to the recipients will look like the following,

We can schedule this alert to execute on a regular basis and email for the changes in positions. Using this process, the old positions on the PO and Requisition hierarchies can be changed manually by the administrator with the new positions.

    
To avoid multiple holders for a position

In the previous customization we had talked about a process to notify the Purchasing administrator about position changes of an employee if he/she is on the PO/Requisition hierarchy.

Now we can also have a problem with the PO/Requisition hierarchy if a position on the hierarchy is assigned to more than 1 person. It will be very straightforward if we assign the position in Oracle HR to be a single incumbent position. The problem arises when the position is multiple incumbent.

We thought of stopping the Oracle HR administrator from assigning multiple employees to a multiple incumbent if the position already exists on the PO/Requisition hierarchy. We personalized the Assignment form to do so.

Step 1: Create a function to validate an assigned position for an employee

We created a function, XXEY_GET_POSITION_VAL, to validate whether a position has holders or not.

CREATE OR REPLACE FUNCTION apps.xxey_get_position_val (p_person_id NUMBER)
   RETURN NUMBER
IS
   l_position_id                NUMBER;
   l_pos_req                    VARCHAR2 (10);
   l_pos_po                     VARCHAR2 (10);
   l_val                        NUMBER;
   l_pos_structure_version_id   per_pos_structure_versions.pos_structure_version_id%TYPE;
BEGIN
   BEGIN
      SELECT position_id
        INTO l_position_id
        FROM per_all_assignments_f
       WHERE person_id = p_person_id AND SYSDATE BETWEEN effective_start_date AND effective_end_date;
   EXCEPTION
      WHEN NO_DATA_FOUND
      THEN
         NULL;
   END;

   --Checking the position in "PO Hierarchy"
   SELECT ppsv.pos_structure_version_id
     INTO l_pos_structure_version_id
     FROM per_position_structures pps, per_pos_structure_versions ppsv
    WHERE pps.position_structure_id = ppsv.position_structure_id
      AND pps.NAME = 'EY PO Approval Hierarchy'
      -- Change as per the PO hierarchy name
      AND SYSDATE BETWEEN date_from AND NVL (date_to, TO_DATE ('31-DEC-4712', 'DD-MON-YYYY'));

   SELECT per_positions_pkg.exists_in_hierarchy (x_pos_structure_version_id    => l_pos_structure_version_id,
                                                 x_position_id                 => l_position_id)
     INTO l_pos_req
     FROM DUAL;

   -- if the employee does not exist in the PO hierarchy check the requisition hierarchy
   IF l_pos_req = 'N'
   THEN
      --Checking the position in "Requisition Hierarchy"
      SELECT ppsv.pos_structure_version_id
        INTO l_pos_structure_version_id
        FROM per_position_structures pps, per_pos_structure_versions ppsv
       WHERE pps.position_structure_id = ppsv.position_structure_id
         AND pps.NAME = 'EY Requisition Hierarchy'
         -- Change as per the REQ hierarchy name
         AND SYSDATE BETWEEN date_from AND NVL (date_to, TO_DATE ('31-DEC-4712', 'DD-MON-YYYY'));

      SELECT per_positions_pkg.exists_in_hierarchy (x_pos_structure_version_id    => l_pos_structure_version_id,
                                                    x_position_id                 => l_position_id)
        INTO l_pos_po
        FROM DUAL;

      IF l_pos_po = 'Y'
      THEN
         l_val := 1;
      ELSE
         l_val := 0;
      END IF;
   ELSE
      l_val := 1;
   END IF;

   RETURN (l_val);
END;
/

 
Step 2: Create a personalization on the Assignment form in HRMS

Open the Assignment form in Oracle HRMS

Click on Help > Diagnostics > Custom Code > Personalize. Add a personalization as shown below.

Condition tab

The condition is as follows,

 WHERE xxey_get_position_val (:assgt.person_id) = 1
   AND (SELECT hap.position_type
          FROM hr_all_positions_f hap
         WHERE position_id = :assgt.position_id AND SYSDATE BETWEEN effective_start_date AND effective_end_date) <> 'SINGLE'
   AND :SYSTEM.block_status = 'CHANGED'

Action tab

Action 1:

The error message defined for this personalization is,

Only Single Incumbent position assignment is allowed for this employee as he/she is part of part of Purchasing / Requisition Hierarchy

Action 2:

Save the form and close all forms.

 
Test the personalization

Open the Assignment form

We shall change the position of this employee to a position that has already been assigned to an employee.

Click on the Position field and type in 7126%

Tab out of the field

Select whether you want to Update or Correct the record. This message is due to the Date Tracking feature in HRMS.

Once you have selected the Date Track option the next popup message appears asking whether the default values attached to the new position are applicable to this employee or not. Press either Yes or No for the position change to take place.

Now save the form.

Now the error message from the personalization is displayed and you are not allowed to save the record. This means that this position cannot be assigned to this employee. This way we can prevent the HR department from assigning multiple employees on a position that exists in the PO/Req hierarchy.

Cheers!


Account generation workflow setup and customization

$
0
0

Accounting information for PO and Requisitions can be derived from multiple places within Oracle Apps. Accounts are setup on Employees, Items, Subinventories, Item Categories, etc. Whenever a PO/Requisition is raised the accounting combination for the document lines are derived by the corresponding account generator workflow. The workflows can be customized as well to deviate from the seeded rules of account generation.

Oracle has defined account generator processes for many types of documents/transactions. If you need to modify the account generation logic then you need to customize the corresponding logic. You can check the Account Generator workflow names and the process names within Oracle.

Responsibility: General Ledger SuperUser

Navigation: Setup > Financials > Flexfields > Key >Accounts

Query the form

You can see that we can have a set of Account generation based on the Accounting Flexfield structure. Therefore if we have multiple accounting structures we will also have multiple account generation workflow processes. Essentially within 1 instance the workflow items will be the same but we can customize the workflows or add new processes for the workflows for different flexfield structures.

Requisition Account Generator workflow modification

We have added a function called Expense Account to modify the default expense account generation. This function has been added in the process, Build Expense Charge Account.

Build Expense Charge Account process

The properties for the function, Expense Account is as follows

This customization will generate different segment values based on the business logic in the PL/SQL code.

You will find examples of account generator at the following link,

Account setup in Employee Master

Responsibility: HRMS

Enter employee number, say 11854

Click on Find

Click on Assignment

Click on extra Tab button as shown below

Click on Purchasing Order Information

Note the default set of books and expense account for the employee

Accounts setup on Inventory organization

Navigation: Setup > Organization > Subinventories

Select a subinventory. We selected CMS

Click on OK.

Now query on this form for the subinventories. Click on Ctrl+F11.

Select a name, FURNTIURE.

Click on Open.

The subinventory is displayed. Click on Accounts tab.

The accounts set on the sub inventory are displayed as those are setup. As an alternate you can check the accounts from the previous screen.

Scroll right on the Subinventories screen

Now you can view the accounts

Accounts setup on Item Master

Responsibility: Inventory SuperUser

Navigation: Items > Master Items

You will be first prompted to change the organization to the correct subinventory

Choose a subinventory. We have chosen, CMS.

Query for an item, say CMS002.

Go to Purchasing tab

Note the account segment of the Expense account, i.e. 5774.

Account setup on Item Categories

Responsibility: Inventory SuperUser responsibility

Navigation: Setup > Items > Categories > Category Codes

Enter the following

Structure: Item Categories

Item Segment: Non-Stock

Item Family: Printing – Revenue Documents (5772)

Click on OK

Click on Find

Click on the DFF for Structure name=Item Categories

The account code is set on this DFF. This value is used by the PO/Requisition Account Generator when the PO or the Requisition is raised for a Non Stock item with these categories.

If we did not enter a particular Structure Name and Category and clicked on Find, then we would have got the records as shown below.

All the item categories are displayed. We have enabled a DFF for item categories on the prior form.

DFF Name: Item Categories

The segments are the following

Let us check the accounts for each scenario now.

Requisition for a Stock item

In this requisition the item, CMS002, is a stock item (as we have checked in Item master earlier). Check the distribution account.

The charge account is being picked up by the Requisition Account generator from the org setup. This is the expense account and it is picked from the material account of the subinventory.

Requisition for a Non Stock Item

The Non Stock item will not have an item number. Instead it goes by the category. In this requisition the category is Non-Stock.Printing – Revenue Documents (5772)..

Check the distributions for this requisition line.

The Requisition charge account, i.e. the item expense account, is derived from the Item Categories setup for the category used on the item line (as shown in the setup earlier)

Logic for PO account generation in this Oracle instance

Item type Document type Account generation rule
Non stock item Internal requisition There is no such scenario as this can only be done for a Purchase requisition
Stock item Internal requisition 1st 3 segments from emp master 4th seg from item master expense acc – Req acc generator
Non stock item Purchase requisition 1st 3 segments from emp master 4th seg from item category – PO acc generator
Stock item Purchase requisition Complete accountingl combination from organization setup

This logic is built into the PO account generator and you will see the results when you raise a PO and add distributions on the PO.

Cheers!


Customized item requisition process

$
0
0

The requirement:

A new class of requisitions will be created by the end users requesting for items from a decentralized location/organization termed as Outstations. The requisitions will be processed by a centralized location/organization (known as Head Office/Main Store) and the items will be issued to the requesting location/organization.

To meet this requirement, 2 custom forms were developed:

  1. To enter requisitions from decentralized location (XXEYIFNREQ.fmb)
    1. Tables used: XXEY_REQUISITION_HEADER_T and XXEYIN_T_REQUISITION_LINES
  2. To fulfill the requisitions from the central location (XXEYIFNTXN.fmb)
    1. This form will allow the user to decide from which warehouse the items will be picked up
    2. The items will be transacted as well.
    3. Tables used: XXEYIN_T_TRANSACTION_HEADER and XXEY_T_TRANSACTION_LINES

This custom process has been created because a standard requisition process will involve

The entire requisition process is given below and the code is given at the bottom

Step 1: Create the requisitions

The requisitions will be created by stock requestors.

Requisitions are created from EY Catering Stores User in a custom form.

Enter the Outstation/Location

Then enter the requisition lines

Save the requisition

After saving the data click on Submit button to freeze the requisition

Once this requisition is created and saved the requisition is stored in 2 custom tables, XXEY_REQUISITION_HEADER_T and XXEYIN_T_REQUISITION_LINES.

You can check with the following queries

select * from XXEY_REQUISITION_HEADER_T where requisition_number = 'R-BOM-7669-05-SEP-2012'


select * from XXEYIN_T_REQUISITION_LINES where in_requisition_header_id = 7669

This form allows only 1 requisition per outstation/location (this also refers to a subinventory as per the setup in this instance of Oracle), i.e. . If you try to create a requisition for an outstation/location for which an active requisition already exists then you will get the following error message,

Step 2: Transact the requisitions

This transaction will be executed by the Warehouse manager from a centralized location (Head Office) from where stock will be issued to the outstation/decentralized location/sub inventory.

After requisitions are created the requisitions are transacted from EY Main Stores – Stores User. The requisitions are picked up for each location and the quantity of the items, to be transacted, are entered. Once this is done, the user submits the transactions. The form internally creates Material Transactions to transfer the items from one sub inventory to the other sub inventory.

The Warehouse Manager opens the form Named EY Stock Transactions.

Enter the name of the Outstation in the header section of the form

After entering the name of the Outstation click on the line section of the form for the form to populate the lines section with the requisitions entered for this outstation.

Now click on Subinventory field of the requisition line and fill out the Subinventory for both lines.

Click on the Locator button on the the line level to enter the value of Transaction Qty fields. On clicking this button the Locator window opens. Enter the quantity to be issued.

Enter the quantity in the locator for the other line as well.

Now the data looks like this

Now save the form.

At this moment the form moves the requisition data from the following tables (the requisition data is converted to material transaction data)

  1. XXEY_REQUISITION_HEADER_T
    to
    XXEYIN_T_TRANSACTION_HEADER

  2. XXEYIN_T_REQUISITION_LINES
    to
    XXEY_T_TRANSACTION_LINES

You can use the following queries

select * from XXEY_REQUISITION_HEADER_T where requisition_number = 'R-BOM-7669-05-SEP-2012'


select * from XXEYIN_T_TRANSACTION_HEADER where in_transaction_header_id = 5887

After saving the data on the form click on Submit button. On clicking on this button the material transaction lines are inserted into MTL_TRANSACTION_INTERFACE and the Material Transaction Interface is executed.

The following requests are executed,

  1. Process Transaction Interface
  2. Inventory transaction worker

You can use the following query to check the status of the records.

select * from mtl_transactions_interface where transaction_reference = 'R-BOM-7668-05-SEP-2012'

Appendix:

Table Structure

XXEY_REQUISITION_HEADER_T table
CREATE TABLE XXEY_REQUISITION_HEADER_T
(
  IN_REQUISITION_HEADER_ID  NUMBER,
  REQUISITION_NUMBER        VARCHAR2(60 BYTE)   NOT NULL,
  REQUISITION_DATE          DATE,
  HEADER_DESCRIPTION        VARCHAR2(240 BYTE),
  PREPARER_ID               NUMBER(10),
  PREPARER_NUMBER           VARCHAR2(30 BYTE),
  APPROVER_ID               NUMBER(10),
  APPROVER_NUMBER           VARCHAR2(30 BYTE),
  REMARKS                   VARCHAR2(150 BYTE),
  CANCEL_REQUISITION        VARCHAR2(1 BYTE),
  COMMENTS                  VARCHAR2(240 BYTE),
  CATERER_ORGANIZATION_ID   NUMBER,
  CATERER_SUBINVENTORY      VARCHAR2(10 BYTE),
  ITEM_CLASS                VARCHAR2(30 BYTE),
  ORG_ID                    NUMBER,
  ORGANIZATION_ID           NUMBER,
  ATTRIBUTE1                VARCHAR2(150 BYTE),
  ATTRIBUTE2                VARCHAR2(150 BYTE),
  ATTRIBUTE3                VARCHAR2(150 BYTE),
  ATTRIBUTE4                VARCHAR2(150 BYTE),
  ATTRIBUTE5                VARCHAR2(150 BYTE),
  LAST_UPDATE_DATE          DATE                NOT NULL,
  LAST_UPDATED_BY           NUMBER              NOT NULL,
  CREATION_DATE             DATE                NOT NULL,
  CREATED_BY                NUMBER              NOT NULL,
  LAST_UPDATE_LOGIN         NUMBER              NOT NULL,
  WF_ITEM_TYPE              VARCHAR2(8 BYTE),
  WF_ITEM_KEY               VARCHAR2(240 BYTE),
  ATTRIBUTE_CATEGORY        VARCHAR2(240 BYTE),
  SUBMITTED                 VARCHAR2(1 BYTE),
  REQ_VALUE                 NUMBER
)
XXEYIN_T_REQUISITION_LINES table
CREATE TABLE XXEYIN_T_REQUISITION_LINES
(
  IN_REQUISITION_LINE_ID    NUMBER,
  IN_REQUISITION_HEADER_ID  NUMBER,
  LINE_NUMBER               NUMBER,
  ITEM_CODE                 VARCHAR2(40 BYTE),
  ITEM_ID                   NUMBER,
  DESCRIPTION               VARCHAR2(240 BYTE),
  REMARKS                   VARCHAR2(150 BYTE),
  CANCEL                    VARCHAR2(1 BYTE),
  UNIT_PRICE                NUMBER,
  ON_HAND_QTY               NUMBER,
  IN_TRANSIT_QTY            NUMBER,
  AVG_03_MONTH_CONSUMPTION  NUMBER,
  REQUIRED_QTY              NUMBER,
  COMMENTS                  VARCHAR2(240 BYTE),
  UOM                       VARCHAR2(10 BYTE),
  PENDING_REQUISITION_QTY   NUMBER,
  ISSUED_QTY                NUMBER,
  INTERFACE_FLAG            VARCHAR2(1 BYTE),
  INTERFACE_DATE            DATE,
  ORG_ID                    NUMBER,
  ORGANIZATION_ID           NUMBER,
  ATTRIBUTE1                VARCHAR2(150 BYTE),
  ATTRIBUTE2                VARCHAR2(150 BYTE),
  ATTRIBUTE3                VARCHAR2(150 BYTE),
  ATTRIBUTE4                VARCHAR2(150 BYTE),
  ATTRIBUTE5                VARCHAR2(150 BYTE),
  LAST_UPDATE_DATE          DATE                NOT NULL,
  LAST_UPDATED_BY           NUMBER              NOT NULL,
  CREATION_DATE             DATE                NOT NULL,
  CREATED_BY                NUMBER              NOT NULL,
  LAST_UPDATE_LOGIN         NUMBER              NOT NULL,
  URGENT_BOX                VARCHAR2(1 BYTE),
  NEED_BY_DATE              DATE,
  IFS_ONHAND_QTY            NUMBER,
  CANCELLED_QTY             NUMBER,
  REQ_QTY_VALUE             NUMBER,
  FIXED_LOT_MULTIPLIER      NUMBER
)

XXEYIN_T_TRANSACTION_HEADER table
CREATE TABLE XXEYIN_T_TRANSACTION_HEADER
(
  IN_TRANSACTION_HEADER_ID  NUMBER(15),
  TRANSACTION_NUMBER        VARCHAR2(60 BYTE),
  TRANSACTION_DATE          DATE,
  REMARKS                   VARCHAR2(300 BYTE),
  CATERER_SUBINVENTORY      VARCHAR2(30 BYTE),
  CATERER_ORGANIZATION_ID   NUMBER,
  INTERFACE_FLAG            VARCHAR2(1 BYTE),
  INTERFACE_DATE            DATE,
  ORG_ID                    NUMBER,
  ORGANIZATION_ID           NUMBER,
  DESCRIPTION               VARCHAR2(240 BYTE),
  EXP_RECEIPT_DATE          DATE,
  AMW_BOL_NUM               VARCHAR2(60 BYTE),
  ATTRIBUTE1                VARCHAR2(150 BYTE),
  ATTRIBUTE2                VARCHAR2(150 BYTE),
  ATTRIBUTE3                VARCHAR2(150 BYTE),
  ATTRIBUTE4                VARCHAR2(150 BYTE),
  ATTRIBUTE5                VARCHAR2(150 BYTE),
  LAST_UPDATE_DATE          DATE                NOT NULL,
  LAST_UPDATED_BY           NUMBER              NOT NULL,
  CREATION_DATE             DATE                NOT NULL,
  CREATED_BY                NUMBER              NOT NULL,
  LAST_UPDATE_LOGIN         NUMBER              NOT NULL
)

XXEY_T_TRANSACTION_LINES table
CREATE TABLE XXEY_T_TRANSACTION_LINES
(
  IN_TRANSACTION_LINE_ID    NUMBER(15),
  IN_TRANSACTION_HEADER_ID  NUMBER(15),
  IN_REQUISITION_LINE_ID    NUMBER,
  REQUISITION_NUMBER        VARCHAR2(40 BYTE),
  SUBINV_CODE               VARCHAR2(250 BYTE),
  IN_REQUISITION_HEADER_ID  NUMBER,
  REQUISITION_QTY           NUMBER,
  ISSUE_ITEM_CODE           VARCHAR2(40 BYTE)   NOT NULL,
  ISSUE_ITEM_ID             NUMBER,
  LINE_NUMBER               NUMBER,
  UOM                       VARCHAR2(25 BYTE),
  BALANCE_QTY               NUMBER,
  ISSUE_DESCRIPTION         VARCHAR2(240 BYTE),
  TRANSACTION_QTY           NUMBER,
  REMARKS                   VARCHAR2(150 BYTE),
  TRANSACT                  VARCHAR2(1 BYTE),
  INTERFACE_FLAG            VARCHAR2(1 BYTE),
  INTERFACE_DATE            DATE,
  ORG_ID                    NUMBER,
  ORGANIZATION_ID           NUMBER,
  ATTRIBUTE1                VARCHAR2(150 BYTE),
  ATTRIBUTE2                VARCHAR2(150 BYTE),
  ATTRIBUTE3                VARCHAR2(150 BYTE),
  ATTRIBUTE4                VARCHAR2(150 BYTE),
  ATTRIBUTE5                VARCHAR2(150 BYTE),
  LAST_UPDATE_DATE          DATE                NOT NULL,
  LAST_UPDATED_BY           NUMBER              NOT NULL,
  CREATION_DATE             DATE                NOT NULL,
  CREATED_BY                NUMBER              NOT NULL,
  LAST_UPDATE_LOGIN         NUMBER              NOT NULL
)

 You will find the code at the following link, Code

Cheers!


Order to Cash (O2C) process flow

$
0
0

The Order to Cash or O2C cycle, as it is popularly called, is one of the basic and common business flows within Oracle apps. This cycle is common for any manufacturing or related companies which have implemented Oracle eBusiness Suite.

The phases in the Order to Cash cycle are,

  • Enter Order
  • Book Order
  • Pick Release
  • Pick Confirm (Optional)
  • Ship Confirm
  • Create Invoice
  • Create Receipt
  • Transfer to GL
  • Bank Reconciliation

Step (i): Check item assignment to sub inventory

We shall first check the warehouses which can transact for the item in question. We shall raise a sales order for this item later on.

Responsibility: Inventory

Navigation: Items > Master Items

You will be first asked to select the sub inventory. We shall choose the sub inventory numbered 125.

Click on OK

Now that the item form is opened, query for the item APX.L600M11.A.

Note:
The item flexfield has 3 segments and hence the item code has 3 values.

Click on the Organization Assignment tab () on the left.

We see that the item, APX.L600M11.A, is assigned to the sub inventory 125. Therefore the sub inventory can store and issue this particular item.

   
Step (ii): Receive goods in sub inventory

We shall provide stock in the sub inventory for this item so that sales orders can be created. To increase stock of this item we shall issue a miscellaneous receipt. If we use a miscellaneous receipt then we do not have to go through a P2P cycle.

Responsibility: Inventory

Navigation: Transactions > Miscellanous Transaction

If you are asked to select the organization/sub inventory, select 125.

Click on OK

Select Type as Miscellanous Issue.

Click on Transaction Lines.

Now enter the Item details. We shall create miscellaneous issue of quantity 50 for item, APX.L600M11.A.

As this item is lot controlled (you can find it from the item master form in step 1) click on Lot/Serial button.

The Lot/Serial form opens. Click on Generate Lot button to generate a new Lot number. Then assign the entire quantity to the same lot.

Click on Done. You will be taken back to the Miscellanous Transaction form.

Save the form. The transaction will complete and the form will be cleared automatically. Close the form.

  
Step (iii): Verify the quantity

We shall now check the current on hand quantity of the item, APX.L600M11.A.

Responsibility: Inventory

Navigation: On-Hand Quantity > On-hand Quantity

Enter the item name.

Click on Find

Click on Availability button.

You can see that the warehouse or sub inventory 125 has a quantity of 650 of item, APX.L600M11.A.

Close the form.

  
Step 1: Enter the sales order

Open the Sales Order form.

Responsibility: Order Management

Navigation: Orders, Returns > Sales Orders

Enter the sales order header information

Enter the Order Type as it is a mandatory field. Notice that the Order Number and Status fields are blank. Also, the Sales Person and Price List fields are set to default values of “No Sales Credit” and “RPL01“. These 2 values come from the setup. Save the form.

Important:

Setup for Pricelist

The profile option, OM: Default Salesrep, is set.


When the form is saved Order Number is populated along with Status. The status of the order now is “Entered”. Click on Others tab.

Ensure that Payment terms is filled out.

Enter the Warehouse if all the order lines will be fulfilled from a single warehouse. We shall enter the value of the Warehouse. This value will be 125, i.e. that the warehouse where we had received the goods initially in step (ii).

We have entered the order header. We shall now enter the order line(s). Notice the top tab on the form.

Click on Line Items tab.

Enter the line details. We shall enter the item number, APX.L600M11.A. In step (ii) we had received the same item into the warehouse. We shall order a quantity of 2.

The price is automatically populated from the price list. The price list in use is RPL01 (which is set as the default price list on the order header)

Click on Pricing tab

The price list is populated from the header. Now click on Shipping tab.

The warehouse is populated from the order header. Save the form to save the order.

Tables Affected:
OE_ORDER_HEADERS_ALL
OE_ORDER_LINES_ALL
FLOW_STATUS_CODE in both the tables is ENTERED

Note:
Whenever an order is entered and saved 2 workflows are kicked off. These 2 workflows move the order from Entered phase to Completed phase. You might find that the order has not progressed into the next phase even though the current phase has been completed. In such a case you need to execute the program, Workflow Background Process. You will find this program under System Administrator responsibility.

The names of the 2 workflows are,

  1. OM Order Header (OEOH)
  2. OM Order Line (OEOL)

You can follow the workflows in Workflow Status Monitor,

You can get details on how to track workflows in this article.

  
Step 2: Book the sales order

Click on Availability button on the sales order form.

We can now check whether there are enough items available to be ordered from the warehouse. We see that the warehouse number 125 has total quantity of 650 and the ordered quantity is 2. Therefore the order can be fulfilled. Close the Availability window.

Click on Book Order button.

A pop message is displayed showing that the order has been booked. Now close the popup message by click on OK and go to the Order header by clicking on Order Information tab.

Notice that Status is now changed to Booked. Close the sales order form.

Tables affected:
The FLOW_STATUS_CODE in OE_ORDER_HEADERS_ALL will be BOOKED.

The FLOW_STATUS_CODE in OE_ORDER_LINES_ALL will be AWAITING_SHIPPING.
New records will be created in WSH_DELIVERY_DETAILS with RELEASED_STATUS=’R’ (Ready to Release)
New record(s) will be created in WSH_DELIVERY_ASSIGNMENTS
When the order is booked the DEMAND INTERFACE PROGRAM will run in the background and insert records into MTL_DEMAND table.

   
Step 3: Pick the order

There are 2 ways of picking the ordered items.

1. Release Sales Order form

Navigation: Shipping > Release Sales Orders > Release Sales Orders

Enter the Order number

Enter Document Set as All Pick Release Documents. Click on Shipping tab.

Enter the following,

AutoCreate Delivery: Yes

Auto pick Confirm: Yes

Autopack Delivery: Yes

Release Sequence Rule: All Standard Orders

Ship From: <The organization from which the item is shipped>

Click on Inventory tab.

Enter the Subinventory

Click on Execute Now button to pick the items. After this the ordered items will be picked from the warehouse and Pick Slip report will be executed. Once this is done we have to go to the Shipping Transaction form in step (ii).

If we pick the order from this form we have more control over the picking process but we will not follow this process to pick the order. We shall use step 2 to pick the order.

2. Shipping Transaction Form

If we pick the items using the Shipping Transaction form we have to manually execute the Move Order.

Navigation: Shipping > Transactions

Enter the Order Number.

Click on Find button.

The order is displayed and the line status shows Ready to Release. The next step is displayed also. It is Pick Release.

Click on the Actions drop down at the bottom of the form.

Select Launch Pick Release.

Click on Go button.

You will get a popup message. Click on OK button. Close the Shipping Transactions form.

Go to the SRS (Standard Request Submission) form by clicking on View > Requests on the main menu. Query for all the requests.

You will find 3 requests executed,

  1. Pick Selection List Generation
  2. Pick Slip Report
  3. Shipping Exceptions Report

Now the items have been picked. You can check the output of Pick Slip Report. It will look like the following.

                                                                                                Report Date:02-MAR-2013 21:08

                                                            Pick Slip                           Report Page:     1
                                                                                             Pick Slip Page:     1

          Warehouse:125     Medical Devices & Consumables, Dubai

          Pick Slip:1079165                       Pick Batch:35483804
 ----------------------------------------------------------------------------------------------------------------------------------
        Grouping Rule: Default: Order Number
                       ----------------------------------
    Customer:AL AHALI PHARMACY - DXB             Delivery:                                             Order:441726
    Ship to:                                         Stop:                                          Priority:
                                                                                                     Carrier:
                                                                                                Subinventory:
                                                                                                 Requisition:

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

Pick From       Pick To         Pick To
Subinv          Subinv          Location
--------------  --------------  --------------
Buset Bulk      Staging

 Move Order
 --------------

 35483804

                                                                    Tolerance
                                                                        Below
                                                             Tolerance      |
                                   Unit                          Above      |
       Move                        |                                 |      |                   Sales
      Order                        |       Quantity    Quantity      |      |       Sales       Order  Ship
   Line No. Item                   |      Requested     Shipped      |      |       Order    Line No.  Set      Trip     Delivery
    ------- ---------------------  ----   ---------    --------  ----- ------  ----------     -------  ----     -----    ---------
          1 14176 LYNCO CASUAL,    PAR            2                  0      0      441726           1                    103577630
            L600M11

                      Lot Number       From Serial       To Serial         Quantity  Revision       Pick from Location
                      --------------   -----------       ---------    -------------  ----------     ------------------

                      1250469993                                                  2

                                                        ** End of Data **

Tables Affected:
If Autocreate Delivery is set to ‘Yes’ on the “Release Sales Order” form then a new record is created in the table WSH_NEW_DELIVERIES
DELIVERY_ID is populated in the table WSH_DELIVERY_ASSIGNMENTS
The RELEASED_STATUS in WSH_DELIVERY_DETAILS would be now set to ‘Y’ (Pick Confirmed) if Auto Pick Confirm is set to Yes otherwise RELEASED_STATUS is ‘S’ (Release to Warehouse)

Step 4: Pick Confirm

We have to transact a Move Order to confirm picking of the items.

Open the Shipping Transactions form again and query for the order, i.e. 441726.

Now the Line Status has changed to Release to Warehouse and the Next Step is Transact Move Order. Scroll the line to the right.

Note the Move Order Number. It is 35483804. Close the form.

Change the responsibility.

Responsibility: Inventory

Navigation: Move Orders > Transact Move Orders

As we are picking the items from Warehouse, 125, we need to select the organization as 125.

Click OK button and the Transact Move Order form will open for this organization.

Enter the Order Number we had got earlier from the Shipping Transaction form.

Click on Find button.

Now check the line.

Now the Transact button is enabled. Click on Transact button.

Once the transaction is processed a popup is displayed. Click on OK to close the popup. Close the form.

      
Step 5: Ship Confirm

Now open the Shipping Transaction form.

Responsibility: Order Management

Navigation: Shipping > Transactions

Query for the Order, 441726.

Now the Line Status is Staged/Pick Confirmed and Next Step is Ship Confirm/Close Trip Stop. Click on Delivery tab at the bottom.

Change the Actions dropdown to Ship Confirm.

Click on Go button. The Confirm Delivery form opens.

Click on OK button.

A popup message is displayed. Click on OK button.

Now the line status shows Closed. Close the form.

Now go to the SRS form and view the requests. The following requests will have run.

The programs are,

  1. Packing Slip Report
  2. Interface Trip Stop
  3. Bill of Lading (if Create Bill of Lading is checked)

The output of Packing Slip Report is,

Medical Devices & Consumables, Dubai                 Packing Slip                                Date:  02-MAR-13
Draft                                                   482899                                   Page:     1     of      1

Ship From:                                  Ship To:                                     Bill To:
Medical Devices & Consumables, Dubai        AL AHALI PHARMACY - DXB                      AL AHALI PHARMACY - DXB
Gulf Drug Establishment Warehouse 2         NEAR DUBAI HOSPITAL                          NEAR DUBAI HOSPITAL
Rashidiya                                   DEIRA DUBAI                                  DEIRA DUBAI
2                                           DUBAI, U.A.E                                 DUBAI, U.A.E
,  , United Arab Emirates                   TEL:04-2626353   FAX:04-2620453              TEL:04-2626353   FAX:04-2620453
                                            , United Arab Emirates                       ,  , United Arab Emirates

                 Tax Name:                                                         Tax Number:
            Delivery Name: 103577630                                             Pick Up Date: 02-MAR-13
                      FOB:                                                        Ship Method: Van-LTL-Door to Door
            Freight Terms:                                                           Way Bill:
      Reason of Transport:                                                   Service Contract:
                  PO Number                Order Number                            Description
                  ------------             --------------                          -------------
                                           441726                                  14176 LYNCO CASUAL, L600M11

   Lot Number             Grade          Order Line Number UOM     Qty Requested      Qty Shipped
   -----------            -----          ----------------- ---     -------------      -----------
   1250469993                                          1.1 PAR              2.00             2.00
                     Secondary  Qty:                                        0.00             0.00

            Gross Weight:                        PCS     Net Weight:                    PCS     Volume:                       PCS
         External Aspect:
        Additional Information:
           Total Cartons: 0
 Unshipped Details
 -----------------
 Item Number                            Order Number     Line Number Unshipped Qty
 -------------------------------------- ---------------- ----------- -------------

                                *** End Of Report ***

Once the programs complete, the order is shipped.

Tables Affected:
RELEASED_STATUS in WSH_DELIVERY_DETAILS will become ‘C’ (Ship Confirmed)
FLOW_STATUS_CODE in OE_ORDER_HEADERS_ALL will become “BOOKED”
FLOW_STATUS_CODE in OE_ORDER_LINES_ALL will become ”SHIPPED”

Execute the program named, Workflow Background Process from System Administrator responsibility. Enter the parameters,

Process Deferred: Yes

Process Timeout: No

Once the program completes go back to order management responsibility and query for the order in Shipping Transaction form.

Notice that the Line Status shows Interfaced and Next Step is Not Applicable. This means that the order has been fulfilled and the invoice can be raised.

Workflow Background Process inserts the records RA_INTERFACE_LINES_ALL with
INTERFACE_LINE_CONTEXT = “ORDER ENTRY”
INTERFACE_LINE_ATTRIBUTE1 = <<Order number>>
INTERFACE_LINE_ATTRIBUTE3 = <<Delivery id>>

   
Step (iv): Check on hand quantity

Open the On hand Quantity as we did in step (iii).

Click on Availability button.

We see that the quantity has been reduced by 2 as Primary Quantity is 648 (650 -2). Availability to Reserve and Transact are 646 as another order with a quantity of 2 for the same item has been picked from the inventory but not shipped.

  
Step 6: Create Invoice in AR

Go to the Receivables responsibility for the corresponding operating unit.

Navigation: View > Requests

Click on Submit a New Request. Select Single Request.

Enter the program name as Autoinvoice Master Program. Enter the following parameters

Invoice Source: Order Entry

Default Date: <Any date. Normally current date>

Click OK

Click on Submit button.

The programs executed are,

  1. Autoinvoice Master Program
  2. Autoinvoice Import Program

After the programs complete, you can check the output of Autoinvoice Import Program.

GDE SET OF BOOKS                                    AutoInvoice Execution Report                             Date: 02-MAR-2013 22:01
                                                                                                             Page:       1 of      4
             Request Id: 51488875

           Batch Source: Order Entry

  Transaction Flexfield:

       Transaction Type:
Bill To Customer Number:                                          to
  Bill To Customer Name:                                          to
                GL Date:                                          to
              Ship Date:                                          to
     Transaction Number:                                          to
     Sales Order Number:                                          to
       Transaction Date:                                          to
    Ship To Cust Number:                                          to
      Ship To Cust Name:                                          to

Interface Lines:                                 Interface Distributions:

                   Selected:          6                             Selected:          0
     Successfully Processed:          1               Successfully Processed:          0
                   Rejected:          5                             Rejected:          0

Interface Salesreps:                             Interface Contingencies:

                   Selected:          6                             Selected:          0
     Successfully Processed:          1               Successfully Processed:          0
                   Rejected:          5                             Rejected:          0

Transactions Created:

     Currency Name UAE Dirham

                                        Number of     Number of     Number of     Number of     Number of    Invoice Currency
     Class                           Transactions     Lines (*) Sales Credits Distributions Contingencies              Amount
     ------------------------------ ------------- ------------- ------------- ------------- -------------   -----------------
     Invoice                                    1             1             1                           0              257.50
                                    ------------- ------------- ------------- ------------- -------------   -----------------
                                                1             1             1                                          257.50

GDE SET OF BOOKS                                    AutoInvoice Execution Report                             Date: 02-MAR-2013 22:01
                                                                                                             Page:       2 of      4
             Request Id: 51488875

    Grand Totals:

                                        Number of     Number of     Number of     Number of     Number of
     Class                           Transactions     Lines (*) Sales Credits Distributions Contingencies      Invoice Amount
     ------------------------------ ------------- ------------- ------------- ------------- ------------- -------------------
     Invoice                                    1             1             1                                          257.50
                                    ------------- ------------- ------------- ------------- ------------- -------------------
                                                1             1             1                                          257.50

    * Number of Lines includes Tax lines

View the invoice.

Navigation: Transactions > Transactions

Query for the invoice.

Reference: 412726 (This is the order number)

Date: 02-Mar-13

The invoice, 1092025, for the order has been created. This invoice will be paid off with a standard receipt.

Affected Tables:
RA_CUSTOMER_TRX_ALL will have the Invoice header information. The column INTERFACE_HEADER_ATTRIBUTE1 will have the Order Number.
RA_CUSTOMER_TRX_LINES_ALL will have the Invoice lines information. The column INTERFACE_LINE_ATTRIBUTE1 will have the Order Number.

  
Step 7: Create receipt for the invoice

After the invoice is created it is sent to the customer. It could be via email after running the Invoice report or an interface program or via a middleware. The customer receives the invoice and makes a payment.

Responsibility: Receivables Manager

Navigation: Receipts > Receipts

Create the receipt, ALAHALI-001, for the payment

Click on Apply button.

Enter the invoice number in the Apply To field. The Applications form opens.

Click on OK.

Close this form to go back to the Receipts form.

You can now see that the receipt has been applied on the invoice. Click on Tools menu item on the main menu.

Select View Accounting. A new web page opens which shows the accounting.

Click on View Journal Entry

Save and close this form.

  
Step 8: Transfer to General Ledger

After the receipt has been applied to the invoice the details will be transferred to General Ledger and journals will be created.

Responsibility: Receivables

Click on View > Requests. Click on Submit a New Request and the Single Request.

Enter program name, Transfer Journal Entries to GL.

Enter the parameters

Click on OK and submit the request.

We shall now view the journal that has been created in General Ledger.

Responsibility: General Ledger

Navigation: Journals > Enter

Enter the Category as Receipts and Period as Mar-13.

Click on Find.

You have 2 journals. Select the 2nd journal that has debit and credit values as 257.50 and click on Review Journal.

Now you can see the created journal. This journal can now be posted and this amount will reflect in the trial balance report.

   
Step 9: Bank Reconciliation

For this demonstration we do not have a bank file that can be loaded into Oracle and then reconciled for the receipt that was applied on the Invoice. You can check the reconciliation process at the following link. In that article we have reconciled payments for Payables module. In this process we have to reconcile for Receivables module.

Cheers!


How to get access to AME configurations

$
0
0

For working on AME or Approval Management we would need access to the responsibility, Approvals Management Business Analyst. In this responsibility we can configure the different approval hierarchy for each transaction. If we provide the responsibility to a user the user might not get access to AME. This is because the user might not have the privileges to access AME functions.

We have created a user in Oracle, JDOE, and given this user the System Administrator responsibilities.

We will add the responsibility, Approvals Management Business Analyst.

As Approvals Management Business Analyst is a self service responsibility, we will click on this responsibility from the Oracle home page.

On clicking Oracle displays a message saying “There are no functions available for this responsibility”. This is because user JDOE does not have privileges to access AME functions.

How do we provide the user with AME functions?

Step 1: Assign AME roles

Log in to Oracle as SYSADMIN user or any other user that has SYSADMIN privileges/role. In this case let us assign user JDOE with AME and SYSADMIN role.

The list of responsibilities are displayed

Click on the responsibility named, User Management.

Click on Users function.

Enter the user name as JDOE and press Go button.

Click on the Update button next to the user.

First we shall assign AME roles to the JDOE. Click on Assign Roles button and the popup window to select roles will open.

Type in Roles and Responsibilities as Approval% and click on Go

We will check all the roles except for Approvals Management System Viewer as it is a view only role for AME. After checking the boxes click on Select button and you will be taken back to the User Management responsibility.

Enter the justification for each of the roles you have just added

Click on Apply button

You will get a confirmation message. Once the Workflow Background Engine program has run the roles will be assigned to the user.

Now we shall assign SYSADMIN privileges to JDOE user. You need to through the same steps as we have gone through to add the AME privilege. Only the role this time will be different. The role that will be added is, Security Administrator. The search screen is shown below.

After accessing the roles log out of Oracle.

Step 2: Grant Transaction Type Access

Log in to Oracle as SYSADMIN user. Check the responsibilities.


Click on Functional Administrator responsibility

The Grants page opens by default. Click on Create Grant button

We shall create a new grant with the following information.

The grant entries will be,

Name: AME access for JDOE

Grantee Type: All Users

Grantee: <The user who wishes to get AME access>

Object: AME Transaction Types

Click on Next

Keep Data Context Type as All Rows and click on Next.

Enter Set as AME Calling Applications and click on Next

On the next page you can review the data you had entered. Now click on Finish and you will be taken to Grants page.

Now you can see the confirmation message from Oracle. Hence the grant has been created successfully. Log out of Oracle.


Test AME responsibility

Log in to Oracle as JDOE user

Notice the responsibilities attached to JDOE user. We had only assigned Approvals Management Business Analyst from the User form after creating the user. Now we have 2 responsibilities added automatically because we added the roles in step 1.

  1. Approvals Management Administrator responsibility added for Approvals Management Administrator role
  2. User Management responsibility added for Security Administrator role.

Click on Approvals Management Business Analyst responsibility

The responsibility now opens as the user has full access to the AME roles (from Step 1) and has the grants on AME transactions (Step 2).

Cheers!


Security Profile usage in Oracle HRMS

$
0
0

The security profile determines which applicant, employee, contingent worker and other person type records are available to holders of the responsibility the profile is linked to.

This is a very effective way of restricting access to employee records on responsibilities/users. The security profile determines which applicant, employee, contingent worker and other person type records are available to holders of the responsibility the profile is linked to.

If you are using HRMS Standard security, you link a security profile to one responsibility using the HR:Security Profile profile option.

If you are using Security Groups Enabled security, you link a security profile to the user’s responsibility and business group using the Assign Security Profile window. You can also link more than one security profile to a responsibility, as long as the user is different. This saves you setting up a new responsibility for each security profile you use.

Note: If you are using the Security Groups Enabled security model you must not use the HR:Security Profile profile option. This is automatically set up when you assign security profiles using the Assign Security Profile window.

Here is how security profile is created and used.

Step 1: Create a security profile

Responsibility: Global HRMS Manager

Navigation: Security > Profile

By default Oracle provides a security profile named, Setup Business Group.

Note: Setup Business Group is also a business group given by Oracle to allow us to install business groups. This is because business groups are created in HRMS responsibilities and a HRMS responsibility cannot exist without being assigned to a business group. Therefore the default HR responsibility, Global HRMS Manager, is assigned a business group, Setup Business Group, and the same security profile until it is changed.

We shall create security profile as shown below

Save and close the form

Step 2: Assign the security profile to the responsibility

Responsibility: System Administrator

Navigation: Profile > System

Query for profile options,

HR: Security Profile

HR:User Type         – This profile option is optional

HR:Business Group     – Business group of the responsibility

Important:

  1. The business groups in the profile option, HR:Business Group, and the Security Profile should match else we shall get the following error.

  1. When Standard HRMS Security is used you will get the following error when trying to access the Assign Security Profiles form from the menu.

Important notes from Oracle:

Restricting Access to Records

You set up a security profile by identifying records of employees, applicants, contingent workers, and candidates in the system which you want users to be able to access. You identify the records by selecting work structures or other criteria in the application to which employees, applicants, contingent workers, or candidates are attached. For example, you could give users access only to the records of employees, applicants, contingent workers, or candidates in a single organization.

You can also create restrictions on records with a person type of “Other“. This includes contacts for employees or applicants, and any other people with a person type in the category of “Other“. You do this using the “View Contacts” option.

You can combine different types of restriction to create a set of rules giving exactly the security access permissions you require.

When you create a business group a view-all security profile is automatically created. This has the same name as the business group. The security profile provides access to all employee, contingent worker, and
applicant records in the business group. The system administrator links this view-all profile to users who are setting up the system. They in turn can set up security for other users.

The criteria you can use to identify records are:

  • Internal organizations and organization hierarchies
  • Positions and position hierarchies
  • Payrolls
  • Supervisors and supervisor hierarchies
  • Custom restrictions
  • Assignments

Tip: Oracle recommends that you use either a supervisor or position hierarchy for Self-Service Human Resources (SSHR).

Cheers!


Error on Supplier OAF page – APP-FND-02902: Multi-Org profile option is required

$
0
0

We got an error on trying to access the Supplier entry OAF page in Oracle from the home page,

Whenever we clicked on the page we got the following error,

If you check the exception details,

In text format the error was,

## Detail 0 ##

JBO-30003: The application pool (dev3.na.fellowes.comdev31533oracle.apps.pos.supplier.server.SuppSummAM) failed to checkout an application module due to the following exception:

oracle.jbo.JboException: JBO-29000: Unexpected exception caught: oracle.apps.fnd.framework.OAException, msg=Application: FND, Message Name: FND_GENERIC_MESSAGE. Tokens: MESSAGE = java.sql.SQLException: ORA-20001: SQL_PLSQL_ERROR: N, ROUTINE, MO_GLOBAL.INIT, N, ERRNO, -20001, N, REASON, ORA-20001: APP-FND-02902: Multi-Org profile option is required. Please set either MO: Security Profile or MO: Operating Unit profile option.

ORA-06512: at "APPS.FND_MESSAGE", line 509

ORA-06512: at "APPS.MO_GLOBAL", line 36

ORA-06512: at "APPS.MO_GLOBAL", line 757

ORA-06512: at "APPS.MO_GLOBAL", line 700

ORA-06512: at line 1

;

As per the error either MO: Operating Unit or MO: Security Profile options have to be set. When I checked the profile option values I found the following,

Responsibility: DON AP Manager

MO: Security Profile

MO: Operating Unit

We see that the value of both profile options are set for this responsibility. Then why does this error occur? This is because the value of the profile option, MO: Operating Unit is not set on the Site level.

I set a value at site level.

Then I tried to open the page once again.

Yeah, it worked! Ideally it should have worked at the beginning but certain seeded packages need a value at the site level as well and so we have to set it else for this responsibility OAF pages will be affected but not Oracle Forms! Strange, but true!

Cheers!



Custom Templates in Advanced Collections – Sending invoice copy letters using Collections

$
0
0

One of the requirements I have come across in Oracle Accounts Receivables is to send invoice copy to the customers about the outstanding dues the customer has with the company. Oracle Advanced Collections can be used to send the copy of an existing invoice to the customer via email, fax or as a printed letter. But my requirement was to send the invoice details in a format suggested by my client which means a custom format for invoice.

First let us look at the standard process and understand where the customization would be needed.

The collector/user will login to Oracle applications and navigate to the Collections responsibility.

Open the collections function shown in above screenshot.

Query a customer and navigate to the “Transactions” tab. Note that when you enter the customer name, you will have to click on its LOV button to retrieve the transactions.

An open transaction is highlighted as shown above and the transaction details button is clicked to open the transaction details window.

The user will now click the “Send Copy” button to send the invoice copy details to the customer and selects the print/fax/email as mode of transmission as shown below.

Once the Send Copy button is clicked, a concurrent program named “Oracle Collections Delivery XML Process” is triggered that will generate the invoice copy in PDF as output and send it to the printer/email/fax. The PDF output can be seen from the concurrent program view output option as well.

However the user wants the invoice copy to be in the format/template that he wishes and not the oracle standard format. This is where I need a custom format which means that I create a custom template that can be used to display the invoice details.

Oracle has provided standard formats in which the invoice copy is sent to the customers using Advanced Collections. An example of such standard template available is the “Invoice Letter” template in Collections application. Oracle has also provided the flexibility of creating custom formats (templates) for invoice copies. A custom template can be created in Collection application to send the invoice details in a custom format.

Analyzing the Invoice Letter template can help in creating a custom template. The template takes the data from a SQL query and creates the xml data that is fetched to the template to create an invoice copy in PDF. This PDF is either printed or sent via fax/email based on the option chosen while generating the invoice copy.

The SQL query that fetches the invoice details is to be registered in Collections application and attached to the custom template created for the invoice copy. The Collections Administrator responsibility helps in registering the SQL query and attaching it to the custom template to produce the invoice copy in PDF.

Let us look at creating a SQL query. Oracle provides standard queries that can be enhanced to capture details that are not present in the standard query. For example you can add columns like Legal Entity name, item code and contact details that standard query does not capture.

Let us use the below query as example.

select to_char(a.trx_date, 'MM/DD/YYYY') trx_date,
a.trx_number trx_number,
a.invoice_currency_code inv_currency_code,
to_char(a.term_due_date, 'MM/DD/YYYY') term_due_date,
b.name term_name,
a.purchase_order purchase_order,
a.ship_date_actual ship_date_actual,
p.party_name rac_bill_to_customer_name,
ca.ACCOUNT_NUMBER rac_bill_to_customer_num,
loc.address1  raa_bill_to_address1,
loc.address2  raa_bill_to_address2 ,
loc.address3  raa_bill_to_address3,
loc.city || decode(loc.state, null, null, ', ' || loc.state) || decode(loc.postal_code, null, null, ', ' || loc.postal_code) || decode(loc.address4, null, null, ', ' || loc.address4)  raa_bill_to_address4,
p.party_name rac_ship_to_customer_name,
loc2.address1  raa_ship_to_address1 ,
loc2.address2  raa_ship_to_address2 ,
loc2.address3  raa_ship_to_address3,
loc2.city || decode(loc2.state, null, null,  ', ' || loc2.state) || decode(loc2.postal_code, null, null, ', ' || loc2.postal_code) || decode(loc2.address4, null, null, ', ' || loc2.address4)  raa_ship_to_address4,
loc3.address1  raa_remit_to_address1 ,
loc3.address2  raa_remit_to_address2 ,
loc3.address3  raa_remit_to_address3,
loc3.city || decode(loc3.state, null, null, ', ' || loc3.state) || decode(loc3.postal_code, null, null, ', ' || loc3.postal_code) || decode(loc3.address4, null, null, ', ' || loc3.address4) raa_remit_to_address4,
(select sum(c.extended_amount) from  ra_customer_trx_lines_all c, ar_vat_tax tax where c.customer_trx_id = a.customer_trx_id and c.vat_tax_id = tax.vat_tax_id(+) and c.line_type = 'TAX' ) tax,
(select sum(c.extended_amount) from  ra_customer_trx_lines_all c, ar_vat_tax tax where c.customer_trx_id = a.customer_trx_id and c.vat_tax_id = tax.vat_tax_id(+) and c.line_type &lt;&gt; 'TAX' ) sub_total,
(select sum(c.extended_amount) from  ra_customer_trx_lines_all c, ar_vat_tax tax where c.customer_trx_id = a.customer_trx_id and c.vat_tax_id = tax.vat_tax_id(+) ) sum_extended_amount,
cursor (select decode(c.line_type, 'LINE', c.line_number, null) line_number, decode (line_type, 'TAX',   initcap(c.line_type) || ' ' || TAX.tax_code || ' @ ' || TAX.tax_rate, 'LINE',  c.description, 'CB', c.description, initcap(c.line_type)) description,
c.quantity_invoiced quantity,
c.unit_selling_price unit_selling_price,
c.extended_amount extended_amount,
a.invoice_currency_code inv_currency_code
from  ra_customer_trx_lines_all C
,AR_VAT_TAX       TAX
where c.customer_trx_id = a.customer_trx_id
and c.vat_tax_id = tax.vat_tax_id(+)
order by c.customer_trx_id) as payment_history
from  ra_customer_trx_all a
,ra_terms_vl b
,hz_parties p
,hz_cust_accounts ca
,hz_locations loc
,hz_locations loc2
,hz_locations loc3
,HZ_CUST_ACCT_SITES_ALL  RAA_REMIT
,HZ_PARTY_SITES      RAA_REMIT_PS
where a.customer_trx_id in (select cust_trx_id from iex_dunning_transactions where dunning_id = : DUNNING_ID AND cust_trx_id is not null)
and a.printing_option = 'PRI'
and a.term_id = b.term_id (+)
and p.party_id = : PARTY_ID
and ca.cust_account_id = : ACCOUNT_ID
and loc.location_id(+) = IEX_DUNNING_PVT.get_dunning_location(a.bill_to_site_use_id)
and loc2.location_id(+) = IEX_DUNNING_PVT.get_dunning_location(a.ship_to_site_use_id)
and a.REMIT_TO_ADDRESS_ID = RAA_REMIT.CUST_ACCT_SITE_ID(+)
and RAA_REMIT.PARTY_SITE_ID = RAA_REMIT_PS.PARTY_SITE_ID(+)
AND RAA_REMIT.PARTY_SITE_ID = RAA_REMIT_PS.PARTY_SITE_ID(+)
AND loc3.LOCATION_ID(+) = RAA_REMIT_PS.LOCATION_ID

Go to the Collections Administrator responsibility and click on the Manage Queries function under Administration menu.

The following page opens.

Click on the “Create Query” button on the bottom right end to create a new query.

The following page opens.

Choose the Query level as customer and give a name to the query by filling in the query description field. Paste the SQL query in the query editor. If your query length exceeds 4000 characters, then you will have to check the CLOB query option to save it.

Note: Save the query without a semicolon at the end. The application will accept a semicolon with the query but it will end in error at run time later.

Once you hit the Apply button, the query is saved in all UPPER case and a record is inserted in the iex_xml_queries table. The query string is stored in the statement column and if your query is registered as CLOB query the query string is stored in the additional_query column.

Select * from iex_xml_queries where description = 'Test Invoice Query'; 

Now the query is registered and ready to be attached to the custom template.

The creation of custom template needs few points to be considered. The xml tags that are to be placed in the rtf and the group names that are to be used if you are displaying the line level details.

The column names in the query can be used as the XML tags but only in UPPER case as this is case sensitive. The query has a cursor PAYMENT_HISTORY to display the line level details hence the template will use PAYMENT_HISTORY_ROW as the group that will deal with line level details.

There will be no group initialized for the header details and only the line level details will have a group mentioned above.

Once the RTF file is ready, register it using the XML Publisher responsibility. Navigate to the mentioned responsibility and use the template function. You can use an existing data definition named “Collection XML Data Source“. Therefore directly move to creating a template and choose the “Create Template“. Give the details and choose the application as Collections and Data definition as Collection XML Data Source.

Now the template is ready and query can be attached to the template to generate the invoice copy in custom PDF format.

Go to the Collections administrator responsibility and choose the Manage Templates Query function under Administration menu.

Collections Administrator à Administration à Manage Template Query

Click on the Assign Query button at the bottom right corner to assign the template to the query. The following page opens.

Enter the custom template name and choose the query description from its LOV. The query string is automatically populated in the query editor as shown below.

Click Apply to save and attach the query to the template.

If you wish to edit the query then assign another standard query to the template in the above screen and then the update the query and reassign it to the custom template. You will not be able to edit the query as long as the query is assigned to any template.

Collections Setup Changes required:

There is however a small setup change that would be needed for Collections to use your custom template when sending invoice copy.

Go to the Collections administrator responsibility and choose the Setup checklist function.

Click on the “Go to task” option for setup correspondence row.

Now choose the custom template as entry for the Invoice Copy LOV and save the changes.

When the user logs in to the Collections Agent responsibility and queries a transaction to send a copy, the above custom template will be chosen to generate the invoice copy.

Once the Send Copy option is clicked, the Oracle Collections Delivery XML Process is run and the invoice copy is generated and sent to printer/email/fax whichever applicable.

The xml data that is generated can be viewed from the table IEX_XML_REQUEST_HISTORIES using the concurrent request id.

Related articles


AR Customer Balance Statement Letter setup and usage

$
0
0

For a European rollout across most countries in Europe we had applied 7 language packs in Oracle r12. I had executed Customer Statement Print report for UK operating unit after the language packs were applied. I was surprised to see the results as I did not match to what I knew in this article. Here is why.

Executing the statement print

Navigation: Print Documents > Statements

Submit the program

Notice multiple request ids in the box, Request Id. Now check the requests in SRS form.

The Statement Generation Program is executed 7 times because there are 7 languages installed in this Oracle instance. Also notice that the Statement Generation Program executes AR Customer Balance Statement Letter instead of Customer Statement Print program.


This is because of the language pack installation.

Concurrent program definition

AR Customer Balance Statement Letter (AR Customer Balance Statement Letter)

Setup for this report

Checking the template of this report.

Responsibility: XML Publisher Administrator

Navigation: Template

Code: CLE_F_ARCUSBALSL

Scroll down

Notice that the translations have been added automatically by the language patches. To know about translated templates check this article.

Check the lookup AR_EMEA_COUNTRIES

Responsibility: Receivables Manager

Navigation: Setup > System > QuickCodes > Receivables

Query for lookup type, AR_EMEA_COUNTRIES

Search for Meaning = United Kingdom

This is a seeded lookup from Oracle that lists all the EMEA countries. The countries enabled here determine which responsibility will execute AR Customer Balance Letter. If the country is not enabled here then the corresponding responsibility will execute Customer Statement Print report.

If a particular EMEA country does not want to execute AR Customer Balance Letter then it can be disabled by unchecking the Enabled box. Then Customer Statement Print report will be automatically enabled for that country. Also, if a non EMA country wants to use the AR Customer Balance Letter then the country can be added in this lookup.

The check for the country is done from the country associated with the operating unit that is associated with the responsibility from which Statements are being printed. The operating unit in turn comes from the profile option MO: Operating Unit. See below,

In our example the address associated with the operating unit UK OPERATIONS determines whether Customer Balance Letter is called or not. Check the address of the operating unit.

Responsibility: Receivables Super User

Navigation: Setup > System > System Options

Click on Miscellaneous tab

Notice the Default Country is United Kingdom. (In the database this data resides in the table AR_SYSTEM_PARAMETERS_ALL).

We have seen that this country exists in the lookup AR_EMEA_COUNTRIES earlier. Hence the AR Customer Balance Letter is kicked off from this operating unit instead of Customer Statement Report.

Cheers!


Provide Shipping Grants to selected users

$
0
0

All Oracle users do not have privileges to all functionalities of Order Management even though they might have Order Management responsibility. The super user allows which functionality individual users get. Here is how the users get access.

Create/View a Role

Responsibility: Order Management Super User

Navigation: Setup > Shipping > Grants and Role Definitions > Grants

Query on this form.

Notice that each role has access to certain functionalities.


Grant Role to a user

Responsibility: Order Management Super User

Navigation: Setup > Shipping > Grants and Role Definitions > Grants

Add a user, say ARAY.

Now check all the values for Role

Once the user is assigned a role he/she will get the privileges as setup for the role.

Cheers!


Custom concurrent program in Shipping Document Set

$
0
0

You can create custom concurrent programs that can be configured to be submitted after,

  1. Pick Release
  2. Ship Confirm

The programs are added in the Shipping Document Sets form.

Navigation: Setup > Shipping > Documents > Document Sets

Query for Document Set as All Pick Release Documents

There is only 1 concurrent program added for this Document Set, Shipping Exceptions Report.

As the Document Set we have used for Pick Release is “All Pick Release Documents” the only program which was executed after Pick Release was Shipping Exceptions Report.

As a part of document sets only a few parameter names are supported in Shipping document sets.

The parameters supported are in the following PL/SQL code from the package WSH_DOCUMENT_SETS :

cursor c_document_params in procedure WSH_DOCUMENT_SETS.Print_Document_Sets (file WSHDSPRB.pls)

CURSOR c_document_params(i NUMBER) IS
SELECT
decode(
lower(decode(l_execution_method_code, ‘P’, srw_param, ‘K’, srw_param, end_user_column_name)), –Bugfix 7493868 Modified decode
‘p_request_id’, to_char(l_doc_set_params(i).p_request_id), — bug 1589045
‘p_customer_id’, to_char(l_doc_set_params(i).p_customer_id),
‘p_item_id’, to_char(l_doc_set_params(i).p_item_id),
‘p_item_cate_set_id’, to_char(l_doc_set_params(i).p_item_cate_set_id),
‘p_item_category_id’, to_char(l_doc_set_params(i).p_item_category_id),
‘p_transaction_type_id’, to_char(l_doc_set_params(i).p_transaction_type_id),
‘p_header_id_low’, to_char(l_doc_set_params(i).p_header_id_low),
‘p_header_id_high’, to_char(l_doc_set_params(i).p_header_id_high),
‘p_salesrep_id’, to_char(l_doc_set_params(i).p_salesrep_id),
‘p_user_id’, to_char(l_doc_set_params(i).p_user_id),
‘p_territory_name’, l_doc_set_params(i).p_territory_name,
‘p_item_display’, l_doc_set_params(i).p_item_display,
‘p_item_flex_code’, l_doc_set_params(i).p_item_flex_code,
‘p_organization_id’, to_char(l_doc_set_params(i).p_organization_id),
‘p_org_id’, to_char(l_doc_set_params(i).p_organization_id),
‘p_sort_by’, to_char(l_doc_set_params(i).p_sort_by),
‘p_show_functional_currency’, l_doc_set_params(i).p_show_functional_currency,
‘p_set_of_books_id’, to_char(l_doc_set_params(i).p_set_of_books_id),
‘p_order_date_low’, to_char(l_doc_set_params(i).p_order_date_low),
‘p_order_date_high’, to_char(l_doc_set_params(i).p_order_date_high),
‘p_delivery_date_low’, to_char(l_doc_set_params(i).p_delivery_date_low),
‘p_delivery_date_high’, to_char(l_doc_set_params(i).p_delivery_date_high),
‘p_freight_code’, l_doc_set_params(i).p_freight_code,
‘p_delivery_id’, to_char(l_doc_set_params(i).p_delivery_id),
‘p_delivery_id_high’, to_char(l_doc_set_params(i).p_delivery_id_high),
‘p_delivery_id_low’, to_char(l_doc_set_params(i).p_delivery_id_low),
‘p_trip_id’, to_char(l_doc_set_params(i).p_trip_id),
‘p_trip_id_high’, to_char(l_doc_set_params(i).p_trip_id_high),
‘p_trip_id_low’, to_char(l_doc_set_params(i).p_trip_id_low),
‘p_bill_of_lading_number’, to_char(l_doc_set_params(i).p_bill_of_lading_number),
‘p_trip_stop_id’, to_char(l_doc_set_params(i).p_trip_stop_id),
‘p_departure_date_low’, to_char(l_doc_set_params(i).p_departure_date_low),
‘p_departure_date_high’, to_char(l_doc_set_params(i).p_departure_date_high),
‘p_container_id’, to_char(l_doc_set_params(i).p_container_id),
‘p_print_cust_item’, l_doc_set_params(i).p_print_cust_item,
‘p_print_mode’, l_doc_set_params(i).p_print_mode,
‘p_print_all’, l_doc_set_params(i).p_print_all,
‘p_sort’, l_doc_set_params(i).p_sort,
‘p_delivery_date_lo’, to_char(l_doc_set_params(i).p_delivery_date_lo),
‘p_delivery_date_hi’, to_char(l_doc_set_params(i).p_delivery_date_hi),
‘p_freight_carrier’, l_doc_set_params(i).p_freight_carrier,
‘p_quantity_precision’, l_doc_set_params(i).p_quantity_precision,
‘p_locator_flex_code’, l_doc_set_params(i).p_locator_flex_code,
‘p_warehouse_id’, to_char(l_doc_set_params(i).p_warehouse_id),
‘p_pick_slip_num_low’, to_char(l_doc_set_params(i).pick_slip_num_l),
‘p_pick_slip_num_high’, to_char(l_doc_set_params(i).pick_slip_num_h),
‘p_order_type_id’, to_char(l_doc_set_params(i).p_order_type_id), –Bugfix 3604021
‘p_order_num_l’, to_char(l_doc_set_params(i).p_order_num_l),
‘p_order_num_h’, to_char(l_doc_set_params(i).p_order_num_h),
‘p_order_num_low’, to_char(l_doc_set_params(i).p_order_num_low),
‘p_order_num_high’, to_char(l_doc_set_params(i).p_order_num_high),
‘p_move_order_low’, l_doc_set_params(i).p_move_order_l,
‘p_move_order_high’, l_doc_set_params(i).p_move_order_h,
‘p_ship_method_code’, l_doc_set_params(i).p_ship_method_code,
‘p_customer_name’, l_doc_set_params(i).p_customer_name,
‘p_pick_status’, l_doc_set_params(i).p_pick_status,
‘p_detail_date_low’, to_char(l_doc_set_params(i).p_detail_date_l),
‘p_detail_date_high’, to_char(l_doc_set_params(i).p_detail_date_h),
‘p_exception_name’, l_doc_set_params(i).p_exception_name,
‘p_logging_entity’, l_doc_set_params(i).p_logging_entity,
‘p_location_id’, to_char(l_doc_set_params(i).p_location_id),
‘p_creation_date_from’, to_char(l_doc_set_params(i).p_creation_date_from),
‘p_creation_date_to’, to_char(l_doc_set_params(i).p_creation_date_to),
‘p_last_update_date_from’, to_char(l_doc_set_params(i).p_last_update_date_from),
‘p_last_update_date_to’, to_char(l_doc_set_params(i).p_last_update_date_to),
‘p_severity’, l_doc_set_params(i).p_severity,
‘p_status’, l_doc_set_params(i).p_status,
‘p_text1′, l_doc_set_params(i).p_text1,
‘p_text2′, l_doc_set_params(i).p_text2,
‘p_text3′, l_doc_set_params(i).p_text3,
‘p_text4′, l_doc_set_params(i).p_text4,
‘p_currency_code’, l_doc_set_params(i).p_currency_code,
‘p_printer_name’, l_doc_set_params(i).p_printer_name,
‘UNSUPPORTED’)
arg_value,
end_user_column_name,
required_flag,
default_value,
default_type,
flex_value_set_id,
lower(decode(l_execution_method_code, ‘P’, srw_param, end_user_column_name)) parameter_name
FROM
fnd_descr_flex_column_usages
WHERE application_id = l_application_id
AND descriptive_flexfield_name = ‘$SRS$.’||l_concurrent_program_name
AND enabled_flag = ‘Y’
ORDER BY
column_seq_num;

Custom program details

Concurrent Program definition

Click on Parameters

Note that the tokens of all 3 parameters match with the parameters listed in cursor c_document_params in procedure WSH_DOCUMENT_SETS.Print_Document_Sets

Create the data definition

Create the template

When Pick Release process is kicked off this report will be kicked off.

Cheers!


Transaction setup for Sales Orders in OM

$
0
0

I have shown example of transaction setup for Sales Orders below.

Responsibility: Order management super user

Navigation: Setup > Transaction Types > Define

Query for Transaction Type, STANDARD-UK.


Assigning workflow to the order type:

You can assign the header level workflow by clicking on the LOV for Fulfillment Flow.

You can select the workflow for the header level. Click on OK on selecting the workflow. Back on the main form click on Assign Line Flows button.

A workflow process is already assigned for the order lines. You can add another flow for another line type as shown below.

After selecting the workflow on the header and line levels come back to the Transaction Type form and click on Validate Workflow button.

A request will be submitted to check the status of the workflow. The concurrent program is Validate OM Workflow. If you check the SRS window you will see the request.

Check the output of the request

The output in text,

Validating Order Type : STANDARD-UK (1901)
------------------------------------------

1. Please verify that the value for attribute WAIT_RELATIVE_TIME of activity WAIT in process R_STANDARD_HEADER ( Order Flow - Generic ) is greater than the average time it takes Workflow Background Process to complete.

2. Please verify that activity SHIP_LINE precedes FULFILL_LINE in process R_STANDARD_LINE ( Line Flow - Generic ).

3. Please verify that the value for attribute WAIT_RELATIVE_TIME of activity WAIT in process R_STANDARD_LINE ( Line Flow - Generic ) is greater than the average time it takes Workflow Background Process to complete.

4. Please verify that activity SHIP_LINE precedes INVOICE_INTERFACE in process R_STANDARD_LINE ( Line Flow - Generic ).


Set Approvals:

Click on Approvals button on the Transaction Type form.

You will find that the approval hierarchy is defined for a transaction type. There are 2 roles defined in the hierarchy, DON OM Return User and DON Order Management Super User.

If you query for both roles in the database you will find them as shown below.

select * from wf_roles where display_name IN
 ('DON OM Return User',
 'DON Order Management Super User')


Credit Check Rule:

On the Transaction Type form the Credit Check Rules are defined for each stage of the order, i.e. Booking (mentioned as Ordering on the form), Picking, Packing and Shipping.

The Credit Rules are picked up from the Credit Check Rules form.

Navigation: Setup > Credit > Define Credit Check Rules

Query for Book – GBP.

Check Exposure tab

Shipping details:

We can define preset controls on the Transaction Types. On this form click on Shipping tab.

Finance:

The finance rules can also be set on the transaction type. Click on Finance tab on Transaction Types form.

Cheers!


Viewing all 68 articles
Browse latest View live