Tuesday, 9 August 2016

Last Concurrent Program request on reports

SELECT fcr.CONCURRENT_PROGRAM_ID,
        fcr.RESPONSIBILITY_ID,
        fcpt.user_concurrent_program_name,
        fcr.REQUEST_ID,
        frt.responsibility_name  ,
        fcr.REQUESTED_START_DATE ,
        fcr.ARGUMENT_TEXT,
        fcr.COMPLETION_TEXT,
        fu.user_name ,
        fu.DESCRIPTION
FROM apps.fnd_concurrent_requests fcr,
     apps.fnd_concurrent_programs_tl fcpt,
     apps.fnd_responsibility_tl frt,
     apps.fnd_user fu
where 1=1
AND fcpt.concurrent_program_id = fcr.CONCURRENT_PROGRAM_ID
AND fcpt.user_concurrent_program_name like '%ReportName%'  
and frt.responsibility_id = fcr.responsibility_id
and fu.user_id=fcr.REQUESTED_BY
order by fcr.REQUESTED_START_DATE DESC

Monday, 11 May 2015

Based on Concurrent Program Get Request group name

Based on Concurrent Program Get Request group name:

SELECT cpt.user_concurrent_program_name "Concurrent Program Name",
DECODE(rgu.request_unit_type,
'P', 'Program',
'S', 'Set',
rgu.request_unit_type) "Unit Type",
cp.concurrent_program_name "Concurrent Program Short Name",
rg.application_id "Application ID",
rg.request_group_name "Request Group Name",
fat.application_name "Application Name",
fa.application_short_name "Application Short Name",
fa.basepath "Basepath"
FROM fnd_request_groups rg,
fnd_request_group_units rgu,
fnd_concurrent_programs cp,
fnd_concurrent_programs_tl cpt,
fnd_application fa,
fnd_application_tl fat WHERE rg.request_group_id = rgu.request_group_id
AND rgu.request_unit_id = cp.concurrent_program_id
AND cp.concurrent_program_id = cpt.concurrent_program_id
AND rg.application_id = fat.application_id
AND fa.application_id = fat.application_id
AND cpt.language = USERENV('LANG')
AND fat.language = USERENV('LANG')
AND cpt.user_concurrent_program_name = ''Concurrent_Program_name';

Monday, 29 September 2014

Oracle Apps Interview Questions On Reports


1. What are the various report triggers ? What is their order of firing ?
    There are eight report triggers. Of these there are five global triggers called the Report Triggers. 
        They are fired in the following order :
    * Before Parameter Form
    * After Parameter Form
    * Before Report
    * Between Pages
    * After Report

Apart from the above Five Report Triggers, there are three other types of triggers :
    * Validation Triggers
    * Format Triggers
    * Action Triggers

Before Form : Fires before the Runtime Parameter Form is displayed. From this trigger, you can access and change the values of parameters, PL/SQL global variables, and report-level columns. (Note : If the Runtime Parameter Form is suppressed, this trigger still fires. Consequently, you can use this trigger for validation of command line parameters).

After Form : Fires after the Runtime Parameter Form is displayed. From this trigger, you can access parameters and check their values. This trigger can also be used to change parameter values or, if an error occurs, return to the Runtime Parameter Form. Columns from the data model are not accessible from this trigger. (Note : If the Runtime Parameter Form is suppressed, the After Form trigger still fires. Consequently, you can use this trigger for validation of command line parameters or other data).

Before Report : Fires before the report is executed but after queries are parsed and data is fetched.

Between Pages : Fires before each page of the report is formatted, except the very first page. This trigger can be used for customized page formatting. (Note : In the Previewer, this trigger only fires the first time that you go to a page. If you subsequently return to the page, the trigger does not fire again.)

After Report : Fires after you exit the Previewer, or after report output is sent to a specified destination, such as a file, a printer, or an Oracle*Mail userid. This trigger can be used to clean up any initial processing that was done, such as deleting tables. Note, however, that this trigger always fires, whether or not your report completed successfully.

Validation Triggers : Validation Triggers are PL/SQL functions that are executed when parameter values are specified on the command line and when you accept the Runtime Parameter Form. (Notice that this means each Validation Trigger may fire twice when you execute the report). Validation Triggers are also used to validate the Initial Value of the parameter in the Parameter property sheet.

Format Triggers : Format Triggers are PL/SQL functions executed before the object is formatted. The trigger can be used to dynamically change the formatting attributes of the object.

Action Triggers : Action Triggers are PL/SQL procedures executed when a button is selected in the Previewer. The trigger can be used to dynamically call another report (drill down) or execute any other PL/SQL.




2. What is the Format Trigger?
Format Trigger is a PL/SQL function. This trigger is going to fire before an object is printed in report output. 
 it return boolean-true then go to print -false then don't print.


3. What is the diff. when Flex mode is mode on and when it is off?
When flex mode is on, reports automatically resizes the parent when the child is resized.


4. What is the diff. when confine mode is on and when it is off?
When confine mode is on, an object cannot be moved outside its parent in the layout.


5. What is a lexical parameter?
Lexical Parameter is used to replace the where, order by conditions at run time.


6. What are bind variables?
Bind variables are used in report 6i for replacing the single parameter in the select statement


7. How many different layouts are available in Reports?
    There are eight different layout formats:
    Tabular
    Form Like
    Form Letter
    Mailing Label
    Group Left
    Group Above
    Matrix
    Matrix with group


8. What is the minimum number of groups required for a matrix report?
The minimum of groups required for a matrix report are 4


9. What is the lock option in reports layout?
By using the lock option we cannot move the fields in the layout editor outside the frame. This is useful for maintaining the fields.


10. What is the Anchoring in Reports?
Anchor is used to make fixed distance between two objects in Reports Layout.

* An anchor defines the relative position of an object to the object to which it is anchored. 
  Anchors are used to determine the vertical and horizontal positioning of a child object relative 
  to its parent. Since the size of some layout objects may change when the report runs (and data is actually fetched),
  you need anchors to define where you want objects to appear relative to one another.


11. What is the difference between Frame and Repeating Frame?
    Frames are used to surround other objects and protect them from being overwritten or pushed by other objects. 
    For example a frame might be used to surround all objects owned by a group to surround column headings or to surround summaries.

12. When you default the layout for a report Report Builder creates frames around report objects as needed; 
 you can also create a frame manually in the Layout Model view.

Repeating frames surround all of the fields that are created for a group’s columns. The repeating frame prints (is fired) once for each record of the group.
When you default the layout for a report Report Builder creates repeating frames around fields as needed; you can also create a repeating frame manually in the Layout Model view


