Wednesday, February 20, 2013


Oracle Regular Expression
Regular expressions allow you to perform powerful context searches in variable-length strings. They provide a a powerful set of pattern matching capabilities by combining the following
Character Classes
are groups of possible characters at a point in the search
Collation Classes
are sets of characters and are treated like a range
Metacharacters
are operators that specify search algorithms
Metasequences
are operators created by two metacharacters or literals
Literals
are characters, character sets and words

Character Classes
Character classes are groups or ranges of possible characters, they are traditionally delimited by square brackets [], You use a dash "-" to specifiy a range i.e [1-9]. You can use the posix character class inside the brackets [:alpha:] see below for more examples
[:alnum:]
All alphanumeric characters
[:alpha:]
All alphabetic characters
[:cntrl:]
All non-printable control characters
[:digit:]
All numeric digits
[:graph:]
all [:digit:], [:lower:], [:punct:] and [:upper:] portable character class
[:lower:]
All lower alphabetic characters
[:print:]
All printable characters
[:punct:]
All punctuation characters
[:space:]
All nonprinting space characters
[:upper:]
All upper alphabetic characters
[:xdigit:]
All hexidecimal characters
Now for an example
Character class example:

DECLARE
  counter            NUMBER := 1;
  source_string   VARCHAR2(12)    := 'A1';
  pattern1           VARCHAR2(12)   := '[[:alpha:]]';  -- use the posix character class
  pattern2           VARCHAR2(12)   := '[[:alnum:]]';
BEGIN
  -- Compare using standard character class ranges.
  FOR i IN 1..LENGTH(source_string)
  LOOP
    IF REGEXP_INSTR(SUBSTR(source_string,counter,i),pattern1) = i
    THEN
        dbms_output.put(REGEXP_SUBSTR(SUBSTR(source_string,counter,i),pattern1));
    ELSE
        dbms_output.put_line(REGEXP_SUBSTR( SUBSTR(source_string,counter,i),pattern2));                                                           
    END IF;
    counter := counter + 1;
  END LOOP;
END;
/

This class is new and is designed to allow you to collate languages that require a collating element. You define a collation class by using [..]
Collation Classes
Collation class example
[a-[.ch.]]
Note: allows you to find element that is between an a or a ch

Metacharacters
A metacharacter provides some mechanics for performing pattern matching, lots of programming and scripting languages use the same syntax.
Metacharacter
Name
Type
Description
()
parentheses
Delimiter
act as a constraint on the scope of comparsion
{m}
exact
Interval
matches exactly m occurences of the preceding subexpression or character
{m, }
at least
Interval
matches at least m occurences of the preceding subexpression or character
{m,n}
between
Interval
matches exactly m occurences but no more than n of the preceding subexpression or character
|
OR
Logical
acts as a logical OR operator
.
dot
Matching
matches any one character
^
caret
Matching
matches the beginning of a line
$
dollar
Matching
matches the end of a line
[^]
caret
Negation
negates when used inside square brackets (like the NOT operator)
-
dash
Range
specifies a range when inside square brackets
?
question mark
Repetition
makes the proceding character optional
*
asterisk
Repetition
matches any instance of zero to many characters
+
plus
Repetition
matches at least once or many times the preceding character.
The best way to learn these is to google regular expression on the web, as i said before many programming languages and scripting languages use metacharacters.

Metasequences
Those of you who have used Perl before will under the metasequences, they are a character combined with a backslash to represent a pattern or characters.
Metasequence
Name
Type
Description
\n
backreference
Posix
matches the nth preceding subexpression
\d
digit
Perl
matches any digit
\D
nondigit
Perl
matches any non-digit
\w
word character
Perl
matches any word characters
\W
nonword character
Perl
matches any non-word characters
\s
whitespace character
Perl
matches any whitespace character
\S
nonwhitespace character
Perl
matches any non-whitespace character
\A
beginning of a string
Perl
matches a beginning of a string
\Z
end of a sting
Perl
matches the end of a string
\z
end of a string
Perl
matches the end of a string

Literals
Literals values are simply string literals, they may consist of one or many characters.

Oracle 11g Regular Expression
Oracle 11g has implemented a number of regular expression functions, so far there are 5 in total
Regular Expression Functions
REGEXP_COUNT
lets you count the number of times a specific pattern is found in a string
REGEXP_INSTR
lets you find a position index value in a string
REGEXP_LIKE
lets you find a regular expression match inside a string, it's like the LIKE operator
REGEXP_REPLACE
lets you find and replace a substring inside of a string
REGEXP_SUBSTR
lets you find a substring inside a string
Match Type Flags
i
sets the search to case-insensitive matching, overriding the nls_sort parameter
c
sets the search to case-sensitive matching, overriding the nls_sort parameter
n
Enables the dot (.) to truly match any character, including the newline
m
Enables a search to recognise multiple lines inside a string
x
sets the search to ignore any whitespace characters
Examples
REGEXP_COUNT
DECLARE
   mystring varchar2(24) := 'abcdefABCDEFabcdefABCDEF';
   mycount number;
