Quantcast
Channel: Oracle Maniacs' Notes » Abhijit Ray
Viewing all 128 articles
Browse latest View live

Change Viewer Options to view concurrent request output in web browser

$
0
0

In Oracle Apps if you run a concurrent request and check the output (if the output is in text format)/log file then the file will be displayed in the default viewer of Oracle. This can be changed so that the content is displayed in the default web browser of the local computer.

For example, execute a concurrent program that gives TEXT output

Click on View Output button

The request output is displayed in the Oracle form viewer. Now click on Tools > Copy File

You will see the output in the browser

If you instead wanted to view the output directly in the web browser then you need to check the following setup.

  
Setup

Responsibility: System Administrator

Navigation: Install > Viewer Options

Note the value of Description field for File Format = Text and Mime Type = text/plain

Navigation: Profile > System

Query for “Viewer: %

Click on Find button.

You can see that the Profile Option Name = Viewer: Text does not have any value set. Assign the value, Browser for this profile option.

Save the form and log out of Oracle apps.

   
Test the change

Log back into Oracle and open the SRS form to see the concurrent request

Click on View Output button

Now you will see that the output opens directly in the web browser.

Cheers!



How to get explain plan from the database

$
0
0

We would like to get explain plan for a SQL statement. The SQL statement is,

Select * from gl_interface

Execute the following code to generate the explain plan

EXPLAIN PLAN
SET
STATEMENT_ID = 'ray'
FOR
SELECT * FROM gl_interface;

After executing the previous statement you need to extract the explain plan from the database. Execute the following,

SELECT *
  FROM TABLE (DBMS_XPLAN.display ('plan_table', 'ray'));

On executing this SQL you will get,

You can now see the explain plan in the output of the query.

Cheers!


Trace file path in Oracle

$
0
0

The following script returns the path to the trace file that the current session writes. It returns the path whether or not tracing is enabled.

SELECT    u_dump.VALUE
       || '/'
       || db_name.VALUE
       || '_ora_'
       || v$process.spid
       || NVL2 (v$process.traceid,
                '_' || v$process.traceid,
                NULL
               )
       || '.trc' "Trace File"
  FROM v$parameter u_dump CROSS JOIN v$parameter db_name
       CROSS JOIN v$process
       JOIN v$session ON v$process.addr = v$session.paddr
 WHERE u_dump.NAME = 'user_dump_dest' AND db_name.NAME = 'db_name' AND v$session.audsid = SYS_CONTEXT ('userenv', 'sessionid');

Execute this query in the database

If you alter the session using the following script

ALTER
SESSION
SET tracefile_identifier = here_is_my_session;

Now execute the script to generate the trace file name

Note that the trace file name has been modified to include “HERE_IS_MY_SESSION” in the name. This way the trace file can be easily identified in a huge list of trace files within a directory.

Thanks to René Nyffenegger for providing this.

Cheers!


How to enable debugging in Order Management

$
0
0

The process for debugging any operation for Order Management module is given below.

Set the value of profile option, OM: Debug Level to 5. The highest level for debugging is 5. This means that all levels of statements will be logged.

Set the value of profile option, OM: Debug Log Directory to the a directory in Unix where the debug file will be generated. We shall set the directory to /usr/tmp.

Test the change

Now we can conduct any operation in Order Management and the debug details will be stored in a file at the debug log directory.

Let us check the Oracle session id

Click on Help > Diagnostics > Examine

Now you will get the following

Select Block: $PROFILES$ and Field: DB_SESSION_ID

You will get the value of the database session.

We shall open a Sales Order

Click on Actions button and select Cancel

Press OK

Enter a reason and press OK to cancel this order.

Now log in to Unix and go to the directory that you have setup as the debug directory. This has been set to /usr/tmp

In this directory check the files with extension, *.dbg

Open the file using view editor

/usr/tmp>view l0051611.dbg

You will get the debug details.

Once you have got the debug file you should set the debug level back to 0 or else all Order Management programs/process will generate debug logs and it will be an additional load on Oracle.

Using a pl/sql script to debug Order management application

Oracle supplies a seeded package named, OE_DEBUG_PUB, for writing the debug log messages. If you are executing OE_ORDER_PUB using a PL/SQL script, you need to add the following lines to your script to see the Order management debug messages.

OE_DEBUG_PUB.debug_on();