13. What are different types of column in Oracle reports?
    There are three types of columns in the Oracle report these are:
    Formula columns: For doing mathematical calculations and returning one value

    Summary Columns: For doing summary calculations such as summations etc.

    Place holder Columns: These columns are useful for storing the value in a variable


14. What is the difference between Master - Detail Report and report created by breaks ?
    Master/detail data models are very similar to break report data models. However, a master/detail data model 
   is created using two queries, each of which owns at least one group, and a data link. A break report data model 
   is created using one query and at least two groups. While reports based on a single query are usually more efficient 
   than reports based on multiple queries, sometimes the structure of your data tables may require you to link multiple tables.



15. What are the various types of anchors in Reports ?
A There are two types of anchors in Oracle Reports:
* implicit (anchors that Oracle Reports creates when a report is run)
* explicit (anchors you create)

Implicit Anchors : At runtime, Oracle Reports generates an implicit anchor for each layout object that does not already have an explicit anchor. It determines for each layout object which objects, if any, can overwrite it, then creates an anchor from the layout object to the closest object that can overwrite it. This prevents the object from being overwritten. The implicit anchor functionality saves you from having to define the positioning of each object. Implicit anchors are not visible in the Layout editor. However, you can specify that the Object Navigator display anchoring information using the Object Navigator Options dialog.

Explicit Anchors : Create an anchor in the Layout editor by clicking on the Anchor tool, dragging from one edge of the child to the one of the parent's edges, then specifying the anchor's properties in its property sheet. Any anchor you create for an object will override its implicit anchoring. Explicit anchors are always visible in the Layout editor unless you specify otherwise via the Layout Options dialog

16. What are Placeholder Columns ?
 A placeholder is a "dummy" column for which you can conditionally set the datatype and value via PL/SQL or a user exit. Placeholder columns are useful when you want to selectively populate a column with a value (e.g., each time the nth record is fetched, or each time a record is fetched containing a specific value, etc.).

17. What are the various Module Types in Reports ?
A You can build three types of modules with Oracle Reports:
* external queries, which are ANSI-standard SQL SELECT statements that can be referenced by modules
* external PL/SQL libraries, which are collections of PL/SQL source code that can be referenced by modules
* reports, which are collections of report-level objects and references to external queries and PL/SQL libraries (optional) that can be referenced by modules

18. What are Physical and Logical pages in Reports ?
    A report page can have any length and any width. Because printer pages may be smaller or larger 
    than your report's "page," the concept of physical and logical pages is used.

    Physical Page : A physical page (or panel) is the size of a page that will be output by your printer.

   Logical Page : A logical page is the size of one page of your actual report; one logical page may be made 
                  up of multiple physical pages. The Previewer displays the logical pages of your report output, one at a time.

19. What are the various page layout sections in Oracle Reports ?
    A report has three sections : the report header pages, report body/margin pages, and report trailer pages.


20. What are various types of parameters ?
    A There are two types of parameters:
          default (called system parameters)
        user-created (called bind and lexical parameters)


21. Types of Matrix report ?
      1. Single query 2. Multi query 3. Nested Query 4. Matrix Break

22. Can you create a group without any break columns ?
     No.

23. How do you display a message in reports ?
    SRW.Message

24. What are the various values of the 'Print Direction' Property of Repeating frames ?
 The various values are :
    Across : Across means that each instance of the repeating frame subsequent to the first instance is 
    printed to the right of the previous instance across the logical page.

    Across/Down : Across/Down means that each instance of the repeating frame subsequent to the first 
    instance is printed to the right of the previous instance until an entire instance cannot fit between 
    the previous instance and the right margin of the logical page. At that time, Oracle Reports prints 
    the instance below the left-most instance on the logical page, provided there is enough vertical space 
    left on the logical page for the instance to print completely.

    Down : Down means that each instance of the repeating frame subsequent to the first instance is printed below the previous instance down the logical page.

    Down/Across : Down/Across means that each instance of the repeating frame subsequent to the first instance is printed below the previous instance until an entire instance cannot fit inside the bottom margin of the logical page. At that time, Oracle Reports prints the instance to the right of the topmost instance on the logical page, provided there is enough horizontal space left on the logical page for the instance to print completely.

25. What is the 'Print Direction' Property of Repeating frames ?
     'Print Direction' Property specifies the direction in which successive instances of the repeating frame appear.

Wednesday, 24 September 2014

Interview Questions

Oracle Apps 11i Interview Questions:

