Oracle Applications Interface Programs

longwansheng發表於2008-11-04
Oracle Applications Interface Programs[@more@]

Order Import Interface (Sales Order Conversion)

Interface tables:

· OE_HEADERS_IFACE_ALL

· OE_LINES_IFACE_ALL

· OE_ACTIONS_IFACE_ALL

· OE_ORDER_SOURCES

· OE_CUSTOMER_INFO_IFACE_ALL

· OE_PRICE_ADJS_IFACE_ALL

· OE_PRICE_ATTS_IFACE_ALL

Base tables:

· OE_ORDER_HEADERS_ALL

· OE_ORDER_LINES_ALL

Pricing tables

· QP_PRICING_ATTRIBUTES

During import of orders, shipping tables are not populated.

If importing customers together with the order, OE_ORDER_CUST_IFACE_ALL

Base Tables: HZ_PARTIES HZ_LOCATIONS

Orders can be categorized based on their status:

1. Entered orders

2. Booked orders

3. Closed orders

Concurrent Program: Order Import

Validations:

· Check for sold_to_org_id. If does not exist, create new customer by calling create_new_cust_info API.

· Check for sales_rep_id. Should exist for a booked order.

· Ordered_date should exist. -------- header level

· Delivery_lead_time should exist. ----------- line level

· Earliest_acceptable_date should exist.

· Freight_terms should exist

Order Import API OE_ORDER_PUB.GET_ORDER, PROCESS_ORDER

Concurrent programs will in turn call APIs.

2 APIs are called during order import process.

· OE_CNCL_ORDER_IMPORT_PVT (cancelled orders)

· ORDER_IMPORT_PRIVATE

Procedure: import_order()

Item import (Item conversion)

Always import master and child records.

Interface tables:

· MTL_SYSTEM_ITEMS_INTERFACE

· MTL_ITEM_REVISIONS_INTERFACE( If importing revisions, populate)

· MTL_ITEM_CATEGORIES_INTERFACE(If importing categories, populate)

· MTL_INTERFACE_ERRORS

Item import can be run in create mode or update mode.

Running the Item Open Interface In Create Mode:

Populate the mtl_system_items_interface with the following minimum required columns when creating new items:

PROCESS_FLAG = 1

TRANSACTION_TYPE = 'CREATE'

SET_PROCESS_ID = 1

ORGANIZATION_ID = Master Org id.

DESCRIPTION = 'Description of the item'

ITEM_NUMBER and/or SEGMENT(n)

Note: Using the ITEM_NUMBER column in the mtl_system_items_interface is required if you are populating revision history data into the mtl_item_revisions_interface table. The value of the ITEM_NUMBER must equal the concatenated segments(n) of the item being imported plus the segment separator. If you are not importing revision history you can populate either ITEM_NUMBER or the SEGMENT(n) column(s) or both.

Running the Item Open Interface In Update Mode:

To update existing item(s), set TRANSACTION_TYPE = 'UPDATE'.

For best performance, use inventory_item_id when updating items.

Functionality

Every attribute updateable from the Item form is updateable through the interface, and all required validations are performed to enforce:

· Item Attribute Interdependencies

· Master - Child Attribute Dependencies

· Status Controlled Attributes

· Templates can be applied to existing Items. For best results, use template_id and template_name.

· The Item status can be changed for existing Items, and the proper attributes are Defaulted / Set accordingly. The Status change is recorded in

MTL_PENDING_ITEM_STATUS.

· To populate material costs from IOI: Populate the LIST_PRICE_PER_UNIT column with a value while importing items and you will see your material cost for your item in MTL_SYSTEM_ITEMS after running the Item Import process. (CREATE transaction_type only)

· When launching items into the Master Item Org, the Child records are copied into MTL_SYSTEM_ITEMS_INTERFACE for validation, and are identified with transaction_type of 'AUTO_CHILD'. These records are deleted if the parameter 'Delete Processed Rows' has been passed as 'Yes', and remain for diagnostic purposes if the parameter is passed as 'No'. When the defining attribute for a Functional area is enabled, the proper default category set and category is assigned to the Item.

· Master Items were loaded before child records in MTL_SYSTEM_ITEMS.

Not Supported Issues

=========================================

· Item Costs cannot be UPDATED (using "UPDATE" transaction_type) through the interface.

· New Item revisions cannot be added to existing Items.

· Current functionality does not support updates to a PTO MODEL ITEM through

the IOI update feature. See notes: 1076412.6 and 2121870.6 Updating Item Attributes to NULL The method to update these columns to NULL is to use the following values:

1. for Numeric fields: insert -999999

2. for Character fields: insert '!'

3. for Date fields: the above list does not include any updateable date fields.

Importing Master and Child Records

==================================

The user procedures are as follows :

1. Populate the item interface tables (mtl_system_items_interface). This step is necessary if you are creating items and categories in the same run. For importing item category assignments for already existing items, you do not need to populate item interface table.

2. Populate the item categories interface table (mtl_item_categories_interface).

The user needs to populate the following mandatory columns in item categories interface table:

A. Either inventory_item_id or item_number. When item and category are being imported together, then user can only specify the item_number, since item id will be generated by the import process.

B. Either organization_id or organization_code or both.

C. The transaction_type column should be 'CREATE'. We do not support 'UPDATE' or 'DELETE' for item category assignment.

D. Either category_set_id or category_set_name or both.

E. Either category_id or category_name or both.

F. Process_flag column as 1.

G. Populate the set_process_id column. The item and category interface records should have the same set_process_id, if you are importing item and category assignment together.

3. After populating the item and category interface tables, launch the Item Import process from the applications. In the item import parameters form, for the parameter 'set process id', specify the 'set process id' value given in the mtl_item_categories_interface table. The parameter 'Create or Update' can have have any value. Through the import process, we can only create item category assignment(s).