OE_DEBUG_PUB.Start_ONT_Debugger(‘/usr/tmp’,'skm1′,null);

Cheers!


Forms login error in Oracle Apps

$
0
0

When I tried to login to a new instance of Oracle Apps, an instance to which I had never connected before from my computer, I got the following error:

When I clicked on Details button I got

  
Solution:

The local computer could not validate this applet window as a secure window. We need to add this Oracle apps URL as a local intranet. On the Internet Explorer window click on Tools > Internet Options

The window opens

Now click on Security tab

Click on Local intranet icon

Once this icon is selected the button named, Sites, is enabled.

Click on Sites button.

A popup opens. Click on Advanced button.

Another popup opens. You now need to click on Add button to add the Oracle Apps URL to intranet zone.

Note: Ensure that the checkbox, Require server verification (https) for all sites in this zone is unchecked if the site you are trying to added does not use secure http.

Now the URL is added into the intranet zone close the popup windows. Now try to log back in to Oracle Apps forms.

Now we can access the forms in Oracle applications.

Cheers!


How to enable Record History for a custom form

$
0
0

In this article I shall illustrate the process of enabling record history on a custom form. By checking record history of a record on a form we can identify which user created and modified the record. We also get to know the underlying database table/view where the record is being pulled from.

Open a custom form. Click on Help > Record History

You get a popup message saying that Record History is not available here. This is because the WHO columns are not set on the custom form.

Now we shall follow the steps to add the WHO columns into the table and modify the custom form accordingly

   
Step 1: Describe the custom table

Check the table on which the form is built by describing the table, XX_BLACKLIST_SUPPLIER.

The script is the following.

CREATE TABLE xx_supplier_blacklist ( blacklist_id NUMBER NOT NULL PRIMARY KEY,
supp_number VARCHAR2(30),
supp_name VARCHAR2(240),
address VARCHAR2(1000),
LOCATION VARCHAR2(2),
supp_lob VARCHAR2(240),
blklist_flag VARCHAR2(3),
reason_blklist VARCHAR2(240),
reason_details VARCHAR2(1000),
date_blklist DATE,
date_remove DATE,
reason_blk_remove VARCHAR2(240),
detail_reason_remove VARCHAR2(1000),
linkage VARCHAR2(3) ,
attribute_category VARCHAR2(150),
attribute1 VARCHAR2(240),
attribute2 VARCHAR2(240),
attribute3 VARCHAR2(240),
attribute4 VARCHAR2(240),
attribute5 VARCHAR2(240)
)
/

Note that the WHO columns are missing in this table. You need to add the columns

Column Name Data Type
CREATION_DATE DATE
CREATED_BY NUMBER(15)
LAST_UPDATE_DATE DATE
LAST_UPDATED_BY NUMBER(15)
LAST_UPDATE_LOGIN NUMBER(15)

  
Step 2: Alter the custom table to add the WHO columns

Let us alter the table, XX_BLACKLIST_SUPPLIER, to add these columns

ALTER TABLE xx_supplier_blacklist ADD creation_date DATE
/

ALTER TABLE xx_supplier_blacklist ADD created_by NUMBER (15)
/

ALTER TABLE xx_supplier_blacklist ADD last_update_date DATE
/

ALTER TABLE xx_supplier_blacklist ADD last_updated_by NUMBER(15)
/

ALTER TABLE xx_supplier_blacklist ADD last_update_login NUMBER (15)
/

   
Step 3: Open the custom form

The custom form file name is XX_SUPPLIER_BLACKLIST.fmb. We shall open the form in Forms Builder.

This form was developed earlier and you can find the development steps in this article.
   
   
Step 4: Add the newly added WHO columns on the data block

You can manually add the WHO columns on the data block or you can use the Data Block wizard to do so. I have used the wizard for this purpose as it is fast.

Right click on the data block and select Data Block Wizard.

Click on Next button.

Click on Refresh button to get the newly added WHO columns on the list.

Click on the select all columns button () to add the columns into the data block.

Click on Next

Click on Finish button. Now the WHO columns have been added into the data block but not on the canvas. So these fields will not be visible to the user and this is the required functionality in any Oracle Apps form.

   
Step 5: Add a PRE-INSERT trigger on the data blocks

Check the block XX_SUPPLIER_BLACKLIST as this is the main data block.

This block does not have a PRE-INSERT trigger. Let us add it.

In the same way add the PRE-UPDATE trigger.

After the triggers are added the data block will look like this,

In both the triggers add the following line,

FND_STANDARD.SET_WHO;

This seeded package will add the values for the WHO columns.

Important:
When you invoke the Data block Wizard, add the columns and let the wizard update the data block, some of the field properties might be reset as per the default values. For instance, if a form item refers to a primary field and it is set as non updatable or non insertable in the block, then after invoking the wizard will cause the form builder to reset these properties to updatable and insertable for this item.

  
Step 6: Compile the form

Compile the form as per Step 12 given in this article.

   
Test the form

Open the form

Now create a new record or update an existing record. For our test we shall update an existing record.

First let us query the form for an existing record.

Add a value to the field Supp Lob.

Now save the form. Once the form is saved click on Help > Record History

Now you get to see the record history for the current record on the form.

Cheers!


Develop a custom form to allow auto-query functionality

$
0
0

The functionality that we shall add in the custom form will be the same as the one discussed in this article. The difference is that in the previous article the functionality was to use the existing functionality in a seeded form whereas we shall develop the custom form so that the same functionality can be used as well.

The auto-query functionality is also required if we are calling the form from a workflow notification to display transaction details. You can find development work required on the workflow in this article.

Note:
Almost all standard forms can be configured to display this functionality.

We are reusing the form from this article to demonstrate the development. We want the custom form to open up and automatically query for a record.


Step 1: Add parameter to the custom form

When we want the form to auto query on opening we have to add a parameter to the form. The parameter will pass the value to the data block and query the block to return the record. Normally the value that we pass either queries a unique column or set of dedupe columns. Or we might directly pass the value of a primary key column.

We shall create a parameter on the primary key column, BLACKLIST_ID.

The parameter,

Step 2: Create a program unit to add the parameter to the data block WHERE clause

Now we need to create program unit that will add the value of the parameter to the WHERE clause of the data block if the parameter value is passed. The code will be like the following,

We shall name the program unit/package as XX_SUPPLIER_BLACKLIST.

Package Spec

Code

PACKAGE xx_supplier_blacklist
IS
   PROCEDURE validate_row;
END;

Package Body

Code

PACKAGE BODY xx_supplier_blacklist
IS
   -- WHEN-NEW-FORM event handler
   --
   PROCEDURE validate_row
   IS
      l_message_text   fnd_new_messages.MESSAGE_TEXT%TYPE;
   BEGIN
      IF (:parameter.blacklist_id IS NOT NULL)
      THEN
         -- Auto-Query if BLACKLIST_ID parameter is not null
         --
         app_query.append ('XX_SUPPLIER_BLACKLIST', 'BLACKLIST_ID = ' || :parameter.blacklist_id);
         EXECUTE_QUERY;
         -- Set XX_SUPPLIER_BLACKLIST block back to NULL so that user
         -- can freely query from this point.
         --
         app_query.RESET ('XX_SUPPLIER_BLACKLIST');
      END IF;
   END validate_row;
END;


Step 3: Call the custom program unit from WHEN-NEW-FORM-INSTANCE trigger

We shall call this custom program unit from WHEN-NEW-FORM-INSTANCE trigger so that we check whether the parameter is populated or not. If it is populated we shall query for the record using that value else the form will open in NEW mode.

Code:

FDRCSID ('$Header: TEMPLATE.fmb 115.12 2012/08/13 11:02 Ray ship $');
APP_STANDARD.EVENT ('WHEN-NEW-FORM-INSTANCE');
--

-- app_folder.define_folder_block('template test', 'folder_block', 'prompt_block', 'stacked_canvas', 'window', 'disabled functions');
-- app_folder.event('VERIFY');
--
XX_SUPPLIER_BLACKLIST_DFF ('WHEN-NEW-FORM-INSTANCE');
XX_SUPPLIER_BLACKLIST.VALIDATE_ROW;

  
Step 4: Change the name of the form so that the length is set to max 8 characters

The form name is XX_SUPPLIER_BLACKLIST. This form works fine but it throws an error on the query functionality. According to Oracle the name of a form should not exceed 8 characters. If you notice, all seeded Oracle form names are restricted to 8 characters only.

The current form XX_SUPPLIER_BLACKLIST,

We shall rename this form to XXSUPBLK.

You can check error # 3 at this article for more details.

  
Step 5: Change the form setup in Oracle
Responsibility: Application Developer

Navigation: Application > Form

The old form was XX_SUPPLIER_BLACKLIST.

Change the name of this form to Supplier Blacklist form1 as we cannot have 2 forms with the same User Form Name.

Then create a new form, XXSUPBLK, with the User Form Name as Supplier Blacklist form.

  
Step 6: Change the Form function

Responsibility: Application Developer

Navigation: Application > Function

Query for Function = XX_SUPPLIER_BLACKLIST (The function name does not need a change)

Go to Form tab and select the new form now.

Select the form named, Supplier Blacklist form.

Now add Parameters = “BLACKLIST_ID=123

Note: The parameter name should correspond to the name as we set up in the form. Through the form function we are passing 123 to this parameter within the form. Thus when we are click on form function we will pass the value 123 as BLACKLIST_ID to the form.


Test the form

Login to Oracle and go to the responsibility.

Click on Blacklist function on the Navigator menu

The form now opens and automatically queries the record for the user. You are all set.

Cheers!


Customized process to convert Internal Requisitions to Move Orders

$
0
0

Oracle users can raise Internal as well as Purchase Requisitions in Oracle Purchasing or Oracle iProcurement.

In case of a Purchase Requisitions, once the documents are approved, a buyer creates a Purchase Orders in Purchasing module.

Once Internal Requisitions are approved, the store has to issue materials against the requisitions. The process to issue out the items from the store can be done manually or via Sales Order in Order Management module. In Order Management module,

  1. Sales Order is entered
  2. Sales Order is booked
  3. Pick Release is done
  4. Move Order is created

Once a Move Order is generated stock can be supplied from Inventory and be made ready for shipping.

Say, Oracle is used by businesses which are not into manufacturing or the businesses are not using Oracle Order Management but the business is using Oracle Inventory and Purchasing. The previous process will not work out.

If Move Orders are not created, the Store Manager will have to issue items from Inventory manually after going through a list of approved Internal Requisitions. This could be a very time consuming and laborious task and prone to human errors. In these cases we can device a process to create Move Orders bypassing the Sales Order process.

A method devised to create Move Orders from the Internal Requisitions is by creating a custom program to pull up details from approved Internal Requisitions and pass the details into an Oracle API.

 

The Requisition cycle is given below

 

  1. User raises internal requisition through iProcurement. This requisition can be raised from the Requisition form as well.

  2. Requisition is approved by manager
  3. Optional: We have developed a form to view the approved requisitions and create the Move Orders by calling a custom programs, EY Insert data for Creating Move Orders and Transfers, and EY Create Move Orders and Transfers sequentially. If the form is used then we do not need step 4 & 5 below.
  4. If we skipped step 3 then execute custom program “EY Insert data for Creating Move Orders and Transfers” to pick up the approved requisition from the requisition base tables and insert the data into custom table.

  5. Custom program “EY Create Move Orders and Transfers” is run to pick up the approved requisition data from the custom table and create a move order.

  6. The Move Orders are created for the approved internal requisitions in Inventory module.

  7. Transact a move order to issue the items from the store, i.e. from inventory.

     

Concurrent program: EY Insert data for Creating Move Orders and Transfers

Program definition


Executable


Concurrent program: EY Create Move Orders and Transfers

Program definition

Executable definition

Code

The code uses an internal API,

Inv_Move_Order_Pub.create_move_order_header

Inv_Move_Order_Pub.create_move_order_lines

The code to create the Move Orders from the Internal Requisitions is given in the attached file. In the code there is a functionality to check the type of user that is running the program, i.e. ‘NU’ and ‘SU’. Based on this check the code decides the organization.

The custom table structure

CREATE TABLE xxey_requisition_hdrs
(
segment1 VARCHAR2(20),
org_id NUMBER,
source_organization_id NUMBER,
created_by NUMBER,
creation_date DATE,
nu_ou_su_user VARCHAR2(3),
moh_flag VARCHAR2(1)
);

CREATE TABLE xxey_requisition_lns
(
segment1 VARCHAR2(20 BYTE),
item_id NUMBER,
uom_code VARCHAR2(20 BYTE),
created_by NUMBER,
quantity NUMBER(10,2),
source_subinventory VARCHAR2(20 BYTE),
source_organization_id NUMBER,
org_id NUMBER,
code_combination_id NUMBER,
need_by_date DATE,
destination_subinventory VARCHAR2(20 BYTE),
mol_flag VARCHAR2(1 BYTE)
);

The PL/SQL code and the form to view and convert the approved internal requisitions are available at link below.

Code to create Move Orders from Internal requisitions

Cheers!



How to assign Workflow Administrator role to a user/responsibility from the backend

$
0
0

Login to Oracle and go to Workflow Administrator responsibility. Navigate to Status Monitor tab.

As shown above even though the user has access to Workflow Administrator responsibility, he/she can only view the workflows owned by this user. Now click on Administration tab.

Notice that the role for Workflow System Administrator is given to SYSADMIN. We need to change this value to Workflow Administrator so that anybody with the Workflow Administrator responsibility (this also a role in the Workflow Directory Services) will get access workflows owned by all users.

We need to change the role to EY Workflow Administrator responsibility as shown below,

Run the following query in the database

SELECT *
  FROM wf_roles
 WHERE NAME LIKE 'FND_RESP|FND|EY_WF_ADMIN|STANDARD'

Note: The format for the role is FND_RESP|FND|<Responsibility short name>|STANDARD.

Let us check the role currently set as the Workflow System Administrator in the database now. Run the SQL,

SELECT *
  FROM wf_resources
 WHERE NAME = 'WF_ADMIN_ROLE'

We shall now set the Workflow System Administrator to the role named, FND_RESP|FND|EY_WF_ADMIN|STANDARD.

Execute the following SQL,

UPDATE wf_resources
   SET text = 'FND_RESP|FND|EY_WF_ADMIN|STANDARD'
 WHERE NAME = 'WF_ADMIN_ROLE';

Commit the change into the database. Query for the Workflow System Administrator in the database once again.

SELECT *
  FROM wf_resources
 WHERE NAME = 'WF_ADMIN_ROLE'

We see that the role has been changed in the database. Let’s check from the front end by going to Workflow Administrator responsibility and navigating to Administration tab. It will look like,

The change has taken place on the front end as well. You can now continue monitoring workflows using EY Workflow Administrator responsibility.

Important:
This change will be overwritten when the DBA runs Autoconfig.

Cheers!


Defaulting Sales Person on a Sales Order

$
0
0

While creating a sales order in Oracle Applications we do not need to enter a sales person but the sales person is mandatory when the sales order has to be booked.

For certain organizations sales person may not be very important and any sales person would do or a single sales person can be used for all the orders. In such a situation we can assign this sales person by default so that the user need not enter the sales person every time he/she books an order.

Oracle gives a sales person named, No Sales Credit, to be used in this kind of a scenario if the organization does not give credits for getting the order. We have used this sales person as the default sales person in our illustration below.

Sales Persons setup form

Responsibility: Order Management Superuser

Navigation: Setup > Sales > Salespersons

Enter the Salesperson Name as “No Sales Credit“. Once you tab out of the field the Resource Name field is also populated with the same value.

Click on Find button

Click on Resource Details button

Check the Receivables tab to view the operating units to which the salesperson is attached to.

System Options

The following setup will ensure that the default sales person value is populated by Oracle

Navigation: Setup > Customers > System Options

Query the form to view the Operating Unit in question.

Click on Miscellaneous tab.

Check Require Salesperson and save the form.

Setup Option 1

Responsibility: System Administrator

Navigation: Profile Systems

Query for profile option: OM: Default Salesrep. Set a value for the profile. We have used No Sales Credit.

Once the sales person is set on the Site level then all sales order across the organization will use the same sales person.

Setup option 2

Responsibility: Order Management

Navigation: Setup > Rules > Defaulting

Query the form for Entity = Order header

Scroll down on the Attributes section and see the attribute named Salesperson.

Click on Defaulting Rules button

You can add your own condition after disabling the current seeded condition as shown below.

Save the form

Click on OK.

Now click on View > Requests to execute a concurrent program name, Defaulting Generator.

Since the defaulting rules have been changed only for Order Header we shall execute the program only for this entity.

Once the program has completed the new defaulting rules take effect.

Test the changes

Now open the Order entry form in Oracle

Note that Salesperson field is already populated with the value of the profile option. Now enter the sales order details on the order header and lines.

Now click on Actions > Sales Credits

Click OK

Note that there is no sales credits data. Now click on Cancel button on the popup window to go back to the Order Header form. On the Sales Order Header form click on Book
Order button.

The order is now booked. If you now check the Sales Credits on the Order header you will find,

Now you can see that the sales credits have been applied to the default sales person automatically.

Cheers!


Custom Requisition/PO approval process

$
0
0

I got a very interesting requirement from a customer. The requirement was to customize the flow of Requisition and PO approval. The TO-BE process is given below.

Process Comments
Approvers in the Requisition/PO hierarchy are given an alternate approval group. This was done by enabling a DFF
User raises Requisition/PO Standard process
User sends the document for approval Standard process
The Requisition/PO workflow will check the amount of the document and a field value that will determine whether document was raised for an existing contract or not. A DFF segment was enabled for Requisition and PO header.
The document will go to the approver Standard process
The approver approves the document Standard process
Oracle checks whether the approved document is for an existing contract or not.
  • If the document is for an existing contract then the document amount will be checked for the alternate approval group.

     

  • If the document is not for an existing contract then the document amount will be checked for the usual approval group.
This is a major customization. We had to create custom PL/SQL code to bypass the usual approval check.The seeded Requisition and PO workflows were customized to incorporate the custom approval authority check.
Depending on the previous check the workflow will go to the next approver or end. Standard process

The development process is given below. I have illustrated the development and testing done for Requisitions. The same was applied to PO as well.

   
Configuration & Development

  
DFF setup

Approval Group Assignment DFF

We have enabled the DFF segment on the Approval Group assignment form.

Responsibility: System Administrator

Navigation: Application > Descriptive > Segments

Query for,

Application: Purchasing

Title: Position Controls

Unfreeze the flexfield

Click on Segments

Add an entry for a segment.

Number: 10

Name: EY Alternative Approval Group

Window Prompt: EY Alternative Approval Group

Column: ATTRIBUTE1

Value Set: EY_PO_CONTROL_GROUP_VS

Double click on the segment to open the Segments window

Ensure that Required field is unchecked. Click on Value Set button to open the value set.

This Validation Type is Table. Click on Edit Information button.

As we can see, the value set is pulling the records from PO_CONTROL_GROUPS_ALL table. This means the value set is going to display the Approval Group names that are defined for a particular operating unit.

Save and close all forms. Ensure that the DFF is also compiled.

  
Requisition Header DFF

We have enabled a segment on Requisition Headers as well. This DFF value will determine whether a contract/tender is required for the requisition raised or not.

Open the DFF form and query for the DFF as follows,

Application: Purchasing

Title: Requisition Headers

Unfreeze the flexfield

Now click on Segments button.

Add a segment

Number: 1

Name: Tender Required

Window Prompt: Tender Required

Column: Attribute1

Value Set: XXEY_GL_YES_NO

Double click on the Segments and uncheck Required field.

Click on Value Set button.

The value set is set as Validation Type: Independent . Save and close all forms and compile the DFF.

Navigation: Application > Validation > Values

Enter the name as XXEY_GL_YES_NO (This is the value set of the Requisition Header DFF segment we have enabled)

Click on Find button

We have set 2 values, Yes and No. Hence we shall get only these 2 values on the DFF.

   
Workflow modification

Workflow name: PO Requisition Approval (REQAPPRV)

3 Functions have been added to the seeded workflow

  1. XXEY Set Preparer Notification Attrib

This function is calling the DB object, XXEY_GET_ALL_APPROVERS.GET_ALL_APPROVERS.

  1. XXEY Update Approval Control

This function is calling the DB object, xx_change_approval_control_pkg.update_approval_control.

 

  1. XXEY Update Approval Control Revert

This function is calling the DB object, xx_change_approval_control_pkg.update_approval_control_rev.

The following processes have been modified.

  1. Modified: Main process

The following functions have been added to the main process.

  1. XXEY Update Approval Control
  2. XXEY Set Preparer Notification Attrib

The entire process diagram becomes the following,

  1. Modified: Response with Approve Action

Add the function XXEY Update Approval Control in the process.

  
Database packages to be written

The following database packages had to be written as these will be called from the workflow functions that have been created previously.

  1. XX_CHANGE_APPROVAL_CONTROL_PKG
  2. XXEY_GET_ALL_APPROVERS

You can get the code at the link below,

Developed code

   
Test the customization

We shall define an alternate approval groups for a requisition approver. First let us select an approver from the requisition hierarchy. You can refer to this article if you need details on position hierarchy and approval groups.

Step 1: Select a position

Open the hierarchy form for requisitions. Select the approving position, “7079.Manager Procurement. Finance”.

As per the hierarchy, position 7080 sends requisitions to position 7079 for approval.

  
Step 2: Check the approval group assignment

Let us check the approval groups attached to position 7079.

Note the approval assignments for Internal and Purchase Requisitions

We shall assign alternate approval groups for both types of requisitions.

Set DFF value for Internal Requisition

Set DFF value for Purchase Requisition

Save and close the form.

  
Step 3: Check the approval group limits

We shall check approval groups,

  1. EY Level 4 (For Purchase Requisitions)
  2. EY Level 7 (For Internal Requisitions)
  3. EY Level 10 (For both Internal & Purchase Requisitions as the alternate Approval Group)

EY Level 4

EY Level 7

EY Level 10

Therefore we see that approval group limit for,

Level 4 is 100,000

Level 7 is 10,000,000

Level 10 is 50,000,000

   
Step 4: Raise a requisition as position 7080

As per the customization and setup done, a purchase requisition with an amount of more than 100,000 (limit of Level 4) can be approved by position 7079 if it requires a tender (based on the requisition DFF value) as this position’s alternate approval group (Level 10) has a limit of 50,000,000.

We shall test this now with 2 scenarios by logging in as position 7080 and raising requisitions.

Scenario 1: Raise a purchase requisition for more than 100,000 and setting the DFF value for Tender Required, on the requisition header, to No.

Scenario 2: Raise a purchase requisition for more than 100,000 and setting the DFF value for Tender Required, on the requisition header, to Yes.

Scenario 1 testing

Open the Requisitions form. Create a new Purchase Requisition for more than 100,000.

Send the requisition for approval by clicking Approve button. Note the requisition number, 112001468.

Once the requisition is sent for approval you can trace the workflow in Workflow Status monitor. The item type is REQAPPRV and the user key is 112001468. You can refer to this article if you need details on how to track a workflow.

You will find the workflow is waiting for an approval from position, 7079, i.e. Uzair Khan.

Open the notification and approve it.

Note: Check the approval sequence within the notification


In the sequence you find the entire hierarchy displayed and it displays the position beyond 7079 (Uzair Ahmed Khan). This means that the workflow will go to the approver after Uzair, i.e. Adil (Num 4) as shown in the list.

You might need to execute “Workflow Background process” if the workflow goes into deferred mode. Check the workflow activity again.

You will find that the workflow has gone to the next position in the hierarchy for approval.

Approve the notification again. . You might need to execute “Workflow Background process” if the workflow goes into deferred mode. Check the workflow activity again.

Now the workflow has ended.

In this test scenario we have seen that the requisition approval follows the standard setup.

   
     
Scenario 2 testing

Open the Requisitions form. Create a new Purchase Requisition for more than 100,000.

We have created the requisition with exactly same details as Scenario 1. We shall now enter the value of the requisition header DFF. Click on DFF field on the requisition header.

Click on the LOV of the field named, Tender Required.

Select Yes and press OK. Save the form. Now the form shows the following.

The DFF value has been entered. Send the requisition for approval now.

Check the workflow as you have done in scenario 1.

The workflow is pending on Uzair Khan’s approval, as expected. Now open the notification.

Note:
Position 7079 or Uzair Khan’s name shows as the last person on the approval sequence list.

Approve the notification. Trace the workflow again. You may need to execute “Workflow Background Process” program.

The workflow now completes with only the approval of position 7079 (Uzair Khan). This shows that the customization has kicked into effect and is working as expected.

Cheers!


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!


Understanding Workflow roles

$
0
0

When a workflow sends a notification it has to be sent to a workflow role defined in the Workflow Directory Services. This means this role has to exist in the table WF_ROLES.

In Oracle Apps, a role is created in Workflow Directory Services once a new user or responsibility is created. These roles are created automatically by Oracle. We can create adhoc roles in Workflow Directory by using an API, wf_directory.create_adhoc_roles.

Let us review the roles.

Oracle user

Let us view an Oracle user from the User form. We have selected user, SA1.

The user exists in the following tables

User table

We shall check the user details in the Oracle apps user table, FND_USER.

select user_id, user_name, email_address from fnd_user where user_name = 'SA1';

Workflow tables

Let us check the workflow tables and see how the corresponding role for user, SA1, is stored. The workflow user is stored in WF_USER table.

select * from wf_users where name = 'SA1';

The role corresponding to the workflow user is stored in WF_ROLES table.

select * from wf_roles where name = 'SA1';

The users are attached to the role in the table WF_USER_ROLES.

select * from wf_user_roles where role_name = 'SA1';


Oracle responsibility

Now we shall review a responsibility on the responsibility form. We have picked a custom responsibility named, EY IExpenses Auditor.

Note the details:

Responsibility name: EY IExpenses Auditor

Responsibility key: EY_OIE_EXPENSES_AUDITOR.

Once a responsibility is created on the responsibility form, you will find the responsibility set as a role in the workflow table, WF_ROLES.

select * from wf_roles where display_name = 'EY IExpenses Auditor';

Note the role name. It is, FND_RESP|SQLAP|EY_OIE_EXPENSES_AUDITOR|STANDARD. Now you know the role name corresponding to the responsibility, you need to find out how many users are connected to this role. This essentially means that these users have the responsibility, EY IExpenses Auditor.

select * from wf_user_roles where role_name = 'FND_RESP|SQLAP|EY_OIE_EXPENSES_AUDITOR|STANDARD';

Now if you need to send a workflow notification to the users attached to this responsibility, you can send the notification to the role, FND_RESP|SQLAP|EY_OIE_EXPENSES_AUDITOR|STANDARD, and all the users who have the responsibility will get the notification.

Roles are also created when you add a new bank branch, employee, position, any one added in the TCA architecture.

Example of a bank role, AP_BANK_BRANCHES:12022

Supplier and customers are created as adhoc roles by Oracle, especially if the seeded workflows need to send emails to them, like Payment information, etc.

Example,

Role synchronization

To ensure that the workflow roles are synchronized in the workflow directory services the following programs need to be executed in System Administrator responsibility.

  1. Sync responsibility role data into the WF table – for synchronizing FND_RESPONSIBILITY and WF_ROLES and WF_USER_ROLES in WF directory
  2. Synchronize WF LOCAL tables – for synchronizing FND_USERS and WF_ROLES in WF directory


Usage of Workflow APIs

To add a wf user

wf_directory.CreateUser ( name           => 'newuser',
                      display_name       => 'newuser',
                      orig_system        => NULL,
                      orig_system_id     => NULL,
                      language           => 'AMERICAN',
                      territory          => 'AMERICAN',
                      description        => 'New workflow user',
                      notification_preference => 'MAILHTML',
                      email_address           => 'abc@gmail.com',
                      fax                     => NULL,
                      status                  => 'ACTIVE',
                      expiration_date         => ,
                      start_date              => SYSDATE,
                      parent_orig_system      => NULL,
                      parent_orig_system_id   => NULL,
                      owner_tag               => NULL,
                      last_update_date        => SYSDATE,
                      last_updated_by         => 12691,
                      creation_date           => SYSDATE,
                      created_by              => 12691,
                      last_update_login       => 145617);

To add an adhoc role

wf_directory.createadhocrole (role_name                     => l_role_name,
                                 role_display_name             => l_role_name,
                                 LANGUAGE                      => 'AMERICAN',
                                 territory                     => 'AMERICAN',
                                 role_description              => NULL,
                                 notification_preference       => 'MAILHTML',
                                 role_users                    => NULL,
                                 email_address                 => NULL,
                                 fax                           => NULL,
                                 status                        => 'ACTIVE',
                                 expiration_date               => NULL,
                                 parent_orig_system            => NULL,
                                 parent_orig_system_id         => NULL,
                                 owner_tag                     => NULL
                                );

To remove an adhoc role

   wf_directory.removeusersfromadhocrole (role_name => l_role_name,
                                          role_users => NULL);

To add workflow users to a role

   wf_directory.adduserstoadhocrole (role_name  => l_role_name,
                                     role_users => lv_user_name);

Important:

If a role is for an external party, i.e. if the notification to a role will send an email that is outside the organization, the role name MUST be in capital letters or else workflow will be unable to send the email.

Example

select * from wf_roles where name like '%GMAIL.COM%';

All these roles have email addresses (gmail id) that are outside the organization and therefore the role name is set in CAPITAL letter or else the mail will not be sent by the workflow engine.

Creating and maintaining roles from Oracle Apps forms

You can create a responsibility say, XX User Maintenance

Responsibility Name: XX User Maintenance

Menu Name: User Management : Top Level Menu

Add the responsibility to a user

Save the form.

Now log in to Oracle as this user, i.e. SA1. Check for the responsibility on the Oracle Home page.

On clicking the responsibility you will see the functions attached to it on the home page

Click on the users function

Search for the user (SA1) on this page

Click on Update

This form has the same privileges as the User form in System Administrator responsibility. You can update user details on this form.

Click on Roles & Role Inheritance menu item on the top

Let us search for the responsibility named, EY iExpenses Auditor.

The responsibility is displayed along with the role corresponding to this responsibility (displayed in Code field). You can administer the responsibilities from by clicking on Update button.

You can set the access levels and privileges on this form.

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!


SQL* Loader concurrent program

$
0
0

Here is an example of a concurrent program that calls SQL* Loader to load data files into Oracle tables.


Concurrent executable definition

The SQL Loader concurrent executable is of type

Execution Method: SQL Loader

Execution File Name: Name of the control file without the extension (.ctl)

The control file has to be placed in the $XX_TOP/bin directory.

In this example the executable is registered under Custom Applications. Note that the extension .ctl is not entered in the executable form.

The control file xxeyap_invoices_ctl.ctl file should exist in $XXCUST_TOP/bin directory (XXCUST_TOP corresponds to Custom Applications). The control file should be placed in the bin directory. The application registration form is shown below to show how the custom application is registered.

The control file in Unix:


Concurrent program definition

The concurrent program definition

The program needs 1 parameter for the user to enter the data file path and the file name.

As an option, the parameter can have the file path set as default to any path.


Test this program

Go to the respective responsibility and run the concurrent program.

The path is set by Oracle by default as it has been configured in the concurrent program parameter definition. Add the file name if the file exists on this path, else you will need to enter the full path along with the file name.

Press OK

Submit this request. Once the request completes you might find that the request has ended with a warning.

This could be because all the records could not be loaded into the table. Click on the Output.

The output will show all the records that have failed during loading.

Now click on the log

The log file will give all details about the loading process. At the bottom of the log file you will get to know how many records have been loaded.

Some examples of control files

Control file for delimited files

OPTIONS(ERRORS=200, BINDSIZE=50000)
LOAD DATA
INFILE *
APPEND
INTO TABLE XXCUST.XXEY_AR_KR_CC_HEADER_PRESTG_T
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
RAW_DATA POSITION(1:140)     CHAR "TRIM(:RAW_DATA)",
DATA_FILE_NAME         CONSTANT "<<XXHCM_FILE_NAME>>",
PRELOAD_SEQUENCE_HDR "XXCUST.XXEY_AR_KR_CC_HEADER_PRESTG_S.NEXTVAL",
REQUEST_ID             CONSTANT "<<XXHCM_REQ_ID>>",
RECORD_STATUS         CONSTANT 'N',
CREATED_BY             "FND_GLOBAL.USER_ID",
CREATION_DATE         SYSDATE,
LAST_UPDATED_BY         "FND_GLOBAL.USER_ID",
LAST_UPDATE_DATE     SYSDATE
)