1. Why do we call FND SRWINIT from before Report Trigger
A. FND SRWINIT fetches concurrent request information and sets up the profile options. It must be included if one is using any ORACLE APPLICATION OBJECT LIBRARY features in his report (such as concurrent processing)
2. Why do we call FND SRWEXIT from after Report Trigger
A. FND SRWEXIT frees all the memory allocations done in other Oracle Applications user exits. It must be included if one is using any ORACLE APPLICATION OBJECT LIBRARY features in his report (such as concurrent processing)
3. Why do we call FND FLEXSQL from the Before Report Trigger?
A. One need to pass the concatenated segment values from the underlying code combinations table to the user exit so that it can display appropriate data and derive any description and values from switched value sets as needed. One gets this information by calling the AOL user exit FND FLEXSQL from the before report Trigger.
4. If u call the user exit FND FLEXSQL with MODE = “WHERE” from the Before Report Trigger. What will it do?
A. This user exit populates a lexical parameter that you specify with the appropriate SQL fragment at run time. You include this lexical parameter in the WHERE clause of the report query. This user exit is called once for each lexical to be changed.
5. If u call the user exit FND FLEXSQL with MODE = “ORDER BY” from the Before Report Trigger. What will it do?
A. This user Exit populates the lexical parameter that one specifies with the appropriate SQL fragment at run time. One includes this lexical parameter in the ORDER BY clause of the report query. This user exit is called once for each lexical to be changed.
6. How can we display flex field segment values, descriptions, and prompts on the report?
A. Create a formula Column. Call the user exit FND FLEXIDVAL as the formula for this column. This user exit automatically fetches more complicated information such as descriptions and prompts so that one does not has to use complicated table joins to the flex field tables.
7. Name some options of the FND FLEXSQL user exit
A CODE, APP_SHORT_NAME, OUTPUT, MODE, DISPLAY, SHOWDEPSEG, NUM or MULTINUM, TABLEALIAS, OPERATOR, OPERAND1, OPERAND2.
8. Describe CODE option of the FND FLEXSQL user exit
A. Specify the flex field code for the report (for example, GL#, MCAT).
9. Describe the APP_SHORT_NAME option of the FND FLEXSQL user exit
A. Specifies the short name of the application that owns the flex field (for example: SQLGL, INV)
10. Describe the OUTPUT option of the FND FLEXSQL user exit
A. Specify the name of the lexical parameter to store the SQL fragment. One uses this lexical later in the report when defining the SQL statement that selects the flex field values. the data type of this parameter should be character.
11. Describe the MODE option of the FND FLEXSQL user exit
A. Specify the mode to use to generate the SQL fragment. Valid modes are :
SELECT: Retrieves all segments values in an internal (non- displayable format).
WHERE: Restrict the query by specifying constraints on flex field columns. The fragment returned includes the correct decode statement if one specifies MULTINUM. One must also specify an OPERATOR and OPERANDS.
HAVING: Same calling procedures and functionality as WHERE.
ORDER BY: Order required information by flexfield columns. The fragment Orders your flexfield columns and separates them with a comma. The fragment returned includes the correct decode statement, one specifies in MULTINUM.
12. Describe the DISPLAY option of the FND FLEXSQL user exit
A. One uses the DISPLAY token with the MODE token. The DISPLAY parameter allows you to specify segments that represent specified flexfield qualifiers or specified segments numbers, where the segment numbers are the order in that the segments appear in the flexfield window, not the segment number specified in the Define Key Segments form.
Eg. If your MODE is SELECT and you specify DISPLAY = “ALL” then the SELECT statement includes all the segments of the flexfield. . Similarly, if your MODE is WHERE and you specify DISPLAY = “ALL”, then your WHERE clause includes all segments.
13. Describe the SHOWDEPSEG option of the FND FLEXSQL user exit
A. SHOWDEPSEG = “N” disables automatic addition of depended upon segments to the order criteria. The default is “Y”. This token is valid only for MODE = “ODER BY” In FLEXSQL.
14. Describe the NUM option of the FND FLEXSQL user exit
A. Specify the name or lexical or source column that contains the flexfield structure information. If the flexfield uses just one structure, specify NUM only and use a lexical parameter to hold the value. If the flexfield uses multiple structures, specify MULTINUM only and use a source column to hold the value. The default value is 101.
15. Describe the TABLE ALIAS option of the FND FLEXSQL user exit
A. You use TABLE ALIAS if your SELECT joins to other flexfield tables or uses a self – join.
16. Describe the OPERATOR option of the FND FLEXSQL user exit
A. Specify an operator to use in the WHERE clause.
17. Describe the OPERAND1 option of the FND FLEXSQL user exit
A. Specify an operand to use in the WHERE clause,
18. Describe the OPERAND2 option of the FND FLEXSQL user exit
A. Specify a second operand to use with OPERATOR = “BETWEEN”
19. Where is FND FLEXIDVAL user exit used
A. Call this user exit to populate fields for display. You pass the key flex fields data retrieved by the query into this user exit from the formula column. With this exit you can display values, descriptions and prompts by passing appropriate token (any one of VALUE, DECRIPTION
20. Name the interface tables used for the customer interface?
A. 1. RA_CUSTOMERS_INTERFACE_ALL
2. RA_CUSTOMER_BANKS_INT_ALL
3. RA_CUST_PAY_METHOD_INT_ALL
4. RA_CUSTOMER_PROFILES_INT_ALL
5. RA_CONTACT_PHONES_INT_ALL
21. What is the name of the column in CUSTOMER_INTERFACE_TABLE that indicates whether you are inserting new or updating existing information?
A: When importing data into the interface tables, the column INSERT_UPDATE_FLAG indicates whether you are inserting new or updating existing information. This column is required in RA_CUSTOMERS_INTERFACE.
22. If the INSERT_UPDATE_FLAG is not set correctly or the required column is missing the value, will CUSTOMER INTERFACE reject the entire record or just the attributes u want to update?
A Reject the entire record.
23. List some of the required columns for the RA_CUSTOMERS_INTERFACE?
A. ORIG_SYSTEM_CUSTOMER_REF
INSERT_UPDATE_FLAG
CUSTOMER_NAME
CUSTOMER_NUMBER (if you are not using Automatic Customer Numbering)
CUSTOMER_STATUS
LAST_UPDATED_BY
LAST_UPDATE_DATE
CREATED_BY
CREATION_DATE
If you are importing an address and a business purpose, you must also populate the following columns:
PRIMARY_SITE_USE_FLAG (if you are inserting an address)
LOCATION (if you are not using Automatic Site Numbering)
SITE_USE_CODE (if you are inserting an address)
ADDRESS1
24. List some of the production tables that Customer Interface transfers customer data from the interface tables into?
A. AR_CUSTOMER_PROFILES
AR_CUSTOMER_PROFILE_AMOUNTS
RA_ADDRESSES
RA_CONTACTS
RA_CUSTOMERS
RA_CUSTOMER_RELATIONSHIPS
RA_CUST_RECEIPT_METHODS
RA_PHONES
RA_SITE_USES
AP_BANK_ACCOUNT_USES
AP_BANK_ACCOUNTS
AP_BANK_BRANCHES
25. What validation must be given on the customer_number?
A Must be null if you are using Automatic Customer Numbering. Must exist if you are not using Automatic Customer Numbering. This value must be unique within RA_CUSTOMERS.
26. What validation must be given on the CUSTOMER_STATUS?
A Must equal ’A’ for Active or ’I’ for Inactive.
27. Name some of the Oracle receivables Interfaces?
a) Auto Invoice
b) Auto Lockbox
c) Customer Interface
d) Sales Tax rate Interface
e) Tax Vendor Extension
28. Give some of the Oracle Payables interface?A. a) Credit Card Transaction Interface
b) Invoice Import Interface
c) Payables Open Interface
d) Purchase Order Matching
29. Name some of the oracle general ledger Interface?
A Budget Upload
b) Importing Journals
c) Loading Daily rates
30. What are the names of the parameters u pass to the Procedure which u register in the apps?A. 1) retcode in varchar2
2) errbuf in varchar2
31. What is the use of Auto lock Box?
A Auto Lockbox (or Lockbox) is a service that commercial banks offer corporate customers to enable them to outsource their accounts receivable payment processing.
32. Auto Lockbox is a three-step process, what are those?
A. a) Import
b) Validation
c) PostQuickCash
33. What is the order in which Autolock box searches for the types of the matching number?
A. 1. Transaction Number
2. Sales Order Number
3. Purchase Order Number
4. Consolidated Billing Invoice Number
5. Other, user-defined number.
34. What is application short name for General Ledger you specify in FND FLEXSQL user exit?
A. SQLGL
35 . What are validations to be done in Journal Import interface.
A. Batch level: Set of Books, Period Name, and Batch Name
Journal Level: Set of books, Period name, Source name, Journal entry name, Currency code, Category name, Actual flag, Encumbrance type ID, User conversion type, Accounting date, Budget version ID
36. What subclass in forms6i
A Specifies module, storage & name information about the source object and source module for a referenced objects.
37. What is the clause in SQL * Loader to program to override data into table
A. REPLACE
38. How do you set profile in oracle applications In Application Developer responsibility?
A Open ‘Profile’ Function
39. What is the syntax for loading data through SQL * Loader from multiple files simultaneously
A. Sqlldr scott/tiger@orcl <mailto:scott/tiger@orcl> control = ctlfile
parfile — parameter file: name of file that contains parameter specifications
parallel — do parallel load (Default FALSE)
40. What is the table name for items in Oracle Inventory
A MTL_SYSTEM_ITEMS, MTL_CATEGORIES
41. Tell me names of important production tables & their purpose AP, AR, GL, PO
A AP: AP_INVOICES_ALL, AP_INVOICE_LINES_ALL
To store invoices
AR: RA_SHIPMENT_HEADERS/ _LINES, RA_CUSTOMERS, RA_CONTACTS
PO: PO_VENDORS, PO_VENDOR_SITES – For storing vendor data.
42. Name the interface tables used for the Lockbox Interface
A Interface table : AR_PAYMENTS_INTERFACE_ALL
Lockbox transfers the receipts that pass validation to the Receivables interim tables AR_INTERIM_CASH_RECEIPTS_ALL and AR_INTERIM_CASH_RCPT_LINES_ALL
When you run Post QuickCash, the receipt data is transferred from the QuickCash tables to the following Receipt tables:
AR_CASH_RECEIPTS_ALL
AR_RECEIVABLES_APPLICATIONS_ALL
AR_CASH_RECEIPT_HISTORY_ALL

