Subtract values in the same column - sql

Wip Return Trouble
In the batch details when I consult material transactions, SHOWS a “WIP ISSUE (2)” AND A “WIP RETURN (2)” so when I'm recovering the data, I do not want the numbers to be displayed. ( wip issue and wip return)
SELECT
mmt.subinventory_code subinventario,
msib.segment1 segmento,
msib.description descripción,
SUM(mmln.transaction_quantity) transacción_primaria,
mmt.transaction_uom medida_primaria,
SUM(mmln.secondary_transaction_quantity) transacción_secundaria,
mmt.secondary_uom_code medida_secundaria,
mtl.grade_code grado,
mmt.transaction_type_id,
mmt.transaction_source_id
FROM mtl_transaction_lot_numbers mmln,
mtl_material_transactions mmt,
mtl_system_items_b msib,
mtl_lot_numbers mtl
WHERE mmt.transaction_source_id IN (
SELECT bh.batch_id
FROM gme.gme_batch_header bh, gme.gme_material_details det
WHERE bh.batch_id = det.batch_id
AND det.line_type = 1
AND (TRUNC(actual_start_date) BETWEEN :p_start_date AND TO_DATE(:p_end_date))
AND bh.organization_id = 269)
AND mmt.organization_id = 269
AND mmt.transaction_type_id IN (44, 35, 43, 17)
AND mmt.transaction_id = mmln.transaction_id
AND mmt.inventory_item_id = mmln.inventory_item_id
AND mmt.organization_id = mmln.organization_id
AND msib.inventory_item_id = mmt.inventory_item_id
AND msib.organization_id = mmt.organization_id
AND mtl.lot_number = mmln.lot_number
AND mtl.organization_id = mmln.organization_id
GROUP BY mmt.subinventory_code,
msib.segment1,
msib.description,
mmt.transaction_uom,
mmt.secondary_uom_code,
mtl.grade_code,
mmt.transaction_type_id,
mmt.transaction_source_id
ORDER BY mmt.transaction_type_id

Related

how to optimize max position limit in quantstrat for bollinger bands strategy

The code below is my Bollinger bands strategy for commodity. I add a position limit and want to optimize this strategy through parameter maxpos. For the function add.distribution, it asks for a component.label, but the function addPosLimit does not have a variable called "label". I wonder how to optimize maxpos at this case.
symbol <- 'C1'
currency("USD")
#stock(symbol, currency="USD", multiplier=1)
portfName <- 'RSI_Strategy'
acctName <- portfName
suppressWarnings(rm.strat(stratName))
initPortf(name = portfName, symbols = symbol, initDate = initDate,
currency = 'USD')
initAcct(name = acctName, portfolios = portfName,
initDate=initDate, initEq=initEq)
initOrders(portfolio = portfName, initDate = initDate)
stratName <- portfName
strategy(name = stratName, store=TRUE)
SD = 2
N = 20
add.indicator(strategy = stratName, name = "BBands",
arguments = list(HLC = quote(HLC(mktdata)), maType='SMA',
n=N, sd=SD),
label='BBands')
add.signal(strategy = stratName, name="sigCrossover",
arguments=list(columns=c("Close","up"),relationship="gt"),
label="Cl.gt.UpperBand")
add.signal(strategy = stratName, name="sigCrossover",
arguments=list(columns=c("Close","dn"),relationship="lt"),
label="Cl.lt.LowerBand")
add.signal(strategy = stratName, name="sigCrossover",
arguments=list(columns=c("High","mavg"),relationship="gt"),
label="Hi.Cross.Mid")
add.signal(strategy = stratName, name="sigCrossover",
arguments=list(columns=c("Low","mavg"),relationship="lt"),
label="Lo.Cross.Mid")
add.rule(strategy = stratName, name='ruleSignal',
arguments=list(sigcol="Cl.gt.UpperBand",sigval=TRUE, orderqty=-nShs,
ordertype='market', orderside=NULL, osFUN=osMaxPos
),type='enter',
label = "Enter.Short")
add.rule(strategy = stratName, name='ruleSignal',
arguments=list(sigcol="Cl.lt.LowerBand",sigval=TRUE, orderqty=nShs,
ordertype='market', orderside=NULL, osFUN=osMaxPos
),type='enter',
label = "Enter.Long")
add.rule(strategy = stratName, name='ruleSignal',
arguments=list(sigcol="Hi.Cross.Mid",sigval=TRUE, orderqty= 'all',
ordertype='market', orderside=NULL),type='exit',
label = "Exit.All")
add.rule(strategy = stratName, name='ruleSignal',
arguments=list(sigcol="Lo.Cross.Mid",sigval=TRUE, orderqty= 'all',
ordertype='market', orderside=NULL),type='exit',
label = "Exit.All")
addPosLimit(portfName, symbol, timestamp=initDate, maxpos=maxpos, minpos=0)
.maxpos = seq(3000,8000,1000)
add.distribution(stratName,
paramset.label = 'PosOpt',
component.type = 'order',
component.label = 'addPosLimit',
variable = list(maxpos = .maxpos),
label = 'MaxPos')