BEGIN
   -- match a patterm - should result in 2
   select regexp_count(mystring, 'abcdef')
       into mycount
     from dual;
   dbms_output.put_line('Total Matches: ' || mycount);
   -- match a single pattern starting from position 7 - should result in 1
   select regexp_count(mystring, 'abcdef',7) 
       into mycount
     from dual;
   dbms_output.put_line('Total Matches: ' || mycount);
   -- match a pattern but ignore case - should result in 4
   select regexp_count(mystring, 'abcdef',1,'i')
      into mycount
     from dual;
   dbms_output.put_line('Total Matches: ' || mycount);
END;
/
REGEXP_INSTR
create table employees (emp_id        number
                                    ,emp_name  varchar2(30)
                                    );
insert
into employees values (1, 'Paul Valle');
select regexp_instr(emp_name,'Valle',1,1,0,'i') as Begin
    regexp_instr(emp_name,'Valle',1,1,1,'i') - 1 as End
from employees
REGEXP_LIKE
create table employees ( emp_id       number
                                    ,emp_name  varchar2(30)
                                    );
insert
into employees values (1, 'Paul Valle');
select emp_id
 from employees
where regexp_like(emp_name, 'Valle');
REGEXP_REPLACE
create table employees (emp_id       number
                                    ,emp_name  varchar2(30)
                                    );
insert
into employees values (1, 'Paul Valle');
select regexp_replace(emp_name, 'Paul', 'Lorraine',1)
  from employees;
REGEXP_SUBSTR
create table employees ( emp_id       number
                                     ,emp_name  varchar2(30)
                                    );
insert
into employees values (1, 'Paul Valle');
select regexp_substr(emp_name, 'V[:alpha:]+e',1)
  from employees;   -- using a character class



Useful queries in Oracle Order Management


Order header info
Select * from oe_order_headers_all ooh
where order_number= :p_order_number

Operating unit info
select * from hr_operating_units
where organization_id=oe_order_headers_all.org_id

Order type info
select * from apps.oe_transaction_types_tl
where transaction_type_id=oe_order_headers_all.order_type_id

Price list info
select * from apps.qp_list_headers_tl
where list_header_id=oe_order_headers_all.price_list_id

select * from apps.qp_list_lines
where list_header_id=oe_order_headers_all.price_list_id

Find customer info
select * from hz_cust_accounts hca
where cust_account_id=oe_order_headers_all.sold_to_org_id

select * from apps.hz_parties
where party_id=hz_cust_accounts.party_id

Find Ship to location info
select * from hz_cust_site_uses_all
where site_use_id=oe_order_headers_all.ship_to_org_id

select * from apps.hz_cust_acct_sites_all
where cust_acct_site_id=hz_cust_site_uses_all.cust_acct_site_id

select * from hz_party_sites
where party_site_id=hz_cust_acct_sites_all.party_site_id

Find Bill to location
select * from hz_cust_site_uses_all
where site_use_id=oe_order_headers_all.invoice_to_org_id
       
select * from hz_cust_acct_sites_all
where cust_acct_site_id=hz_cust_site_uses_all.cust_acct_site_id
       
select * from hz_party_sites
where party_site_id=hz_cust_acct_sites_all.party_site_id

actual address
select * from hz_locations
where location_id=hz_party_sites.location_id

Sales rep id
select name from apps.ra_salesreps_all salerep  where
salesrep_id = oe_order_headers_all.salesrep_id  and rownum =1

Payment terms
select name from apps.ra_terms_tl
where term_id =oe_order_headers_all.payment_term_id
and language = 'US'

Order source
select name from apps.oe_order_sources
where order_source_id= oe_order_headers_all.order_source_id
and enabled_flag= 'Y'

Order Source Reference
select orig_sys_document_ref from oe_order_headers_all ooh
where order_number='&oracle order number'

FOB Point Code
select lookup_code from ar_lookups
where lookup_type = 'FOB' and enabled_flag = 'Y'
and upper(meaning) = upper(oe_order_headers_all.fob_point_code)

