R12 12.0.4 Onhand Quantity SQL required
Hi guys
We are a huge retailing company and currently in the process of implementing a custom made application for POS. One of our requirements is to reserve a given quantity against a particular item and once the PO received from the customer, raise a Credit invoice against customer account. Throughout last couple of years after the R12 implementation we kept on adding in-house built modules, mostly for tracking the on-hand quantities. We never used the material reservation until the custom application integration.
As we are planning to go live with the custom built application, we are in a requirement to alter our on-hand quantity scripts throughout the custom modules and reports. Right now we are using the following query to fetch the on-hand quantities:
Select onhand_quantity from
Select sum(onhand_qty) onhand_quantity, inventory_item_id, organization_id, subinventory_code from
Select sum(transaction_quantity) onhand_qty,inventory_item_id, organization_id, subinventory_code from mtl_onhand_quantities
group by organization_id, subinventory_code, inventory_item_id
union all
Select sum(reservation_quantity)*-1 onhand_qty,inventory_item_id, organization_id, subinventory_code from mtl_reservations
group by organization_id, subinventory_code, inventory_item_id
group by inventory_item_id, organization_id, subinventory_code
where inventory_item_id = :item_id and
organization_id = :org_id and
subinventory_code = :subinv_code
Should we consider anything else? We tried to use "apps.INV_QUANTITY_TREE_PUB.QUERY_QUANTITIES" API, unfortunately while compiling we got compilation errors. Please forward your suggestions
regards,
Thanks Sandeep
Unfortunately, we do use move orders quite frequent (OM team just confirmed) and there are just few entries in MTL_MATERIAL_TRANSACTION_TEMP table. A total of 6 records dating back to 2010.
Anyway we are going ahead with the current setup and will include this table if differences are found at later stages. Thank you very much for your replies.
Regards,
Similar Messages
-
Hi All,
Is there any API that I can use to update the onhand quantity of Inventory Item.
Thanks,
Priya.Priya,
We do (or I should say "Shoud") not update the onhand quantity after you book the order. You can create reservations though (standard functionality available). This way others will not be able to take the quantity that is reserved against this order. Onhand quantity is table is exclusively used by transaction manager to move the qty in and out.
If you tell us the functional requirements as why you are trying to do this, we can offer better advice.
Thanks
Nagamohan -
ONHAND QUANTITY SETUP을 확인하는 방법
제품: Applications
작성날짜 : 2006-05-30
ONHAND QUANTITY SETUP을 확인하는 방법
==============================
PURPOSE
Onhand quantity setup을 확인하는 방법
Explanation
script을 통해, 여러 setup사항들 및 onhand수량을 check할 수 있다.
1. Check Organization controls
2. Check Subinventory controls
3. Check item attributes and controls for lot, locator, serial and
revision.
4. Check onhand quantity stock records a) non lot control
b) lot controlled
5. Check that stock records agree with attribute settings including
the following:
- Check that stock has a lot number if under lot control.
- Check expiration date, lots which have expired still show in
transaction screen
- LPN containerized items
6. Show reservations for the item
7. Show overall quantities (from an internal routine called qtytree)
8. Check that cost groups are correct.
9. Check that quantities agree.
아래의 script을 onhand.sql로 생성하여 수행하시기 바랍니다.
$Header: onhand.sql 115.9 2005/05/25 $
FILE
onhand.sql
DESCRIPTION
Gives information regarding quantity values for an item within an organization,
subinventory, revision and lot to determine why the system does not find
available stock.
Quantity on hand
Reservable quantity on hand
Quantity reserved
Quantity suggested
Quantity available to transact
Quantity available to reserve
The retrieved information will be written to an O/S file called: onhand.lst
This script should be used for Release 11.5 only.
BASE
Bug 3089073, 4349223
ARGUMENTS
Organization_id
Inventory_item_id
lot_number => return over this if item is not lot controlled
revision => return over this if item is not revision controlled
subinventory_code
/*WHENEVER SQLERROR EXIT FAILURE;*/
spool onhand.lst
set linesize 125;
set pagesize 200;
set verify off;
set serveroutput on
PROMPT 1/ To check Organization controls
SELECT organization_id ORG_ID,
primary_cost_method CST_TYP,
cost_organization_id CST_ORG,
master_organization_id MAST_ORG,
default_cost_group_id DEF_CST_GRP,
project_reference_enabled PROJ_FLG,
wms_enabled_flag WMS
FROM mtl_parameters
WHERE organization_id = &&org_id;
PROMPT 2/ To check Subinventory controls
SELECT secondary_inventory_name, organization_id org_id, default_cost_group_id DEF_CST_GRP,
locator_type LOC, asset_inventory ASSET_INV
FROM mtl_secondary_inventories
where organization_id = &&org_id;
PROMPT 3/ To check item attributes
select LOT_CONTROL_CODE LOT, REVISION_QTY_CONTROL_CODE REV, LOCATION_CONTROL_CODE LOC,
SERIAL_NUMBER_CONTROL_CODE SER
from mtl_system_items_b
where organization_id= &&org_id
and inventory_item_id = &&item_id;
prompt control = 2 for on
prompt serial_number_control 1-No serial number, 2-Predefined serial number, 5-Dynamic entry at inventory receipt
prompt 6-Dynamic entry at sales order issue
PROMPT 4/ To check onhand quantity stock records a) non lot control b) lot controlled
select moqd.inventory_item_id ITEM_ID, moqd.organization_id ORG_ID,
moqd.primary_transaction_quantity PRIM_QTY, moqd.subinventory_code, moqd.revision REV,
moqd.locator_id, moqd.lot_number,
moqd.cost_group_id CST_GRP_ID, moqd.project_id, moqd.task_id, moqd.lpn_id,
moqd.CONTAINERIZED_FLAG CONT_FLG
from mtl_onhand_quantities_detail moqd
where moqd.organization_id = &&org_id
and moqd.inventory_item_id = &&item_id;
select moqd.inventory_item_id ITEM_ID, moqd.organization_id ORG_ID,
moqd.primary_transaction_quantity PRIM_QTY, moqd.subinventory_code,moqd.revision REV,
moqd.locator_id, moqd.lot_number, mln.expiration_date EXPIRE_DATE,
moqd.cost_group_id CST_GRP_ID, moqd.project_id, moqd.task_id, moqd.lpn_id,
moqd.CONTAINERIZED_FLAG CONT_FLG
from mtl_onhand_quantities_detail moqd, mtl_lot_numbers mln
where moqd.organization_id = &&org_id
and moqd.inventory_item_id = &&item_id
and moqd.inventory_item_id = mln.inventory_item_id
and moqd.organization_id = mln.organization_id
and moqd.lot_number = mln.lot_number;
PROMPT Check that stock records agree with attribute settings ie. stock has a lot
PROMPT number if under lot control. Also check expiration date, lots which have expired
PROMPT still show in transaction screen but cannot be reserved (bug 3818166) and for
PROMPT negative balances, if found apply patch 3747966.
PROMPT Also check for LPN containerised items will not show as available on forms need
PROMPT unpack the material and then try to issue out from desktop or Perform the Misc
PROMPT issue of the LPN from the Mobile (bug 4349223).
PROMPT
PROMPT 5/ Show reservations for item
select organization_id, inventory_item_id, demand_source_name, demand_source_header_id,
demand_source_line_id, primary_reservation_quantity, revision, subinventory_code,
locator_id, lot_number
from mtl_reservations
where organization_id = &&org_id
and inventory_item_id = &&item_id;
PROMPT 6/ Show overall quantities from qtytree
SELECT
x.organization_id organization_id
, x.inventory_item_id inventory_item_id
, x.revision revision
, x.lot_number lot_number
, To_date(NULL) lot_expiration_date
, x.subinventory_code subinventory_code
, sub.reservable_type reservable_type
, x.locator_id locator_id
, x.primary_quantity primary_quantity
, x.date_received date_received
, x.quantity_type quantity_type
, x.cost_group_id cost_group_id
, x.containerized containerized
FROM (
SELECT
x.organization_id organization_id
, x.inventory_item_id inventory_item_id
, NULL revision
, NULL lot_number
, x.subinventory_code subinventory_code
, x.locator_id locator_id
, SUM(x.primary_quantity) primary_quantity
, MIN(x.date_received) date_received
, x.quantity_type quantity_type
, x.cost_group_id cost_group_id
, x.containerized containerized
FROM (
-- reservations
SELECT
mr.organization_id organization_id
, mr.inventory_item_id inventory_item_id
, mr.revision revision
, mr.lot_number lot_number
, mr.subinventory_code subinventory_code
, mr.locator_id locator_id
, mr.primary_reservation_quantity
- Nvl(mr.detailed_quantity,0) primary_quantity
, To_date(NULL) date_received
, 3 quantity_type
, to_number(NULL) cost_group_id
, 0 containerized
FROM mtl_reservations mr
WHERE
Nvl(mr.supply_source_type_id, 13) = 13
AND mr.primary_reservation_quantity > Nvl(mr.detailed_quantity,0)
UNION ALL
-- onhand quantities
SELECT
moq.organization_id organization_id
, moq.inventory_item_id inventory_item_id
, moq.revision revision
, moq.lot_number lot_number
, moq.subinventory_code subinventory_code
, moq.locator_id locator_id
, decode(NULL, NULL, moq.transaction_quantity, nvl(pjm_ueff_onhand.onhand_quantity
(NULL,moq.inventory_item_id,moq.organization_id
,moq.revision,moq.subinventory_code,moq.locator_id,moq.lot_number)
,moq.transaction_quantity))
, nvl(moq.orig_date_received,
moq.date_received) date_received
, 1 quantity_type
, moq.cost_group_id cost_group_id
, decode(moq.containerized_flag,
1, 1, 0) containerized
FROM
mtl_onhand_quantities_detail moq
UNION ALL
-- pending transactions in mmtt
--changed by jcearley on 12/8/99
--added 1 to decode statement so that we make sure the
--issue qtys in mmtt are seen as negative.
--This problem arose because create_suggestions stores
--the suggested transactions in mmtt as a positive number.
-- added 5/23/00
-- if quantity is in an lpn, then it is containerized
SELECT
mmtt.organization_id organization_id
, mmtt.inventory_item_id inventory_item_id
, mmtt.revision revision
, NULL lot_number
, mmtt.subinventory_code subinventory_code
, mmtt.locator_id locator_id
, Decode(mmtt.transaction_status, 2, 1
, Decode(mmtt.transaction_action_id
, 1, -1, 2, -1, 28, -1, 3, -1, Sign(mmtt.primary_quantity))
* Abs( decode(NULL, NULL, mmtt.primary_quantity, Nvl(apps.pjm_ueff_onhand.txn_quantity(NULL,mmtt.transaction_temp_id,mmtt.lot_number,
'N',mmtt.inventory_item_id, mmtt.organization_id, mmtt.transaction_source_type_id,
mmtt.transaction_source_id, mmtt.rcv_transaction_id,
sign(mmtt.primary_quantity)
),mmtt.primary_quantity)) )
, Decode(mmtt.transaction_action_id
, 1, To_date(NULL)
, 2, To_date(NULL)
, 28, To_date(NULL)
, 3, To_date(NULL)
, Decode(Sign(mmtt.primary_quantity)
, -1, To_date(NULL)
, mmtt.transaction_date)) date_received
, Decode(mmtt.transaction_status, 2, 5, 1) quantity_type
, mmtt.cost_group_id cost_group_id
, decode(mmtt.lpn_id, NULL, 0, 1) containerized
FROM
mtl_material_transactions_temp mmtt
WHERE
mmtt.posting_flag = 'Y'
AND mmtt.subinventory_code IS NOT NULL
AND (Nvl(mmtt.transaction_status,0) <> 2 OR -- pending txns
-- only picking side of the suggested transactions are used
Nvl(mmtt.transaction_status,0) = 2 AND
mmtt.transaction_action_id IN (1,2,28,3,21,29,32,34)
-- dont look at scrap and costing txns
AND mmtt.transaction_action_id NOT IN (24,30)
UNION ALL
-- receiving side of transfers
-- added 5/23/00
-- if quantity is in an lpn, then it is containerized
SELECT
Decode(mmtt.transaction_action_id
, 3, mmtt.transfer_organization
, mmtt.organization_id) organization_id
, mmtt.inventory_item_id inventory_item_id
, mmtt.revision revision
, NULL lot_number
, mmtt.transfer_subinventory subinventory_code
, mmtt.transfer_to_location locator_id
, Abs( decode(NULL, NULL, mmtt.primary_quantity, Nvl(apps.pjm_ueff_onhand.txn_quantity(NULL,mmtt.transaction_temp_id,mmtt.lot_number,
'N',mmtt.inventory_item_id, mmtt.organization_id, mmtt.transaction_source_type_id,
mmtt.transaction_source_id, mmtt.rcv_transaction_id,
sign(mmtt.primary_quantity)
),mmtt.primary_quantity)) )
, mmtt.transaction_date date_received
, 1 quantity_type
, mmtt.transfer_cost_group_id cost_group_id
, decode(mmtt.transfer_lpn_id, NULL, 0, 1) containerized
FROM
mtl_material_transactions_temp mmtt
WHERE
mmtt.posting_flag = 'Y'
AND Nvl(mmtt.transaction_status,0) <> 2 -- pending txns only
AND mmtt.transaction_action_id IN (2,28,3)
) x
WHERE x.organization_id = &&org_id
AND x.inventory_item_id = &&item_id
GROUP BY
x.organization_id, x.inventory_item_id, x.revision
, x.subinventory_code, x.locator_id
, x.quantity_type, x.cost_group_id, x.containerized
) x
, mtl_secondary_inventories sub
WHERE
x.organization_id = sub.organization_id (+)
--AND Nvl(sub.availability_type, 1) = 1
AND x.subinventory_code = sub.secondary_inventory_name (+) ;
PROMPT Check that cost groups are correct see Bug 4222079
PROMPT 7/ To find stock values from system nb.<cr> over lot and revision if item
PROMPT is not under lot or revision control, <cr> over subinventory for all subinvs
DECLARE
L_api_return_status VARCHAR2(1);
l_qty_oh NUMBER;
l_qty_res_oh NUMBER;
l_qty_res NUMBER;
l_qty_sug NUMBER;
l_qty_att NUMBER;
l_qty_atr NUMBER;
l_msg_count NUMBER;
l_msg_data VARCHAR2(1000);
l_rev varchar2(100):=NULL;
l_lot VARCHAR2(100):=NULL;
l_loc VARCHAR2(100):=NULL;
l_lot_control BOOLEAN :=false;
l_revision_control BOOLEAN :=false;
l_lot_control_code NUMBER;
l_revision_qty_control_code NUMBER;
l_location_control_code NUMBER;
l_org_id NUMBER;
l_item_id NUMBER;
l_subinv VARCHAR2(10);
BEGIN
select LOT_CONTROL_CODE ,REVISION_QTY_CONTROL_CODE, LOCATION_CONTROL_CODE
into l_lot_control_code, l_revision_qty_control_code, l_location_control_code
from mtl_system_items_b
where organization_id= &&org_id
and inventory_item_id = &&item_id;
if l_lot_control_code = 2 then
l_lot_control :=true;
l_lot:='&lotnumber';
end if;
if l_revision_qty_control_code =2 then
l_revision_control:=true;
l_rev:='&revision';
end if;
inv_quantity_tree_grp.clear_quantity_cache;
dbms_output.put_line('Transaction Mode');
apps.INV_Quantity_Tree_PUB.Query_Quantities (
p_api_version_number => 1.0
, p_init_msg_lst => apps.fnd_api.g_false
, x_return_status => L_api_return_status
, x_msg_count => l_msg_count
, x_msg_data => l_msg_data
, p_organization_id => &&org_id
, p_inventory_item_id => &&item_id
, p_tree_mode => apps.INV_Quantity_Tree_PUB.g_transaction_mode
, p_onhand_source => NULL
, p_is_revision_control=> l_revision_control
, p_is_lot_control => l_lot_control
, p_is_serial_control => NULL
, p_revision => l_rev
, p_lot_number => l_lot
, p_subinventory_code => '&&subinv_code'
, p_locator_id => NULL
, x_qoh => l_qty_oh
, x_rqoh => l_qty_res_oh
, x_qr => l_qty_res
, x_qs => l_qty_sug
, x_att => l_qty_att
, x_atr => l_qty_atr );
dbms_output.put_line('Quantity on hand --> '||to_char(l_qty_oh));
dbms_output.put_line('Reservable quantity on hand --> '||to_char(l_qty_res_oh));
dbms_output.put_line('Quantity reserved --> '||to_char(l_qty_res));
dbms_output.put_line('Quantity suggested --> '||to_char(l_qty_sug));
dbms_output.put_line('Quantity available to transact --> '||to_char(l_qty_att));
dbms_output.put_line('Quantity available to reserve --> '||to_char(l_qty_atr));
end;
PROMPT Check that quantities agree with script 4 and 5.
Spool off;
PROMPT *** Print file onhand.lst created ***
exit
Reference Documents
Bug 4529874 -
How to get MRP elements - quantity received/required
Hi all
I have a report and I need it to show the quantity received/required for each material in a plant due to MRP execution.
Basically something like MD04 showing each MRP element entry (Deliv., OI-SL, Order, etc) but a sum of quantity received and required
Do anyone knows a function, bapi, or other that can helps calculate this?
Thanks in advanceHi,
Sometime ago I were asked to solve a similar problem.
Just try FM 'MD_ABBL_REPORTING', see if this FM meets your requirements.
Hope it helps!
Best regards,
Carlos Constantino. -
Quantity Posting Required (SPRQ),
Dear Friends,
For an Inspection Lot, System status is
UD Usage decision has bee
LTIN Long-term inspection
PASG Plan/specification ***
CCTD Insp. characteristics
CALC Sample calculated
RREC Results confirmed
STIC Short-term insp. compl
SPRQ Quantity posting required
SPCO Stock posting complete
STUP Statistics updated
In inspection Lot tab, inspection Lot qty is 4000,
but total quantity posted is 0 and To be posted is also 0.
And in Stock overview, no quantity is there in Quality Inspection stock type
Please tell me how to post full quantity.
Thanks and Regards
Prashant AtriPrashant,
For the status you provided on the lot, it appears to me that the lot is completed.
According to your posting you have zero stock in QI. According to the statuses you provided in your first post, the stock posting is completed, (SPCO), and the UD is made (UD).
What makes you think you still need to post against this inspection lot? You don't say that you are missing material in unrestrtcited stock.
The inspection lot quantity should not change. It always remains the same, i.e. whatever the initial lot qty was +- any lot qty. corrections. I'm wondering if you are confusing this and thinking that needs to be posted?
The only thing odd about your lot is the "amount posted" being zero. Typically it should equal some value between zero and the lot qty size. What does the sample size value equal on the stock posting screen shown just under the inspection lot quantity? Are they equal? If so, is there any chance one of your characteristics is set up as a destructive test? In that case, the system could think the entire lot was destroyed in testing. Hence zero stock to post, posting complete and no stock in unrestricted.
If you have the stock in unrestricted, then I come back to the question of why do you think you need to post against this inspection lot?
FF -
Reservation: withdrawn quantity exceeded requirement quantity
Hi Gurus.
Please help.
Is there a way to check why withdrawn quantity exceeded requirement quantity in reservation? System should get standard message M7362 when this happens. Settings in OMCQ are correct.
Thanks in advance...Hi,
The message might relevant for the scenario of GI to reservation, which issued quantity greater then reserved quantity in reservation.
You may check your reservation with MB25 for listing your reservation document and I suggest to use MB26 for collective and more accurate GI processing of relevant reservations.
Cheers,
Girang -
The quantity received/required for each material (only sum of Dep and Foreq
Hi all
I have a report and I need it to show the <b>quantity received/required</b> for each material (<b>only sum of Depreq and ForReq</b>) in a plant due to MRP execution.
Basically something like MD04 showing each MRP element entry (only sum of Depreq and ForReq)
Do anyone knows a function, bapi, or other that can helps calculate this?
Thanks in advanceHi srivalli,
U mean that for every material u need sum of recieved quntity and required qunatity? if this is your requirement.
Try the synax below.
Example.
itab - internal table of any sturcture. suppose itab consits of materil and quantity fiedls.
sort itab by matnr.
loop at itab.
At end of matnr.
Sum.
Write: itab-matnr, itab-menge.
ENDAT.
endloop.
This syntax will display the sum of quantity for each material.
<b>Reward if useful</b>
Any thing please reply back if you have any other doubt.
Regards,
sunil kairam. -
How to know onhand quantity at a selected date
Hi,
is there a concurrent ( or a PLSQL package ) which could give the onhand quantity of an item in storage at a given date .
thanks.There are few reports on Oracle that allows you to analyze the past situation of stock, comparing it with the actual situation and the transactions done during the period between the rollback date and the current date. One of these is "Transaction historical summary". You can launch this report from a Cost Management or Inventory responsibility.
Also build inventory position is a good solution.
Regards
Riccardo
Message was edited by:
Riccardo -
How to calucalte onhand quantity in inventory
Hi,
I am facing problem to calculate the onhand quantity ,reserved quantity and available quantity,
Please help this.
ThanksHi
Please use inv_quantity_tree_pub.query_quantities. It has all the out variables that you are looking for.
Thanks
Nagamohan -
How to get the onhand quantity along with zero quantities in Inventory?
How to get the onhand quantity along with zero quantities in Inventory...Plz reply me as son as possible?
Hi Akshata,
In processRequest you can use pageContext.getParameter
String PartyName = pageContext.getParameter("PartyName");Regards,
Sujoy -
How to find onhand quantity from backend
Hi,
Somebody please tell me how to find onhand quantity for a particular item for particular subinventory.
Please provide the query.
Thanks in advance.mtl_onhand_quantities view contains the details of onhand.
You can sum up transaction_quantities and group by item_id, org_id and subinventory code.
Hope this helps,
Sandeep Gandhi -
Procurement of more quantity than required in case of non stock items
Dear Experts,
Requirement is given below.
I have one maintenance order with non stock item category N for quantity 5 pieces which is actual need.But user wants to procure 50 pieces against order and consume 5 pieces and rest will keep as stock.
But in case of procurement against non stock item the moment we received the Goods (GR), all procurement quantity will goes to consumption account and postings will happen accordingly.Correct me if i am wrong.
Now my requirement is to keep the remaining stock 45 pieces (5 pieces consumed against actual need) as stock and to be consumed whenever there is a need.Can it possible to keep as stock in storage location which was procured against order as non stock item.
How can i resolve this issue.
Please somebody can help me.<<Text removed>>
Thanks in advance.
Reddiy.A.V
Edited by: Matt on Oct 12, 2011 6:46 AMFor the orders which you consumed, do the reversal of that material document. Also create one GR for the qty which has been returned to vendor & keeping the stock to storage location.
In future, define those as stock items, so that this work around won't be required. -
R12 OM Copy does not navigate to required field when OK button is clicked
We are upgrading from 11.5.10 to 12.1.3.
When a user is copying a Sales Order to a Return in 11i and the user leaves the return reason blank, the form will navigate to the return reason and raise ORA-40202 Field must be Entered.
In R12, the navigation to the required field does not happen. The ORA-420202 is still raised, but the user must click through the tabs to find the return reason.
I have examined OEORDCPY.pll and found the procedure OE_ORDER_COPY_WINDOW.action_ok, which is called when the user clicks on the OK button.
The code below is from R12. Only the section for bug 4879216 is new since 11i. It is clear that the intent is for the form to navigate to the line type or return reason when they are missing (null, required, and enabled).
I have attempted to use forms personalization to navigate to the return reason, when it is missing. However, I could not get the desired result using when-new-item-instance or when-button-pressed as the trigger. Anyone have any suggesstions to correct this change in behaviour?
procedure action_ok IS
QUERY_HEADER_ID NUMBER;
BEGIN
/* Added for bug 4879216 */
validate(ITEM_SCOPE);
IF NOT FORM_SUCCESS THEN
raise form_trigger_failure;
END IF;
/* End of bug 4879216 */
OE_Navigate.g_exec_post_forms_commit:='N';
IF get_item_property('COPY.LINE_TYPE',REQUIRED) = 'TRUE' AND
get_item_property('COPY.LINE_TYPE',ENABLED) = 'TRUE' AND
NAME_IN('COPY.LINE_TYPE') IS NULL THEN
--fnd_message.debug('go line type');
go_item('copy.line_type');
ELSIF get_item_property('COPY.RETURN_REASON',REQUIRED) = 'TRUE' AND
get_item_property('COPY.RETURN_REASON',ENABLED) = 'TRUE' AND
NAME_IN('COPY.RETURN_REASON') IS NULL THEN
--fnd_message.debug('go return reason');
go_item('copy.return_reason');
ELSE
--fnd_message.debug('copy');
OE_ORDER_COPY_MAIN.copy_main(QUERY_HEADER_ID);
END IF;
/* OE_ORDER_COPY_GLOBALS.G_HEADER_ID_TO_QUERY := QUERY_HEADER_ID;
hide_window('COPY');
go_block(OE_ORDER_COPY_GLOBALS.G_SOURCE_BLOCK_NAME);
app_special.enable('MODAL',PROPERTY_ON);
app_special.enable('file.save',PROPERTY_ON);
app_special.enable('file.accept',PROPERTY_ON);
END action_ok;We have obtained a one-off patch from Oracle to address the issue. Is the patch available for public access? If yes, it would be great if you could share the patch number with us.
Thanks,
Hussein -
Stuck with this SQL requirement
Ok here's the basic test data for my requirement:
with test_data as
select to_date('15/12/2008','dd/mm/yyyy') as start_date, to_date('15/12/3000','dd/mm/yyyy') as end_date from dual
select *
from test_data;
START_DATE END_DATE
15-12-2008 15-12-3000We work with a pattern, which is divided in two parts:
The first week : the first 7 days of the pattern, starting from START_DATE
The Second week : the 7 days that follow the first week (self explanatory)
I've got a requirement that says that if I'm supplied with a date, I have to find out what pattern (first or second week) the supplied date falls in.
so, our pattern for test_data is:
15-12-2008 : First day of 1st week
16-12-2008 : Second day of 1st week
17-12-2008 : Third day of 1st week
18-12-2008 : Fourth day of 1st week
19-12-2008 : Fifth day of 1st week
20-12-2008 : Sixth day of 1st week
21-12-2008 : Seventh day of 1st week
22-12-2008 : First day of second week
23-12-2008 : Second day of second week
28-12-2008 : Seventh day of second week
============================== end of pattern =================================
29-12-2008 : Start of First day of 1st week
Now, if my date supplied is 16 Dec 2008, my sql should return something like: "First Week".
If my date supplied is 24-12-2008, my sql should return "Second week".
If my date supplied is 29-12-2008, my sql should return "First Week".
phew, I thought of a connect by, but this wouldn't do the trick I think because the comparison is between columns and no rows. No clue.. I could only got til using 16/12/2008 as test date, but it doesn't work in all cases :-(:
with test_data as
select to_date('15/12/2008','dd/mm/yyyy') as start_pattern, to_date('15/12/3000','dd/mm/yyyy') as end_pattern from dual
select
start_pattern,
start_pattern + 7,
case when to_date('16/12/2008','dd/mm/yyyy') between start_pattern and start_pattern + 7 then
'first'
else
'second'
end week_it_belongs_in_pattern
from test_data
START_PATT START_PATT WEEK_I
15-12-2008 22-12-2008 firstEdited by: user9541973 on Nov 18, 2008 8:57 PMSolution
SELECT X SO , PP PATERN
FROM DUAL
MODEL
DIMENSION BY (TO_DATE(&DT1,'YYYY-MM-DD') X)
MEASURES (1 Y, 'FIRST WEEK' PP)
(Y[FOR X FROM DATE &DT1 TO DATE &DT2 INCREMENT INTERVAL '1' DAY ]=0,
PP[FOR X FROM DATE &DT1 TO DATE &DT2 INCREMENT INTERVAL '1' DAY ]=
DECODE(MOD(CV(X)- TO_DATE(&DT1,'YYYY-MM-DD'),7),0,'First',1,'Second ',2,
'Third',3,'Fourth',4,'Fifth',5,'Sixth',6,'Seventh')||
' day of '||
CASE WHEN MOD(TO_CHAR(CV(X),'IW'),2)= 1 THEN
'first week'
ELSE 'second week' END )
Demo
SQL> SELECT X SO , PP PATERN
2 FROM DUAL
3 MODEL
4 DIMENSION BY (TO_DATE(&DT1,'YYYY-MM-DD') X)
5 MEASURES (1 Y, 'FIRST WEEK' PP)
6 (Y[FOR X FROM DATE &DT1 TO DATE &DT2 INCREMENT INTERVAL '1' DAY ]=0,
7 PP[FOR X FROM DATE &DT1 TO DATE &DT2 INCREMENT INTERVAL '1' DAY ]=
8 DECODE(MOD(CV(X)- TO_DATE(&DT1,'YYYY-MM-DD'),7),0,'First',1,'Second ',2,
9 'Third',3,'Fourth',4,'Fifth',5,'Sixth',6,'Seventh')||
10 ' day of '||
11 CASE WHEN MOD(TO_CHAR(CV(X),'IW'),2)= 1 THEN
12 'first week'
13 ELSE 'second week' END );
Entrez une valeur pour dt1 : '2008-12-15'
ancien 4 : DIMENSION BY (TO_DATE(&DT1,'YYYY-MM-DD') X)
nouveau 4 : DIMENSION BY (TO_DATE('2008-12-15','YYYY-MM-DD') X)
Entrez une valeur pour dt1 : '2008-12-15'
Entrez une valeur pour dt2 : '2009-02-15'
ancien 6 : (Y[FOR X FROM DATE &DT1 TO DATE &DT2 INCREMENT INTERVAL '1' DAY ]=0,
nouveau 6 : (Y[FOR X FROM DATE '2008-12-15' TO DATE '2009-02-15' INCREMENT INTERVAL '1' DAY ]=0,
Entrez une valeur pour dt1 : '2008-12-15'
Entrez une valeur pour dt2 : '2009-02-15'
ancien 7 : PP[FOR X FROM DATE &DT1 TO DATE &DT2 INCREMENT INTERVAL '1' DAY ]=
nouveau 7 : PP[FOR X FROM DATE '2008-12-15' TO DATE '2009-02-15' INCREMENT INTERVAL '1' DAY ]=
Entrez une valeur pour dt1 : '2008-12-15'
ancien 8 : DECODE(MOD(CV(X)- TO_DATE(&DT1,'YYYY-MM-DD'),7),0,'First',1,'Second ',2,
nouveau 8 : DECODE(MOD(CV(X)- TO_DATE('2008-12-15','YYYY-MM-DD'),7),0,'First',1,'Second ',2,
SO PATERN
2008-12-15 First day of first week
2008-12-16 Second day of first week
2008-12-17 Third day of first week
2008-12-18 Fourth day of first week
2008-12-19 Fifth day of first week
2008-12-20 Sixth day of first week
2008-12-21 Seventh day of first week
2008-12-22 First day of second week
2008-12-23 Second day of second week
2008-12-24 Third day of second week
2008-12-25 Fourth day of second week
SO PATERN
2008-12-26 Fifth day of second week
2008-12-27 Sixth day of second week
2008-12-28 Seventh day of second week
2008-12-29 First day of first week
2008-12-30 Second day of first week
2008-12-31 Third day of first week
2009-01-01 Fourth day of first week
2009-01-02 Fifth day of first week
2009-01-03 Sixth day of first week
2009-01-04 Seventh day of first week
2009-01-05 First day of second week
SO PATERN
2009-01-06 Second day of second week
2009-01-07 Third day of second week
2009-01-08 Fourth day of second week
2009-01-09 Fifth day of second week
2009-01-10 Sixth day of second week
2009-01-11 Seventh day of second week
2009-01-12 First day of first week
2009-01-13 Second day of first week
2009-01-14 Third day of first week
2009-01-15 Fourth day of first week
2009-01-16 Fifth day of first week
SO PATERN
2009-01-17 Sixth day of first week
2009-01-18 Seventh day of first week
2009-01-19 First day of second week
2009-01-20 Second day of second week
2009-01-21 Third day of second week
2009-01-22 Fourth day of second week
2009-01-23 Fifth day of second week
2009-01-24 Sixth day of second week
2009-01-25 Seventh day of second week
2009-01-26 First day of first week
2009-01-27 Second day of first week
SO PATERN
2009-01-28 Third day of first week
2009-01-29 Fourth day of first week
2009-01-30 Fifth day of first week
2009-01-31 Sixth day of first week
2009-02-01 Seventh day of first week
2009-02-02 First day of second week
2009-02-03 Second day of second week
2009-02-04 Third day of second week
2009-02-05 Fourth day of second week
2009-02-06 Fifth day of second week
2009-02-07 Sixth day of second week
SO PATERN
2009-02-08 Seventh day of second week
2009-02-09 First day of first week
2009-02-10 Second day of first week
2009-02-11 Third day of first week
2009-02-12 Fourth day of first week
2009-02-13 Fifth day of first week
2009-02-14 Sixth day of first week
2009-02-15 Seventh day of first week
63 ligne(s) sélectionnée(s).
SQL> Edited by: Salim11 on 2008-11-19 08:16
Edited by: Salim11 on 2008-11-19 08:17
Edited by: Salim11 on 2008-11-19 08:18 -
REPORT - Sold quantity and OnHand quantity
Hello Everyone,
How can I create a query to show what I have sold within a date range and how much inventory I have of those items. Thank you.
itemcode sold onhand whscod
x 10 5 AH
x 5 0 CH
x 12 3 GB
Y 0 5 AH
Y 0 10 CH
Y 2 20 GBThat is the 2nd step for the query. I would like him to try this first.
Here is the final:
SELECT S.ItemCode, SUM(S.quantity) 'Sold', S.Onhand, S.WhsCode
FROM (SELECT T0.ItemCode, T0.quantity, T2.Onhand, T0.WhsCode
FROM dbo.INV1 T0
INNER JOIN dbo.OINV T1 ON T1.DocEntry=T0.DocEntry
INNER JOIN dbo.OITW T2 ON T2.WhsCode=T0.WhsCode AND T2.ItemCode=T0.ItemCode
WHERE T1.DocDate Between [%0\] AND [%1\]
UNION ALL
SELECT T0.ItemCode, -T0.quantity, T2.Onhand, T0.WhsCode
FROM dbo.RIN1 T0
INNER JOIN dbo.ORIN T1 ON T1.DocEntry=T0.DocEntry
INNER JOIN dbo.OITW T2 ON T2.WhsCode=T0.WhsCode AND T2.ItemCode=T0.ItemCode
WHERE T1.DocDate Between [%0\] AND [%1\]) S
GROUP BY S.ItemCode, S.Onhand, S.WhsCode
ORDRE BY S.ItemCode
Maybe you are looking for
-
Since upgrading to Windows 8.1, iTunes no longer recognizes my iPhone or iPad. I tried to reinstall iTunes. That did not address my problem. Any suggetions on what I should do?
-
Hi, I received an email from VH1 today (I do receive periodic emails so they are legit) that keeps running a dialog box of "To view this page, you need to log in to area "" on www.vh1-d.mtvi.com:80." And it asks for a login & password. This dialog bo
-
Problems Undeploying on Application Server
I am having problems with the "asant undeploy" command because after I try to re-deploy a .war file, I get the error message below in the servers log. I'm guessing the original undeploy was not completed successfully despite what it says at the comma
-
How can read BOM component date before save the production order??
Hi Experts, In our company, we need to develop a program to read the BOM component data of the production order before we save the production order. That for example ,when we create and release a production order , before we save the production order
-
Old version of Spotify on iOS 6 in France (iPhone 3GS)
Since Spotify update on Apple Store, it is impossible to install Spotify on my iPhone 3GS as it has to stay on the iOS6 . Do you know a way to run Spotify on iPhone 3GS (iOS6) ? Depuis la mise à jour de Spotify sur Apple Store, il est impossible d'in