Updation or Deletion of item category assignment is not supported.

4. Once the concurrent process completes, check the mtl_interface_errors table for any error(s) during the item and category import. Correct those error conditions in the interface tables and run the item import again. If the process_flag is 7, that means the item category interface records were successfully imported.

Revisions

==============================

Note: Using the ITEM_NUMBER column in the mtl_system_items_interface table is required if you are populating revision data into the mtl_item_revisions_interface table. The value of the ITEM_NUMBER must equal the concatenated segments(n) of the item being imported, plus the segment separator. If you are not importing revision history you can populate either ITEM_NUMBER or the SEGMENT(n) column(s) or both. For historical item revision data, do NOT populate the REVISION column in the mtl_system_items_interface table. This column is used only if the current revision of the item is being imported.

Populate these columns in the mtl_item_revisions_interface table:

PROCESS_FLAG = 1

TRANSACTION_TYPE = 'CREATE'

SET_PROCESS_ID = 1

ORGANIZATION_ID = Master Org ID.

REVISION

EFFECTIVITY_DATE

IMPLEMENTATION_DATE

ITEM_NUMBER = (Must match the item_number in mtl_system_items_interface table.)

Each row in the mtl_item_revisions_interface table must have the REVISION and EFFECTIVITY_DATE in alphabetical (ASCII sort) and chronological order.

Run the IOI process. Navigate --&gt Inventory: Items: Import Items

There are 6 parameters to enter to begin the process:

1. Specify one or all organizations.

2. Validate items, yes or no.

3. Process items, yes or no.

4. Delete processed rows, yes or no.

5. Process set (null for all)

6. Create or update items (1 for create, 2 for update)

Note: If you are importing Master and Child records, insert them into the mtl_system_items_interface and mtl_item_revisions_interface tables, and run them at the same time by setting the 'All organizations' parameter to 'Yes'. If you do not do this, then the Child revision records will not be imported.

Error Checking:

======================================

When importing multiple revisions, if one record for an item fails validation, all revisions for that item fail. Resolve failed rows by checking the mtl_interface_errors table.

SELECT table_name, column_name, error_message, message_name

FROM mtl_interface_errors;

Base tables:

§ MTL_SYSTEM_ITEMS_B

§ MTL_ITEM_REVISIONS_B

§ MTL_CATEGORIES_B

§ MTL_CATEGORY_SETS_B

§ MTL_ITEM_STATUS

§ MTL_ITEM_TEMPLATES

Concurrent program: Item Import

Validations: check for valid item type.

Check for valid part_id/segment of the source table.

Validate part_id/segment1 for master org.

Validate and translate template id of the source table.

Check for valid template id. (attributes are already set for items, default attributes for

that template, i.e., purchasable, stockable, etc)

Check for valid item status.

Validate primary uom of the source table.

Validate attribute values.

Validate other UOMs of the source table.

Check for unique item type. Discard the item, if part has non-unique item type.

Check for description, inv_um uniqueness

Validate organization id.

Load master records and category records only if all validations are passed.

Load child record if no error found.

Interface Tables Base Tables

MTL_SYSTEM_ITEMS_INTERFACE MTL_SYSTEM_ITEMS

MTL_TRANSACTIONS_INTERFACE

MTL_ITEM_REVISION_INTERFACE MTL_ITEM_REVISIONS

MTL_DEMAND_INTERFACE

MTL_ITEM_CATEGORIES_INTERFACE MTL_ITEM_CATEGORIES

MTL_CROSS_REFERENCES_INTERFACE MTL_CROSS_REFERENCES


On-hand quantity

Interface tables: MTL_TRANSACTIONS_INTERFACE

MTL_TRANSACTION_LOTS_INTERFACE

MTL_SERIAL_NUMBERS_INTERFACE

The Transaction Manager picks up the rows to process based on the LOCK_FLAG, TRANSACTION_MODE, PROCESS_FLAG to manipulate the records in the table. Only records with TRANSACTION_MODE of 3, LOCK_FLAG of '2', and PROCESS_FLAG of '1' will be picked up by the Transaction Manager and assigned to a Transaction Worker. If a record fails to process completely, then PROCESS_FLAG will be set to '3' and ERROR_CODE and ERROR_EXPLANATION will be populated with the cause for the error.

Base tables: MTL_ON_HAND_QUANTITIES

MTL_LOT_NUMBERS MTL_SERIAL_NUMBERS

Concurrent program:

Validations: validate organization_id, organization_code.

Validate inventory item id.

Transaction period must be open.

Customer conversion

Interface tables: RA_CUSTOMERS_INTERFACE_ALL

RA_CUSTOMER_PROFILES_INT_ALL

RA_CONTACT_PHONES_INT_ALL

RA_CUSTOMER_BANKS_INT_ALL

RA_CUST_PAY_METHOD_INT_ALL

Base tables: HZ_PARTIES

HZ_CONTACTS

HZ_PROFILES

HZ_LOCATIONS

Base tables for RA_CUSTOMERS_INTERFACE_ALL

RA_CUSTOMERS

RA_ADDRESSES_ALL

RA_CUSTOMER_RELATIONSHIPS_ALL

RA_SITE_USES_ALL

Uses TCA APIs.

Concurrent program: Customer Interface

Validations: Check if legacy values fetched are valid.

; Check if customer address site is already created.

Check if customer site use is already created.

Check is customer header is already created.

Check whether the ship_to_site has associated bill_to_site

Check whether associated bill_to_site is created or not.

Profile amounts validation: validate cust_account_id, validate customer status.

Check if the location already exists in HZ_LOCATIONS. If does not exist, create new location.

Customer API

1. Set the organization id

Exec dbms_application_info.set_client_info(‘204’);