Freight terms
select lookup_code from apps.oe_lookups
where upper (lookup_type) = 'FREIGHT_TERMS'  and enabled_flag = 'Y'
and upper (lookup_code) = upper (oe_order_headers_all.freight_terms_code)

For sales channel code validation
select lookup_code from apps.oe_lookups
where lookup_type = 'SALES_CHANNEL' and enabled_flag = 'Y'
upper(lookup_code) = upper(oe_order_headers_all.sales_channel_code)

Ship method
select ship_method_code from wsh.wsh_carrier_services
where ship_method_code = oe_order_headers_all.shipping_method_code

Warehouse Info
select * from org_organization_definitions
where organization_id = oe_order_headers_all.ship_from_org_id

Sales order Lines Details
select * from apps.oe_order_lines_all
where header_id=oe_order_headers_all.header_id

Transactional currency code
select ota.price_list_id, qhb.currency_code
from ont.oe_transaction_types_all ota, qp.qp_list_headers_b qhb
where ota.transaction_type_id = oe_order_headers_all.order_type_id
and ota.price_list_id = qhb.list_header_id(+)
and NVL(qhb.list_type_code, 'PRL') = 'PRL'
and qhb.currency_code =oe_order_headers_all.transactional_curr_code

Item info
select * from apps.mtl_system_items_b
where segment1 like oe_order_lines_all.ordered_item
and organization_id=oe_order_lines_all.ship_from_org_id

UOM
select uom_code from inv.mtl_units_of_measure_tl
where upper(uom_code)= upper(oe_order_lines_all.order_quantity_uom)
and language= 'US' and nvl(disable_date, (sysdate + 1)) > sysdate

Item type code validation
select lookup_code from apps.oe_lookups
where upper(lookup_type) = 'ITEM_TYPE'
and enabled_flag = 'Y'
and upper(lookup_code)= oe_order_lines_all.item_type_code

On hand quantities
select * from apps.mtl_onhand_quantities
where inventory_item_id=oe_order_lines_all.inventory_item_id
and organization_id=oe_order_lines_all.ship_from_org_id

Shipping
select * from wsh_delivery_details
where source_header_id=oe_order_headers_all.header_id

select * from wsh_delivery_assignments
where delivery_detail_id=wsh_delivery_details.delivery_detail_id

select * from wsh_new_deliveries
where delivery_id=wsh_delivery_assignments.delivery_id

select * from wsh_delivery_legs
where delivery_id=wsh_new_deliveries.delivery_id

select * from wsh_trip_stops wts
where stop_id=wsh_delivery_legs.pick_up_stop_id

select * from wsh_trips wt
where trip_id=wsh_trip_stops.trip_id

select * from org_organization_definitions
where organization_id = wsh_new_deliveries.organization_id

Material transactions
select * from mtl_material_transactions
where inventory_item_id=oe_order_lines_all.inventory_item_id
and organization_id=oe_order_lines_all.ship_from_org_id

select * from mtl_transaction_types
where transaction_type_id = mmt.transaction_type_id

select * from apps.mtl_txn_source_types
where transaction_source_type_id= mmt.transaction_source_type_id
mmt = mtl_material_transactions


Join between OM, WSH, AR Tables
SELECT ooh.order_number
              ,ool.line_id
              ,ool.ordered_quantity
              ,ool.shipped_quantity
              ,ool.invoiced_quantity
              ,wdd.delivery_detail_id
              ,wnd.delivery_id
              ,rctl.interface_line_attribute1
              ,rctl.interface_line_attribute3
              ,rctl.interface_line_attribute6
              ,rct.org_id
              ,rct.creation_date
              ,trx_number
              ,rctl.quantity_ordered
              ,rct.interface_header_context
  FROM oe_order_headers_all ooh
             ,oe_order_lines_all ool
             ,wsh_delivery_details wdd
             ,wsh_new_deliveries wnd
             ,wsh_delivery_assignments wda
             ,ra_customer_trx_all rct
             ,ra_customer_trx_lines_all rctl
 WHERE ooh.header_Id=ool.header_id
      AND wdd.source_header_id=ooh.header_id
      AND wdd.delivery_detail_Id=wda.delivery_detail_id
      AND wda.delivery_id=wnd.delivery_id
      AND rctl.interface_line_attribute1=to_char(ooh.order_number)
      AND rctl.interface_line_attribute6=to_char(ool.line_id)
      AND rctl.interface_line_attribute3=to_char(wnd.delivery_id)
      AND rctl.customer_trx_id=rct.customer_trx_id
      AND rct.interface_header_context='ORDER ENTRY'