43. Name the interface tables used for the AutoInvoice Interface.
A AutoInvoice transfers transaction data from the interface tables
RA_INTERFACE_LINES_ALL,
RA_INTERFACE_SALESCREDITS_ALL, and
RA_INTERFACE_DISTRIBUTIONS_ALL
into the following Receivables tables:
• RA_BATCHES_ALL
• RA_CUSTOMER_TRX _ALL
• RA_CUSTOMER_TRX_LINES _ALL
• RA_CUST_TRX_LINE_GL_DIST_ALL
• RA_CUST_TRX_LINE_SALESREPS_ALL
• AR_PAYMENT_SCHEDULES_ALL
• AR_RECEIVABLE_APPLICATIONS_ALL
• AR_ADJUSTMENTS_ALL

Saturday, 20 September 2014

OM Queries

Useful Order Management Queries


1) To know the details of the Order Header.
--------------------------------------------------------------

SELECT * from oe_order_headers_all WHERE ORDER_NUMBER = ;

2) To know the line details of the Order lines:-
----------------------------------------------------------------

SELECT * FROM OE_ORDER_LINES_ALL WHERE HEADER_ID =

3) To know the reason of cancellation.
-------------------------------------------------------

SELECT reason_code
         FROM   oe_order_lines_history
         WHERE  line_id =
         AND    hist_type_code = 'CANCELLATION';

SELECT attribute1  pos_reason_code
        FROM FND_LOOKUP_VALUES
        WHERE lookup_type = p_lookup_type
        AND LANGUAGE = 'US'
        AND LOOKUP_CODE = ;
        
4) if some discount or adjustment is done for the item in the order line then we can know the original price and selling price.
   ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        
SELECT SUM(DECODE(line_id, , unit_selling_price,
                   DECODE(return_attribute5, , - unit_selling_price, 0))) unit_selling_price,
                SUM(DECODE(line_id, , unit_list_price, 0)) unit_list_price
         FROM   oe_order_lines_all
         WHERE  header_id =
         AND    Nvl(cancelled_flag, 'N') = 'N'
         AND    booked_flag = 'Y'
         AND    attribute7 IS Not Null;

5) To know the number of the days from the cash receipt day for any particular line.
-----------------------------------------------------------------------------------------------------------------------

SELECT floor(sysdate-to_date(To_Char(ar.receipt_date, 'dd-mon-yyyy'))) date_difference
         FROM oe_order_lines_all ol,
              ar_cash_receipts_all ar
         WHERE ol.header_id =
         AND   ol.line_id=
         AND   ol.attribute7=ar.cash_receipt_id
         AND   ar.attribute1=;

6) To know the receipt ID from the based on the header_id (HBC Specfic).
  --------------------------------------------------------------------------------------------------------

select distinct attribute1 from oe_price_adjustments where HEADER_ID =

7) To know the Location exist or not.
------------------------------------------------------

SELECT 1 FROM hr_organization_units_v
     WHERE  location_code = Trim();

8) Deposit_payment_made
  -------------------------------------
The following query is useful to know whether Deposit is made or not.
-----------------------------------------------------------------------------------------------------

SELECT 1 FROM ar_cash_receipts_all r, ar_receipt_methods m
     WHERE  r.attribute1=to_char('')
    AND r.receipt_method_id=m.receipt_method_id
    AND m.name='POS_DEPOSIT';

8.1) Deposit Payment and Order status and Header ID. (HBC Specfic).
-----------------------------------------------------------------------------------------------------

     SELECT header_id "Header ID",
             flow_status_code "Status",
             attribute3 "deposit_amount"
      FROM   oe_order_headers_all
      WHERE  order_number = 1029243
      AND    flow_status_code in ('BOOKED', 'CANCELLED');

8.2) Getting the Line information of the order.
  ---------------------------------------------------------------

SELECT line_id,
LINE_NUMBER,
             Nvl(cancelled_flag, 'N') cancelled_flag,
             open_flag,
             attribute7 receipt_id,
             line_category_code,
             global_attribute10,
             Nvl(attribute10, 'Y') pos_elig_flag,
            return_attribute5 closed_line_adjustment
      FROM   oe_order_lines_all
WHERE  header_id = ;    

8.3) If the Deposit Money is refunded, that can be found from the following query:-
-------------------------------------------------------------------------------------------------------------------

 SELECT 'Y'
      FROM   oe_order_headers_all oeoh
      WHERE  oeoh.header_id =
      AND    oeoh.flow_status_code = 'CANCELLED'
      AND    oeoh.attribute3 IS Not Null
      AND    oeoh.attribute5 IS NOT Null
      AND    oeoh.global_attribute20 IS Null
      AND    NOT EXISTS
             (SELECT 1
              FROM   oe_order_lines_all oeol
              WHERE  oeol.header_id = oeoh.header_id
              AND    oeol.attribute7 IS NOT Null
              AND    oeol.booked_flag = 'Y');