2. Create a party and an account

HZ_CUST_ACCOUNT_V2PUB.CREATE_CUST_ACCOUNT()

HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE

HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE

HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE

3. Create a physical location

HZ_LOCATION_V2PUB.CREATE_LOCATION()

HZ_LOCATION_V2PUB.LOCATION_REC_TYPE

4. Create a party site using party_id you get from step 2 and location_id from step 3.

HZ_PARTY_SITE_V2PUB.CREATE_PARTY_SITE()

HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE

5. Create an account site using account_id you get from step 2 and party_site_id from step 4.

HZ_CUST_ACCOUNT_SITE_V2PUB.CREATE_CUST_ACCT_SITE()

HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_ACCT_SITE_REC_TYPE

6. Create an account site use using cust_acct_site_id you get from step 5 ans site_use_code = ‘BILL_TO’.

HZ_CUST_ACCOUNT_SITE_V2PUB.CREATE_CUST_SITE_USE()

HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE

HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE

Base table:

· HZ_PARTIES

· HZ_PARTY_SITES

· HZ_LOCATIONS

· HZ_CUST_ACCOUNTS

· HZ_CUST_SITE_USES_ALL

· HZ_CUST_ACCT_SITES_ALL

· HZ_PARTY_SITE_USES

Validations: Check if legacy values fetched are valid.

Check if customer address site is already created.

Check if customer site use is already created.

Check is customer header is already created.

Check whether the ship_to_site has associated bill_to_site

Check whether associated bill_to_site is created or not.

Profile amounts validation: validate cust_account_id, validate customer status.

Check if the location already exists in HZ_LOCATIONS. If does not exist, create new location.

Auto Invoice interface

Interface tables: RA_INTERFACE_LINES_ALL

Base tables:

RA_CUSTOMER_TRX_ALL
RA_BATCHES
RA_CUSTOMER_TRX_LINES_ALL
AR_PAYMENT_SCHEDULES_ALL
RA_CUSTOMER_TRX_LINE_SALESREPS
RA_CUST_TRX_GL_DIST_ALL
AR_RECEIVABLES_APPLICATIONS
AR_ADJUSTMENTS
AR_CASH_RECEIPTS
RA_CUSTOMER_TRX_TYPES_ALL

Concurrent Program: Auto invoice master program

Validations: check for amount, batch source name, conversion rate, conversion type.

Validate orig_system_bill_customer_id, orig_system_bill_address_id, quantity.

Validate if the amount includes tax flag.

Receipt API

AR_RECEIPT_API_PUB.CREATE_CASH

AR_RECEIPT_API_PUB.CREATE_AND_APPLY

To bring in Unapplied Receipts and Conversion Receipts for Open Debit items to reduce the balance to the original amount due.

Base tables: AR_CASH_RECEIPTS

Validations: check the currency and the exchange rate type to assign the exchange rate.

Validate bill to the customer.

Get bill to site use id.

Get the customer trx id for this particular transaction number.

Get payment schedule date for the customer trx id.

Lockbox interface

Interface tables: AR_PAYMENTS_INTERFACE_ALL (Import data from bank file )

Base tables: AR_INTERIM_CASH_RECEIPTS_ALL AR_INTERIM_CASH_RCPT_LINES_ALL (Validate data in interface table and place in quick cash tables)

Related Tables: AR_BANK_ACCOUNTS_ALL AR_RECEIPT_METHODS

AR_TRANSMISSIONS_ALL HZ_CUST_ACCOUNTS HZ_CUST_SITE_USES_ALL AR_CASH_RECEIPTS

(POST QUICK CASH -- applies the receipts and updates customer balances)

Concurrent program: nav-> receivables->interfaces->lockbox

Validations: check for valid record type, transmission record id.

Validate sum of the payments within the transmission.

Identify the lockbox number (no given by a bank to identify a lockbox).

AP invoice interface

Interface tables: AP_INVOICES_INTERFACE AP_INVOICE_LINES_INTERFACE

Base tables: AP_INVOICES_ALL – header information

AP_INVOICE_DISTRIBUTIONS_ALL – lines info

Concurrent program: Payables Open Interface Import

Validations: check for valid vendor

Check for valid vendor site code.

Check if record already exists in payables interface table.

Vendor conversion/interface

No interface tables

Base tables: PO_VENDORS PO_VENDOR_SITES_ALL

No concurrent program as data is directly populated into base tables.

Validations: check if a vendor already exists with the same name as the TIMSS customer

mail name.

Check if the proper site code and id exists based on the site code from TIMSS.

Check for uppercase value of the vendor name existed in Oracle and in TIMSS, vendor name is mixed case, a new Oracle vendor will not be created.

Purchasing:

Interface Tables Base Tables

PO_HEADERS_INTERFACE PO_HEADERS_ALL

PO_LINES_INTERFACE PO_LINES_ALL

PO_REQUISITIONS_INTERFACE_ALL PO_REQUISITIONS_HEADERS_ALL

PO_REQUISITION_LINES_ALL

PO_REQ_DISTRIBUTIONS_ALL

PO_REQ_DIST_INTERFACE_ALL PO_REQ_DISTRIBUTIONS_ALL

PO_DISTRIBUTIONS_INTERFACE PO_DISTRIBUTIONS_ALL

PO_RESCHEDULE_INTERFACE PO_REQUISITION_LINES_ALL

Requisition import

Interface tables: PO_REQUISITIONS_INTERFACE_ALL

PO_REQ_DIST_INTERFACE_ALL

Basetables: PO_REQUISITIONS_HEADERS_ALL

PO_REQUISITION_LINES_ALL

PO_REQ_DISTRIBUTIONS_ALL

Concurrent program: REQUISITION IMPORT

Validations: check for interface transaction source code, requisition destination type.