Purchase release concurrent program will transfer the details from OM to PO requisitions interface. The following query will verify the same:
SELECT interface_source_code,

           interface_source_line_id,
           quantity,
           destination_type_code,
           transaction_id,
           process_flag,
           request_id,
           TRUNC (creation_date)
  FROM po_requisitions_interface_all
 WHERE interface_source_code = 'ORDER ENTRY'
   AND interface_source_line_id IN (SELECT drop_ship_source_id
                                      FROM oe_drop_ship_sources
                                     WHERE header_id = &order_hdr_id
                                       AND line_id = &order_line_id);

The following sql is used to review the requisition, sales order, and receipt number. It shows the joins between various tables in Internal Sales order (ISO)

SELECT porh.segment1,
           porl.line_num,
           pord.distribution_num,
           ooh.order_number
           sales_order,
           ool.line_number so_line_num,
           rsh.receipt_num,
           rcv.transaction_type
  FROM oe_order_headers_all ooh,
          po_requisition_headers_all porh,
          po_requisition_lines_all porl,
          po_req_distributions_all pord,
          oe_order_lines_all ool,
          po_system_parameters_all posp,
          rcv_shipment_headers rsh,
          rcv_transactions rcv
 WHERE ooh.order_source_id = posp.order_source_id
   AND porh.org_id = posp.org_id
   AND porh.requisition_header_id = ool.source_document_id
   AND porl.requisition_line_id = ool.source_document_line_id
   AND porh.requisition_header_id = porl.requisition_header_id
   AND porl.requisition_line_id = pord.requisition_line_id
   AND porl.requisition_line_id = rcv.requisition_line_id
   AND pord.distribution_id = rcv.req_distribution_id
   AND rcv.shipment_header_id = rsh.shipment_header_id

QUERY FOR CUSTOMER SHIPTO & BILLTO ADDRESS


SELECT
     h.order_number
    ,h.sold_to_org_id bill_cust_account_id
    ,h.ship_to_org_id ship_to_site_use_id
    ,h.invoice_to_org_id bill_to_site_use_id
    ,hp.party_name "Customer Name"
    ,hca.account_name
    ,hca.org_id
    ,hcasab.orig_system_reference      BILL_TO_ORIG_REF
    ,hpb.status                        BILL_TO_STATUS
    ,'ADDRESS1 - '||bill_loc.address1||','||CHR(10)||
     'ADDRESS2 - '||bill_loc.address2||','||CHR(10)||
     'ADDRESS3 - '||bill_loc.address3||','||CHR(10)||
     'CITY     - '||bill_loc.city||','||CHR(10)||
     'POSTAL CD- '||bill_loc.postal_code||','||CHR(10)||
     'COUNTRY  - '|| bill_loc.country  BILL_TO_ADDRESS
    ,hcasas.orig_system_reference      SHIP_TO_ORIG_REF
    ,hps.status                        SHIP_TO_STATUS
    ,'ADDRESS1 - '||ship_loc.address1||','||CHR(10)||
     'ADDRESS2 - '||ship_loc.address2||','||CHR(10)||
     'ADDRESS3 - '||ship_loc.address3||','||CHR(10)||
     'CITY     - '||ship_loc.city||','||CHR(10)||
     'POSTAL CD- '||ship_loc.postal_code||','||CHR(10)||
     'COUNTRY  - '|| ship_loc.country  SHIP_TO_ADDRESS
FROM
     oe_order_headers_all h
    ,hz_parties hp
    ,hz_cust_accounts hca
    ,hz_cust_acct_sites_all hcasab
    ,hz_cust_acct_sites_all hcasas
    ,hz_cust_site_uses_all hzsuab
    ,hz_cust_site_uses_all hzsuas
    ,hz_party_sites hps
    ,hz_party_sites hpb
    ,hz_locations bill_loc
    ,hz_locations ship_loc
WHERE 1 =1
AND hp.party_id             = hca.party_id
AND hca.CUST_ACCOUNT_ID     = h.sold_to_org_id
AND hcasab.cust_account_id  = hca.cust_account_id
AND hcasas.cust_account_id  = hca.cust_account_id
AND hpb.location_id         = bill_loc.location_id
AND hps.location_id         = ship_loc.location_id
AND hcasab.party_site_id    = hpb.party_site_id
AND hcasas.party_site_id    = hps.party_site_id
AND hcasab.cust_acct_site_id= hzsuab.cust_acct_site_id
AND hcasas.cust_acct_site_id= hzsuas.cust_acct_site_id
AND h.ship_to_org_id        = hzsuas.site_use_id
AND h.invoice_to_org_id     = hzsuab.site_use_id
AND h.order_number          = '&order_number';

FND TABLES