9) pos_payment_made
  ----------------------------------
The following query is useful to know whether payment is made or not.
-----------------------------------------------------------------------------------------------------

SELECT 1 FROM ar_cash_receipts_all r, ar_receipt_methods m
     WHERE  r.attribute1=to_char(p_order_number)
    AND r.receipt_method_id=m.receipt_method_id
    AND m.name='POS_PAYMENT';

10) Adjustment Amount for this order:-
   ---------------------------------------------------

  SELECT SUM(oepj.adjusted_amount)
      FROM   oe_order_lines_all oeol, oe_price_adjustments oepj
      WHERE  oeol.line_id = oepj.line_id
      AND    oeol.attribute7 IS NOT Null
      AND    Nvl(oeol.cancelled_flag, 'N') = 'N'
      AND    oeol.return_attribute5 IS Null
      AND    oeol.open_flag = 'Y'
      AND    Nvl(Upper(oeol.attribute10), 'Y') = 'Y'
      AND    oeol.booked_flag = 'Y'
      AND    oepj.attribute1 IS Null
      AND    oeol.header_id =

11) find out unprocessed lines in ORDER LINES table:-
    ---------------------------------------------------------------------------

SELECT NVL(SUM(DECODE(line_category_code,'RETURN',1,0)),0),
                       NVL(SUM(DECODE(line_category_code,'ORDER',1,0)),0)
            FROM OE_ORDER_LINES_ALL oola
      WHERE header_id=
               AND oola.BOOKED_FLAG = 'Y'
               AND oola.OPEN_FLAG = 'Y'
               AND oola.ATTRIBUTE7 IS NULL
               AND oola.CANCELLED_FLAG = 'N'
AND Nvl(Upper(oola.attribute10), 'Y') = 'Y';

12) Findout unhandled_cancels_exists or not:-
     -------------------------------------------------------------

 SELECT 1
           FROM oe_order_lines_all l, oe_order_headers_all h
           WHERE h.header_id = l.header_id
           AND l.line_id =
           AND l.attribute7 IS NOT NULL  --previously processed
           AND l.cancelled_flag='Y'      --now cancelled.
           AND h.order_number=
           AND NOT EXISTS (
             SELECT 1 FROM xxcofipos_posting_ol_history p
             WHERE p.order_line_id=l.line_id
             AND p.order_line_table_source = 'OL_CANCEL');

13) Findout the region short name with the location code:-
     ------------------------------------------------------------------------------

SELECT  region_1
             FROM hr_organization_units_v hv
             WHERE  hv.location_code = ''; --Store Number

14) For initial determination of whether it is a "NEW" or a "NON-NEW" transaction type
     -----------------------------------------------------------------------------------------------------------------------

          SELECT COUNT(*),
              SUM(DECODE(NVL(attribute7,'xx'),'xx',0,1)) --if null then do not count : old : --SUM(DECODE(attribute7,'Y',1,0))
       --   INTO l_total_lines_count, l_processed_lines_count
          FROM OE_ORDER_LINES_ALL
          WHERE header_id=;

15) find out line_category_codes for unprocessed lines in ORDER LINES table:-
     ------------------------------------------------------------------------------------------------------------

         SELECT NVL(SUM(DECODE(line_category_code,'RETURN',1,0)),0),
                       NVL(SUM(DECODE(line_category_code,'ORDER',1,0)),0)
      --   INTO l_return_count, l_sale_count
         FROM OE_ORDER_LINES_ALL oola
         WHERE header_id=
         AND oola.BOOKED_FLAG = 'Y'
         AND oola.OPEN_FLAG = 'Y'
         AND oola.ATTRIBUTE7 IS NULL
         AND oola.CANCELLED_FLAG = 'N';

16) To know all sales rep name and other information:-
      ----------------------------------------------------------------------

SELECT  jr.name,SALESREP_NUMBER,/* pf.attribute1 */, pf.EMAIL_ADDRESS , pf.PERSON_ID, pf.sex--nvl(pf.attribute1,'') --salesrep_number
         FROM   jtf_rs_salesreps  jr,
                per_all_people_f pf
         WHERE -- salesrep_id = c_salesrep_id  AND
             pf.person_id = jr.person_id
         AND    Nvl(status, 'A') = 'A'
         AND    Sysdate BETWEEN start_date_active AND Nvl(end_date_active, Sysdate + 1);