Check for quantity ordered, authorization status type.

PO Receipts Interface

Interface tables:

· RCV_HEADERS_INTERFACE

· RCV_TRANSACTIONS_INTERFACE

Base tables:

· RCV_SHIPMENT_HEADERS

· RCV_SHIPMENT_LINES

· RCV_TRANSACTIONS

Concurrent program: RECEIVING OPEN INTERFACE

Error messages: 1. Run RECEIVING INTERFACE ERRORS REPORT

2. Look in PO_INTERFACE_ERRORS

Query to check interface errors: PO_INTERFACE_ERRORS .inteface_transaction_id =

RCV_HEADERS_INTERFACE.header_interface_id and processing_status_code in (‘error’ ,’print’)

Validations:

GL interface

Interface tables: GL_INTERFACE

Base tables:

GL_JE_HEADERS
GL_JE_LINES
GL_JE_BACTHES

Concurrent Program: Journal Import

Journal Posting --- populates GL_BALANCES

Validations: check SOB, journal source name, journal category name, actual flag

A – actual amounts

B – budget amounts

E – encumbrance amount

If u enter E in the interface table, then enter appropriate encumbrance ID.

B – budget id.

Check if accounting date or GL date based period name is valid (i.e., not closed).

Check if accounting date falls in open or future open period status.

Check chart of accounts id based on Sob id.

Check if valid code combination.

Check if ccid is enabled.

Check if record already exists in GL interface table.

Check if already journal exists in GL application.

Validations for the staging table:

Check if the input data file is already uploaded into staging table.

Check if the record already exists in the interface table.

Check if the journal already exists in the GL application.

GL budget interface

Interface tables: GL_BUDGET_INTERFACE

Base tables:

GL_BUDGETS
GL_BUDGET_ASSIGNMENTS
GL_BUDGET_TYPES

Concurrent program: Budget Upload

Validations: Check Account combination is valid or not. You check this in GL_CODE_COMBINATIONS table.

GL daily conversion rates

Interface tables: GL_DAILY_RATES_INTERFACE

Base tables:

· GL_DAILY_RATES

· GL_DAILY_CONVERSION_TYPES

Concurrent Program: Program - Daily Rates Import and Calculation


Fixed Assets Conversion

Interface tables: fa_mass_additions


Base tables:

· FA_ADDITIONS

· FA_BOOKS_BOOK_CONTROLS_V (It's view). fa_additions_tl .........

Concurrent Program: Program -

Fixed Assets Manager-> Mass Additions -> Post Mass Additions

Fixed Assets Manager-> Mass Additions -> Delete Mass Additions

Fixed Assets Manager-> Tax -> Initial Mass Copy

Fixed Assets Manager-> Tax -> period mass copy

liangxichen 發表於:2008.10.23 17:07 ::分類: ( 開發類 ) ::閱讀:(25次) :: 評論 (0)
--&gt
===========================================================
Trace a Concurrent Request And Generate TKPROF File
===========================================================

Trace a Concurrent Request And Generate TKPROF File
October 5, 2008 · 1 Comment
Hello Friends, As in Oracle Application, there always need to tune programs , procedure and it is always difficult to make a perfect program, here i am trying to put a “How to” on tkprof and surely like to know if you find it useful.
How to Trace a Concurrent Request And Generate TKPROF File

Enable Tracing For The Concurrent Manager Program

Responsibility: System Administrator
Navigate: Concurrent > Program > Define
Query Concurrent Program
Select the Enable Trace Checkbox

Turn On Tracing

Responsibility: System Administrator
Navigate: Profiles > System
Query Profile Option Concurrent: Allow Debugging
Set profile to Yes
Run Concurrent Program With Tracing Turned On

Logon to the Responsibility that runs the Concurrent Program
In the Submit Request Screen click on Debug Options (B)
Select the Checkbox for SQL Trace
2. Find Trace File Name

Run the following SQL to find out the Raw trace name and location for the concurrent program. The SQL prompts the user for the request id

SELECT ’Request id: ’||request_id , ‘Trace id: ’||oracle_Process_id, ‘Trace Flag: ’||req.enable_trace, ‘Trace Name: ‘||dest.value||’/'||lower(dbnm.value)||’_ora_’||oracle_process_id||’.trc’, ‘Prog. Name: ’||prog.user_concurrent_program_name, ‘File Name: ’||execname.execution_file_name|| execname.subroutine_name , ‘Status : ’||decode(phase_code,’R',’Running’) ||’-'||decode(status_code,’R',’Normal’), ‘SID Serial: ’||ses.sid||’,'|| ses.serial#, ‘Module : ’||ses.module from fnd_concurrent_requests req, v$session ses, v$process proc, v$parameter dest, v$parameter dbnm, fnd_concurrent_programs_vl prog, fnd_executables execname where req.request_id = &request and req.oracle_process_id=proc.spid(+) and proc.addr = ses.paddr(+) and dest.name=’user_dump_dest’ and dbnm.name=’db_name’ and req.concurrent_program_id = prog.concurrent_program_id and req.program_application_id = prog.application_id and prog.application_id = execname.application_id and prog.executable_id=execname.executable_id;


3. TKPROF Trace File

Once you have obtained the Raw trace file you need to format the file using TKPROF.

$tkprof raw_trace_file.trc output_file explain=apps/apps sort=(exeela,fchela) sys=no

Where: raw_trace_file.trc: Name of trace file

output_file: tkprof out file

explain: This option provides the explain plan for the sql statements

sort: his provides the sort criteria in which all sql statements will be sorted. This will bring the bad sql at the top of the outputfile.

sys=no:Disables sql statements issued by user SYS

Another example: To get (TKPROF) sorted by longest running queries first and limits the results to the “Top 10″ long running queries