Here there are few key FND tables that we use in our AOL queries.
FND_APPLICATION: Stores applications registered with Oracle Application Object Library.
FND_APPLICATION_TL: Stores translated information about all the applications registered with Oracle Application Object Library.
FND_APP_SERVERS: This table will track the servers used by the E-Business Suite system.
FND_ATTACHED_DOCUMENTS: Stores information relating a document to an application entity.
FND_CONCURRENT_PROCESSES: Stores information about concurrent managers.
FND_CONCURRENT_PROCESSORS: Stores information about immediate (subroutine) concurrent program libraries.
FND_CONCURRENT_PROGRAMS: Stores information about concurrent programs. Each row includes a name and description of the concurrent program.
FND_CONCURRENT_PROGRAMS_TL: Stores translated information about concurrent programs in each of the installed languages.
FND_CONCURRENT_QUEUES: Stores information about concurrent managers.
FND_CONCURRENT_QUEUE_SIZE: Stores information about the number of requests a concurrent manager can process at once, according to its work shift.
FND_CONCURRENT_REQUESTS: Stores information about individual concurrent requests.
FND_CONCURRENT_REQUEST_CLASS: Stores information about concurrent request types.
FND_CONC_REQ_OUTPUTS: This table stores output files created by Concurrent Request.
FND_CURRENCIES: Stores information about currencies.
FND_DATABASES: It tracks the databases employed by the eBusiness suite. This table stores information about the database that is not instance specific.
FND_DATABASE_INSTANCES: Stores instance specific information. Every database has one or more instance.
FND_DESCRIPTIVE_FLEXS: Stores setup information about descriptive flex fields.
FND_DESCRIPTIVE_FLEXS_TL: Stores translated setup information about descriptive flex fields.
FND_DOCUMENTS: Stores language-independent information about a document.
FND_EXECUTABLES: Stores information about concurrent program executable.
FND_FLEX_VALUES: Stores valid values for key and descriptive flex field segments.
FND_FLEX_VALUE_SETS: Stores information about the value sets used by both key and descriptive flex fields.
FND_LANGUAGES: Stores information regarding languages and dialects.
FND_MENUS: It lists the menus that appear in the Navigate Window, as determined by the System Administrator when defining responsibilities for function security.
FND_MENUS_TL: Stores translated information about the menus in FND_MENUS.
FND_MENU_ENTRIES: Stores information about individual entries in the menus in FND_MENUS.
FND_PROFILE_OPTIONS: Stores information about user profile options.
FND_REQUEST_GROUPS: Stores information about report security groups.
FND_REQUEST_SETS: Stores information about report sets.
FND_RESPONSIBILITY: Stores information about responsibilities. Each row includes the name and description of the responsibility, the application it belongs to, and values that identify the main menu, and the first form that it uses.
FND_RESPONSIBILITY_TL: Stores translated information about responsibilities.
FND_RESP_FUNCTIONS: Stores security exclusion rules for function security menus. Security exclusion rules are lists of functions and menus inaccessible to a particular responsibility.
FND_SECURITY_GROUPS: Stores information about security groups used to partition data in Service Bureau architecture.
FND_SEQUENCES: Stores information about the registered sequences in your applications.
FND_TABLES: Stores information about the registered tables in your applications.
FND_TERRITORIES: Stores information for countries, alternatively known as territories.
FND_USER: Stores information about application users.
FND_VIEWS: Stores information about the registered views in your applications.

FNDLOAD SCRIPTS


The Generic Loader (FNDLOAD) is a concurrent program that can transfer Oracle Application entity data between database and text file. The loader reads a configuration file to determine which entity to access. In simple words FNDLOAD is used to transfer entity data from one instance/database to other. For example if you want to move a concurrent program/menu/value sets developed in DEVELOPMENT instance to
PRODUCTION instance you can use this command.


1. Lookups
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/aflvmlu.lct XX_CUSTOM_LKP.ldt FND_LOOKUP_TYPE APPLICATION_SHORT_NAME="XXCUST" LOOKUP_TYPE="XX_LOOKUP_TYPE"
FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/aflvmlu.lct XX_CUSTOM_LKP.ldt UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE

2. Concurrent Program
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afcpprog.lct XX_CUSTOM_CP.ldt PROGRAM APPLICATION_SHORT_NAME="XXCUST" CONCURRENT_PROGRAM_NAME="XX_CONCURRENT_PROGRAM"
FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/afcpprog.lct XX_CUSTOM_CP.ldt - WARNING=YES UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE

3. Profile  
FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afscprof.lct XX_CUSTOM_PRF.ldt PROFILE PROFILE_NAME="XX_PROFILE_NAME" APPLICATION_SHORT_NAME="XXCUST"
$FND_TOP/bin/FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/afscprof.lct XX_CUSTOM_PRF.ldt - WARNING=YES UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE

4. Request Set and Link  
FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afcprset.lct XX_CUSTOM_RS.ldt REQ_SET REQUEST_SET_NAME='REQUEST_SET_NAME'
FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afcprset.lct  XX_CUSTOM_RS.ldt UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE

5. FND Message
FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afmdmsg.lct XX_CUSTOM_MESG.ldt FND_NEW_MESSAGES APPLICATION_SHORT_NAME="XXCUST" MESSAGE_NAME="MESSAGE_NAME%"
FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afmdmsg.lct XX_CUSTOM_MESG.ldt UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE

6. D2K FORMS
$FND_TOP/bin/FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afsload.lct XX_CUSTOM_FRM.ldt FORM FORM_NAME="FORM_NAME"  
$FND_TOP/bin/FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/afsload.lct XX_CUSTOM_FRM.ldt - WARNING=YES UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE

7. Form Function
FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afsload.lct XX_CUSTOM_FUNC.ldt FUNCTION FUNCTION_NAME="FORM_FUNCTION_NAME"
$FND_TOP/bin/FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/afsload.lct XX_CUSTOM_FUNC.ldt - WARNING=YES UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE

8. Alerts
FNDLOAD apps/apps 0 Y DOWNLOAD $ALR_TOP/patch/115/import/alr.lct XX_CUSTOM_ALR.ldt ALR_ALERTS APPLICATION_SHORT_NAME=XXCUST ALERT_NAME="XX - Alert Name"
FNDLOAD apps/apps 0 Y UPLOAD $ALR_TOP/patch/115/import/alr.lct XX_CUSTOM_ALR.ldt CUSTOM_MODE=FORCE

9. Value Set
$FND_TOP/bin/FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct XX_CUSTOM_VS.ldt VALUE_SET FLEX_VALUE_SET_NAME="XX Value Set Name"
$FND_TOP/bin/FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/afffload.lct XX_CUSTOM_VS.ldt - WARNING=YES UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE

10. Data Definition and Associated Template
FNDLOAD apps/$CLIENT_APPS_PWD O Y DOWNLOAD  $XDO_TOP/patch/115/import/xdotmpl.lct XX_CUSTOM_DD.ldt XDO_DS_DEFINITIONS APPLICATION_SHORT_NAME='XXCUST' DATA_SOURCE_CODE='XX_SOURCE_CODE' TMPL_APP_SHORT_NAME='XXCUST' TEMPLATE_CODE='XX_SOURCE_CODE'
FNDLOAD apps/$CLIENT_APPS_PWD O Y UPLOAD $XDO_TOP/patch/115/import/xdotmpl.lct XX_CUSTOM_DD.ldt

11. DATA_TEMPLATE (Data Source .xml file)
java oracle.apps.xdo.oa.util.XDOLoader DOWNLOAD -DB_USERNAME apps -DB_PASSWORD apps -JDBC_CONNECTION '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XX_HOST_NAME)(PORT=XX_PORT_NUMBER))(CONNECT_DATA=(SERVICE_NAME=XX_SERVICE_NAME)))' -LOB_TYPE DATA_TEMPLATE -LOB_CODE XX_TEMPLATE -APPS_SHORT_NAME XXCUST -LANGUAGE en -lct_FILE $XDO_TOP/patch/115/import/xdotmpl.lct -LOG_FILE $LOG_FILE_NAME
java oracle.apps.xdo.oa.util.XDOLoader UPLOAD -DB_USERNAME apps -DB_PASSWORD apps -JDBC_CONNECTION '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XX_HOST_NAME)(PORT=XX_PORT_NUMBER))(CONNECT_DATA=(SERVICE_NAME=XX_SERVICE_NAME)))' -LOB_TYPE DATA_TEMPLATE -LOB_CODE XX_TEMPLATE -XDO_FILE_TYPE XML -FILE_NAME $DATA_FILE_PATH/$DATA_FILE_NAME.xml -APPS_SHORT_NAME XXCUST -NLS_LANG en -TERRITORY US -LOG_FILE $LOG_FILE_NAME