Control file of position based records

OPTIONS(skip = 1) -- Skipping header row
LOAD DATA
APPEND
INTO TABLE xxeyar_receipts_int_stage
(  record_type                POSITION(1:2)       CHAR             "TRIM(:record_type)"
  ,status                     POSITION(3:32)      CHAR             "TRIM(:status)"
  , item_number                POSITION(33:42)     CHAR             "TRIM(:item_number)"
  , currency_code              POSITION(43:57)     CHAR             "TRIM(:currency_code)"
  , remittance_amount          POSITION(58:70)     DECIMAL EXTERNAL "TRIM(:remittance_amount/100)"
  , account                    POSITION(71:100)    CHAR             "TRIM(:account)"
  , check_number               POSITION(101:130)   CHAR             "TRIM(leading '0' from :check_number)"
  , receipt_date               POSITION(131:138)   DATE 'RRRRMMDD'  "TRIM(:receipt_date)"
  , customer_number            POSITION(139:168)   CHAR             "TRIM(:customer_number)"
  , deposit_date               POSITION(169:176)   DATE 'RRRRMMDD'  "TRIM(:deposit_date)"
  , batch_name                 POSITION(177:201)   CHAR             "TRIM(:batch_name)"
  , data_source                POSITION(202:261)   CHAR             "TRIM(:data_source)"
  , pnr_number                 POSITION(262:268)   CHAR             "LTRIM(:pnr_number,0)"
  , load_sequence              sequence(max,1)
  , CREATION_DATE			   "SYSDATE"
  , CREATED_BY				   "fnd_global.user_id"
  , PROCESS_FLAG		       CONSTANT	'N'
  , ORG_ID                     "XXEY_AR_ORION_TRX_PKG.get_org_id(TRIM(to_number(:location_code)))"
  , ORG_NAME                   "XXEY_AR_ORION_TRX_PKG.get_org_name(TRIM(:location_code))"
  , DATAFILE_NAME              CONSTANT "<<XXHCM_FILE_NAME>>"
  , SET_OF_BOOKS_ID            "XXEY_AR_ORION_TRX_PKG.get_sob_id(TRIM(to_number(:location_code)))"
)