Nested in line view Add Column

I have to add a column to this report - the new column name is: uda_value_desc
The code below will give me a result if I enter a PM_ITEM number, I need to insert the code into one of the in line views.
Any help would be appreciated
WITH item_temp AS (SELECT im.item
,uv.uda_value_desc uda_value_desc -----
FROM item_master im
,TABLE(mff_report.parse_strings(:PM_item)) t
, uda_item_lov uil
, uda_values uv
WHERE t.Column_Value = uil.item
and uil.UDA_ID = 511
and uv.uda_id = uil.uda_id
and uv.uda_value = uil.uda_value
and im.item = uil.item
UNION ALL
SELECT im.item
,null
FROM item_master im
,TABLE(mff_report.parse_strings(:PM_item)) t
WHERE t.COLUMN_VALUE = im.item_parent
AND im.item_level = im.tran_level
UNION ALL
SELECT sd.item
,null
FROM skulist_detail sd
,TABLE(mff_report.parse_strings(:PM_item_list)) t
WHERE t.COLUMN_VALUE = sd.skulist
UNION ALL
SELECT ia.item
,null
FROM mffecom.item_attr ia
,TABLE(mff_report.parse_strings(:PM_product_id)) t
WHERE t.COLUMN_VALUE = ia.product_id
UNION ALL
SELECT im.item
,null
FROM item_master im
WHERE :PM_item IS NULL
AND :PM_item_list IS NULL
AND :PM_product_id IS NULL )
SELECT v_item.item_parent
,uda_value_desc
,v_item.item
,mff_report.mff_merch_sql.get_brand_name(v_item.item) brand_name
,v_item.item_desc
,v_selling.product_id
,v_product.product_web_desc
,v_product.product_template
,v_product.romance_copy
,v_selling.selling_point_1
,v_selling.selling_point_2
,v_selling.selling_point_3
,v_selling.selling_point_4
,v_selling.selling_point_5
,v_selling.selling_point_6
,v_selling.selling_point_7
,v_selling.selling_point_8
,v_selling.selling_point_9
,v_selling.selling_point_10
,v_selling.selling_point_11
,v_selling.selling_point_12
,v_selling.selling_point_13
,v_selling.selling_point_14
,v_selling.selling_point_15
,v_selling.selling_point_16
,v_item.vpn
,v_item.diff_1
,v_item.diff1_desc
,v_item.diff_2
,v_item.diff2_desc
,v_item.diff_3
,v_item.diff3_desc
,v_item.diff_4
,v_item.diff4_desc
,v_item.supplier
,v_item.sup_name
,v_product.code_desc fulfillment_method_desc
,v_product.air_ship_restrict
,v_product.do_not_freeze
,v_product.free_shipping
,v_product.refrigerate
,v_product.serial_reqd
,v_product.vaccination
,v_product.is_consumable
,v_product.zero_weight
,v_product.restrict_state
,v_product.no_of_alt_image
,v_product.product_status
,v_product.item_ecom_status
,TO_CHAR(v_product.deactivate_date, 'MM/DD/YYYY') product_deactivate_date
,TO_CHAR(v_product.product_activate_date, 'MM/DD/YYYY') product_activate_date
,TO_CHAR(v_product.item_activate_date, 'MM/DD/YYYY') item_activate_date
,TO_CHAR(v_product.item_deactivate_date, 'MM/DD/YYYY') item_deactivate_date
,v_product.prod_created_by
,TO_CHAR(v_product.prod_created_date, 'MM/DD/YYYY') prod_created_date
,v_product.prod_updated_by
,v_product.item_created_by
,TO_CHAR(v_product.item_created_date, 'MM/DD/YYYY') item_created_date
,v_product.item_updated_by
,v_item.delete_type purge
,v_item.dept
,v_item.class
,v_item.subclass
,mff_orders_sql.buyer_for_item(v_item.item) buyer
,mff_orders_sql.buyer_name_for_item(v_item.item) buyer_name
,v_item.soh
,v_item.length
,v_item.width
,v_item.height
,v_item.weight
,v_variant.variant_id1
,v_variant.value_id1
,v_variant.variant_id2
,v_variant.value_id2
,v_variant.variant_id3
,v_variant.value_id3
,v_variant.variant_id4
,v_variant.value_id4
,v_variant.variant_id5
,v_variant.value_id5
,v_variant.variant_id6
,v_variant.value_id6
FROM (SELECT ia.item
,v_sell.product_id
,MIN(DECODE(row_num,1,selling_point)) selling_point_1
,MIN(DECODE(row_num,2,selling_point)) selling_point_2
,MIN(DECODE(row_num,3,selling_point)) selling_point_3
,MIN(DECODE(row_num,4,selling_point)) selling_point_4
,MIN(DECODE(row_num,5,selling_point)) selling_point_5
,MIN(DECODE(row_num,6,selling_point)) selling_point_6
,MIN(DECODE(row_num,7,selling_point)) selling_point_7
,MIN(DECODE(row_num,8,selling_point)) selling_point_8
,MIN(DECODE(row_num,9,selling_point)) selling_point_9
,MIN(DECODE(row_num,10,selling_point)) selling_point_10
,MIN(DECODE(row_num,11,selling_point)) selling_point_11
,MIN(DECODE(row_num,12,selling_point)) selling_point_12
,MIN(DECODE(row_num,13,selling_point)) selling_point_13
,MIN(DECODE(row_num,14,selling_point)) selling_point_14
,MIN(DECODE(row_num,15,selling_point)) selling_point_15
,MIN(DECODE(row_num,16,selling_point)) selling_point_16
FROM mffecom.item_attr ia
,(SELECT sp.product_id
,row_number () OVER (PARTITION BY sp.product_id ORDER BY sp.selling_point_id) row_num
,sp.selling_point
FROM mffecom.selling_point sp
ORDER BY sp.product_id
,sp.selling_point) v_sell
WHERE ia.product_id = v_sell.product_id
GROUP BY ia.item
,v_sell.product_id) v_selling
,(SELECT NVL(im.item_parent,im.item) item_parent
,im.item
,im.item_desc
,im.dept
,im.class
,im.subclass
,isupp.supplier
,s.sup_name
,isupp.vpn
,miim.stock_on_hand soh
,iscd.length
,iscd.width
,iscd.height
,iscd.weight
,im.diff_1
,di.diff_desc diff1_desc
,im.diff_2
,di2.diff_desc diff2_desc
,im.diff_3
,di3.diff_desc diff3_desc
,im.diff_4
,di4.diff_desc diff4_desc
,dp.delete_type
FROM item_supplier isupp
,sups s
,item_supp_country_dim iscd
,item_master im
,diff_ids di
,diff_ids di2
,diff_ids di3
,diff_ids di4
,daily_purge dp
,merch_item_inv_mv miim
WHERE isupp.item = im.item
AND isupp.item = miim.item (+)
AND isupp.supplier = s.supplier
AND isupp.item = iscd.item
AND isupp.supplier = iscd.supplier
AND isupp.primary_supp_ind = 'Y'
AND iscd.dim_object = 'EA'
AND im.item_level = im.tran_level
AND im.sellable_ind = 'Y'
AND im.diff_1 = di.diff_id (+)
AND im.diff_2 = di2.diff_id (+)
AND im.diff_3 = di3.diff_id (+)
AND im.diff_4 = di4.diff_id (+)
AND im.item = dp.key_value (+)) v_item
,(SELECT ia.item
,pm.product_id
,pm.product_web_desc
,pm.template product_template
,pm.romance_copy
,ia.air_ship_restrict
,ia.do_not_freeze
,ia.free_shipping
,ia.refrigerate
,ia.serial_reqd
,ia.vaccination
,ia.is_consumable
,ia.zero_weight
,pm.no_of_alt_image
,pm.status product_status
,ia.status item_ecom_status
,pm.deactivate_date deactivate_date
,pm.activate_date product_activate_date
,ia.activate_date item_activate_date
,ia.deactivate_date item_deactivate_date
,pm.created_by prod_created_by
,pm.create_datetime prod_created_date
,pm.updated_by prod_updated_by
,ita.created_by item_created_by
,ita.create_date item_created_date
,ia.updated_by item_updated_by
,str.restrict_state
,cd.code_desc
FROM MFFECOM.product_master pm
,MFFECOM.item_attr ia
,MFFECOM.ship_to_restrict str
,rms13.mff_brand mb
,rms13.item_attributes ita
,rms13.code_detail cd
WHERE ia.product_id = pm.product_id
AND ia.item = str.item (+)
AND ia.item = ita.item (+)
AND pm.brand_id = mb.brand_id (+)
AND to_char(ia.fulfillment_method) = cd.code
AND cd.code_type = 'EIFM') v_product
,(SELECT item
,product_id
,MIN(DECODE(row_num,1,variant_id)) variant_id1
,MIN(DECODE(row_num,1,value_id)) value_id1
,MIN(DECODE(row_num,2,variant_id)) variant_id2
,MIN(DECODE(row_num,2,value_id)) value_id2
,MIN(DECODE(row_num,3,variant_id)) variant_id3
,MIN(DECODE(row_num,3,value_id)) value_id3
,MIN(DECODE(row_num,4,variant_id)) variant_id4
,MIN(DECODE(row_num,4,value_id)) value_id4
,MIN(DECODE(row_num,5,variant_id)) variant_id5
,MIN(DECODE(row_num,5,value_id)) value_id5
,MIN(DECODE(row_num,6,variant_id)) variant_id6
,MIN(DECODE(row_num,6,value_id)) value_id6
FROM (SELECT item
,product_id
,row_number () OVER (PARTITION BY item ORDER BY variant_id) row_num
,variant_id
,value_id
FROM mffecom.item_variant)
GROUP BY item
,product_id) v_variant
,item_temp it
WHERE v_item.item = v_selling.item (+)
AND v_item.item = v_product.item (+)
AND v_item.item = v_variant.item (+)
AND v_item.item = it.item
AND v_item.supplier = NVL(:PM_supplier,v_item.supplier)
AND (v_product.prod_created_by = :PM_prod_created_by OR :PM_prod_created_by IS NULL)
AND (v_product.item_created_by = :PM_item_created_by OR :PM_item_created_by IS NULL)
AND (v_product.prod_created_date BETWEEN :prod_created_date_start AND :prod_created_date_to OR :prod_created_date_start IS NULL)
AND (v_product.item_created_date BETWEEN :item_created_date_start AND :item_created_date_to OR :item_created_date_start IS NULL)
ORDER BY v_product.product_id