12. RTF TEMPLATE (Report Layout .rtf file)
java oracle.apps.xdo.oa.util.XDOLoader DOWNLOAD -DB_USERNAME apps -DB_PASSWORD apps -JDBC_CONNECTION '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XX_HOST_NAME)(PORT=XX_PORT_NUMBER))(CONNECT_DATA=(SERVICE_NAME=XX_SERVICE_NAME)))' -LOB_TYPE TEMPLATE -LOB_CODE XX_TEMPLATE -APPS_SHORT_NAME XXCUST -LANGUAGE en -TERRITORY US -lct_FILE $XDO_TOP/patch/115/import/xdotmpl.lct -LOG_FILE $LOG_FILE_NAME
java oracle.apps.xdo.oa.util.XDOLoader UPLOAD -DB_USERNAME apps -DB_PASSWORD apps -JDBC_CONNECTION '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XX_HOST_NAME)(PORT=XX_PORT_NUMBER))(CONNECT_DATA=(SERVICE_NAME=SERVICE_NAME)))' -LOB_TYPE TEMPLATE -LOB_CODE XX_TEMPLATE -XDO_FILE_TYPE RTF -FILE_NAME $RTF_FILE_PATH/$RTF_FILE_NAME.rtf -APPS_SHORT_NAME XXCUST -NLS_LANG en -TERRITORY US -LOG_FILE $LOG_FILE_NAME


SQL*LOADER

SQL LOADER is an Oracle utility used to load data into table given a datafile which has the
records that need to be loaded. SQL*Loader takes data file, as well as a control file, to
insert data into the table. When a Control file is executed, it can create Three (3) files called
log file, bad file or reject file, discard file.

Log file tells you the state of the tables and indexes and the number of logical records
already read from the input datafile. This information can be used to resume the load
where it left off.
Bad file or reject file gives you the records that were rejected because of formatting
errors or because they caused Oracle errors.
Discard file specifies the records that do not meet any of the loading criteria like when
any of the WHEN clauses specified in the control file. These records differ from
rejected records.