$ tkprof sys=no explain=apps/ sort=’(prsela,exeela,fchela)’ print=10


Thanks - Shivmohan Purohit

liangxichen 發表於:2008.10.21 20:24 ::分類: ( 維護類 ) ::閱讀:(8次) :: 評論 (0)
--&gt
===========================================================
如何把資料上傳到EBS的forms的資料塊中
===========================================================

轉:http://henryren.itpub.net/post/15063/413360

前幾天做了一個把檔案上傳到form的輸入域中的程式,這裡把步驟簡單的寫一下,附上關鍵的原始碼.以供參考.

1.建立一個臨時表: XXX_TEMP_FILES

建表語句是:

CREATE TABLE XXX_TEMP_FILES (
FILE_ID
NUMBER,
SEQ
NUMBER,
TEXT
VARCHAR2(2000),
CREATION_DATE
DATE)

建立這個表的目的就是要把資料從FND_LOBS這個表的file_data這個欄位的資料,透過程式,因為這個表的這個資料是lobs型別的,所以整個檔案都放在這個欄位裡,我們利用這個臨時表,把資料檔案拆成一行一個紀錄.然後每行在根據分個符查分.

2. 建立上傳包: XXX_FILE_IO

XXX_FILE_IO 包含三個子程式:
INS_TEMP_FILES:從fnd_lobs 表中取上傳的資料,把它按行來拆分,並插入到:
XXX_TEMP_FILES 表中
SEL_TEMP_FILES:從XXX_TEMP_FILES 中把資料去出
DEL_TEMP_FILES:資料已經上傳到Form的介面中,需要刪除檔案.

主要語句就是:

PROCEDURE INS_TEMP_FILES(p_file_id IN NUMBER) IS
w_integer INTEGER;
w_blob BLOB;

w_raw RAW(10);
w_buff VARCHAR2(30000);
w_line VARCHAR2(30000);
w_len INTEGER;
eofsw BOOLEAN := FALSE;
offset INTEGER;
w_b_len NUMBER := 0;
w_num NUMBER;
w_seq NUMBER := 0;

BEGIN
SELECT file_data INTO w_blob FROM fnd_lobs WHERE file_id = p_file_id;

offset := 1;
LOOP
EXIT WHEN eofsw;
w_seq := w_seq + 1;
w_raw := utl_raw.cast_to_raw(chr(10));
w_num := dbms_lob.instr(w_blob, w_raw, offset, 1);
w_len := w_num - w_b_len;
w_b_len := w_num;

IF w_num = 0
THEN
w_len := 20000;
eofsw := TRUE;
END IF;

BEGIN
DBMS_LOB.READ(w_blob, w_len, offset, w_buff);
EXCEPTION
WHEN no_data_found THEN
EXIT;
WHEN OTHERS THEN
RAISE;
END;

w_line := utl_raw.cast_to_varchar2(w_buff);

SELECT REPLACE(w_line, chr(10), NULL) INTO w_line FROM dual;
SELECT REPLACE(w_line, chr(13), NULL) INTO w_line FROM dual;

INSERT INTO XXX_TEMP_FILES
(FILE_ID, SEQ, TEXT, CREATION_DATE)
VALUES
(p_file_id, w_seq, w_line, SYSDATE);

offset := offset + w_len;
END LOOP;

END;
3. 在Form檔案中的Program Unit中健一個包.XXX_UPLOAD
這個檔案最好做成PLL,和其他客製化的有用的程式一起打包,上傳到form這是一個系統比較有用的通用的程式.
主要是利用FND_GFM這個通用上傳的工具,把檔案傳到,FND_LOBS中去,然後第二步建好的的包,進行資料拆分:

p_file_id := NULL;
access_id := FND_GFM.AUTHORIZE(NULL);

FND_PROFILE.GET('APPS_WEB_AGENT', l_server_url);
l_url := rtrim(l_server_url, '/') ||
'/fnd_file_upload.displayGFMform?access_id=' ||
to_char(access_id) ||
chr(38) ||
'l_server_url=' ||
l_server_url;

if (l_url is NULL) then
raise form_trigger_failure;
return NULL;
end if;

FND_UTILITIES.OPEN_URL(l_url);

FND_MESSAGE.SET_NAME('FND', 'ATCHMT-FILE-UPLOAD-COMPLETE');

button_choice := FND_MESSAGE.QUESTION(
button1 => 'YES',
button2 => null,
button3 => 'NO',
default_btn => 1,
cancel_btn => 3,
icon => 'question'
);

if button_choice = 1 then


p_file_id := FND_GFM.GET_FILE_ID(access_id);

XXX_FILE_IO.INS_TEMP_FILES(p_file_id);
-- pcm_dbms_lob.UPOPEN(p_file_id);

else

return NULL;

end if;


return p_file_id;

1. Form檔案中的Program Unit中健一個程式如: UPLOAD_XXX_XXX(X根據實際需要轉換)

UPLOAD_XXX_XXX 這個檔案的需要在實際的應用中作改動,根絕實際的要匯入的欄位修改程式.主要功能就是從XXX_TEMP_FILES把資料讀出,然後根據分割符來,把每個資料對應到form的域中.

檢視全文
liangxichen 發表於:2008.08.20 16:24 ::分類: ( 開發類 ) ::閱讀:(27次) :: 評論 (2)
--&gt
===========================================================
使用 fnd_user_pkg API 建立使用者,新增職責,修改使用者密碼等
===========================================================

比如有一個外圍支援系統,使用者需要在外圍系統登入之後點個link就可以登入到Oracle ERP系統中,那麼我們需要先把外圍系統的使用者建立在Oracle ERP中,並且分配職責給他。


DECLARE

a BOOLEAN;