To Find Duplicate Item Category Code
SELECT category_set_name, category_concat_segments, COUNT (*)
FROM mtl_category_set_valid_cats_v
WHERE (category_set_id = 1)
GROUP BY category_set_name, category_concat_segments
HAVING COUNT (*) > 1
ORDER BY category_concat_segments
Get Number Of canceled requisition
SELECT a.AUTHORIZATION_STATUS,(a.ORG_ID),(SELECT distinct hr.per_all_people_f.first_name|| ‘ ‘|| hr.per_all_people_f.middle_names|| ‘ ‘|| hr.per_all_people_f.last_name “Employee Name”
FROM hr.per_all_people_f
where hr.per_all_people_f.PERSON_ID in
(select employee_id from fnd_user fu where fu.user_id = a.CREATED_BY)) CREATED_BY,count(SEGMENT1 )
FROM
po_requisition_headers_all a
WHERE
a.creation_date BETWEEN TO_DATE(’01/01/2007′, ‘DD/MM/YYYY’)
and TO_DATE(’30/05/2007′, ‘DD/MM/YYYY’)
and a.AUTHORIZATION_STATUS = ‘CANCELLED’
group by a.AUTHORIZATION_STATUS,a.ORG_ID,a.CREATED_BY
Number of line processed in Order Management
SELECT COUNT (line_id) “Order Line Processed”
FROM oe_order_lines_all
WHERE creation_date BETWEEN TO_DATE (:Fdate, ‘DD/MM/YYYY’)
AND TO_DATE (:tdate, ‘DD/MM/YYYY’)
AND flow_status_code = ‘CLOSED’;
To Check Item Catogry For Inventory master (No Of Segments May Varry)
SELECT ood.organization_name,
segment1|| ‘-’|| segment2|| ‘-’|| segment3 catgory
FROM org_organization_definitions ood,
mtl_categories_vl mcv,
mtl_category_sets mcs
WHERE mcs.structure_id = mcv.structure_id
ORDER BY ood.organization_name
Check Locators for inventory Inventory Org Wise(Number of segment may varry)
SELECT mil.segment1 loc_seg1, mil.segment11 loc_seg11, mil.segment2 loc_seg2,
mil.segment3 loc_seg3, mil.segment4 loc_seg4, mil.segment5 loc_seg5,
mil.segment6 loc_seg6,ood.ORGANIZATION_NAME,mil.SUBINVENTORY_CODE
FROM mtl_item_locations mil,org_organization_definitions ood
where mil.ORGANIZATION_ID = ood.ORGANIZATION_ID
Display All Subinventories Setup
select msi.secondary_inventory_name, MSI.SECONDARY_INVENTORY_NAME “Subinventory”, MSI.DESCRIPTION “Description”,
MSI.DISABLE_DATE “Disable Date”, msi.PICKING_ORDER “Picking Order”,
gcc1.concatenated_segments “Material Account”,
gcc2.concatenated_segments “Material Overhead Account”,
gcc3.concatenated_segments “Resource Account”,
gcc4.concatenated_segments “Overhead Account”,
gcc5.concatenated_segments “Outside Processing Account”,
gcc6.concatenated_segments “Expense Account”,
gcc7.concatenated_segments “Encumbrance Account”,
msi.material_overhead_account,
msi.resource_account,
msi.overhead_account,
msi.outside_processing_account,
msi.expense_account,
msi.encumbrance_account
from mtl_secondary_inventories msi,
gl_code_combinations_kfv gcc1,
gl_code_combinations_kfv gcc2,
gl_code_combinations_kfv gcc3,
gl_code_combinations_kfv gcc4,
gl_code_combinations_kfv gcc5,
gl_code_combinations_kfv gcc6,
gl_code_combinations_kfv gcc7
where msi.material_account = gcc1.CODE_COMBINATION_ID(+)
and msi.material_overhead_account = gcc2.CODE_COMBINATION_ID(+)
and msi.resource_account = gcc3.CODE_COMBINATION_ID(+)
and msi.overhead_account = gcc4.CODE_COMBINATION_ID(+)
and msi.outside_processing_account = gcc5.CODE_COMBINATION_ID(+)
and msi.expense_account = gcc6.CODE_COMBINATION_ID(+)
and msi.encumbrance_account = gcc7.CODE_COMBINATION_ID(+)
order by msi.secondary_inventory_name
To Select Unit Of measure exist in ebusiness suite
select uom_code,unit_of_measure
from mtl_units_of_measure
Query to find out Customer Master Information. Customer Name, Account Number, Adress etc.
select p.PARTY_NAME,ca.ACCOUNT_NUMBER,loc.address1,loc.address2,loc.address3,loc.city,loc.postal_code,
loc.country,ca.CUST_ACCOUNT_ID
from apps.ra_customer_trx_all I,
apps.hz_cust_accounts CA,
apps.hz_parties P,
apps.hz_locations Loc,
apps.hz_cust_site_uses_all CSU,
apps.hz_cust_acct_sites_all CAS,
apps.hz_party_sites PS
where I.COMPLETE_FLAG =’Y’
and I.bill_TO_CUSTOMER_ID= CA.CUST_ACCOUNT_ID
and ca.PARTY_ID=p.PARTY_ID
and I.bill_to_site_use_id=csu.site_use_id
and csu.CUST_ACCT_SITE_ID=cas.CUST_ACCT_SITE_ID
and cas.PARTY_SITE_ID=ps.party_site_id
and ps.location_id=loc.LOCATION_ID
Query to find on Hand Quantity
select sum(transaction_quantity) from MTL_ONHAND_QUANTITIES
where inventory_item_id=9
and organization_id=188
Qunatity on order, Expected Deliver
select sum(ordered_quantity),a.SCHEDULE_SHIP_DATE
from oe_order_lines_all a
where inventory_item_id=10
and ship_from_org_id=188
group by a.SCHEDULE_SHIP_DATE
Query to find Item Code, Item Description Oracle Item Master Query
select item, description from mtl_system_items_b
where inventory_item_id=&your_item
and organization_id=&organization_id) item
Query to Find out On Hand Quantity of specific Item Oracle inventory
select sum(transaction_quantity) from mtl_onhand_quantity_details
where inventory_item_id=&your_item
and organization_id=&organization_id
Qty On Order,
Expected deivery date(select sum(ordered_quantity),
scheduled_ship_date from oe_order_lines_all
where inventory_item_id=&your_item
and ship_from_org_id=&organization_id
group by scheduled_ship_date) order_info
–Total Received Qty
select sum(transaction_quantity) from mtl_material_transactions
inventory_item_id=&your_item
and organization_id=&organization_id
and transaction_quantity>0)
Total received Qty in 9 months
select sum(transaction_quantity) from mtl_material_transactions
inventory_item_id=&your_item
and organization_id=&organization_id
and transaction_quantity>0
and transaction_date between trunc(sysdate) and trunc(sysdate-270))
Total issued quantity in 9 months
select sum(transaction_quantity) from mtl_material_transactions
inventory_item_id=&your_item
and organization_id=&organization_id
and transaction_quantity<0 and transaction_date between trunc(sysdate) and trunc(sysdate-270)) tot_iss_qty_9mths, –Average monthly consumption
(select sum(transaction_quantity)/30 from mtl_material_transactions
inventory_item_id=&your_item
and organization_id=&organization_id
and transaction_quantity<0) ;
Display all categories that the Item Belongs
SELECTunique micv.CATEGORY_SET_NAME “Category Set”,
micv.CATEGORY_SET_ID “Category Set ID”,
decode( micv.CONTROL_LEVEL,
1, ‘Master’,
2, ‘Org’,
‘Other’) “Control Level”,
micv.CATEGORY_ID “Category ID”,
micv.CATEGORY_CONCAT_SEGS “Category”
FROM
MTL_ITEM_CATEGORIES_V micv
Another Query to Get Onhand Qty With Oranization ID, Item Code, Quantity
SELECT organization_id,
(SELECT ( msib.segment1|| ‘-’|| msib.segment2|| ‘-’|| msib.segment3|| ‘-’|| msib.segment4)
FROM mtl_system_items_b msib
WHERE msib.inventory_item_id = moq.inventory_item_id
AND msib.organization_id = moq.organization_id) “Item Code”,
(SELECT description
FROM mtl_system_items_b msib
WHERE msib.inventory_item_id =
moq.inventory_item_id
AND msib.organization_id = moq.organization_id)
“item Description”,
SUM (moq.transaction_quantity) onhandqty
FROM mtl_onhand_quantities moq
GROUP BY moq.organization_id, (moq.inventory_item_id)
SO AND CUSTOMER AND RECEIPTS RELATED QUERIES
--- find OUT the customer, line item, ordered qty AND price info OF the ORDER :
SELECT h.order_number, org.NAME customer_name, h.ordered_date order_date,
ot.NAME order_type, s.NAME sales_rep, l.line_id, l.line_number,
l.inventory_item_id, si.segment1, l.ordered_quantity,
l.unit_selling_price,
NVL (l.ordered_quantity, 0) * NVL (l.unit_selling_price, 0) amount,
h.transactional_curr_code currency_code
FROM ra_salesreps s,
oe_transaction_types_tl ot,
oe_sold_to_orgs_v org,
mtl_system_items_vl si,
oe_order_lines_all l,
oe_order_headers_all h
WHERE h.order_number = 14463
AND h.org_id = 204
AND l.header_id = h.header_id
AND h.sold_to_org_id = org.organization_id
AND (h.cancelled_flag IS NULL OR h.cancelled_flag = 'N')
AND h.open_flag = 'Y'
AND l.open_flag = 'Y'
AND l.service_reference_line_id IS NULL
AND l.inventory_item_id = si.inventory_item_id
AND NVL (si.organization_id, 0) = 204 --Item master orgn
AND h.order_type_id = ot.transaction_type_id
AND h.salesrep_id = s.salesrep_id
AND h.org_id = s.org_id
ORDER BY l.line_id
/
--find customer, ship TO AND bill TO information OF an ORDER :
SELECT h.order_number, c.NAME customer_name, lk1.meaning freight_terms,
lk2.meaning fob, s.location_code ship_location_code,
s.address_line_1 ship_address1, s.address_line_2 ship_address2,
s.state ship_state, s.postal_code ship_zip, s.country ship_country,
b.location_code bill_location_code, b.address_line_1 bill_address1,
b.address_line_2 bill_address2, b.country bill_country
FROM ar_lookups lk2,
oe_lookups lk1,
oe_sold_to_orgs_v c,
oe_invoice_to_orgs_v b,
oe_ship_to_orgs_v s,
oe_order_headers_all h
WHERE h.order_number = '123'
AND h.org_id = '204'
AND h.ship_to_org_id = s.organization_id
AND h.invoice_to_org_id = b.organization_id
AND h.sold_to_org_id = c.organization_id
AND h.freight_terms_code = lk1.lookup_code(+)
AND lk1.lookup_type(+) = 'FREIGHT_TERMS'
AND lk2.lookup_code(+) = h.fob_point_code
AND lk2.lookup_type(+) = 'FOB'
/
-- find OUT ORDER AND line hold information :
SELECT ho.NAME hold_name, hs.hold_until_date, hs.hold_comment,
h.order_number, oh.header_id, oh.line_id, oh.order_hold_id,
l.item_identifier_type, l.inventory_item_id, l.ordered_item
FROM oe_order_holds_all oh,
oe_order_lines_all l,
oe_order_headers_all h,
oe_hold_definitions ho,
oe_hold_sources_all hs
WHERE h.order_number = '1234'
AND oh.header_id = h.header_id
AND (h.cancelled_flag IS NULL OR h.cancelled_flag = 'N')
AND h.open_flag = 'Y'
AND oh.hold_source_id = hs.hold_source_id
AND hs.hold_id = ho.hold_id
AND h.header_id = l.header_id(+)
AND l.open_flag = 'Y'
AND l.line_id = NVL (oh.line_id, l.line_id)
AND l.service_reference_line_id IS NULL
AND oh.hold_release_id IS NULL
AND NVL (h.org_id, 0) = '204'
AND NVL (l.org_id, 0) = NVL (h.org_id, 0)
ORDER BY ho.NAME, h.order_number
/
---find freight related info OF ORDER viz: freight carrier, ship method AND service LEVEL :
SELECT h.order_number, h.shipping_method_code, wc.carrier_name,
wcsm.service_level, wcsm.freight_code
FROM wsh_carrier_ship_methods_v wcsm,
wsh_carriers_v wc,
oe_order_headers_all h
WHERE h.order_number = 14463
AND h.org_id = 204
AND h.shipping_method_code = wcsm.ship_method_code(+)
AND NVL (wcsm.organization_id(+), 0) = 204 --Master Organization
AND wcsm.freight_code = wc.freight_code(+)
ORDER BY h.order_number
/
--find price discounts AND surcharges ON ORDER lines :
SELECT h.order_number, l.line_number, pa.list_line_type_code,
pa.arithmetic_operator, pa.operand,
DECODE (pa.modifier_level_code,
'ORDER', l.unit_list_price
* l.ordered_quantity
* pa.operand
* SIGN (pa.adjusted_amount)
/ 100,
(pa.adjusted_amount * NVL (l.ordered_quantity, 0))
) discount_amt
FROM qp_list_headers_vl lh,
oe_price_adjustments pa,
oe_order_lines_all l,
oe_order_headers_all h
WHERE h.order_number = '12345'
AND h.header_id = l.header_id
AND h.org_id = l.org_id
AND h.header_id = pa.header_id
AND l.line_id = pa.line_id(+)
AND pa.list_header_id = lh.list_header_id
AND ( pa.list_line_type_code = 'DIS'
OR pa.list_line_type_code = 'SUR'
OR pa.list_line_type_code = 'PBH'
)
AND pa.applied_flag = 'Y'
AND NOT EXISTS (
SELECT 'X'
FROM oe_price_adj_assocs pas, oe_price_adjustments pa1
WHERE pas.rltd_price_adj_id = pa.price_adjustment_id
AND pa1.price_adjustment_id = pas.price_adjustment_id
AND pa1.list_line_type_code = 'PBH')
ORDER BY l.line_id
/
a: Qp_list_headers_vl IS VIEW based ON qp_list_headers_b AND qp_list_headers_tl TABLES.
-- find freight charges ON ORDER lines :
SELECT header_id, line_id, charge_id, charge_name, charge_amount,
currency_code, invoiced_flag, interco_invoiced_flag, org_id,
source_system_code, estimated_flag, invoiced_amount
FROM oe_charge_lines_v
WHERE header_id = (SELECT header_id
FROM oe_order_headers_all
WHERE order_number = '12345')
ORDER BY line_id
/
a: The OE_CHARGE_LINES_V VIEW IS based ON oe_price_adjustments, oe_order_headers_all ANDoe_order_lines_all FOR FREIGHT CHARGES.
---SALES tax rate FOR State 'xx' :
SELECT DISTINCT lv.parent_segment_id, lc.location_id_segment_1,
location_segment_user_value, lr.from_postal_code,
lr.to_postal_code, location_segment_value, lr.tax_rate
FROM ar_location_rates lr,
ar_location_combinations lc,
ar_location_values lv
WHERE lv.location_segment_user_value = 'xx' --State name
AND lv.location_segment_id = lc.location_id_segment_1
AND lv.location_structure_id = lc.location_structure_id
AND lc.location_structure_id = '101'
AND lv.location_segment_id = lr.location_segment_id
ORDER BY 1
/
---TABLE ar_sales_tax contains location wise total tax- rates WITH tax break up ..
SELECT DISTINCT location_id, rate_context, tax_rate, location1_rate,
location2_rate, location3_rate, from_postal_code,
to_postal_code
FROM ar_sales_tax
WHERE location_id = 1000 AND enabled_flag = 'Y'
/
-- find OUT the shipper info :
/* Formatted on 2010/08/24 11:32 (Formatter Plus v4.8.0) */
SELECT wnd.delivery_id delivery_id, SUBSTRB (party.party_name, 1,
50) customer,
wpb.NAME batch_name,
wsh_util_core.get_location_description
(wnd.initial_pickup_location_id,
'NEW UI CODE'
) ship_from,
wsh_util_core.get_location_description
(wnd.ultimate_dropoff_location_id,
'NEW UI CODE'
) ship_to,
wnd.initial_pickup_date pickup_date,
wnd.ultimate_dropoff_date dropoff_date, lv.meaning ship_method,
wnd.waybill waybill, wnd.gross_weight gross_weight,
wnd.weight_uom_code uom, wnd.status_code, we.MESSAGE
FROM wsh_new_deliveries wnd,
wsh_picking_batches wpb,
wsh_exceptions we,
fnd_lookup_values_vl lv,
hz_cust_accounts cust_acct,
hz_parties party
WHERE wnd.delivery_id = '123'
AND wpb.batch_id = wnd.batch_id
AND we.delivery_id(+) = wnd.delivery_id
AND we.exception_name(+) = 'WSH_BATCH_MESSAGE'
AND lv.lookup_code(+) = wpb.ship_method_code
AND lv.lookup_type(+) = 'SHIP_METHOD'
AND lv.view_application_id(+) = '1'
AND cust_acct.cust_account_id(+) = wnd.customer_id
AND party.party_id(+) = cust_acct.party_id
/
-- find OUT shipper detail info :
SELECT wnd.delivery_id, wnd.NAME delivery_name,
wdd.source_header_number so_order_number,
oola.line_number so_line_number, wdd.source_header_id so_header_id,
wdd.source_line_id so_line_id, wdd.shipping_instructions,
wdd.inventory_item_id, wdd.requested_quantity_uom,
msi.description item_description, msi.revision_qty_control_code,
wdd.ship_method_code carrier, wdd.shipment_priority_code priority,
wdd.organization_id, wnd.initial_pickup_location_id,
wdd.released_status, wdd.source_code
FROM mtl_system_items_vl msi,
oe_order_lines_all oola,
wsh_delivery_details wdd,
wsh_delivery_assignments wda,
wsh_new_deliveries wnd
WHERE wnd.delivery_id = '123'
AND wda.delivery_id = wnd.delivery_id(+)
AND wdd.delivery_detail_id = wda.delivery_detail_id
AND wdd.inventory_item_id = msi.inventory_item_id(+)
AND wdd.organization_id = msi.organization_id(+)
AND wdd.source_line_id = oola.line_id
AND wdd.source_header_id = oola.header_id
/
---find OUT Move ORDER line details :
SELECT wnd.delivery_id, wnd.NAME delivery_name,
wnd.initial_pickup_location_id, mtrh.request_number mo_number,
mtrl.line_number mo_line_number, mtrl.line_id mo_line_id,
mtrl.from_subinventory_code, mtrl.to_subinventory_code,
mtrl.lot_number, mtrl.serial_number_start, mtrl.serial_number_end,
mtrl.uom_code, mtrl.quantity, mtrl.quantity_delivered,
mtrl.quantity_detailed, wdd.source_header_number so_order_number,
oola.line_number so_line_number, wdd.source_header_id so_header_id,
wdd.source_line_id so_line_id, wdd.shipping_instructions,
wdd.inventory_item_id, wdd.requested_quantity_uom,
msi.description item_description, msi.revision_qty_control_code,
wdd.ship_method_code carrier, wdd.shipment_priority_code priority,
wdd.organization_id, wdd.released_status, wdd.source_code
FROM mtl_system_items_vl msi,
oe_order_lines_all oola,
mtl_txn_request_lines mtrl,
mtl_txn_request_headers mtrh,
wsh_delivery_details wdd,
wsh_delivery_assignments wda,
wsh_new_deliveries wnd
WHERE wnd.delivery_id = '123'
AND wda.delivery_id = wnd.delivery_id(+)
AND wdd.delivery_detail_id = wda.delivery_detail_id
AND wdd.move_order_line_id = mtrl.line_id
AND mtrl.header_id = mtrh.header_id
AND wdd.inventory_item_id = msi.inventory_item_id(+)
AND wdd.organization_id = msi.organization_id(+)
AND wdd.source_line_id = oola.line_id
AND wdd.source_header_id = oola.header_id
/
--- find Bill OF Lading info OF the Delivery :
SELECT wnd.delivery_id delivery_id, wdi.sequence_number bol_number,
wdi.bol_notify_party, wdi.port_of_loading, wdi.port_of_discharge,
wnd.waybill waybill, wnd.gross_weight gross_weight,
wnd.weight_uom_code uom, wnd.status_code
FROM wsh_new_deliveries wnd,
wsh_delivery_legs wdl,
wsh_document_instances wdi
WHERE wnd.delivery_id = '123'
AND wnd.delivery_id = wdl.delivery_id(+)
AND wdi.entity_id(+) = wdl.delivery_leg_id
AND wdi.entity_name(+) = 'WSH_DELIVERY_LEGS'
AND wdi.document_type(+) = 'BOL'
AND wdi.status(+) <> 'CANCELLED'
/
--- find delivery leg AND pick up STOP info :
SELECT wt.trip_id, wt.NAME, wt.status_code, wt.vehicle_item_id,
wt.vehicle_number, wt.carrier_id, wt.ship_method_code, wts.stop_id,
wts.stop_location_id, wts.status_code, wts.stop_sequence_number,
wts.planned_arrival_date, wts.planned_departure_date,
wts.actual_arrival_date, wts.actual_departure_date,
wts.departure_net_weight, wts.weight_uom_code, wdl.delivery_leg_id,
wdl.delivery_id, wdl.pick_up_stop_id, wdl.drop_off_stop_id,
wdl.sequence_number, wdl.loading_order_flag, wdl.shipper_title,
wdl.shipper_phone
FROM wsh_trips wt, wsh_trip_stops wts, wsh_delivery_legs wdl
WHERE wdl.delivery_id = '123'
AND wts.stop_id = wdl.pick_up_stop_id
AND wts.trip_id = wt.trip_id;