Alternate loader program using HOST program

As an alternate process I prefer to use a Host program to load data files into Oracle. This is because I get the flexibility to move the files to different directories after the data has been loaded, email log files and perform several checks.

Example:

Parameter

The executable

The shell script

# ******************************************************************************
# Usage:        XXEY_AR_KALE_LOAD.prog
# Description:  This program processes KALE Data files available in
#               KALE_AR folder and calls associated Data Loader Program
#
#
# History:
#
# ******************************************************************************

#Initialise parameters
#By default these four paramters 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_AR_KALE.ctl
BASE_DIR=$XXCUST_TOP
LOADER_DIR=$BASE_DIR/bin
LOADER=$LOADER_DIR/$CONTROL_FILE
DATA_DIR=$XXCUST_TOP/KALE_AR/KALE_AR_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/KALE_AR/KALE_AR_Unprocessed/
v_file_path_name=$XXCUST_TOP/KALE_AR/KALE_AR_Unprocessed/
v_processed_dir=$XXCUST_TOP/KALE_AR/KALE_AR_Processed/
v_error_dir=$XXCUST_TOP/KALE_AR/KALE_AR_Errors/
v_check_file=$XXCUST_TOP/log/"check_file_"$p_request_id.log

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

BAD_FILE=$XXCUST_TOP/KALE_AR/bad_files
LOG_FILE=$XXCUST_TOP/KALE_AR/log_files
DIS_FILE=$XXCUST_TOP/KALE_AR/discard_files
# -------------------
# Get Parameter value
# -------------------

RETCODE=$?
code_error=$RETCODE

cd $v_work_dir

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/BSP_CREDIT/bsp_credit_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/KALE_AR/KALE_AR_Processed folder: "$v_file_name
uuencode $LOG_FILE/$v_log_file.log $v_log_file.log|mailx -m -s "AR Invoices Log File" $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/KALE_AR/KALE_AR_Errors folder with name: "$4"-"$v_bad_file.bad
uuencode $BAD_FILE/$v_bad_file.bad $v_bad_file.bad|mailx -m -s "AR Invoices Bad File" $p_support_user
mv $BAD_FILE/$v_bad_file.bad $v_error_dir$4"-"$v_bad_file.bad
fi
else
echo "SQL*Loader Failled for Current Data File \n"
mailx -m -s "SQL*Loader Failed for Current Data File" $p_support_user
fi
fi
fi
done
fi

Both methods are fine depending on how much flexibility you need and the time you have for development.

Cheers!


Viewing all 128 articles
Browse latest View live