BEGIN
-------------------------------------------------------------
--Change password
-------------------------------------------------------------
/*
a := apps.fnd_user_pkg.changepassword('SIMON','oracle');

IF NOT a THEN

--RAISE_APPLICATION_ERROR(-20002, 'Password not updated');

dbms_output.put_line('Password not updated');

ELSE

dbms_output.put_line('***Password updated');

COMMIT;

END IF;
*/
-------------------------------------------------------------
--Create User
-------------------------------------------------------------

fnd_user_pkg.CreateUser('SIMON',
'SEED',
'PW$234567'
);
-------------------------------------------------------------
--Add Resp
--select * from fnd_responsibility fr where fr.responsibility_id =
--select * from fnd_responsibility_tl frt where upper(frt.responsibility_name) like '%%'
--select * from fnd_application fa where fa.application_id =
--select * from fnd_security_groups fs
-------------------------------------------------------------


fnd_user_pkg.AddResp ('SIMON',
'SYSADMIN',
'SYSTEM_ADMINISTRATOR',
'STANDARD',
'Test API',
sysdate,
null
);
Commit;
End;

--使用下面程式碼可以在Link中直接登入Oracle ERP系統:



iSupport Login


method="post" name="Login" id="Login">




檢視全文
liangxichen 發表於:2008.08.15 17:38 ::分類: ( 開發類 ) ::閱讀:(29次) :: Permanent link
--&gt
===========================================================
Export data from a data block
===========================================================

WEB_SERVER_PREFIX := FND_WEB_CONFIG.GFM_AGENT; MIME_TYPE := NVL (FND_PROFILE.VALUE ('FND_EXPORT_MIME_TYPE'), 'text/tab-separated-values' ); DB_FILE := FND_GFM.FILE_CREATE (CONTENT_TYPE => MIME_TYPE, PROGRAM_NAME => 'export'); V_RECORD_NUM := :SYSTEM.CURSOR_RECORD; GO_BLOCK ('PO_RULE'); FIRST_RECORD LOOP EXIT WHEN SYSTEM.LAST_QUERY = TRUE ; OUTSTRING := 輸入你要的資料 FND_GFM.FILE_WRITE_LINE (DB_FILE, OUTPUT_STRING); NEXT_RECORD; END LOOP; GO_RECORD (V_RECORD_NUM); DB_FILE := FND_GFM.FILE_CLOSE (DB_FILE); URL := FND_GFM.CONSTRUCT_DOWNLOAD_URL (WEB_SERVER_PREFIX, DB_FILE, TRUE); FND_UTILITIES.OPEN_URL (URL); 這樣就搞定了,我剛開始想的太複雜了。因為我要使用Excle的模版,認為模版要在程式中呼叫,所以走了很多的彎路。 TO Mypeking : 你隨便開啟一個form只要有資料列的,你選擇檔案--〉匯出就可以存入excel了。

Oracle標準功能就用這一句程式碼:app_export.event('EXPORT');
自己寫最多再在前面加個:go_block('xxx');
就夠了。

liangxichen 發表於:2007.11.02 19:06 ::分類: ( 開發類 ) ::閱讀:(82次) :: 評論 (1)
--&gt
===========================================================
透過後臺建立使用者及增加職責
===========================================================
DECLARE
--By: Anil Passi
--When Jun-2001
v_session_id INTEGER := userenv('sessionid');
v_user_name VARCHAR2(30) := upper('&Enter_User_Name');
BEGIN
--Note, can be executed only when you have apps password.
-- Call the procedure to Creaet FND User
fnd_user_pkg.createuser(x_user_name => v_user_name
,x_owner => ''
,x_unencrypted_password => 'oracle'
,x_session_number => v_session_id
,x_start_date => SYSDATE - 10
,x_end_date => SYSDATE + 100
,x_last_logon_date => SYSDATE - 10
,x_description => 'appstechnical.blogspot.com'
,x_password_date => SYSDATE - 10
,x_password_accesses_left => 10000
,x_password_lifespan_accesses => 10000
,x_password_lifespan_days => 10000
,x_employee_id => 30 /*Change this id by running below SQL*/
/*
SELECT person_id
,full_name
FROM per_all_people_f
WHERE upper(full_name) LIKE '%' || upper('full_name') || '%'
GROUP BY person_id
,full_name
*/
,x_email_address => 'appstechnical.blogspot@gmail.com'
,x_fax => ''
,x_customer_id => ''
,x_supplier_id => '');
fnd_user_pkg.addresp(username => v_user_name
,resp_app => 'SYSADMIN'
,resp_key => 'SYSTEM_ADMINISTRATOR'
,security_group => 'STANDARD'
,description => 'Auto Assignment'
,start_date => SYSDATE - 10
,end_date => SYSDATE + 1000);
END;
liangxichen 發表於:2007.08.22 15:10 ::分類: ( 維護類 ) ::閱讀:(67次) :: 評論 (0)
--&gt
===========================================================
如何處理Oracle中TEMP表空間滿的問題?
===========================================================
正常來說,在完成Select語句、create index等一些使用TEMP表空間的排序操作後,Oracle是會自動釋放掉臨時段a的。但有些有侯我們則會遇到臨時段沒有被釋放,TEMP表空間幾乎滿的狀況,甚至是我們重啟了資料庫仍沒有解決問題。這個問題在論壇中也常被網友問到,下面我總結一下,給出幾種處理方法。

法一、重啟庫

庫重啟時,Smon程式會完成臨時段釋放,TEMP表空間的清理操作,不過很多的時侯我們的庫是不允許down的,所以這種方法缺少了一點的應用機會,不過這種方法還是很好用的。


法二、Metalink給出的一個方法

修改一下TEMP表空間的storage引數,讓Smon程式觀注一下臨時段,從而達到清理和TEMP表空間的目的。

SQL>alter tablespace temp increase 1;
SQL>alter tablespace temp increase 0;