Structure of a Control file:
OPTIONS (SKIP = 1)          —The first row in the data file is skipped without loading
LOAD DATA
INFILE ‘$FILE’                   — Specify the data file path and name
APPEND                             — Type of loading (INSERT, APPEND, REPLACE, TRUNCATE
INTO TABLE “APPS”.”BUDGET”    The table to be loaded into
FIELDS TERMINATED BY ‘|’          Specify the delimiter if variable format datafile
OPTIONALLY ENCLOSED BY ‘”‘ — The values of the data fields may be enclosed in“
TRAILING NULLCOLS                    columns that are not present in the record treated as null
(ITEM_NUMBER “TRIM(:ITEM_NUMBER)”,  Can use all SQL functions on columns
QTY DECIMAL EXTERNAL,
REVENUE DECIMAL EXTERNAL,
EXT_COST DECIMAL EXTERNAL TERMINATED BY WHITESPACE
“(TRIM(:EXT_COST))” ,
MONTH “to_char(LAST_DAY(ADD_MONTHS(SYSDATE,-1)),’DD-MON-YY’)” ,
DIVISION_CODE CONSTANT “AUD”   Can specify constant value instead of
Getting value from datafile
)

OPTION statement precedes the LOAD DATA statement. The OPTIONS parameter allows
you to specify runtime arguments in the control file, rather than on the command line. The
following arguments can be specified using the OPTIONS parameter.
SKIP = n          Number of logical records to skip (Default 0)
LOAD = n        Number of logical records to load (Default all)
ERRORS = n    Number of errors to allow (Default 50)
ROWS = n       Number of rows in conventional path bind array or between direct path data
                            saves (Default: Conventional Path 64, Direct path all)
BINDSIZE = n  Size of conventional path bind array in bytes (System-dependent default)
SILENT = {FEEDBACK | ERRORS | DISCARDS | ALL}  Suppress messages during run
                             (header, feedback, errors, discards, partitions, all)
DIRECT = {TRUE | FALSE}         — Use direct path (Default FALSE)
PARALLEL = {TRUE | FALSE}     Perform parallel load (Default FALSE)

LOADDATA statement is required at the beginning of the control file.
INFILE: INFILE keyword is used to specify location of the datafile or datafiles.
INFILE* specifies that the data is found in the control file and not in an external file. INFILE
‘$FILE’, can be used to send the filepath and filename as a parameter when registered as a
concurrent program.

Example where datafile is an external file:
LOAD DATA
INFILE ‘/home/vision/kap/import2.csv’
INTO TABLE kap_emp
FIELDS TERMINATED BY “,”
( emp_num, emp_name, department_num, department_name )

Example where datafile is in the Control file:
LOAD DATA
INFILE *
INTO TABLE kap_emp
FIELDS TERMINATED BY “,”
( emp_num, emp_name, department_num, department_name )
BEGINDATA
7369,SMITH,7902,Accounting
7499,ALLEN,7698,Sales
7521,WARD,7698,Accounting
7566,JONES,7839,Sales
7654,MARTIN,7698,Accounting

Example where file name and path is sent as a parameter when registered as a concurrent
program:
LOAD DATA
INFILE ‘$FILE’
INTO TABLE kap_emp
FIELDS TERMINATED BY “,”
( emp_num, emp_name, department_num, department_name )

TYPE OF LOADING:
INSERT                 — If the table you are loading is empty, INSERT can be used.
APPEND               — If data already exists in the table, SQL*Loader appends the new rows to it. If
                                    data doesn’t already exist, the new rows are simply loaded.
REPLACE             — All rows in the table are deleted and the new data is loaded
TRUNCATE         — SQL*Loader uses the SQL TRUNCATE command.

INTOTABLE is required to identify the table to be loaded into.
FIELDS TERMINATED BY specifies how the data fields are terminated in the datafile.(If the
file is Comma delimited or Pipe delimited etc)
OPTIONALLY ENCLOSED BY ‘”‘ specifies that data fields may also be enclosed by
quotation marks.
TRAILINGNULLCOLS clause tells SQL*Loader to treat any relatively positioned columns
that are not present in the record as null columns.

Loading a fixed format data file:
LOAD DATA
INFILE ‘sample.dat’
INTO TABLE emp
( empno       POSITION(01:04) INTEGER EXTERNAL,
  ename        POSITION(06:15) CHAR,
  job             POSITION(17:25) CHAR,
  mgr            POSITION(27:30) INTEGER EXTERNAL,
  sal              POSITION(32:39) DECIMAL EXTERNAL,
  comm         POSITION(41:48) DECIMAL EXTERNAL,
  deptno        POSITION(50:51) INTEGER EXTERNAL)

Steps to Run the SQL* LOADER from UNIX:
At the prompt, invoke SQL*Loader as follows:

sqlldr USERID=USERNAME/PASSWORDCONTROL=<control filename> LOG=<Log filename>

Register as concurrent Program:
Place the Control file in $CUSTOM_TOP/bin.
Define the Executable. Give the Execution Method as SQL*LOADER.
Define the Program. Add the Parameter for FILENAME.

Skip columns:
You can skip columns using the ‘FILLER’ option.
Load Data
----------
----------
TRAILING NULLCOLS
(
name Filler,
Empno ,
sal
)
here the column name will be skipped.

Load multiple files into a single table:
LOAD DATA
INFILE ‘eg.dat’ — File 1
INFILE ‘eg1.dat’ — File 2
APPEND
INTO TABLE emp
FIELDS TERMINATED BY “,”
( emp_num, emp_name, department_num, department_name )

Load a single file into multiple tables:
LOAD DATA
INFILE ‘eg.dat’
APPEND
INTO TABLE emp
FIELDS TERMINATED BY “,”
( emp_num, emp_name )
INTO TABLE dept
FIELDS TERMINATED BY “,”
(department_num, department_name)


Skip a column while loading using “FILLER” and Load field in the
delimited data file into two different columns in a table using “POSITION”
LOAD DATA
INFILE ‘eg.dat’
APPEND
INTO TABLE emp
FIELDS TERMINATED BY “,”
(emp_num,
emp_name,
desc_skip FILLER POSITION(1),
description,
department_num,
department_name)

Explanation on how SQL LOADER processes the above CTL file:
· The first field in the data file is loaded into column emp_num of table EMP
· The second field in the data file is loaded into column emp_name of table EMP
· The field desc_skip enables SQL LOADER to start scanning the same record it is
  at from the beginning because of the clause POSITION(1) . SQL LOADER again
  reads the first delimited field and skips it as directed by “FILLER” keyword.
· Now SQL LOADER reads the second field again and loads it into description
  column of the table EMP.
· SQL LOADER then reads the third field in the data file and loads into column
  department_num of table EMP
· Finally the fourth field is loaded into column department_name of table EMP.

Usage of BOUNDFILLER
LOAD DATA
INFILE ‘C:\eg.dat’
APPEND
INTO TABLE EMP
FIELDS TERMINATED BY “,”
(
Rec_skip BOUNDFILLER,
tmp_skip BOUNDFILLER,
Emp_num “(:Rec_skip||:tmp_skip||:emp_num)”,
Emp_name
)

How To Create User in Oracle Apps:

Navigation:

Go to System Administrator->Security->User->Define



Save.
Assign the  required responsibilities to user.
Save.

Query to check  from backend:
SELECT *
FROM FND_USER
WHERE USER_NAME LIKE 'KILL%'