Updating multiple tables inside cursor not working

I have two records in a table A. This helps me to update table 2 however the update is not been applied. This is the SQL code where I added a validation section that allow me to determinate the problem.
DECLARE abc CURSOR FOR
select d.cod_suc, d.cod_ramo_comercial, d.nro_pol, d.cod_item, d.cod_ramo_tecnico, d.cod_tarifa,
d.id_stro, d.nro_stro, d.fec_hora_reclamo, d.fec_aviso, d.fec_registro, d.fec_ingreso_contable,
d.txt_place_of_accident, d.id_substro, d.txt_nombre_cober, d.txt_direccion_bien_siniestrado, d.txt_descripcion_perdida, d.txt_cheque_a_nom, d.cod_manager_code, d.importe_pago_eq
from table1 d
where d.fec_hora_reclamo between '20140801' and '20150731'
and (d.cod_suc = 2 and d.cod_ramo_comercial = 255 and d.nro_pol = 1000001 and d.cod_item = 5)
OPEN abc
FETCH abc INTO #cod_suc, #cod_ramo_comercial, #nro_pol, #cod_item, #cod_ramo_tecnico, #cod_tarifa,
#id_stro, #nro_stro, #fec_hora_reclamo, #fec_aviso, #fec_registro, #fec_ingreso_contable,
#txt_place_of_accident, #id_substro, #txt_nombre_cober, #txt_direccion_bien_siniestrado, #txt_descripcion_perdida, #txt_cheque_a_nom, #cod_manager_code, #importe_pago_eq
WHILE (##FETCH_STATUS = 0)
BEGIN
select #varIDPV = min(id_pv), #varCodTarifa = min(cod_tarifa)
from #portfolio p
where p.cod_suc = #cod_suc and p.cod_ramo_comercial = #cod_ramo_comercial and p.Poliza = #nro_pol and p.Item = #cod_item and p.cod_ramo_tecnico = #cod_ramo_tecnico
and p.[ID Incident] IS NULL
/**************************************************************************************************************
-- Validation section
-- First record:
mid(id_pv) = 100, min(cod_tarifa) = 1
-- Second record:
mid(id_pv) = 100, min(cod_tarifa) = 1
--> Should be mid(id_pv) = 100, min(cod_tarifa) = 2
*/
select min(id_pv), min(cod_tarifa)
from #portfolio p
where p.cod_suc = #cod_suc and p.cod_ramo_comercial = #cod_ramo_comercial and p.Poliza = #nro_pol and p.Item = #cod_item and p.cod_ramo_tecnico = #cod_ramo_tecnico
and p.[ID Incident] IS NULL
/**************************************************************************************************************/
update p set p.[ID Incident] = #id_stro, p.[No. Incident] = #nro_stro,
p.[Fecha Accidente] = #fec_hora_reclamo, p.[Fecha Notificacion] = #fec_aviso, p.[Fecha Registro] = #fec_registro, p.[Fecha Pago] = #fec_ingreso_contable,
p.[Lugar Accidente] = #txt_place_of_accident, p.[ID Subsiniestro] = #id_substro, p.[Cobertura Amparo] = #txt_nombre_cober, p.[Direccion Bien Siniestrado] = #txt_direccion_bien_siniestrado, p.[Descripcion Perdida] = #txt_descripcion_perdida, p.[Pago A] = #txt_cheque_a_nom, p.[Referida] = #cod_manager_code,
[Incurrido R12] = #importe_pago_eq, [Incurrido Cerrados R12] = #importe_pago_eq
from #portfolio p
where p.cod_suc = #cod_suc and p.cod_ramo_comercial = #cod_ramo_comercial and p.Poliza = #nro_pol and p.Item = #cod_item and p.cod_ramo_tecnico = #cod_ramo_tecnico
and p.[ID Incident] IS NULL and p.id_pv = #varIDPV and p.cod_tarifa = #varCodTarifa
FETCH abc INTO #cod_suc, #cod_ramo_comercial, #nro_pol, #cod_item, #cod_ramo_tecnico, #cod_tarifa,
#id_stro, #nro_stro, #fec_hora_reclamo, #fec_aviso, #fec_registro, #fec_ingreso_contable,
#txt_place_of_accident, #id_substro, #txt_nombre_cober, #txt_direccion_bien_siniestrado, #txt_descripcion_perdida, #txt_cheque_a_nom, #cod_manager_code, #importe_pago_eq
END
CLOSE abc
DEALLOCATE abc
When I see the result, only the first record is updated.
I found the problem. I forgot to add one condition more in update (inside where). Thanks for the support

WITH clause causing ORA-32044

I have a query which is used in an OBIEE report which erroring out for "ora-32044 while executing recursive WITH query". Tried running in SQL and it is erroring out in there as well. Can anyone take a look at the query and suggest how it can be run without the WITH clause. I have seen examples but without any level, for a case where WITH has been used in the middle of the query, how can it be rewritten without WITH clause so no ora-32044 occurs
`SELECT 1 dummy, oh.order_number, ol.line_number, ol.shipment_number,
oh.ordered_date, ot.NAME order_type, items.concatenated_segments item,
items.description item_description
,bom.assembly_item
,bom.component_item
,bom.implementation_date
,bom.disable_date as date_disabled
,bom.component_item_description
,ol.flow_status_code line_status
,ol.ordered_quantity,
ol.shipped_quantity,
ol.unit_selling_price,
ol.fulfilled_quantity,
ol.invoiced_quantity,
ol.cancelled_quantity,
ol.schedule_ship_date,
ol.promise_date,
ol.actual_shipment_date,
ol.request_date,
cust_acct.account_number customer_number,
party.party_name customer,
ct.trx_number invoice_number,
ctl.line_number inv_line_number,
ctl.extended_amount,
ct.trx_date invoice_date,
ct.creation_date invoice_creation_date,
wnd.NAME delivery_number,
wdd.released_status,
hp2.party_name endcustomer,
oh.attribute6 business_unit,
TO_CHAR (ol.actual_shipment_date, 'MM/YY') shipped_month,
TO_CHAR (ol.actual_shipment_date, '"Q"Q YY') shipped_qtr,
TO_CHAR (ol.actual_shipment_date, 'YYYY') shipped_year,
mc.segment1 product_group, mc.segment2 product_subgroup,
items.attribute7 drive_capacity,
items.attribute10 drive_form,
items.attribute8 drive_speed,
items.attribute6 drive_type,
items.attribute12 AgileParttype,
items.organization_id,
case when dis.arithmetic_operator = 'NEWPRICE' then operand
when dis.arithmetic_operator = '%'
then (ol.unit_selling_price* ol.ordered_quantity)*dis.operand/100.0
else NVL((NVL (ol.pricing_quantity, 0) * NVL (dis.adjusted_amount, 0)),0) end
discount_amount
FROM apps.oe_order_headers_all oh,
apps.oe_order_lines_all ol,
apps.wsh_new_deliveries wnd,
apps.wsh_delivery_assignments wda,
apps.wsh_delivery_details wdd,
apps.ra_customer_trx_all ct,
apps.ra_customer_trx_lines_all ctl,
apps.oe_transaction_types_tl ot,
(SELECT *
FROM apps.mtl_system_items_vl
WHERE organization_id = 84
) items,
apps.hz_parties party,
apps.hz_cust_accounts cust_acct,
apps.hz_parties hp2,
apps.hz_cust_accounts hca2,
apps.mtl_item_categories mic,
(SELECT *
FROM apps.mtl_category_sets
WHERE category_set_name = 'Inventory') ms,
apps.mtl_categories mc,
(select a.header_id, a.line_id ,a.list_header_id,a.creation_date,
a.arithmetic_operator,a.unit_selling_price,a.operand,
a.ordered_quantity, a.adjusted_amount
from
(select oh.header_id,
ol.line_id,pl.list_header_id,pl.creation_date,opa.arithmetic_operator,
ol.unit_selling_price,opa.operand,
ol.ordered_quantity, opa.adjusted_amount
from apps.oe_price_adjustments opa,
apps.oe_order_lines_all ol,
apps.oe_order_headers_all oh,
apps.qp_list_headers_vl pl
where oh.header_id = opa.header_id
and ol.line_id = opa.line_id
and opa.list_header_id = pl.list_header_id
and opa.applied_flag = 'Y'
AND opa.list_line_type_code = 'DIS') a,
(select oh.header_id, ol.line_id,max(pl.creation_date) creation_date, min(operand)
operand
from apps.oe_price_adjustments opa,
apps.oe_order_lines_all ol,
apps.oe_order_headers_all oh,
apps.qp_list_headers_vl pl
where oh.header_id = opa.header_id
and ol.line_id = opa.line_id
and opa.list_header_id = pl.list_header_id
and opa.applied_flag = 'Y'
AND opa.list_line_type_code = 'DIS'
group by oh.header_id, ol.line_id) b
where
a.header_id = b.header_id
and a.line_id = b.line_id
and a.creation_date = b.creation_date
and a.operand = b.operand ) dis
,(
WITH recursiveBOM (parent_item_id,parent_item,parent_org_id,assembly_item_id,
assembly_item,assembly_org_id,
component_item_id,component_item, component_item_description,implementation_date,
disable_date) AS
(
SELECT item.inventory_item_id parent_item_id
,item.segment1 parent_item
,item.organization_id parent_org_id
,bom.assembly_item_id
,msi.segment1 assembly_item
,bom.organization_id assembly_org_id
,bic.component_item_id
,msi2.segment1 component_item
,msi2.description component_item_description
,bic.implementation_date
,bic.disable_date
FROM apps.mtl_system_items_b item, apps.bom_bill_of_materials_v bom,
apps.bom_inventory_components_v bic, apps.mtl_system_items msi,
apps.mtl_system_items msi2
WHERE 1=1
AND bom.assembly_item_id = item.inventory_item_id
AND bom.organization_id = item.organization_id
AND bic.bill_sequence_id = bom.common_bill_sequence_id
AND msi.inventory_item_id = bom.assembly_item_id
AND msi.organization_id = bom.organization_id
AND msi2.inventory_item_id = bic.component_item_id
AND msi2.organization_id = msi.organization_id
AND bic.implementation_date IS NOT NULL
AND item.organization_id = 84
AND item.inventory_item_id > 0
UNION ALL
SELECT parent.parent_item_id
,parent.parent_item
,parent.parent_org_id
,bom.assembly_item_id
,msi.segment1 assembly_item
,bom.organization_id assembly_org_id
,bic.component_item_id
,msi2.segment1 component_item
,msi2.description component_item_description
,bic.implementation_date
,bic.disable_date
FROM recursiveBOM parent, apps.bom_bill_of_materials_v bom,
apps.bom_inventory_components_v bic, apps.mtl_system_items msi,
apps.mtl_system_items msi2
WHERE 1=1
AND bic.bill_sequence_id = bom.common_bill_sequence_id
AND msi.inventory_item_id = bom.assembly_item_id
AND msi.organization_id = bom.organization_id
AND msi2.inventory_item_id = bic.component_item_id
AND msi2.organization_id = msi.organization_id
AND bic.implementation_date IS NOT NULL
AND bom.assembly_item_id = parent.component_item_id
AND bom.organization_id = parent.assembly_org_id
AND bom.organization_id = 84
AND parent.assembly_org_id = 84
)
SELECT DISTINCT parent_item_id,parent_item,parent_org_id
,assembly_item_id
,assembly_item
,assembly_org_id
,component_item_id
,component_item
,component_item_description
,implementation_date
,disable_date
FROM recursiveBOM
) bom
WHERE oh.header_id = ol.header_id
AND ol.line_id = wdd.source_line_id
AND wdd.source_code = 'OE'
AND wda.delivery_detail_id = wdd.delivery_detail_id
AND wda.delivery_id = wnd.delivery_id
AND ol.line_id = ctl.interface_line_attribute6(+)
AND ctl.customer_trx_id = ct.customer_trx_id(+)
AND oh.order_type_id = ot.transaction_type_id
AND ol.inventory_item_id = items.inventory_item_id
AND ol.sold_to_org_id = cust_acct.cust_account_id
AND cust_acct.party_id = party.party_id
AND oh.end_customer_id = hca2.cust_account_id(+)
AND hca2.party_id = hp2.party_id(+)
AND items.inventory_item_id = mic.inventory_item_id(+)
AND items.organization_id = mic.organization_id(+)
AND mic.category_id = mc.category_id(+)
AND mic.category_set_id = ms.category_set_id(+)
and ol.line_id = dis.line_id(+)
and ol.header_id = dis.header_id(+)
AND bom.parent_item_id (+) = items.inventory_item_id
AND bom.parent_org_id (+) = items.organization_id `

Outer join operator not allowed with OR in my WHERE clause - Error: ORA-01719

I need to check for the conditions at the bottom, but I cannot change use OR because of the (+) that are involved. I did not set that part up, so I am not sure how to rearrange it. Can someone tell me what I could do to get those conditions to go through?
SELECT DISTINCT
t.tkt_sid,
ts.tkt_sts_dsc,
tp.prty_dsc,
a.agt_cont_nbr,
au_a.user_nm assigned_to,
t.rcd_lst_user_ts
FROM
afp_asd.tkt t,
afp_asd.tkt_prty tp,
afp_asd.tkt_sts ts,
afp_asd.tkt_type tt,
afp_asd.tkt_log tl,
afp_asd.agt a,
afp_asd.asd_user au_a,
afp_asd.asd_user au_c,
afp_asd.asd_user au_l,
afp_asd.asd_user au_log,
afp_asd.prb_area pa1,
afp_asd.prb_area pa2,
afp_asd.prb_area pa3,
afp_asd.mktg_org mo,
afp_asd.src_sys ss,
afp_asd.agt ofc,
afp_asd.co c,
afp_asd.agt_sts ast
WHERE (
t.prty_cd = tp.prty_cd
AND t.tkt_sts_cd = ts.tkt_sts_cd
AND t.tkt_type_cd = tt.tkt_type_cd
AND t.agt_sid = a.agt_sid
AND t.assigned_id = au_a.asd_user_id
AND t.rcd_crt_user_id = au_c.asd_user_id (+)
AND t.lst_updater_id = au_l.asd_user_id
AND t.tkt_sid = tl.tkt_sid
AND t.prb_area_sid = pa3.prb_area_sid
AND tl.rcd_crt_user_id = au_log.asd_user_id
AND pa3.prb_hier_sid = pa2.prb_area_sid (+)
AND pa2.prb_hier_sid = pa1.prb_area_sid (+)
AND a.mktg_org_cd = mo.mktg_org_cd
AND a.src_sys_cd = mo.src_sys_cd
AND a.src_sys_cd = ss.src_sys_cd
AND a.ofc_id = ofc.agt_cont_nbr (+)
AND a.src_sys_cd = ofc.src_sys_cd (+)
AND a.co_sid = c.co_sid (+)
AND a.agt_sts_cd = ast.agt_sts_cd
AND tl.rcd_lst_user_ts >= :b_start_date
AND t.user_grp_sid = :b_group_id
)
AND (
(TKT_STS_DSC NOT LIKE 'Completed')
OR (
tp.prty_dsc = 'High'
AND ts.tkt_sts_dsc = 'Pending'
AND t.rcd_lst_user_ts < SYSDATE- 2
)
OR (
t.rcd_lst_user_ts < SYSDATE- 3
AND ts.tkt_sts_dsc = 'In Progress'
AND tp.prty_dsc = 'High'
)
OR (
t.rcd_lst_user_ts < SYSDATE- 15
AND ts.tkt_sts_dsc = 'In Progress'
AND tp.prty_dsc = 'Medium'
)
OR (
t.rcd_lst_user_ts < SYSDATE- 28
AND ts.tkt_sts_dsc = 'In Progress'
AND tp.prty_dsc = 'Low'
)
OR (
t.rcd_lst_user_ts < SYSDATE- 7
AND ts.tkt_sts_dsc = 'Pending'
AND tp.prty_dsc = 'High'
)
OR (
t.rcd_lst_user_ts < SYSDATE- 21
AND ts.tkt_sts_dsc = 'Pending'
AND tp.prty_dsc = 'Medium'
)
OR (
t.rcd_lst_user_ts < SYSDATE- 43
AND ts.tkt_sts_dsc = 'Pending'
AND tp.prty_dsc = 'Low'
)
)
ORDER BY ASSIGNED_TO,
PRTY_DSC
Don't use the old FROM TableA,TableB WHERE ... join syntax. Just don't.
Instead, write out your joins individually:
FROM TableA
INNER JOIN TableB ON ...
LEFT JOIN TableC ON ...
This isn't just a general rant against the old syntax: using the new (I say "new", but it's more than 20 years old now), standard syntax will fix your problem in this case.