法三、我常用的一個方法,具體內容如下:

1、 使用如下語句a檢視一下認誰在用臨時段

SELECT username,
sid,
serial#,
sql_address,
machine,
program,
tablespace,
segtype,
contents
FROM v$session se,
v$sort_usage su
WHERE se.saddr=su.session_addr

2、 那些正在使用臨時段的程式

SQL>Alter system kill session 'sid,serial#';

3、把TEMP表空間回縮一下

SQL>Alter tablespace TEMP coalesce;

法四、使用診斷事件的一種方法,也是被我認為是“殺手鐧”的一種方法

1、 確定TEMP表空間的ts#

SQL>select ts#, name from sys.ts$ ;

TS# NAME
-----------------------
0 SYSYEM
1 RBS
2 USERS
3* TEMP
4 TOOLS
5 INDX
6 DRSYS

2、 執行清理操作

SQL>alter session set events 'immediate trace name DROP_SEGMENTS level 4' ;

說明:
temp表空間的TS# 為 3*, So TS#+ 1= 4

其它:

1、 出現如上問題的原因我認為可能是由於大的排序超出了TEMP表空間的空間允許範圍引起的。也可能包含著其它的異常的因素。

2、 觀注TEMP等這些空間的狀態是Dba日常職責之一,我們可以透過Toad、Object Browser等這些工具辦到,也可以用如下的語句:

SELECT UPPER(F.TABLESPACE_NAME) "表空間名",
D.TOT_GROOTTE_MB "表空間大小(M)",
D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空間(M)",
TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,
2),
'990.99') "使用比",
F.TOTAL_BYTES "空閒空間(M)",
F.MAX_BYTES "最大塊(M)"
FROM (SELECT TABLESPACE_NAME,
ROUND(SUM(BYTES) / (1024 * 1024), 2) TOTAL_BYTES,
ROUND(MAX(BYTES) / (1024 * 1024), 2) MAX_BYTES
FROM SYS.DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F,
(SELECT DD.TABLESPACE_NAME,
ROUND(SUM(DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB
FROM SYS.DBA_DATA_FILES DD
GROUP BY DD.TABLESPACE_NAME) D
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
ORDER BY 4 DESC
liangxichen 發表於:2007.04.25 09:34 ::分類: ( 維護類 ) ::閱讀:(98次) :: 評論 (0)
--&gt
===========================================================
重建臨時表空間
===========================================================
1.startup --啟動資料庫

2.create temporary tablespace TEMP2 TEMPFILE @#/home2/oracle/oradata/sysmon/temp02.dbf@# SIZE 512M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED; --建立中轉臨時表空間

3.alter database default temporary tablespace temp2; --改變預設臨時表空間 為剛剛建立的新臨時表空間temp2

4.drop tablespace temp including contents and datafiles;--刪除原來臨時表空間

5.create temporary tablespace TEMP TEMPFILE @#/home2/oracle/oradata/sysmon/temp01.dbf@# SIZE 512M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED; --重新建立臨時表空間

6.alter database default temporary tablespace temp; --重置預設臨時表空間為新建的temp表空間

7.drop tablespace temp2 including contents and datafiles;--刪除中轉用臨時表空間

8.alter user roll temporary tablespace temp; --重新指定使用者表空間為重建的臨時表空間
liangxichen 發表於:2007.04.25 09:29 ::分類: ( 維護類 ) ::閱讀:(92次) :: 評論 (0)
--&gt
===========================================================
空間修改及查詢
===========================================================

SELECT B.FILE_ID 檔案ID號
,B.TABLESPACE_NAME 表空間名
,B.FILE_NAME 檔名
,B.BYTES / 1024 / 1024 "空間(M)"
,(B.BYTES - SUM(NVL(A.BYTES, 0))) / 1024 / 1024 "已使用(M)"
,SUM(NVL(A.BYTES, 0)) / 1024 / 1024 "剩餘空間(M)"
,SUM(NVL(A.BYTES, 0)) / (B.BYTES) * 100 剩餘百分比
FROM DBA_FREE_SPACE A
,DBA_DATA_FILES B
WHERE A.FILE_ID = B.FILE_ID
AND B.TABLESPACE_NAME = 'POD' --GTD
GROUP BY B.TABLESPACE_NAME
,B.FILE_ID
,B.FILE_NAME
,B.BYTES
ORDER BY B.FILE_ID;
SELECT d.status "Status"
,d.tablespace_name "Name"
,a.file_name
,d.contents "Type"
,d.extent_management "Extent Management"
,to_char(nvl(a.bytes / 1024 / 1024,
0),
'99,999,990.900') "Size (M)"
,nvl(t.bytes,
0) / 1024 / 1024 || '/' ||
nvl(a.bytes / 1024 / 1024,
0) "Used (M)"
,to_char(nvl(t.bytes / a.bytes * 100,
0),
'990.00') "Used %"
FROM d
,(SELECT tablespace_name
,file_name
,SUM(bytes) bytes
FROM

GROUP BY tablespace_name
,file_name) a
,(SELECT tablespace_name
,SUM(bytes_cached) bytes
FROM
GROUP BY tablespace_name) t
WHERE d.tablespace_name = a.tablespace_name(+)
AND d.tablespace_name = t.tablespace_name(+)

AND d.contents LIKE 'TEMPORARY'SELECT d.status "Status"
,d.tablespace_name "Name"
,a.file_name
,d.contents "Type"
,d.extent_management "Extent Management"
,to_char(nvl(a.bytes / 1024 / 1024,
0),
'99,999,990.900') "Size (M)"
,nvl(t.bytes,
0) / 1024 / 1024 || '/' ||
nvl(a.bytes / 1024 / 1024,
0) "Used (M)"
,to_char(nvl(t.bytes / a.bytes * 100,
0),
'990.00') "Used %"
FROM sys.dba_tablespaces d
,(SELECT tablespace_name
,file_name
,SUM(bytes) bytes
FROM dba_temp_files
GROUP BY tablespace_name
,file_name) a
,(SELECT tablespace_name
,SUM(bytes_cached) bytes
FROM v$temp_extent_pool
GROUP BY tablespace_name) t
WHERE d.tablespace_name = a.tablespace_name(+)
AND d.tablespace_name = t.tablespace_name(+)
AND d.extent_management LIKE 'LOCAL'
AND d.contents LIKE 'TEMPORARY'
/*ALTER DATABASE DATAFILE '/oracle/gttest/gttestdata/pod01.dbf' RESIZE 550M;*/


liangxichen 發表於:2007.04.24 15:37 ::分類: ( 維護類 ) ::閱讀:(93次) :: 評論 (0)
--&gt
===========================================================
FORMS開發中FOLDER(資料夾)功能的應用
===========================================================

一、模板製作:YSFOLDER.FMB

開啟TEMPLATE.FMB,如果開啟的是APPSTAND.FMB,以下步驟省略

1FORM級觸發器:

1、 WHEN-NEW-FORM-INSTANCE後面新增以下程式碼:

--定義資料夾資料塊

app_folder.define_folder_block(

object_name => ' DETAILBLOCK _FOLDER' ,

folder_block_name => 'DETAILBLOCK',

prompt_block_name => 'DETAILBLOCK_PROMPT',

folder_canvas_name => 'DETAILBLOCK_STACKED',

folder_window_name => 'BLOCKNAME',

disabled_functions => '');

--以上引數均為VARCHAR2,長度不得超過20個字元

2、 增加FORM級觸發器:FOLDER_ACTION PL/SQL程式碼如下:

app_folder.event(:global.folder_action);

3、 增加FORM級觸發器:FOLDER_RETURN_ACTION PL/SQL程式碼如下:

null;

--

-- action code is in :global.folder_action

-- affected field is in :global.folder_field

--

2Attached Libraries

新增檔案:APPFLDR.PLL

來源:ERP安裝目錄下,AU目錄下查詢該類檔案所在的目錄

3Object Groups

繼承一個物件組:STANDARD_FOLDER

做法:複製APPSTAND.FMB中的同名物件,貼上到模板物件組中,選擇“Refence”(繼承),路徑方式選擇“Remove path”(不要路經)。

結果:將會把物件組中的所有物件對映新增到相應的物件節點中。

二、模板例子的製作

1、 修改WHEN-NEW-FORM-INSTANCE中資料夾資料塊定義語句中的引數,確定物件名稱(一般為form物件名稱)、資料夾資料塊名稱、標題塊名稱、堆疊畫布名稱、視窗名稱。

2、 定義視窗(windows),win_main:繼承屬性WINDOW_NORMAL

3、 定義堆疊畫布(stacked canvas-views, cv_detail_stacked:繼承屬性類CANVAS_STACKED

4、 定義資料夾資料塊(folder block),blk_detail:繼承屬性類BLOCK

(1) 觸發器:

· KEY-EXEQRY

app_folder.event('KEY-EXEQRY');

· KEY-NEXT-ITEM

app_folder.event('KEY-NEXT-ITEM');

· KEY-PREV-ITEM

app_folder.event('KEY-PREV-ITEM');

· POST-BLOCK

app_folder.event('POST-BLOCK');

· PRE-BLOCK

app_folder.event('PRE-BLOCK');

· WHEN-NEW-BLOCK-INSTANCE

App_folder.event('WHEN-NEW-BLOCK-INSTANCE');

· KEY_CLRBLK

App_folder.event(' KEY_CLRBLK ');

· KEY_ENTQRY

App_folder.event(' KEY_ENTQRY ');

· KEY_NXTREC

App_folder.event(' KEY_NXTREC ');

· KEY_PRVREC

App_folder.event(' KEY_PRVREC ');

· PRE_QUERY

App_folder.event(' PRE_QUERY ');

· WHEN-NEW-RECORD-INSTANCE

App_folder.event('WHEN-NEW-RECORD-INSTANCE');

(2) 定義資料項,可以是表項,也可以是非基表項,確定哪些項需要放在堆疊畫布上,注意只有在堆疊畫布上的項才能使用資料夾功能

(3) 注意:資料項的型別不能是:Display ItemList Item等;

可以是:Text ItemCheck Box等;

如果開啟folder時出現錯誤:“Set_Item_Property沒有這樣的屬性”,說明erp標準程式中用到的屬性在個別項中不存在,出現幾次就有幾個缺乏這個屬性的Item;是否擁有這個屬性,是由Item的型別確定的,因此有些Item型別不能用於folder功能。

(4) 確定各個項在畫布中的位置

5、 定義標題資料塊(prompt block, blk_detail_prompt:繼承屬性類BLOCK_DIALOG

便捷的做法:先複製資料夾資料塊blk_detail,改名稱,再刪去新塊下的全部觸發器,然後除去不需要的項,修改剩下所有項的屬性繼承FOLDER_PROMPT_MULTRIROW,最後將各個項的default value屬性值寫入對應的中文或英文標題

(1) 觸發器:無

(2) 標題項,來自資料夾資料塊blk_detail,屬性繼承自FOLDER_PROMPT_MULTIROWdefault value屬性值寫入相應的中英文標題

標題項必須和參與folder功能的資料項保持一一對應,名稱必須一致

(3) 資料夾功能項(6個):

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/92289/viewspace-1012938/,如需轉載,請註明出處,否則將追究法律責任。

下一篇: Oracle Case When
Oracle Applications Interface Programs
請登入後發表評論 登入
全部評論

相關文章