Oracle ebs 常用标准表
call fnd_global.APPS_INITIALIZE(1318,50583,401)
select fnd_profile.VALUE(\'ORG_ID\') FROM DUAL
select * from hr_operating_units hou where hou.organization_id=204;
----弹性域
select * from fnd_id_flexs
select * from fnd_id_flex_structures where id_flex_code=\'GL#\'
select * from fnd_id_flex_segments where id_flex_code=\'GL#\' and id_flex_num=50671
select * from fnd_profile_options_vl
select * from fnd_concurrent_programs 程序表
select * from fnd_concurrent_requests 请求表
select * from fnd_concurrent_processes 进程表
一、INV(库存)
子库存: mtl_secondary_inventories
事物处理: mtl_material_transactions mmt
事务处理来源类型:mtl_txn_source_types
事务处理类型: mtl_transaction_types
库存组织视图(带公司): org_organization_definitions
库存组织基表:HR_ALL_ORGANIZATION_UNITS
组织参数: mtl_parameters
事务处理批次: MTL_TRANSACTION_LOT_NUMBERS
事务处理序列: mtl_serial_numbers
物料: MTL_SYSTEM_ITEMS_B
批次:mtl_lot_numbers
货位: MTL_ITEM_LOCATIONS
会计期: gl_periods
物料价钱: CST_ITEM_COSTS
物料现有量: mtl_onhand_quantities
账户别名:MTL_GENERIC_DISPOSITIONS
库存期间表: org_acct_periods
物料事务处理接口表:
mtl_TRANSACTIONS_INTERFACE
MTL_MATERIAL_TRANSACTIONS_TEMP
mtl_transaction_lots_temp
<1>.获取事务处理来源:
BEGIN
inv_object_genealogy.getsource(mmt.organization_id,
mmt.transaction_source_type_id,
mmt.transaction_source_id);
END ;
<2>.物料搬运单行视图: mtl_txn_request_lines_v
行上的销售订单表: mtl_sales_orders 使用 sales_order_id 关联 行视图的 txn_source_id
<3>.库存现有量界面按照LPN查找时的sql里面包含LPN.LPN_CONTEXT IN (1, 9, 11)
<4>.事务处理来源是销售订单:mmt. trx_source_line_id = oe_order_lines_all. line_id
二、值集
fnd_flex_values_vl,
fnd_flex_value_sets
三、lookup_code
fnd_lookup_values_vl
四、供应商
供应商头信息:ap_suppliers
供应商地点信息:ap_supplier_sites_all
供应商税率: hz_code_assignments
供应商银行账号: iby_ext_bank_accounts
供应商税信息:zx_party_tax_profile
供应商银行支行: iby_ext_bank_branches_v
供应商银行: iby_ext_banks_v
银行账户的拥有者: iby_account_owners
银行账户所在的地点: iby_pmt_instr_uses_all
供应商联系人: ap_supplier_contacts
供应商联系人电话等信息: hz_contact_points
供应商地点附加信息: pos_supp_prof_ext_b
供应商付款信息: iby_external_payees_all
五、HR(人员)
员工基表: per_people_f
员工视图:hr_employees
用户:fnd_user
员工分配表:per_all_assignments_f
员工职务表:per_jobs
员工职务语言表:per_jobs_tl
员工职位表:per_all_positions
员工职位多语言表:hr_all_positions_f_tl
代码:hr_lookups
地区:fnd_territories_tl
六、GL(总账)
账户科目段: gl_code_combinations
账套表: gl_sets_of_books
日记帐批表:gl_je_batches
日记账头表: gl_je_headers
日记账行表:gl_je_lines
日记帐科目余额表:gl_balances
凭证分类表:gl_je_categories
凭证来源表:gl_je_sources
总账导入参考信息表(GL与XLA之间的关联):gl_import_references
子分类帐头:xla_ae_headers
子分类帐行:xla_ae_lines
子分类帐事务处理实体信息:xla_transaction_entities
子分类帐事件表:xla_events xe --对客户合并的需要限制 xe.process_status_code not in (\'P\',\'F\')
子分类帐分配连接信息(XLA和AR之间的关联):xla_distribution_links
获取期间的下个期间:gl_period_statuses_pkg.get_next_period
七、AP(应付)
发票(invoice)头表:ap_invoices(ap_invoices_all)
发票行表:ap_invoice_lines(ap_invoice_lines_all)
发票(invoice)分配行表:ap_invoice_distributions_all
付款信息表:ap_invoice_payments_all
付款检查表:ap_checks_all
付款计划表:ap_payment_schedules_all
单据表:ap_check_stocks_all
支行表:ap_bank_branches
银行账户表:ap_bank_accounts_all
核销历史表:AP_PREPAY_HISTORY_ALL
核销历史分配表:AP_PREPAY_APP_DISTS
八、FA(资产)
资产信息表:fa_additions
资产类别表:fa_categories
资产账簿表:fa_books
资产分配信息表:fa_distribution_history
折旧信息表:fa_deprn_detail
折旧事务表:fa_transaction_headers
资产分配地点:fa_locations
九、AR(应收)
事务处理批表:ar_batches_all
应收发票头表:ra_customer_trx_all
应收发票行表:ra_customer_trx_lines_all
应收发票分配表:ra_cust_trx_line_gl_dist_all
收款信息表:ar_cash_receipts_all
核销信息表:ar_receivable_applications_all
调整表:ar_payment_schedules_all
会计分录表:ar_adjustments_all
付款计划表:ar_distributions_all
十、OE(销售模块)
销售订单头表:oe_order_headers_all
销售订单行表:oe_order_lines_all
客户信息表:ra_customers=> ar_customers
地址信息表:ra_addresses_all
用户信息表:ra_site_uses_all
发送信息表:wsh_new_deliveries
销售订单状态lookup:oe_lookups
销售订单头,行类型: oe_transaction_types_tl
销售订单行的FLOW_STATUS_CODE真实值:
l_line_status := oe_line_status_pub.get_line_status(l.line_id,
l.flow_status_code);
发运事务处理表: wsh_delivery_details wdd
物料搬运单行表: mtl_txn_request_lines mtrl
物料搬运单头表:mtl_txn_request_headers mtrh
交货表: wsh_delivery_assignments wda
和物料事务处理表: mtl_material_transactions mmt 关联:wdd. transaction_id = mmt. transaction_id
发运事务处理和物料搬运单关联:wdd.move_order_line_id = mtrl.line_id
mtrl.header_id = mtrh.header_id
wdd. delivery_detail_id = wda. delivery_detail_id
十一、PO(采购)
采购订单头表:po_headers_all pha
采购订单行表:po_lines_all pla
采购申请头表:po_requisition_headers_all prh
采购申请行表:po_requisition_lines_all prl prl
采购申请人表: per_people_f papf
采购申请行类型表: po_line_types plt
分配表:po_distributions_all
发送表:po_releases_all
采购接收头表:rcv_shipment_headers rsh
采购接收行表:rcv_shipment_lines rsl
采购接收事务处理表:rcv_transactions
采购供应商表:po_vendors
采购供应商地点表:po_vendor_sites_all
表关联:
prh.requisition_header_id = prl.requisition_header_id
--关联采购申请人
prh.preparer_id = papf.person_id
AND trunc ( SYSDATE ) BETWEEN papf.effective_start_date AND
papf.effective_end_date
--关联采购申请行类型
plt.line_type_id = prl.line_type_id
--关联采购订单
rsl. po_line_id = pla. po_line_id
rsl. po_header_id = pha. po_header_id
采购接收事务处理类型
SELECT plc.lookup_code,
plc.lookup_type,
plc.displayed_field,
plc.description,
plc.enabled_flag
FROM po_lookup_codes plc
WHERE plc.lookup_type LIKE \'RCV TRANSACTION TYPE\'
--
采购申请申请人:
SELECT per.full_name,
per.person_id employee_id,
per.employee_number employee_num,
pb.name
FROM per_workforce_current_x per , per_business_groups_perf pb
WHERE (per.business_group_id = pb.business_group_id AND
per.assignment_type IN
( \'E\' ,
decode ( nvl (fnd_profile.value( \'HR_TREAT_CWK_AS_EMP\' ), \'N\' ),
\'Y\' ,
\'C\' ,
\'E\' )))
--AND per.person_id = 1032
ORDER BY per.full_name;
--
采购订单行已承诺字段取值
po_line_locations_all.PROMISED_DATE
十二、XLE
法人主体: xle_entity_profiles
十三、成本
成本组: cst_cost_groups
十四、附件
附件主要视图:fnd_attached_docs_form_vl
附件主要表:fnd_attached_documents fad
附件表: fnd_documents fd
附件短文本表:fnd_documents_short_text fst
附件长文本表:fnd_documents_long_text
附件数据类型表:fnd_document_datatypes dat
附件类别表: fnd_document_categories_tl dct
表关联:
fad.document_id = fd.document_id
--
dct.category_id = fd.category_id
AND dct.language = userenv ( \'LANG\' )
--
fd.datatype_id = dat.datatype_id
AND dat.language = userenv ( \'LANG\' )
--
fd.media_id = fst.media_id
SELECT * FROM fnd_attached_documents;--系列的表保存我们在开发员职责里面的附件定义
SELECT * FROM fnd_documents;--系列的表保存最终用户的具体的附件业务数据
SELECT * FROM fnd_lobs;--file类型的附件存储在fnd_lobs表中
--fnd_documents_tl.media_id可以关联到fnd_lobs.file_id、fnd_documents_long_text.media_id、fnd_documents_shot_text.media_id取得相应的附件内容
--应用开发员配置
SELECT * FROM fnd_document_entities t where t.table_name=\'CUX_INV_WH_MANAGER_HEADER\'; --文档实体
SELECT * FROM fnd_document_categories;--单据类别
SELECT * FROM fnd_attachment_functions t WHERE t.function_name = \'CUXWHMANAGER\' ORDER BY t.creation_date desc;--附件功能
SELECT * FROM fnd_attachment_blk_entities t WHERE t.data_object_code=\'CUX_INV_WH_MANAGER_HEADER\' ORDER BY t.creation_date DESC;--附件功能-块
SELECT * FROM fnd_attachment_blocks t WHERE t.block_name=\'MANAGER_HEADER\';--附件和功能的关系
SELECT * FROM fnd_doc_category_usages t WHERE t.attachment_function_id=1004818;
--附件应用相关的表SELECT * FROM fnd_attached_documents;--实体名称SELECT * FROM fnd_documents;--文档SELECT * FROM fnd_lobs t ORDER BY t.file_name;--大对象SELECT * FROM fnd_attached_documents t WHERE t.creation_date LIKE TO_DATE(\'2011-05-25\', \'YYYY-MM-DD\') AND t.entity_name = \'CUX_INV_WH_MANAGER_HEADER\'; --附件SELECT * FROM fnd_documents fd WHERE fd.document_id IN (117961, 117960, 117959, 117958, 117957);SELECT * FROM fnd_lobs t WHERE t.file_id IN (496821, 496827, 496829);--文件格式。SELECT * FROM fnd_documents_long_text t WHERE t.media_id = 1001; --长文本SELECT * FROM fnd_documents_short_text t WHERE t.media_id = 2; --短文本
十五、WIP
离散任务表: wip_discrete_jobs wdj
工序表: wip_operations wo
工序部门表: bom_departments bd
离散任务名称表:wip_entities
移动事务处理:wip_move_transactions
资源事务处理表: wip_transactions
表关联:
--
wdj.organization_id = wo.organization_id
AND wdj.wip_entity_id = wo.wip_entity_id
--
bd.department_id = wo.department_id
十六、QA
质量收集计划表:qa_plans qp
质量收集要素PROMPT表:qa_plan_chars qpc
质量收集要素名称表:qa_chars qc
质量收集要素类型表:fnd_common_lookups fl
表关联:
qp.plan_id = qpc.plan_id
qpc.char_id = qc.char_id
qc.char_type_code = fl.lookup_code
AND fl.lookup_type = \'ELEMENT_TYPE\'
AND fl.application_id = 250
十七、WMS
LPN表:wms_license_plate_numbers
内容LPN表: wms_lpn_contents
挑库发放规则: wsh_picking_rules
物料搬运单头表: mtl_txn_request_headers h
物料搬运单行表: mtl_txn_request_lines l
物料搬运单行分配表: mtl_material_transactions_temp t
LPN表中的LPN_CONTEXT字段取值,LOOKUP_TYPE: WMS_LPN_CONTEXT
表关联:h.header_id = l.header_id
l.line_id = t.move_order_line_id
标准程序包
1、物料单位转换:inv_convert.inv_um_convert --作用:返回折算率
1)凭证主要信息
SELECT gjb.NAME "批名称",
gjh.name "头名",
gjcv.description "类别",
gjsv.description "来源",
gjh.CURRENCY_CODE "币种",
gjh.CURRENCY_CONVERSION_RATE "汇率",
gjl.ENTERED_DR "原币借" ,
gjl.ENTERED_CR "原币贷" ,
gjl.ACCOUNTED_DR "本币借" ,
gjl.ACCOUNTED_CR "本币贷" ,
gcc.SEGMENT1 "(来往)公司代码??"
FROM gl_je_batches gjb,
gl_je_headers gjh,
gl_je_lines gjl,
gl_je_categories_vl gjcv,
gl_je_sources_vl gjsv,
gl_code_combinations gcc
WHERE gjb.je_batch_id=gjh.je_batch_id
AND gjh.JE_HEADER_ID=gjl.JE_HEADER_ID
AND gjh.JE_CATEGORY =gjcv.je_category_name
AND gjh.JE_SOURCE=gjsv.je_source_name
AND gjl.CODE_COMBINATION_ID=gcc.code_combination_id;
Select d.user_name,
d.description,
cux_common_utl2.get_user_pass(p_ebs_user => d.user_name)
From fnd_user d
Where d.user_name = \'00166899\';
---EBS值集,弹性域常用表
--取固定资产 科目 组合
select * from FA_ADDITIONS_V a where a.ASSET_NUMBER=\'100008813\';
Select a.asset_number,
c.segment1|| \'.\' ||
c.segment2|| \'.\' ||
c.segment3|| \'.\' ||
c.segment4|| \'.\' ||
c.segment5|| \'.\' ||
c.segment6|| \'.\' ||
c.segment7 a,
(Select f.description
From fnd_flex_values_vl f
Join fnd_id_flex_segments i On (f.flex_value_set_id =
i.flex_value_set_id)
Where f.flex_value = c.segment1
And i.id_flex_num = 101
And i.id_flex_code = \'LOC#\'
And i.application_column_name = upper(\'SEGMENT1\')
And rownum = 1) || \'.\' ||
(Select f.description
From fnd_flex_values_vl f
Join fnd_id_flex_segments i On (f.flex_value_set_id =
i.flex_value_set_id)
Where f.flex_value = c.segment2
And i.id_flex_num = 101
And i.id_flex_code = \'LOC#\'
And i.application_column_name = upper(\'SEGMENT2\')
And rownum = 1) || \'.\' ||
(Select f.description
From fnd_flex_values_vl f
Join fnd_id_flex_segments i On (f.flex_value_set_id =
i.flex_value_set_id)
Where f.flex_value = c.segment3
And i.id_flex_num = 101
And i.id_flex_code = \'LOC#\'
And i.application_column_name = upper(\'SEGMENT3\')
And rownum = 1) || \'.\' ||
(Select f.description
From fnd_flex_values_vl f
Join fnd_id_flex_segments i On (f.flex_value_set_id =
i.flex_value_set_id)
Where f.flex_value = c.segment4
And i.id_flex_num = 101
And i.id_flex_code = \'LOC#\'
And i.application_column_name = upper(\'SEGMENT4\')
And rownum = 1) || \'.\' ||
(Select f.description
From fnd_flex_values_vl f
Join fnd_id_flex_segments i On (f.flex_value_set_id =
i.flex_value_set_id)
Where f.flex_value = c.segment5
And i.id_flex_num = 101
And i.id_flex_code = \'LOC#\'
And i.application_column_name = upper(\'SEGMENT5\')
And rownum = 1) || \'.\' ||
(Select f.description
From fnd_flex_values_vl f
Join fnd_id_flex_segments i On (f.flex_value_set_id =
i.flex_value_set_id)
Where f.flex_value = c.segment6
And i.id_flex_num = 101
And i.id_flex_code = \'LOC#\'
And i.application_column_name = upper(\'SEGMENT6\')
And rownum = 1) || \'.\' ||
(Select f.description
From fnd_flex_values_vl f
Join fnd_id_flex_segments i On (f.flex_value_set_id =
i.flex_value_set_id)
Where f.flex_value = c.segment7
And i.id_flex_num = 101
And i.id_flex_code = \'LOC#\'
And i.application_column_name = upper(\'SEGMENT7\')
And rownum = 1) b
From fa_additions_v a
Join fa_distribution_history b On (a.asset_id = b.asset_id)
Join fa_locations c On (b.location_id = c.location_id)
Where a.ASSET_ID=100061889--a.asset_number = \'100008813\';
select msi.segment1 物料编码,
-- msi.inventory_item_id return_item_id,
msi.primary_unit_of_measure 单位,
msi.description 描述,
pha.segment1 订单号,
pha.TYPE_LOOKUP_CODE 类型,
-- pha.po_header_id,
pv.vendor_name 供应商名称,
-- pv.vendor_id,
--.po_line_id,
pla.LINE_NUM 行,
-- pll.LINE_LOCATION_ID,
pll.quantity 行数量,
rt.QUANTITY 交易数量,
-- rt.TRANSACTION_ID rcv_transacion_id,
-- rt.SHIPMENT_HEADER_ID,
-- rt.SHIPMENT_LINE_ID,
-- rt.DESTINATION_TYPE_CODE,
-- RT.SUBSTITUTE_UNORDERED_CODE,
RT.TRANSACTION_TYPE 交易类型,
-- RT.PO_REVISION_NUM,
RT.PO_UNIT_PRICE 价格,
rsh.RECEIPT_NUM 收据量,
rsl.LINE_NUM 接据行号,
RT.SUBINVENTORY 子库,
RT.Transaction_Date 交易日期
from po.rcv_transactions rt,
po.po_line_locations_all pll,
po.Rcv_Shipment_Lines Rsl,
po.Rcv_Shipment_headers rsh,
po.po_lines_all pla,
po.po_headers_all pha,
inv.mtl_system_items_b msi,
po.po_vendors pv
where pha.PO_HEADER_ID = pla.po_header_id and
pla.PO_LINE_ID = pll.PO_LINE_ID and
pha.VENDOR_ID = pv.VENDOR_ID and
pla.item_id = msi.inventory_item_id and
rt.PO_HEADER_ID = pha.PO_HEADER_ID and
rt.PO_LINE_ID = pla.PO_LINE_ID and
rt.PO_LINE_LOCATION_ID = pll.LINE_LOCATION_ID and
msi.organization_id = X and
trunc(RT.Transaction_Date) >= to_date(\'20**-01-01\',\'yyyy-mm-dd\') and
trunc(rT.Transaction_Date) < to_date(\'20**-01-32\',\'yyyy-mm-dd\') and
rt.TRANSACTION_TYPE = \'RETURN TO VENDOR\' and
RT.SHIPMENT_LINE_ID = RSL.SHIPMENT_LINE_ID and
rsh.SHIPMENT_HEADER_ID = rsl.SHIPMENT_HEADER_ID and
rt.SHIPMENT_HEADER_ID = rsh.SHIPMENT_HEADER_ID
值集
select * from fnd_flex_value_sets
select * from fnd_flex_values
select * from fnd_flex_values_vl
弹性域
select * from fnd_id_flexs
select * from fnd_id_flex_structures where id_flex_code=\'GL#\'
select * from fnd_id_flex_segments where id_flex_code=\'GL#\' and id_flex_num=50671
select * from fnd_profile_options_vl
select * from fnd_concurrent_programs 程序表
select * from fnd_concurrent_requests 请求表
select * from fnd_concurrent_processes 进程表
--取OU
SELECT * FROM hr_all_organization_units A;
select*
from wf_item_types_vl a where a.display_name like \'CUX%\';--保存工作流的定义,即类
select*
from wf_items --保存实际的工作流,或者说工作流的对象实例
select*
from wf_item_attribute_values --保存工作流实例的attribute最新值
select*
from wf_item_activity_statuses --保存工作流实例的各个activity的状态,比如完成否,返回值
select*
from wf_notifications --保存工作流实例的notifications消息,基本是按顺序的,可以看发给谁了
select*
from wf_roles --角色视图,工作流引用角色的依据,有mail地址等信息
select*
from wf_item_attribute_values
select*
from wf_notification_attributes
select*
from wf_item_activity_statuses
select*
from wf_item_activity_statuses_h
select*
from wf_items
select*
from wf_comments
select*
from wf_notifications
select*
from wf_user_role_assignments
select*
from wf_local_user_roles
select*
from wf_attribute_cache
select*
from wf_user_roles --用户和角色关系视图,工作流可以根据它进行“群发”
select*
from all_tab_columns a where a.table_name like \'CUX%\' AND A.COLUMN_NAME LIKE \'COA_SUB%\';
SELECT * FROM ALL_ALL_TABLES USER_TABLES
select*
from all_tab_columns a where a.table_name like \'CUX%\' AND A.COLUMN_NAME LIKE \'COA_SUB%\'
1、 查询EBS 系统在线人数
SELECT U.USER_NAME,
APP.APPLICATION_SHORT_NAME,
FAT.APPLICATION_NAME,
FR.RESPONSIBILITY_KEY,
FRT.RESPONSIBILITY_NAME,
FFF.FUNCTION_NAME,
FFT.USER_FUNCTION_NAME,
ICX.FUNCTION_TYPE,
ICX.FIRST_CONNECT,
ICX.LAST_CONNECT
FROM ICX_SESSIONS ICX,
FND_USER U,
FND_APPLICATION APP,
FND_APPLICATION_TL FAT,
FND_RESPONSIBILITY FR,
FND_RESPONSIBILITY_TL FRT,
FND_FORM_FUNCTIONS FFF,
FND_FORM_FUNCTIONS_TL FFT
WHERE 1 = 1
AND U.USER_ID = ICX.USER_ID
AND ICX.RESPONSIBILITY_APPLICATION_ID = APP.APPLICATION_ID
AND FAT.APPLICATION_ID = ICX.RESPONSIBILITY_APPLICATION_ID
AND FAT.LANGUAGE = \'ZHS\'
AND FR.APPLICATION_ID = ICX.RESPONSIBILITY_APPLICATION_ID
AND FR.RESPONSIBILITY_ID = ICX.RESPONSIBILITY_ID
AND FRT.LANGUAGE = \'ZHS\'
AND FRT.APPLICATION_ID = ICX.RESPONSIBILITY_APPLICATION_ID
AND FRT.RESPONSIBILITY_ID = ICX.RESPONSIBILITY_ID
AND FFF.FUNCTION_ID = ICX.FUNCTION_ID
AND FFT.FUNCTION_ID = ICX.FUNCTION_ID
AND ICX.DISABLED_FLAG != \'Y\'
AND ICX.PSEUDO_FLAG = \'N\'
AND (ICX.LAST_CONNECT +
DECODE(FND_PROFILE.VALUE(\'ICX_SESSION_TIMEOUT\'),
NULL,
ICX.LIMIT_TIME,
0,
ICX.LIMIT_TIME,
FND_PROFILE.VALUE(\'ICX_SESSION_TIMEOUT\') / 60) / 24) >
SYSDATE
AND ICX.COUNTER < ICX.LIMIT_CONNECTS;
2、 查询数据库表对象
SELECT *
FROM dba_objects db
WHERE db.object_type = \'TABLE\' --可以变为 其他对象如 VI
AND db.object_name LIKE \'%INTERFACE%\'; --查询接口表
3、EBS 系统当前完成请求时间监测
SELECT
REQUEST_ID,
PROGRAM,
round((to_number(LAST_UPDATE_DATE-REQUESTED_START_DATE)*24*60)/60,2) 待定时间,
round((to_number(ACTUAL_COMPLETION_DATE-LAST_UPDATE_DATE)*24*60)/60,2) 运行时间,
\'小时\' 单位,
REQUESTED_START_DATE 提交日期,
LAST_UPDATE_DATE 起始日期,
ACTUAL_COMPLETION_DATE 完成日期,
PROGRAM_SHORT_NAME,
ARGUMENT_TEXT,
COMPLETION_TEXT,
RESPONSIBILITY_APPLICATION_ID,
STATUS_CODE,
PRIORITY_REQUEST_ID,
REQUESTOR
FROM FND_CONC_REQ_SUMMARY_V
WHERE PHASE_CODE = \'C\'
and (nvl(request_type, \'X\') != \'S\')
and (trunc(request_date) >= trunc(sysdate - 7))
and round((to_number(ACTUAL_COMPLETION_DATE-LAST_UPDATE_DATE)*24*60)/60,2)>0.1 --6分钟以上程序
order by 运行时间 DESC,PROGRAM_SHORT_NAME,REQUEST_ID DESC
4、查询死锁的Session SQL 语句
SELECT dob.OBJECT_NAME Table_Name,
lo.LOCKED_MODE,
lo.SESSION_ID,
vss.SERIAL#,
vps.spid,
vss.action Action,
vss.osuser OSUSER,
vss.process AP_PID,
VPS.SPID DB_PID,
\'alter system kill session \' || \'\'\'\' || lo.SESSION_ID || \',\' ||
vss.SERIAL# || \'\'\';\' kill_command
from v$locked_object lo, dba_objects dob, v$session vss, V$PROCESS VPS
where lo.OBJECT_ID = dob.OBJECT_ID
and lo.SESSION_ID = vss.SID
AND VSS.paddr = VPS.addr
/* AND dob.OBJECT_NAME like \'AP_%\' */
/* AND vss.client_info like \'OU_ID%\' --OU_ID:就是指所在企业的OU的ID*/
order by 2, 3, DOB.object_name;
5、 查询并发程序是否启动跟踪功能-trc文件对数据库性能有影响
SELECT ICON_NAME,
ROW_ID,
USER_CONCURRENT_PROGRAM_NAME,
ENABLED_FLAG,
CONCURRENT_PROGRAM_NAME,
DESCRIPTION,
EXECUTION_OPTIONS,
REQUEST_PRIORITY,
INCREMENT_PROC,
RUN_ALONE_FLAG,
RESTART,
ENABLE_TRACE,
NLS_COMPLIANT,
OUTPUT_FILE_TYPE,
SAVE_OUTPUT_FLAG,
PRINT_FLAG,
MINIMUM_WIDTH,
MINIMUM_LENGTH,
OUTPUT_PRINT_STYLE,
REQUIRED_STYLE,
PRINTER_NAME,
APPLICATION_ID,
LAST_UPDATE_DATE,
EXECUTION_METHOD_CODE,
LAST_UPDATE_LOGIN,
CREATION_DATE,
CREATED_BY,
EXECUTABLE_ID,
LAST_UPDATED_BY,
EXECUTABLE_APPLICATION_ID,
CONCURRENT_PROGRAM_ID,
CONCURRENT_CLASS_ID,
CLASS_APPLICATION_ID,
ARGUMENT_METHOD_CODE,
REQUEST_SET_FLAG,
QUEUE_METHOD_CODE,
QUEUE_CONTROL_FLAG,
SRS_FLAG,
CD_PARAMETER,
MLS_EXECUTABLE_ID,
MLS_EXECUTABLE_APP_ID,
RESOURCE_CONSUMER_GROUP,
ROLLBACK_SEGMENT,
OPTIMIZER_MODE,
SECURITY_GROUP_ID,
ENABLE_TIME_STATISTICS,
REFRESH_PORTLET,
PROGRAM_TYPE,
ACTIVITY_SUMMARIZER,
ALLOW_MULTIPLE_PENDING_REQUEST,
DELETE_LOG_FILE,
TEMPLATE_APPL_SHORT_NAME,
TEMPLATE_CODE,
MULTI_ORG_CATEGORY
FROM FND_CONCURRENT_PROGRAMS_VL
WHERE queue_control_flag = \'N\'
--and (APPLICATION_ID = 555)
-- and (CONCURRENT_PROGRAM_ID = 46914)
and ENABLE_TRACE = \'Y\'
order by application_id, user_concurrent_program_name
6、 查询 EBS 系统物料净重、毛重
select distinct MSI.SEGMENT1 || \',\' 物料编码,
MSI.DESCRIPTION 物料名称,
MSI.UNIT_WEIGHT 毛重,
MSI.WEIGHT_UOM_CODE 毛重单位,
MSI.UNIT_VOLUME 净重,
MSI.VOLUME_UOM_CODE 净重单位
from MTL_SYSTEM_ITEMS_FVL MSI
where MSI.INVENTORY_ITEM_STATUS_CODE = \'Active\'
and MSI.SEGMENT1 like \'82%\' --物料编码
--and (MSI.UNIT_WEIGHT is null or MSI.UNIT_VOLUME is null)
order by 1
7、月结各模块关闭情况查询SQL
-----库存模块
SELECT oap.STATUS 关闭状态,
oap.PERIOD_NAME 所属期间,
oap.ORGANIZATION_ID 组织ID,
(select name from hr_organization_units x where x.ORGANIZATION_ID = oap.ORGANIZATION_ID) 组织名称,
oap.LAST_UPDATE_DATE 执行关闭日期,
(select hre.full_name from hr_employees_all_v hre,fnd_user fu where hre.employee_id = fu.employee_id and fu.user_id = oap.LAST_UPDATED_BY) 执行关闭人,
oap.CREATED_BY
FROM ORG_ACCT_PERIODS_V oap
WHERE
(oap.PERIOD_NUMBER = 6) --月份
and (oap.PERIOD_YEAR = 2012) -- 年份
and oap.ORGANIZATION_ID <> 0
order by oap.ORGANIZATION_ID,oap.PERIOD_NAME desc,oap.Status desc
-----------------------------------------------------------------其他模块------------------------------------------------------------
SELECT gps.PERIOD_NAME 所属期间,
(select faa.Application_name
from fnd_application_all_view faa
where faa.APPLICATION_ID = gps.APPLICATION_ID) 模块名称,
gps.LEDGER_ID 分类账套,
gps.SHOW_STATUS 期间状态,
(select hre.full_name from hr_employees_all_v hre,fnd_user fu where hre.employee_id = fu.employee_id and fu.user_id = gps.LAST_UPDATED_BY) 执行关闭人,
gps.LAST_UPDATE_DATE 最后次操作时间
FROM GL_PERIOD_STATUSES_V gps
WHERE --gps.application_id = 101
--AND
gps.ledger_id = 2021
AND gps.closing_status != \'N\'
and (gps.LEDGER_ID = 2021)
order by gps.APPLICATION_ID,gps.PERIOD_NAME desc
8、总账库存科目明细追溯SQL
SELECT xel.subinventory_code 子库,
decode(xel.lot_number,\'\',\'来源,非库存\') 批次,
cux_public_pkg.get_item_segment1(81, xeh.inventory_item_id) 物料编码,
cux_public_pkg.get_item_description(81, xeh.inventory_item_id) 物料品名,
xeh.transaction_uom 单位,
sum(xdl.unrounded_entered_dr)借方金额,
sum(xdl.unrounded_entered_cr) 贷方金额
FROM XLA_AE_HEADERS AH,
XLA_AE_LINES AL,
xla_distribution_links xdl,
gmf_xla_extract_headers xeh,
gmf_xla_extract_lines xel
WHERE AH.AE_HEADER_ID = AL.AE_HEADER_ID
--AND AH.APPLICATION_ID = 555
AND AH.PERIOD_NAME = \'2012-03\'
and al.CODE_COMBINATION_ID =
(select k.code_combination_id
from gl_code_combinations_kfv k
where k.concatenated_segments = \'10.0.141103.0.0.0.0\')
and al.ae_header_id = xdl.ae_header_id
and al.ae_line_num = xdl.ae_line_num
and al.application_id = xdl.application_id
and xdl.source_distribution_id_num_1 = xel.line_id(+)
and xel.header_id = xeh.header_id(+)
group by xel.subinventory_code,
xel.lot_number,
xeh.inventory_item_id,
xeh.transaction_uom
9、应收事物处理删除 SQL 语句
--组织表
select * from hr_organization_units_v
--AR 事物处理安全性限制
begin
mo_global.set_policy_context(\'S\',\'107\');
end;
-- 备份事物处理
create table bak.RA_CUSTOMER_TRX_ALL20120619 as
select * from RA_CUSTOMER_TRX_ALL where TRX_NUMBER = \'10102672\'
-- 检测备份情况
select * from bak.RA_CUSTOMER_TRX_ALL20120619
-- 修改事物处理
select t.*,t.rowid from RA_CUSTOMER_TRX_ALL t where TRX_NUMBER = \'10102672\'
-- 备份事物处理行
create table bak.RA_CUSTOMER_TRX_LINES_all0619 as
SELECT *
FROM RA_CUSTOMER_TRX_LINES_all where CUSTOMER_TRX_ID = 978317 --CUSTOMER_TRX_LINE_ID
-- 检测备份数据
select * from bak.RA_CUSTOMER_TRX_LINES_all0619
-- 修改事物处理行
SELECT t.*,t.rowid
FROM RA_CUSTOMER_TRX_LINES_all t where CUSTOMER_TRX_ID = 978317 --CUSTOMER_TRX_LINE_ID
-- 备份应收事物处理分配行
create table bak.RA_CUST_TRX_LINE_GL_DIST0619 as
select *
from RA_CUST_TRX_LINE_GL_DIST where CUSTOMER_TRX_ID = 978317
-- 检测备份数据
select * from bak.RA_CUST_TRX_LINE_GL_DIST0619
-- 修改应收事物处理分配行
select t.*,t.rowid
from RA_CUST_TRX_LINE_GL_DIST t where CUSTOMER_TRX_ID = 978317
-- 备份应收事物处理-税行
create table bak.ZX_LINES20120619 as
select * from ZX_LINES where TRX_NUMBER = \'10102672\'
-- 检测备份数据
select * from bak.ZX_LINES20120619
-- 修改应收事物处理-税行
select t.*,t.rowid from ZX_LINES t where TRX_NUMBER = \'10102672\'
10、BC_SQL_用户与职责与请求关系语句
---------------------------------------------------------------------------------------------------
--本SQL获取的是用户对应职责职责对应请求组、请组下对应“程序”【除程序以外还有 集、应用等】
--本SQL也可以简单理解为 获取用户可以提交什么请求,(请求可以简单理解为报表,但请求不是报表,包含关系)
--SQL addTime 2012-05-14 13:11, create by sunyukun
---------------------------------------------------------------------------------------------------
select fu.user_ID,
fu.user_name,
fu.start_date,
fu.END_DATE,
fu.description,
fe.last_name,
fr.RESPONSIBILITY_NAME,
fr.description, --职责描述
fr.start_date,
fr.END_DATE,
frg.request_group_name, ---- 请求组名称
frg.description requestdsc, ---- 请求组描述
fr.menu_id, ---- 菜单 ID
REQUEST_UNIT_TYPE, ---- 请求类型
fcp.user_concurrent_program_name, ---请求并发程序名
decode(fcp.EXECUTION_METHOD_CODE,
\'H\',
\'主机\',
\'S\',
\'立即\',
\'J\',
\'Java 存储过程\',
\'K\',
\'Java 并发程序\',
\'M\',
\'多语言功能\',
\'P\',
\'Oracle Reports\',
\'I\',
\'PL/SQL 存储过程\',
\'B\',
\'请求集阶段函数\',
\'A\',
\'派生\',
\'L\',
\'SQL*Loader 程序\',
\'Q\',
\'SQL*Plus\',
\'E\',
\'Perl 并发程序\')
from fnd_user fu,
hr_employees fe,
FND_USER_RESP_GROUPS_DIRECT ugd,
FND_RESPONSIBILITY_VL fr,
fnd_request_groups frg,
FND_REQUEST_GROUP_UNITS frgu,
FND_CONCURRENT_PROGRAMS_VL fcp
where to_char(fu.creation_date, \'yyyy\') >= \'2008\'
and fu.employee_id = fe.employee_id(+) --用户与职员关系
and fu.user_id = ugd.user_id
and ugd.RESPONSIBILITY_ID = fr.responsibility_id
and ugd.RESPONSIBILITY_APPLICATION_ID = fr.APPLICATION_ID --- 以上用户与职责关系
and fr.request_group_id = frg.request_group_id(+)
and fr.group_application_id = frg.application_ID(+) --- 以上是请求组和职责关系
and frgu.application_id(+) = frg.application_ID
and frg.request_group_id = frgu.request_group_id(+) --- 以上是请求组中间表与职责
and fcp.CONCURRENT_PROGRAM_ID = frgu.REQUEST_UNIT_ID
and frgu.UNIT_application_id = fcp.application_id
and user_name = \'SUNYUKUN\' --- \'SUNYUKUN\' 登录用户名,可变量
order by User_id,
Responsibility_name
11、应收发票相关 脚本
--组织表
select * from hr_organization_units_v
--AR 事物处理安全性限制
begin
mo_global.set_policy_context(\'S\',\'107\');
end;
-- 备份事物处理
create table bak.RA_CUSTOMER_TRX_ALL20120619 as
select * from RA_CUSTOMER_TRX_ALL where TRX_NUMBER = \'10102672\'
-- 检测备份情况
select * from bak.RA_CUSTOMER_TRX_ALL20120619
-- 修改事物处理
select t.*,t.rowid from RA_CUSTOMER_TRX_ALL t where TRX_NUMBER = \'10102672\'
-- 备份事物处理行
create table bak.RA_CUSTOMER_TRX_LINES_all0619 as
SELECT *
FROM RA_CUSTOMER_TRX_LINES_all where CUSTOMER_TRX_ID = 978317 --CUSTOMER_TRX_LINE_ID
-- 检测备份数据
select * from bak.RA_CUSTOMER_TRX_LINES_all0619
-- 修改事物处理行
SELECT t.*,t.rowid
FROM RA_CUSTOMER_TRX_LINES_all t where CUSTOMER_TRX_ID = 978317 --CUSTOMER_TRX_LINE_ID
-- 备份应收事物处理分配行
create table bak.RA_CUST_TRX_LINE_GL_DIST0619 as
select *
from RA_CUST_TRX_LINE_GL_DIST where CUSTOMER_TRX_ID = 978317
-- 检测备份数据
select * from bak.RA_CUST_TRX_LINE_GL_DIST0619
-- 修改应收事物处理分配行
select t.*,t.rowid
from RA_CUST_TRX_LINE_GL_DIST t where CUSTOMER_TRX_ID = 978317
-- 备份应收事物处理-税行
create table bak.ZX_LINES20120619 as
select * from ZX_LINES where TRX_NUMBER = \'10102672\'
-- 检测备份数据
select * from bak.ZX_LINES20120619
-- 修改应收事物处理-税行
select t.*,t.rowid from ZX_LINES t where TRX_NUMBER = \'10102672\'
12、 安全性 SQL
begin
mo_global.set_policy_context(\'S\',\'组织ID\');
end;
select * from hr_organization_units_v --组织表
13、删除 AP 发票相关脚本 SQL
--发票
create table bak.AP_INVOICES_ALL_110707 as
select * from AP_INVOICES_ALL aia
where aia.invoice_id in (90490,90333)
--发票行
create table bak.AP_INVOICE_LINES_110707 as
select * from AP_INVOICE_LINES_ALL ala
where ala.invoice_id in (90490,90333);
--分配
create table bak.Ap_Invoice_Dist_110707 as
select *
from Ap_Invoice_Distributions_All aid
where aid.invoice_id = 90490;
--计划付款
create table bak.AP_PAYMENT_SCHEDULES_110707 as
select * from AP_PAYMENT_SCHEDULES_ALL p
where p.invoice_id in (90490,90333);
--暂挂
create table bak.AP_HOLDS_110707 as
select * from AP_HOLDS_ALL h
where h.invoice_id = 90490;
--付款行
create table bak.AP_INVOICE_PAYMENTS_110707 as
select * from AP_INVOICE_PAYMENTS_all aip
where aip.invoice_id = 90333;
--付款头
create table bak.AP_CHECKS_110707 as
select * from AP_CHECKS_ALL ac where ac.check_id = 64863;
--分录事件
create table bak.xla_trans_entities_110707 as
select *
from xla.xla_transaction_entities xte
where xte.source_id_int_1 in (90490, 90333)
and xte.security_id_int_1 = 81
and application_id = 200;
insert into bak.xla_trans_entities_110707
select * from xla.xla_transaction_entities xte
where xte.source_id_int_1 in (64863)
and xte.security_id_int_1 = 81
and application_id = 200;
--分录头
create table bak.xla_ae_headers_110707 as
select *
from xla.xla_ae_headers xah
where xah.entity_id in (9556541, 9554363);
insert into bak.xla_ae_headers_110707
select * from xla.xla_ae_headers xah where xah.entity_id in (9554366);
--会计事件
create table bak.xla_events_110707 as
select *
from xla_events xe
where xe.event_id in
(select event_id
from xla.xla_ae_headers xah
where xah.entity_id in (9556541, 9554363));
insert into bak.xla_events_110707
select * from xla_events xe
where xe.event_id in
(select event_id
from bak.xla_ae_headers_110707 xah
where xah.entity_id in (9554366));
--分录行
create table bak.xla_ae_lines_110707 as
select *
from xla.xla_ae_lines xal
where xal.ae_header_id in (14101317, 14103708, 14299824);
insert into bak.xla_ae_lines_110707
select *
from xla.xla_ae_lines xal
where xal.ae_header_id=14101322;
--日记账导入参考
create table bak.gl_import_references_110707 as
select *
from gl.gl_import_references gr
where gr.gl_sl_link_id in
(select gl_sl_link_id
from xla.xla_ae_lines xal
where xal.ae_header_id in (14101317, 14103708, 14299824));
insert into bak.gl_import_references_110707
select *
from gl.gl_import_references gr
where gr.gl_sl_link_id in (25174221,25174222);
--日记账头
create table bak.gl_je_headers_110707 as
select *
from gl_je_headers gjh
where gjh.je_header_id in
(select je_header_id
from gl.gl_import_references gr
where gr.gl_sl_link_id in
(select gl_sl_link_id
from xla.xla_ae_lines xal
where xal.ae_header_id in (14101317, 14103708, 14299824)));
insert into bak.gl_je_headers_110707
select * from gl_je_headers gjh
where gjh.je_header_id =5553330;
--日记账行
create table bak.gl_je_lines_110707 as
select *
from gl_je_lines gjl
where gjl.je_header_id in
(select je_header_id
from gl.gl_import_references gr
where gr.gl_sl_link_id in
(select gl_sl_link_id
from xla.xla_ae_lines xal
where xal.ae_header_id in (14101317, 14103708, 14299824)));
insert into bak.gl_je_lines_110707
select *
from gl_je_lines gjl
where gjl.je_header_id=5553330;
--日记帐批
create table bak.gl_je_batches_110707 as
select *
from gl_je_batches gjb
where gjb.je_batch_id in
(select je_batch_id
from gl.gl_import_references gr
where gr.gl_sl_link_id in
(select gl_sl_link_id
from xla.xla_ae_lines xal
where xal.ae_header_id in (14101317, 14103708, 14299824)));
--发票
delete from AP_INVOICES_ALL aia
where aia.invoice_id in (90490,90333)
--发票行
delete from AP_INVOICE_LINES_ALL ala
where ala.invoice_id in (90490,90333);
--分配
delete from Ap_Invoice_Distributions_All aid
where aid.invoice_id = 90490;
--计划付款
delete from AP_PAYMENT_SCHEDULES_ALL p
where p.invoice_id in (90490,90333);
--暂挂
delete from AP_HOLDS_ALL h
where h.invoice_id = 90490;
--付款行
delete from AP_INVOICE_PAYMENTS_all aip
where aip.invoice_id = 90333;
--付款头
delete from AP_CHECKS_ALL ac where ac.check_id = 64863;
--分录事件
delete from xla.xla_transaction_entities xte
where xte.source_id_int_1 in (90490, 90333)
and xte.security_id_int_1 = 81
and application_id = 200;
delete from xla.xla_transaction_entities xte
where xte.source_id_int_1 in (64863)
and xte.security_id_int_1 = 81
and application_id = 200;
--分录头
delete from xla.xla_ae_headers xah
where xah.entity_id in (9556541, 9554363);
delete from xla.xla_ae_headers xah where xah.entity_id in (9554366);
--会计事件
delete from xla_events xe
where xe.event_id in
(select event_id
from bak.xla_ae_headers_110707 xah
where xah.entity_id in (9556541, 9554363));
delete from xla_events xe
where xe.event_id in
(select event_id
from bak.xla_ae_headers_110707 xah
where xah.entity_id in (9554366));
--分录行
delete from xla.xla_ae_lines xal
where xal.ae_header_id in (14101317, 14103708, 14299824);
delete from xla.xla_ae_lines xal
where xal.ae_header_id=14101322;
--日记账导入参考
delete from gl.gl_import_references gr
where gr.gl_sl_link_id in
(select gl_sl_link_id
from bak.xla_ae_lines_110707 xal
where xal.ae_header_id in (14101317, 14103708, 14299824));
delete from gl.gl_import_references gr
where gr.gl_sl_link_id in (25174221,25174222);
--日记账头
delete from gl_je_headers gjh
where gjh.je_header_id in
(select je_header_id
from bak.gl_import_references_110707 gr
where gr.gl_sl_link_id in
(select gl_sl_link_id
from bak.xla_ae_lines_110707 xal
where xal.ae_header_id in (14101317, 14103708, 14299824)));
delete from gl_je_headers gjh
where gjh.je_header_id =5553330;
--日记账行
delete from gl_je_lines gjl
where gjl.je_header_id in
(select je_header_id
from bak.gl_import_references_110707 gr
where gr.gl_sl_link_id in
(select gl_sl_link_id
from bak.xla_ae_lines_110707 xal
where xal.ae_header_id in (14101317, 14103708, 14299824)));
delete from gl_je_lines gjl
where gjl.je_header_id=5553330;
select *
from ap_ae_headers_all a
--日记帐批
delete from gl_je_batches gjb where gjb.je_batch_id=5007897
select rowid,gjb.*
from gl_je_batches gjb
where gjb.je_batch_id in
(select je_batch_id
from bak.gl_import_references_110707 gr
where gr.gl_sl_link_id in
(select gl_sl_link_id
from bak.xla_ae_lines_110707 xal
where xal.ae_header_id in (14101317, 14103708, 14299824)));
-- ..应收他总帐gl
SELECT ct.trx_number
,l.accounting_class_code
,l.entered_dr
,l.entered_cr
,fnd_flex_ext.get_segs(\'SQLGL\', \'GL#\', gcc.chart_of_accounts_id, l.code_combination_id) account_number
,xla_oa_functions_pkg.get_ccid_description(gcc.chart_of_accounts_id
,l.code_combination_id) account_description
FROM xla_ae_headers h --子分类帐头
,xla_ae_lines l --子分类帐行
,xla_events e --子分类帐表
,xla.xla_transaction_entities te --会计分录和事务处理关联的表
,ra_customer_trx_all ct
,gl_code_combinations gcc
WHERE h.application_id = l.application_id
AND h.ae_header_id = l.ae_header_id
AND h.application_id = e.application_id
AND h.event_id = e.event_id
AND h.application_id = te.application_id
AND h.entity_id = te.entity_id
AND gcc.code_combination_id = l.code_combination_id
AND te.application_id = 222
AND te.entity_code = \'TRANSACTIONS\'
AND nvl(te.source_id_int_1, (-99)) = ct.customer_trx_id;
ERP系统常用SQL集锦
查看关键用户
select distinct login_name
from (select c.user_name as login_name,
d.full_name as employee_name,
f.name as department_name,
a.user_id as user_id,
a.responsibility_id as responsibility_id,
b.RESPONSIBILITY_NAME as RESPONSIBILITY_NAME
from FND_USER_RESP_GROUPS a,
FND_RESPONSIBILITY_VL b,
fnd_user c,
hr_employees d,
per_assignments_f e,
hr_all_organization_units_tl f
where a.user_id = c.user_id
and c.employee_id = d.employee_id
and c.employee_id = e.PERSON_ID
and e.ORGANIZATION_ID = f.organization_id
and a.responsibility_id = b.RESPONSIBILITY_ID
and sysdate > e.EFFECTIVE_START_DATE
and sysdate < e.EFFECTIVE_END_DATE
and b.RESPONSIBILITY_NAME not in
(\'员工自助 (1)\')
order by c.description, c.user_name, a.responsibility_id) a
;
得到员工的部门和成本中心
select a.full_name as employee_name,
c.name as hr_depart,
cux_hr11_report.getDepartmentNameByName(a.full_name) as account_name
from (select *
from apps.PER_PEOPLE_f a
where a.PERSON_TYPE_ID = 6
and a.LAST_NAME not like \'虚拟%\'
and sysdate > a.EFFECTIVE_START_DATE
and sysdate < a.EFFECTIVE_END_DATE) a,
per_assignments_f b,
hr_all_organization_units_tl c
where a.PERSON_ID = b.ASSIGNMENT_ID
and b.ORGANIZATION_ID = c.organization_id
and c.language = \'ZHS\'
and sysdate > b.EFFECTIVE_START_DATE
and sysdate < b.EFFECTIVE_END_DATE
order by c.name
导出AR退款的SQL
begin
fnd_client_info.set_org_context(85);
end;select tt.customer_id,
tt.customer_name,
tt.customer_number,
tt.gl_date as shoukuan_date,
t.GL_DATE as tuikuan_date,
t.AMOUNT_APPLIED,
t.TRX_NUMBER,
tt.receipt_number
from AR_RECEIVABLE_APPLICATIONS_V t, AR_CASH_RECEIPTS_V tt
where t.TRX_NUMBER = \'Receipt Write-off\'
and t.CASH_RECEIPT_ID = tt.cash_receipt_id
and t.GL_DATE > to_date(\'20050101\', \'YYYYMMDD\')
and t.GL_DATE < to_date(\'20050331\', \'YYYYMMDD\');
基于gl_balances 的部门费用SQL
这是一个统计某个会计科目在某个会计期内的费用合计,在SQL中有
and b.segment2 = p_department_id
and b.segment3 = p_account_id
这即是假设你的segment2 为部门段,segment3为会计科目
budget_version_id为预算的ID,可以用select * from gl.gl_budgets t确认相应的预算id
set_of_books_id 的值可以用 select * from gl_sets_of_books确认
该SQL实际证明是完全可靠和可信赖的,我们的很多取值都用这个SQL。
select sum(a.period_net_dr - a.period_net_cr)
from apps.gl_balances a, apps.gl_code_combinations b
where b.enabled_flag = \'Y\'
and a.set_of_books_id = 1
and a.code_combination_id = b.code_combination_id
and nvl(a.budget_version_id, 1022) = 1022
AND (upper(a.ACTUAL_FLAG) = upper(p_money_type))
AND trim(nvl(a.PERIOD_NAME, \'XXX\')) =
trim(to_char(to_date(2005|| \'-\' || 1, \'YYYY-MM\'),
\'MON-YY\',
\'NLS_DATE_LANGUAGE=American\'))
and b.segment2 = p_department_id
and b.segment3 = p_account_id
有查询User具体权限的SQL吗?
这就是
select c.user_name as login_name,
d.full_name as employee_name,
f.name as department_name,
a.user_id as user_id,
a.responsibility_id as responsibility_id,
b.RESPONSIBILITY_NAME as RESPONSIBILITY_NAME
from FND_USER_RESP_GROUPS a,
FND_RESPONSIBILITY_VL b,
fnd_user c,
hr_employees d,
per_assignments_f e,
hr_all_organization_units_tl f
where a.user_id = c.user_id
and c.employee_id = d.employee_id
and c.employee_id = e.PERSON_ID
and e.ORGANIZATION_ID = f.organization_id
and a.responsibility_id = b.RESPONSIBILITY_ID
and sysdate > e.EFFECTIVE_START_DATE
and sysdate < e.EFFECTIVE_END_DATE
order by c.description, c.user_name, a.responsibility_id
;
关联一下fnd_application 表就可以了select c.user_name as login_name,
d.full_name as employee_name,
f.name as department_name,
a.user_id as user_id,
a.responsibility_id as responsibility_id,
b.RESPONSIBILITY_NAME as RESPONSIBILITY_NAME,
g.application_short_name
from FND_USER_RESP_GROUPS a,
FND_RESPONSIBILITY_VL b,
fnd_user c,
hr_employees d,
per_assignments_f e,
hr_all_organization_units_tl f,
fnd_application g
where a.user_id = c.user_id
and c.employee_id = d.employee_id
and c.employee_id = e.PERSON_ID
and e.ORGANIZATION_ID = f.organization_id
and a.responsibility_id = b.RESPONSIBILITY_ID
and sysdate > e.EFFECTIVE_START_DATE
and sysdate < e.EFFECTIVE_END_DATE
and b.APPLICATION_ID = g.application_id
order by c.description, c.user_name, a.responsibility_id;
按照天,列出发票总额
select a.trx_date,
sum(b.unit_selling_price *
NVL(b.QUANTITY_CREDITED, b.QUANTITY_INVOICED)) as amount
from ra_customer_trx_all a, ra_customer_trx_lines_all b
where a.customer_trx_id = b.customer_trx_id
and a.trx_date >= to_date(\'20050101\', \'YYYYMMDD\')
and a.trx_date < to_date(\'20050701\', \'YYYYMMDD\')
and a.org_id = 85
group by a.trx_date
/*120*240,创建于2011-6-8*/ var cpro_id = \'u501098\';-员工姓名及其部门信息表:
select a.LAST_NAME,
a.PERSON_ID,
a.SEX,
a.EMAIL_ADDRESS,
b.ORGANIZATION_ID,
c.name
from per_people_f a, PER_ASSIGNMENTS_F b, HR_ALL_ORGANIZATION_UNITS c
where a.PERSON_ID = b.person_id
and sysdate between b.EFFECTIVE_START_DATE and b.EFFECTIVE_END_DATE
and a.PERSON_TYPE_ID = 6
and b.ORGANIZATION_ID = c.organization_id
按照部门名称得到报销单
select e.name as department_name,
c.last_name as employee_name,
--d.PERSON_ID,
--a.employee_id,
a.invoice_num as expense_number,
b.ITEM_DESCRIPTION as expense_type,
b.amount,
b.ATTRIBUTE1,
b.ATTRIBUTE2,
b.ATTRIBUTE3,
b.ATTRIBUTE4,
b.JUSTIFICATION
from ap_expense_report_headers_all a,
ap_expense_report_lines_all b,
hr_employees c,
per_assignments_f d,
hr_organization_units e
where a.REPORT_HEADER_ID = b.REPORT_HEADER_ID
and c.employee_id = d.PERSON_ID
and a.employee_id = c.employee_id
and d.ORGANIZATION_ID = e.organization_id
and e.name = \'部门名称\'
and a.CREATION_DATE > to_date(\'20050715\', \'YYYYMMDD\')
and (sysdate between d.EFFECTIVE_START_DATE and d.EFFECTIVE_END_DATE)
order by c.last_name, a.invoice_num;
得到公司组织架构的SQL:
create or replace view cux_org_level1 as
select a_pa.organization_id as org_id1, a_pa.name as org_name1, a_ch.organization_id as org_id2, a_ch.name as org_name2
from per_org_structure_elements t,
hr_organization_units a_pa,
hr_organization_units a_ch
where t.organization_id_parent = 0
and a_pa.organization_id = t.organization_id_parent
and a_ch.organization_id = t.organization_id_child;
create view cux_org_level2 as
select a_pa.organization_id as org_id1, a_pa.name as org_name1, a_ch.organization_id as org_id2, a_ch.name as org_name2
from per_org_structure_elements t,
hr_organization_units a_pa,
hr_organization_units a_ch
where t.organization_id_parent in
(select t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent = 0)
and a_pa.organization_id = t.organization_id_parent
and a_ch.organization_id = t.organization_id_child;
create view cux_org_level3 as
select a_pa.organization_id as org_id1,
a_pa.name as org_name1,
a_ch.organization_id as org_id2,
a_ch.name as org_name2
from per_org_structure_elements t,
hr_organization_units a_pa,
hr_organization_units a_ch
where t.organization_id_parent in
(select t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent in
(select t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent = 0))
and a_pa.organization_id = t.organization_id_parent
and a_ch.organization_id = t.organization_id_child;
create view cux_org_level4 as
select a_pa.organization_id as org_id1,
a_pa.name as org_name1,
a_ch.organization_id as org_id2,
a_ch.name as org_name2
from per_org_structure_elements t,
hr_organization_units a_pa,
hr_organization_units a_ch
where t.organization_id_parent in
(select t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent in
(select t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent in
(select t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent = 0)))
and a_pa.organization_id = t.organization_id_parent
and a_ch.organization_id = t.organization_id_child;
select t.organization_id_parent, t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent in
(select t.organization_id_child
from per_org_structure_elements t
where t.organization_id_parent = 0);
select t1.org_name2,
t2.org_name2,
t3.org_name2,
t4.org_name2
from cux_org_level1 t1,
cux_org_level2 t2,
cux_org_level3 t3,
cux_org_level4 t4
where t1.org_id2 = t2.org_id1(+)
and t2.org_id2 = t3.org_id1(+)
and t3.org_id2 = t4.org_id1(+)
;
事务处理登记
select to_char(d.gl_date, \'YYYY-MON\') as yuefen,
a.trx_number,
e.name as trx_type,
a.doc_sequence_value,
c.customer_name,
c.customer_number,
a.trx_date,
d.gl_date,
b.unit_selling_price * NVL(b.QUANTITY_CREDITED, b.QUANTITY_INVOICED) as amount,
a.attribute3
from ra_customer_trx_all a,
ra_customer_trx_lines_all b,
ra_customers c,
RA_CUST_TRX_LINE_GL_DIST_ALL d,
RA_CUST_TRX_TYPES_ALL e
where a.org_id = 90
and a.customer_trx_id = b.customer_trx_id
and a.cust_trx_type_id=e.cust_trx_type_id
and a.bill_to_customer_id = c.customer_id
and d.customer_trx_line_id = b.customer_trx_line_id
--and d.gl_date >= to_date(\'20050101\', \'YYYYMMDD\')
--and d.gl_date < to_date(\'20050801\', \'YYYYMMDD\')
and d.gl_date >= to_date(\'20050701\', \'YYYYMMDD\')
and d.gl_date < to_date(\'20050801\', \'YYYYMMDD\')
order by to_char(d.gl_date, \'YYYY-MON\');
销售人员信息表
select JRS.SALESREP_ID, JRS.NAME, hla.description from jtf_rs_srp_vl jrs, per_all_assignments_f pasf, HR_LOCATIONS_ALL hla
where jrs.PERSON_ID = pasf.person_id and SYSDATE between pasf.effective_start_date and pasf.effective_end_date and pasf.location_id = hla.location_id
参看系统请求的SQL
select t.CONCURRENT_PROGRAM_NAME, t.EXECUTABLE_ID, tt.EXECUTABLE_NAME, tt.EXECUTION_FILE_NAME from FND_CONCURRENT_PROGRAMS_VL t, FND_EXECUTABLES_FORM_V tt where upper(t.CONCURRENT_PROGRAM_NAME) like \'%CUX%\' and t.EXECUTABLE_ID = tt.EXECUTABLE_ID order by tt.EXECUTION_FILE_NAME;
员工成本,采购订单,部门表(注一个员工如果他的成本有多条的话,那么就有多条记录)
select d.ASSIGNMENT_ID, a.person_id as person_id, a.last_name as last_name, --cux_hr_common.getDepartmentNameByPersonID(a.person_id) as hr_department, cux_hr_common.getDepartmentIDByPersonID(a.person_id) as hr_department, e.segment1 || \'.\' || e.segment2 || \'.\' || e.segment3 || \'.\' || e.segment4 || \'.\' || e.segment5 || \'.\' || e.segment6 || \'.\' || e.segment7 || \'.\' || e.segment8 "²É¹º¶©µ¥ÐÅÏ¢", f.PROPORTION, f.CONCATENATED_SEGMENTS from PER_PEOPLE_f a, PER_ASSIGNMENTS_F d, gl_code_combinations e, (SELECT PAY.ROWID ROW_ID, PAY.COST_ALLOCATION_ID, PAY.EFFECTIVE_START_DATE, PAY.EFFECTIVE_END_DATE, PAY.BUSINESS_GROUP_ID, PAY.COST_ALLOCATION_KEYFLEX_ID, PAY.ASSIGNMENT_ID, PAY.PROPORTION, PAY.REQUEST_ID, PAY.PROGRAM_APPLICATION_ID, PAY.PROGRAM_ID, PAY.PROGRAM_UPDATE_DATE, PAY.LAST_UPDATE_DATE, PAY.LAST_UPDATED_BY, PAY.LAST_UPDATE_LOGIN, PAY.CREATED_BY, PAY.CREATION_DATE, PCAF.CONCATENATED_SEGMENTS FROM PAY_COST_ALLOCATION_KEYFLEX PCAF, PAY_COST_ALLOCATIONS_F PAY WHERE PCAF.COST_ALLOCATION_KEYFLEX_ID(+) = PAY.COST_ALLOCATION_KEYFLEX_ID) f where a.PERSON_ID = d.PERSON_ID and a.person_type_id = 6 and d.EFFECTIVE_START_DATE >= (select max(EFFECTIVE_START_DATE) from PER_ASSIGNMENTS_F where person_id = d.PERSON_ID) and sysdate between d.EFFECTIVE_START_DATE and d.EFFECTIVE_END_DATE and sysdate between a.EFFECTIVE_START_DATE and a.EFFECTIVE_END_DATE and sysdate between f.EFFECTIVE_START_DATE and f.EFFECTIVE_END_DATE and e.code_combination_id = d.DEFAULT_CODE_COMB_ID and d.ASSIGNMENT_ID = f.ASSIGNMENT_ID-- and d.ASSIGNMENT_ID = 67
--以下部分为没有导入成发票的报销单和导入成报销单又没有导入gl的报销单 select 1 as set_of_books_id, b.code_combination_id, \'CNY\' currency_code, to_char(a.creation_date, \'MON-YY\'), 0 a_1, 0 a_2, 0 b_1, 0 b_2, b.amount unpost_1, 0 unpost_2, 0, 0 from apps.ap_expense_report_headers_all a, apps.ap_expense_report_lines_all b, apps.per_assignments_f c where a.report_header_id = b.report_header_id and a.employee_id = c.PERSON_ID and a.creation_date between c.EFFECTIVE_START_DATE and c.EFFECTIVE_END_DATE and a.expense_current_approver_id <> c.SUPERVISOR_ID and a.employee_id = 285 and (select count(*) from ap_invoices_all t where t.invoice_num = a.invoice_num) = 0 union all select 1 as set_of_books_id, a.dist_code_combination_id, \'CNY\' currency_code, a.period_name, 0 a_1, 0 a_2, 0 b_1, 0 b_2, a.amount unpost_1, 0 unpost_2, 0, 0 from apps.AP_INVOICE_DISTRIBUTIONS_all a where a.posted_flag = \'N\'
1.begin
2.fnd_client_info.set_org_context(90);
3.end;
4.
5.select a.customer_id,
6. d.address_id,
7. a.customer_number 客户编号,
8. a.customer_name 客户名称,
9. a.attribute1 与公司关系,
10. a.attribute2 渠道,
11. a.attribute3 行业,
12. b.description 一级行业分类,
13. c.description 二级行业分类,
14. d.status 状态,
15. d.country 国家,
16. d.address1 地址,
17. d.address2 地址2,
18. d.address3 地址3,
19. d.address4 地址4,
20. e.last_name 联系人,
21. f.phone_type 联系方式,
22. f.area_code 地区代码,
23. f.phone_number 电话号码
24. from apps.ra_customers a,
25. (select t.FLEX_VALUE, t.DESCRIPTION
26. from apps.FND_FLEX_VALUES_VL t
27. where t.FLEX_VALUE_SET_ID = 1009676) b,
28. (select t.FLEX_VALUE, t.DESCRIPTION
29. from apps.FND_FLEX_VALUES_VL t
30. where t.FLEX_VALUE_SET_ID = 1009735) c,
31. apps.AR_ADDRESSES_V d,
32. apps.ar_contacts_v e,
33. apps.ra_PHONES f
34.where a.customer_number like \'AD_%\'
35. and b.flex_value(+) = a.attribute4
36. and c.flex_value(+) = a.attribute5
37. and d.customer_id = a.customer_id
38. and e.address_id = d.address_id
39. and e.contact_id = f.contact_id
查看AP发票的撤销人
select t.invoice_num, t.cancelled_by, t.cancelled_by_display
from ap_invoices_v t
where t.gl_date between to_date(\'20060701\', \'YYYYMMDD\') and
to_date(\'20060930\', \'YYYYMMDD\')
and t.cancelled_by is not null;
begin
fnd_client_info.set_org_context(560);
end;
更改AR发票会计科目
/*120*240,创建于2011-6-8*/ var cpro_id = \'u501098\';-update ra_cust_trx_line_gl_dist_all t
set t.code_combination_id = 374510
where t.customer_trx_id in
(select customer_trx_id
from RA_CUSTOMER_TRX_ALL t
where t.trx_number >= \'SFQC20061001001174\'
and t.trx_number <= \'SFQC20061001012968\')
and t.customer_trx_line_id is not null;
请求正在执行的sql
SELECT to_char(s.sid) || \',\' || to_char(s.serial#), sql_text
FROM applsys.fnd_concurrent_requests r,
v$process p,
v$session s,
v$sqltext_with_newlines sqlt
WHERE r.oracle_process_id = p.spid
AND p.addr = s.paddr(+)
AND s.sql_address = sqlt.address(+)
AND s.sql_hash_value = sqlt.hash_value(+)
AND r.request_id = 2641173
ORDER BY piece;
select a.LAST_NAME 员工姓名,
a.PERSON_ID 员工ID,
a.SEX 性别,
a.EMAIL_ADDRESS 电子邮件,
b.ORGANIZATION_ID,
aa.LAST_NAME 主管姓名,
aa.EMAIL_ADDRESS 主管email
from per_people_f a, PER_ASSIGNMENTS_F b, per_people_f aa
where a.PERSON_ID = b.person_id
and sysdate between b.EFFECTIVE_START_DATE and b.EFFECTIVE_END_DATE
and sysdate between a.EFFECTIVE_START_DATE and a.EFFECTIVE_END_DATE
and sysdate between aa.EFFECTIVE_START_DATE and aa.EFFECTIVE_END_DATE
and a.PERSON_TYPE_ID <> 9
and b.SUPERVISOR_ID = aa.PERSON_ID
select a.USER_PROFILE_OPTION_NAME 配置文件名,
c.user_name 用户名,
b.profile_option_value 配置文件值,
a.PROFILE_OPTION_ID ,
c.user_id,
c.rowid,
b.rowid
from FND_PROFILE_OPTIONS_VL a, fnd_profile_option_values b, fnd_user c
where a.USER_PROFILE_OPTION_NAME = \'FND:诊断\'
and a.PROFILE_OPTION_ID = b.profile_option_id
and c.user_id = b.level_value
and b.level_id = 10004 --10004为用户层
select t.message_type,
t.begin_date,
t.responder,
t.from_user,
t.to_user,
t.subject
from wf_notifications t
where t.responder = \'SYSADMIN\'
and t.recipient_role <> t.responder
and t.begin_date between to_date(\'20070101\', \'YYYYMMDD\') and
to_date(\'20070331\', \'YYYYMMDD\')
;
ORACLE EBS常用表
call fnd_global.APPS_INITIALIZE(1318,50583,401)
select fnd_profile.VALUE(\'ORG_ID\') FROM DUAL
select * from hr_operating_units hou where hou.organization_id=204
--fnd
select * from fnd_application
select * from fnd_application_tl where application_id=101
select * from fnd_application_vl where application_id = 101
----值集
select * from fnd_flex_value_sets
select * from fnd_flex_values
select * from fnd_flex_values_vl
----弹性域
select * from fnd_id_flexs
select * from fnd_id_flex_structures where id_flex_code=\'GL#\'
select * from fnd_id_flex_segments where id_flex_code=\'GL#\' and id_flex_num=50671
select * from fnd_profile_options_vl
select * from fnd_concurrent_programs 程序表
select * from fnd_concurrent_requests 请求表
select * from fnd_concurrent_processes 进程表
--inv
select * from org_organization_definitions 库存组织
select * from mtl_parameters 组织参数
select * from mtl_system_items_b where inventory_item_id = 171 and organization_id=204 物料表
select * from mtl_secondary_inventories 子库存
select * from mtl_item_locations 货位
select * from mtl_lot_numbers 批次
select * from mtl_onhand_quantities 现有量表
select * from mtl_serial_numbers 序列
select * from mtl_material_transactions 物料事务记录
select * from mtl_transaction_accounts 会计分录
select * from mtl_transaction_types 事务类型
select * from mtl_txn_source_types 事务来源类型
select * from mfg_lookups ml where ml.LOOKUP_TYPE = \'MTL_TRANSACTION_ACTION\'
--po
select * from po_requisition_headers_all 请求头
select * from po_requisition_lines_all 请求行
select * from po_headers_all 订单头
select * from po_lines_all 订单行
select * from po_line_locations_all
select * from po_distributions_all 分配
select * from po_releases_all 发送
select * from rcv_shipment_headers 采购接收头
select * from rcv_shipment_lines 采购接收行
select * from rcv_transactions 接收事务处理
select * from po_agents
select * from po_vendors 订单
select * from po_vendor_sites_all
--oe
select * from ra_customers 客户
select * from ra_addresses_all 地址
select * from ra_site_uses_all 用户
select * from oe_order_headers_all 销售头
select * from oe_order_lines_all 销售行
select * from wsh_new_deliveries 发送
select * from wsh_delivery_details
select * from wsh_delivery_assignments
--gl
select * from gl_sets_of_books 总帐
select * from gl_code_combinations gcc where gcc.summary_flag=\'Y\' 科目组合
select * from gl_balances 科目余额
select * from gl_je_batches 凭证批
select * from gl_je_headers 凭证头
select * from gl_je_lines 凭证行
select * from gl_je_categories 凭证分类
select * from gl_je_sources 凭证来源
select * from gl_summary_templates 科目汇总模板
select * from gl_account_hierarchies 科目汇总模板层次
--ar
select * from ar_batches_all 事务处理批
select * from ra_customer_trx_all 发票头
select * from ra_customer_trx_lines_all 发票行
select * from ra_cust_trx_line_gl_dist_all 发票分配
select * from ar_cash_receipts_all 收款
select * from ar_receivable_applications_all 核销
select * from ar_payment_schedules_all 发票调整
select * from ar_adjustments_all 会计分录
select * from ar_distributions_all 付款计划
--ap
select * from ap_invoices_all 发票头
select * from ap_invoice_distributions_all 发票行
select * from ap_payment_schedules_all 付款计划
select * from ap_check_stocks_all 单据
select * from ap_checks_all 付款
select * from ap_bank_branches 银行
select * from ap_bank_accounts_all 银行帐号
select * from ap_invoice_payments_all 核销
========================华丽的分割线=========================
INV库存
organization 两个含义:
1. 经营单位,A/B/C分公司,A下面有A1,A2等工厂,主题目标是为了独立核算此组织
ORG,ORG_ID;
2. 库存组织,例如制造商的仓库,例如A1,A2等工厂
Organization_id;
HR_ORGANIZATION_UNITS -
Org_organization_definitions
Mtl_subinventory_ 库存组织单位
MTL_PARAMETERS -库存组织参数(没有用ID,直接用name)
MTL_SYSTEM_ITEMS_b -物料信息(同上,应用了库存组织name)
MTL_SECONDARY_INVENTORIES -子库存组织 -
MTL_ITEM_LOCATTIONS -货位 - SUBINVENTROY_CODE
Mtl_Material_Transactions - (库存)物料事物表
成本 mtl_transaction_accounts
transaction_cost是事物成本;
ACTUAL_COST是通过成本算法计算出来的实际成本,主计量单位
现有量
汇总历史记录(正负合计)
Mtl_Material_Transactions
MTL_ONHAND_QUANTITIES现有量表,组织/子库存/货位/物品 summary可能按照挑库先进先出统计,如果设置了"不允许负库存",这样就不可能出现负数
PO
请购单头表
Po_Requisition_Headers_all
行表
Po_Requisition_lines_all
采购订单
PO_HEADER_ALL
PO_LINES_ALL
采购接收-退货/组织间转移/正常状态 都需要使用这个模块
RCV_TRANSACTIONS
1. 接收100单位货物,放入"待质检"货位
2. 接受/拒绝
3. 库存/退回
有三个不同的状态!例如:接收100个,80个接受入库,20个退回,那么有80个接受事务/20个退回事物
select TRANSACTION_TYPE,DESTINATION_TYPE_CODE from RCV_TRANSACTIONS
可以看出以下阶段:
A1.RECEIVE – RECEIVING
A2.ACCEPT – RECEIVING
A3.DELIERY – INVETORY(影响库存现有量)
如果按照正常模式,最后会触发产生MTL_MATERIAL_TRANSACTIONS
销售订单
OE_ORDER_headers_all
SOLD_FROM_ORG_ID
SOLD_TO_ORG_ID 就是客户层
SHIP_FROM_ORG_ID
SHIP_TO_ORG_ID 就是客户收货层
INVOICE_TO_ORG_ID 就是客户收单层
DELIVER_TO_ORG_ID
和客户结构有关
客户 RA_customers
客户Address Ra_Addresses
Address 货品抵达 site RA_SITE_USES_ALL
Address 发票抵达 site
OE_ORDER_LINEs_all
GL凭证
gl_je_batches
凭证日期: DEFAULT_EFFECTIVE_DATE
会计期间: DEFAULT_PERIOD_NAME
原币种凭证批借贷方汇总: RUNNING_TOTAL_DR/CR 比如美元
本位币凭证批借贷方汇总: RUNNING_TOTAL_ACCOUNTED_DR/CR
gl_je_headers日记账头信息
批号: JE_BATCH_ID
会计期间: PERIOD_NAME
币种: CURRENCY_CODE
汇率类型: CURRENCY_CONVERSION_TYPE
汇率日期: CURRENCY_CONVERSION_DATE
帐套: SET_OF_BOOKS_ID 参考 GL_SETS_OF_BOOKS
凭证类型: JE_CATEGORY 参考 GL_JE_SOURCES
凭证来源: JE_SOURCE
gl_je_lines日记账体信息
CODE_COMBINATION_ID 科目组合编号
GL_BALANCES 总帐余额
PERIOD_NET_DR/CR 净值
BEGIN_BALANCE_DR/CR 期初额
AR应收发票
RA_CUSTOMER_TRX_ALL
CUSTOMER_TRX_ID 发票编号
BILL_TO_SITE_USE_ID 客户收单方编号
PRIMARY_SALES_ID销售员
REFERENCE是Oracle提供的外部编号输入框,但是由于版本问题和长度(<=30),不建议用户使用,如果要使用外部编号,请使用说明性弹性域
RA_CUSTOMER_TRX_LINES_ALL
LINE_ID 行号
INVENTORY_ITEM_ID 可以为空,比如非物料的服务,只在DE script ION中出现 /税行
DE script ION
QUANTITY_INVOICE 开票数量
LINE_TYPE 行类型 (一般/税)
EXTEND_PRICE 本行金额
注意:税行是隐藏行,所以至少会有两行
收款情况
AR_CASH_RECEIPTS_ALL(还包含了非收款信息)
CASH_RECEIPT_ID 内部code
RECEIPT_NUMBER 收款号
RECEIPT_DATE 收款日期
AMOUNT 总额
RECEIPT_TYPE 现金/杂项 Cash/Misc
FUNCTIONAL_AMOUNT 本位币计量金额
UI上为RECEIPTS
核销关系不是一一对应,也不是一次核销100%,UI上右下方的Application 按钮
AR_RECEIVABLE_APPLICATIONS_ALL
APPLIED_CUSTOMER_TRX_ID 发票编号
APPLIED_CUSTOMER_TRX_LINE_ID 发票行编号
STATUS APP表示核销 /UNAPP表示未核销
AMOUNT_APPLIED 匹配金额
注意:红冲收款报表时间跨月的问题;必须联查 AR_CASH_RECEIPTS_ALL和 AR_CASH_RECEIPT_HISTORY_ALL
AP
应付帐款(是我方人员按照供应商提供的纸张发票信息录入)UI 上的invoice
AP_INVOICES_ALL
实际付款PAYMENT
AP_CHECKS_ALL
核销关系 同AR,右下方的Payment 按钮
AP_INVOICE_PAYMENTS_ALL客户余额表,情况比较复杂:比如两个用户合并,应收应付差额,预付款
资产信息FA_ADDITIONS
名称
编号
分类
数量
资产类别
FA_CATEGORIES
资产帐簿
FA_BOOK_CONTROLS 和会计帐簿有什么关系?
FA_BOOKS
UI中的Inquiry
Mothed是折旧方法(直线法/产量法)
FA_DISTRIBUTION_HISTORY分配assignment,给什么部门使用多少
LOCATION_ID 部门 联查FA_LOCATIONS
折旧信息(分摊方法)
FA_DEPRN_DETAIL
period_counter 折旧期间编号
折旧事务(新增、重建、转移、报废)
FA_TRANSACTION_HEADERS
========================华丽的分割线=========================
fnd_user --- 系统用户表
po_vendors --- 供应商信息表
po_vendor_sites --- 供应商地点信息表
hr_organization_units --- 组织及库存组织表
per_people_f --- 员工表
wip_entities --- 作业名信息表
wip_discrete_jobs --- 离散作业表
wip_requirement_operations --- 作业名物料需求发放表
po_headers_all --- 采购订单头表
po_lines_all --- 采购订单行表
po_line_locations_all --- 采购行地点表
rcv_transactions --- 接收交易表
bom_bill_of_materials --- 物料清单表
bom_inventory_components --- 物料清单构成表
mtl_system_items --- 物料主表
mtl_onhand_quantities --- 库存数据表
mtl_item_locations --- 项目货位表
mtl_material_transactions --- 出入库记录表
mtl_supply --- 供应表
mtl_demand --- 需求表
----=====================-下面的是用于修改表单注册情况========-------
select * from FND_FORM_VL where form_name=\'出货信息\' order by last_update_date desc
update FND_FORM set form_name=\'OUTINVINFO\' where form_id=58864
select * from fnd_form where form_name=\'出货信息\'
commit;
-------===========================-----------
select item as 物料,subinventory as 子库存,locator as 货位,results_transaction_uom as 单位 from MTL_TXN_REQUEST_HEADERS_V
select lot_number as 批次,LOT_EXPIRATION_DATE as 到期日,pimary_quantity as 数量 from MTL_TXN_REQUEST_LINES_V
/*==================物料发送请求行视图==================================*/
select * from MTL_TXN_REQUEST_LINES_V
select * from MTL_TXN_REQUEST_HEADERS_V
-----其他信息从OE上取
---------organization_id = :parameter.org_id ----------
select * from MTL_ONHAND_LOCATOR_V
select * from MTL_MATERIAL_TRANSACTIONS_TEMP
select * from MTL_SERIAL_NUMBERS_TEMP
select * from MTL_TRANSACTION_LOTS_TEMP
---------------------------------------------------------
通过PO, 找点收单号:
===========================================================
通过PO, 找点收单号:
作者: moonsoft(http://moonsoft.itpub.net)
发表于: 2006.05.08 16:20
分类: 分销
出处: http://moonsoft.itpub.net/post/15182/86513
---------------------------------------------------------------
select rsh.receipt_num
from po_headers_all poh,
rcv_shipment_headers rsh,
rcv_shipment_lines rsl,
po_lines_all pol,
po_line_locations_all poll
where
poh.segment1=\'20600021\'
and
poh.po_header_id=pol.po_header_id
and
pol.po_line_id=poll.po_line_id
and
poll.line_location_id=rsl.po_line_location_id
and
rsh.SHIPMENT_HEADER_ID=rsl.shipment_header_id
/*--------------------------//接收事务处理------------------------************/
select * from RCV_TRANSACTIONS_V
select * from RCV_TRANSACTIONS_INTERFACE
select * from MTL_TRANSACTION_LOTS_TEMP
select * from MTL_SERIAL_NUMBERS_TEMP ----------条码-----------
select * from QA_RESULTS_V
select * from ic_lots_mst
select * from mtl_serial_numbers ----------条码表-----------
select * from wms_license_plate_numbers
select * from rcv_lots_supply
select * from oe_lot_serial_numbers ----------销售订单批次条码---------------
select * from rcv_transactions -----//接收事务处理----
select * from sy_reas_cds
select * from mtl_serial_numbers_all_v
select * from qa_plan_char_value_lookups
select * from mtl_lot_numbers
select * from mtl_serial_numbers-------------序列号
select * from wip_operations_all_v
select * from cs_counter_values
select * from wip_discrete_jobs_all_v
select * from cs_incidents
select * from qa_ahl_mr
select * from cs_counters
select * from qa_csi_item_instances
select * from mtl_system_items_kfv
select * from wms_lpn_contents
select * from ic_item_mst
select * from ic_tran_pnd
select * from ic_loct_inv
select * from ic_loct_mst
select * from hr_employees------------人事人员
select * from pjm_projects_all_v
select * from PA_TASKS_EXPEND_V
select * from wip_osp_jobs_val_v
select * from mtl_kanban_cards
select * from hr_locations_all --------人事组织档案-----
select * from hr_locations_all_tl -------同上
select * from mtl_serial_numbers_all_v ---------序列视图
select * from hz_parties----------
select * from po_pos_val_v
select * from rcv_transactions_interface
select * from PO_LINE_LOCATIONS
select * from PO_REQUISITION_LINES
select * from wip_discrete_jobs_all_v
select * from oke_k_headers_lov_v
select * from oke_k_lines_full_v
select * from oke_k_deliverables_vl
select * from OE_SOLD_TO_ORGS_V ------------
select * from cst_cost_groups --------
select * from rcv_shipment_headers ----------发运头
select * from rcv_shipment_lines --------发运体
select * from rcv_transactions_interface
select * from oe_order_lines_all -----------订单
select * from oe_order_headers_all ---------订单
select * from oe_transaction_types_all ------订单处理\交易类型
select * from MTL_TRANSACTION_TYPES-------交易的类型--
select * from oe_transaction_types_tl -------订单处理类型
select * from rcv_transactions ------接收事务处理
select * from rcv_supply -----------
select * from oe_transaction_types
select * from oe_po_enter_receipts_v
select * from mtl_customer_items_all_v
select * from mtl_lot_issues_val_v ------------
select * from mtl_uom_conversions -----------
select * from mtl_uom_class_conversions --------------
select * from po_lines_supplier_items_v
select * from per_all_people_f ---------------
select * from financials_system_parameters
select * from org_freight ------运输组织--------
select * from mtl_supply -------------物料供给
select * from org_organization_definitions --------------库存组织定义
select * from po_vendor_sites
select * from rcv_sources_both_val_v ----------------
select * from rcv_suppliers_val_v -----------
select * from hr_locations_all ---------
select * from hr_locations_all_tl ------------
select * from mtl_item_revisions -----------
select * from mtl_system_items_kfv ----正规ID编码,------
select * from po_requisition_lines
select * from financials_system_parameters
select * from po_lookup_codes ----------------
select * from po_requisition_headers
select * from rcv_shipment_lines---------
select * from rcv_transactions------------
select * from po_line_locations
select * from hr_locations_all_tl -----------
select * from po_releases
select * from po_pos_all_v
select * from po_pos_val_v
select * from per_all_people_f ------------
select * from rcv_transactions_interface
select * from mtl_serial_numbers ------------------SERIAL----------
select * from mtl_transaction_lots_temp
select * from mtl_employees_view ----------
select * from po_suppliers_val_v ---------------
select * from mtl_employees_current_view -------------
select * from mtl_item_status -------------------物料项状态基础表---------
select * from org_organization_definitions ------------
select * from mtl_secondary_inventories -----子库存组织---------
select * from mtl_transaction_types ------------
select * from mtl_txn_source_types -----------
select * from mtl_system_items_vl ------------
select * from mtl_system_items_kfv --------
select * from mtl_category_sets_vl ---------
select * from mtl_physical_inventories_v ----------
select * from mtl_kanban_cards
select * from mtl_item_sub_inventories
select * from fnd_folders -------
select * from fnd_user --------系统用户
select * from so_order_types_all ----------销售订单类型
select * from oe_order_headers_all ---------
select * from qa_customers_lov_v ---------
select * from qa_sales_orders_lov_v-----------
select * from PO_VENDORS -----采购供货方-----
select * from po_shipments_all_v
select * from po_lines_val_v
select * from po_pos_val_v
select * from mtl_task_v
select * from pjm_projects_all_v
select * from qa_customers_lov_v ---
select * from mtl_item_revisions ----
select * from mtl_category_sets----
select * from wip_operations_all_v
select * from wip_first_open_schedule_v
select * from wip_discrete_jobs_all_v
select * from wip_lines_val_v
select * from mtl_item_uoms_view -----
select * from bom_resources_val_v
select * from bom_departments_val_v
select * from qa_plan_char_value_lookups ---------
select * from qa_plans-------
select * from qa_specs_v
select * from qa_specs_val_v
select * from po_lookup_codes -----
select * from hr_employees_current_v --------
select * from po_quality_codes
select * from mtl_transaction_reasons --库存相关接转信息----
select * from mtl_uom_conversions_val_v ----
select * from mtl_uom_class_conversions ----
select * from hr_locations_all --------
select * from hr_locations_all_tl --------
select * from hz_locations -------
select * from hz_party_sites ---------
select * from hz_cust_site_uses_all --------
select * from hz_cust_acct_sites_all ---------
select * from hz_cust_accounts -----------
select * from oe_order_lines_all -----------
select * from oe_drop_ship_sources
select * from rcv_trx_int_lots_v
select * from mtl_rma_serial_temp
select * from rcv_trx_int_serials_v
select * from po_distributions
select * from pjm_projects_all_v
select * from po_distributions
select * from hr_locations_all_tl-----------
select * from hr_employees_current_v -------
select * from po_lookup_codes -----------
select * from pjm_projects_all_v
select * from pa_tasks_expend_v
select * from mtl_kanban_cards
select * from qa_plans_val_v ---------
------------------------------------------签证分类
select t.meaning from fnd_lookup_values_vl t Where t.lookup_type=\'CUX_FC_QZYY\'
-- 任务ID
Select Distinct A.Task_Number,A.Task_Name From pa_tasks A
---------------------------//发运------------------------------
select * from wsh_new_deliveries_v
select * from mtl_txn_request_lines_v
select * from oe_order_headers_v
select * from wsh.wsh_delivery_details
-------------------------//出货信息--------------------------
select * from oe_lot_serial_numbers ----订单批次与序列号
select * from ic_lots_mst
select * from mtl_serial_numbers---------序列号
select * from rcv_transactions ---------接收处理
select * from gml_recv_trans_map
select * from ic_tran_pnd
select * from ic_loct_inv
select reason_code,reason_desc1 from sy_reas_cds order by 1
select * from MTL_MATERIAL_TRANSACTIONS--是物料交易表,
---------它存放着相关库存物料的每一笔交易,或库存更新的每一笔数据
----物料处理,(库存)物料事物表
select * from MTL_CONSUMPTION_TXN_TEMP
select * from hr_locations_all -------------收货地点档案----------------
select * from hz_locations------交货地点
select * from wms_lpn_contents
select * from mtl_subinventories_val_v ------------子库----------------
select * from mtl_object_genealogy
select * from mtl_lot_numbers-----------物料批号
select * from mtl_lot_issues_val_v -----------物料批号发出
select * from wms_license_plate_numbers
select * from cst_cost_groups
select * from mtl_item_sub_val_v
select * from mtl_subinventories_trk_val_v----------
select * from mtl_item_sub_trk_val_v
select * from mtl_item_sub_exp_val_v
select * from mtl_sub_exp_val_v
select * from mtl_so_rma_interface
select * from mtl_system_items-------库存、工程和采购物料的明细-物料信息--
select * from mtl_item_revisions----------修订
select * from bom_departments
select * from wip_lines_all_v
select * from wip_entities
select * from wip_discrete_jobs_all_v
select * from wsh_inv_delivery_details_v---------库存存货发放明细
select * from mtl_txn_request_lines--------请求
select * from mtl_material_transactions_temp
select * from mtl_transaction_types------物料处理类型
select * from pjm_unit_numbers_lov_v
select * from mtl_sales_orders----------------销售订单
select * from mtl_secondary_inventories ---------
select * from mtl_lot_numbers----------
select * from pjm_tasks_v
select * from pjm_projects_v
select * from pjm_project_parameters
select * from fnd_user --------------系统用户
select * from mtl_txn_request_headers-------------头
select * from mtl_txn_request_lines------------体
select * from mtl_onhand_quantities_detail----物料的库存明细--------
select * from fnd_folders------------
select * from mtl_item_sub_inventories
select * from mtl_kanban_cards-------物料看板
select * from mtl_physical_inventories_v------物理库存
select * from mtl_category_sets_vl---物料类别
select * from mtl_system_items_vl
select * from mtl_txn_source_types
select * from mtl_transaction_types---处理类型
select * from org_organization_definitions------库存组织 where or
select * from mtl_item_status-----物料状态
select * from mtl_employees_current_view------员工
select * from po_suppliers_val_v--------------采购供应商视图
select * from mtl_employees_view-----------------员工
select * from mtl_transaction_lots_temp
select * from pa_projects_expend_v
select * from pa_tasks_expend_v
select * from pa_organizations_expend_v
select * from mtl_onhand_quantities_detail---------物料现存量明细
select * from mtl_lot_numbers----物料批号
select * from mtl_transaction_reasons------------物料处理原因
select * from mtl_item_uoms_view--------------物料单位mtl_units_of_measure
select * from mtl_so_rma_interface
select * from mtl_system_items------------物料项
select * from mtl_item_sub_ast_trk_val_v
select * from mtl_lot_issues_val_v-------------批次-
select * from mtl_so_rma_interface
select * from mtl_sub_ast_trk_val_v ---------------子库
select * from pa_expenditure_types
select * from MTL_TXN_REQUEST_LINES_V--------------发送请求
select * from MTL_SERIAL_NUMBERS_TEMP
select * from MTL_TRANSACTION_LOTS_TEMP
select * from MTL_MATERIAL_TRANSACTIONS_TEMP
select * from MTL_ITEM_LOCATTIONS---------------货位
Select * from Po_Requisition_Headers_all------------请购单头表
Select * from Po_Requisition_lines_all----------体表
Select * from PO_HEADER_ALL---------采购订单头
Select * from PO_LINES_ALL---采购订单体
select * from wsh_pick_slip_v
select * from mtl_system_items_vl msi -- bug# 3306781
select * from wsh_delivery_details wdd
select * from mtl_txn_request_lines mtrl
select * from mtl_txn_request_headers mtrh
select * from wsh_delivery_assignments wda
select * from wsh_new_deliveries wnd
select * from oe_order_lines_all oola
select * from oe_sets os
select * from wsh_pick_grouping_rules wpgr
select * from hz_locations -------交货位置表
select * from hr_locations_all-------收貨位置表
Select flex_value_set_id From apps.fnd_flex_value_sets
select * from MTL_TXN_REQUEST_LINES_V --查找物料搬运单
SELECT
TRANSACTION_TYPE_NAME,TRANSACTION_TYPE_ID,TRANSACTION_ACTION_ID,
TRANSACTION_SOURCE_TYPE_ID,LINE_ID,REQUEST_NUMBER,HEADER_ID,
MOVE_ORDER_TYPE,MOVE_ORDER_TYPE_NAME,LINE_NUMBER,ORGANIZATION_ID,
INVENTORY_ITEM_ID,REVISION,FROM_SUBINVENTORY_CODE,FROM_LOCATOR_ID,
TO_SUBINVENTORY_CODE,FROM_SUB_LOCATOR_TYPE,TO_LOCATOR_ID,TO_ACCOUNT_ID,
LOT_NUMBER,SERIAL_NUMBER_START,SERIAL_NUMBER_END,UNIT_NUMBER,UOM_CODE,
QUANTITY,REQUIRED_QUANTITY,QUANTITY_DELIVERED,QUANTITY_DETAILED,DATE_REQUIRED,
REASON_ID,REFERENCE,REFERENCE_ID,REFERENCE_TYPE_CODE,PROJECT_ID,TASK_ID,
TRANSACTION_HEADER_ID,LINE_STATUS,STATUS_DATE,LAST_UPDATED_BY,
LAST_UPDATE_LOGIN,LAST_UPDATE_DATE,CREATED_BY,REQUEST_ID,CREATION_DATE,
PROGRAM_APPLICATION_ID,PROGRAM_ID,PROGRAM_UPDATE_DATE,ATTRIBUTE1,ATTRIBUTE2,
ATTRIBUTE3,ATTRIBUTE4,ATTRIBUTE5,ATTRIBUTE6,ATTRIBUTE7,ATTRIBUTE8,ATTRIBUTE9,ATTRIBUTE10
,ATTRIBUTE11,ATTRIBUTE12,ATTRIBUTE13,ATTRIBUTE14,ATTRIBUTE15,ATTRIBUTE_CATEGORY,
TO_SUB_LOCATOR_TYPE,FROM_SUB_ASSET,FROM_SUB_QUANTITY_TRACKED,FROM_SUB_MATERIAL_ACCOUNT,
TXN_SOURCE_ID,TXN_SOURCE_LINE_ID,TXN_SOURCE_LINE_DETAIL_ID,PRIMARY_QUANTITY,
TO_ORGANIZATION_ID,PICK_STRATEGY_ID,PUT_AWAY_STRATEGY_ID,SHIP_TO_LOCATION_ID
FROM MTL_TXN_REQUEST_LINES_V
WHERE organization_id = \'117\' AND -1=-1
and ( mtl_txn_request_lines_v.move_order_type != 6
AND mtl_txn_request_lines_v.request_number between \'4009\' AND \'4009\'
AND mtl_txn_request_lines_v.line_status in (3,7,9) ) and (REQUEST_NUMBER=\'4009\')
order by REQUEST_NUMBER,MOVE_ORDER_TYPE_NAME,LINE_NUMBER
------哪个用户锁定了哪个表的SQL----
SELECT c.owner
,c.object_name
,c.object_type
,fu.user_name locking_fnd_user_name
,fl.start_time locking_fnd_user_login_time
,vs.module
,vs.machine
,vs.osuser
,vlocked.oracle_username
,vs.SID
,vp.pid
,vp.spid AS os_process
,vs.serial#
,vs.status
,vs.saddr
,vs.audsid
,vs.process
FROM fnd_logins fl
,fnd_user fu
,v$locked_object vlocked
,v$process vp
,v$session vs
,dba_objects c
WHERE vs.SID = vlocked.session_id
AND vlocked.object_id = c.object_id
AND vs.paddr = vp.addr
AND vp.spid = fl.process_spid(+)
AND vp.pid = fl.pid(+)
AND fl.user_id = fu.user_id(+)
--AND c.object_name LIKE \'%\' || UPPER(\'&tab_name_leaveblank4all\') || \'%\'
AND NVL(vs.status
,\'XX\') != \'KILLED\';
--------------
select * from oe_ra_cust_trx_hdr_v
select * from ar_payment_schedules_all
select * from oe_ra_customers_v-----------客户名称
select * from OE_PO_REQUISITION_LINES_V
------------==================
select
fyhzt.delivery_detail_id,
fyhzt.source_code as 源单类,
fyhzt.source_line_id as 源单行号,
fyhzt.source_header_id as 源单头号,
fyhzt.header_number as 单据号,
fyhzt.line_number as 行号,
fyhzt.ship_method_code as 发运方式,
fyhzt.inventory_item_id as 物料ID,
fyhzt.requested_quantity as 请求数量,
fyhzt.shipped_quantity_uom as 发运单位,
fyhzt.shipped_quantity as 已发运,
fyhzt.requested_quantity_uom as 请求单位,
fyhzt.ship_set_id,
fyhzt.line_number as 批次号,
fyhzt.serial_number as 序列号从,
fyhzt.pick_status as 挑库状态,
fyhzt.pick_meaning as 挑库状态名称,
fyhzt.delivery_id,
fyhzt.delivery_name,
fyhzt.delivery_status,
fyhzt.delivery_status_meaning as 发运状态,
fyhzt.organization_id as 公司,
fyhzt.initial_pickup_location_id as 地点ID,
fyhzt.initial_pickup_location as 地点,
fyhzt.ultimate_dropoff_location_id,
fyhzt.ultimate_dropoff_location,
fyhzt.date_shipped,
fyhzt.date_received,
fyhzt.to_serial_number as 序列号止
from WSH_DELIVERY_LINE_STATUS_V fyhzt-------发运行状态
-------------------------
select * from OE_ORDER_HEADERS_V
-------付款方式
select distinct t.name, t.description from ra_terms t order by t.name
--------收单地点
select * from hz_cust_site_uses_all
-------业务员
select * from JTF_RS_DEFRESOURCES_VL
-----------公司 名称
select * from HR_ALL_ORGANIZATION_UNITS where organization_id=103
建议去看参考二
参考一:
call fnd_global.APPS_INITIALIZE(1318,50583,401)
select fnd_profile.VALUE(\'ORG_ID\') FROM DUAL
select * from hr_operating_units hou where hou.organization_id=204
--fnd
select * from fnd_application
select * from fnd_application_tl where application_id=101
select * from fnd_application_vl where application_id = 101
----值集
select * from fnd_flex_value_sets
select * from fnd_flex_values
select * from fnd_flex_values_vl
----弹性域
select * from fnd_id_flexs
select * from fnd_id_flex_structures where id_flex_code=\'GL#\'
select * from fnd_id_flex_segments where id_flex_code=\'GL#\' and id_flex_num=50671
select * from fnd_profile_options_vl
select * from fnd_concurrent_programs 程序表
select * from fnd_concurrent_requests 请求表
select * from fnd_concurrent_processes 进程表
--inv(库存)
select * from org_organization_definitions 库存组织
select * from mtl_parameters 组织参数
select * from mtl_system_items_b where inventory_item_id = 171 and organization_id=204 物料表
select * from mtl_secondary_inventories 子库存
select * from mtl_item_locations 货位
select * from mtl_lot_numbers 批次
select * from mtl_onhand_quantities 现有量表
select * from mtl_serial_numbers 序列
select * from mtl_material_transactions 物料事务记录
select * from mtl_transaction_accounts 会计分录
select * from mtl_transaction_types 事务类型
select * from mtl_txn_source_types 事务来源类型
select * from mfg_lookups ml where ml.LOOKUP_TYPE = \'MTL_TRANSACTION_ACTION\'
--po(采购订单)
select * from po_requisition_headers_all 请求头
select * from po_requisition_lines_all 请求行
select * from po_headers_all 订单头
select * from po_lines_all 订单行
select * from po_line_locations_all
select * from po_distributions_all 分配
select * from po_releases_all 发送
select * from rcv_shipment_headers 采购接收头
select * from rcv_shipment_lines 采购接收行
select * from rcv_transactions 接收事务处理
select * from po_agents
select * from po_vendors 订单
select * from po_vendor_sites_all
--oe(销售)
select * from ra_customers 客户
select * from ra_addresses_all 地址
select * from ra_site_uses_all 用户
select * from oe_order_headers_all 销售头
select * from oe_order_lines_all 销售行
select * from wsh_new_deliveries 发送
select * from wsh_delivery_details
select * from wsh_delivery_assignments
--gl(总账)
select * from gl_sets_of_books 总帐
select * from gl_code_combinations gcc where gcc.summary_flag=\'Y\' 科目组合
select * from gl_balances 科目余额
select * from gl_je_batches 凭证批
select * from gl_je_headers 凭证头
select * from gl_je_lines 凭证行
select * from gl_je_categories 凭证分类
select * from gl_je_sources 凭证来源
select * from gl_summary_templates 科目汇总模板
select * from gl_account_hierarchies 科目汇总模板层次
--ar(应收)
select * from ar_batches_all 事务处理批
select * from ra_customer_trx_all 发票头
select * from ra_customer_trx_lines_all 发票行
select * from ra_cust_trx_line_gl_dist_all 发票分配
select * from ar_cash_receipts_all 收款
select * from ar_receivable_applications_all 核销
select * from ar_payment_schedules_all 发票调整
select * from ar_adjustments_all 会计分录
select * from ar_distributions_all 付款计划
--ap(应付)
select * from ap_invoices_all 发票头
select * from ap_invoice_distributions_all 发票行
select * from ap_payment_schedules_all 付款计划
select * from ap_check_stocks_all 单据
select * from ap_checks_all 付款
select * from ap_bank_branches 银行
select * from ap_bank_accounts_all 银行帐号
select * from ap_invoice_payments_all 核销
========================华丽的分割线=========================
INV库存
organization 两个含义:
1. 经营单位,A/B/C分公司,A下面有A1,A2等工厂,主题目标是为了独立核算此组织
ORG,ORG_ID;
2. 库存组织,例如制造商的仓库,例如A1,A2等工厂
Organization_id;
HR_ORGANIZATION_UNITS -
Org_organization_definitions
Mtl_subinventory_ 库存组织单位
MTL_PARAMETERS -库存组织参数(没有用ID,直接用name)
MTL_SYSTEM_ITEMS_b -物料信息(同上,应用了库存组织name)
MTL_SECONDARY_INVENTORIES -子库存组织 -
MTL_ITEM_LOCATTIONS -货位 - SUBINVENTROY_CODE
Mtl_Material_Transactions - (库存)物料事物表
成本 mtl_transaction_accounts
transaction_cost是事物成本;
ACTUAL_COST是通过成本算法计算出来的实际成本,主计量单位
现有量
汇总历史记录(正负合计)
Mtl_Material_Transactions
MTL_ONHAND_QUANTITIES现有量表,组织/子库存/货位/物品 summary可能按照挑库先进先出统计,如果设置了"不允许负库存",这样就不可能出现负数
PO
请购单头表
Po_Requisition_Headers_all
行表
Po_Requisition_lines_all
采购订单
PO_HEADER_ALL
PO_LINES_ALL
采购接收-退货/组织间转移/正常状态 都需要使用这个模块
RCV_TRANSACTIONS
1. 接收100单位货物,放入“待质检”货位
2. 接受/拒绝
3. 库存/退回
有三个不同的状态!例如:接收100个,80个接受入库,20个退回,那么有80个接受事务/20个退回事物
select TRANSACTION_TYPE,DESTINATION_TYPE_CODE from RCV_TRANSACTIONS
可以看出以下阶段:
A1.RECEIVE – RECEIVING
A2.ACCEPT – RECEIVING
A3.DELIERY – INVETORY(影响库存现有量)
如果按照正常模式,最后会触发产生MTL_MATERIAL_TRANSACTIONS
销售订单
OE_ORDER_headers_all
SOLD_FROM_ORG_ID
SOLD_TO_ORG_ID 就是客户层
SHIP_FROM_ORG_ID
SHIP_TO_ORG_ID 就是客户收货层
INVOICE_TO_ORG_ID 就是客户收单层
DELIVER_TO_ORG_ID
和客户结构有关
客户 RA_customers
客户Address Ra_Addresses
Address 货品抵达 site RA_SITE_USES_ALL
Address 发票抵达 site
OE_ORDER_LINEs_all
GL凭证
gl_je_batches
凭证日期: DEFAULT_EFFECTIVE_DATE
会计期间: DEFAULT_PERIOD_NAME
原币种凭证批借贷方汇总: RUNNING_TOTAL_DR/CR 比如美元
本位币凭证批借贷方汇总: RUNNING_TOTAL_ACCOUNTED_DR/CR
gl_je_headers日记账头信息
批号: JE_BATCH_ID
会计期间: PERIOD_NAME
币种: CURRENCY_CODE
汇率类型: CURRENCY_CONVERSION_TYPE
汇率日期: CURRENCY_CONVERSION_DATE
帐套: SET_OF_BOOKS_ID 参考 GL_SETS_OF_BOOKS
凭证类型: JE_CATEGORY 参考 GL_JE_SOURCES
凭证来源: JE_SOURCE
gl_je_lines日记账体信息
CODE_COMBINATION_ID 科目组合编号
GL_BALANCES 总帐余额
PERIOD_NET_DR/CR 净值
BEGIN_BALANCE_DR/CR 期初额
AR应收发票
RA_CUSTOMER_TRX_ALL
CUSTOMER_TRX_ID 发票编号
BILL_TO_SITE_USE_ID 客户收单方编号
PRIMARY_SALES_ID销售员
REFERENCE是Oracle提供的外部编号输入框,但是由于版本问题和长度(<=30),不建议用户使用,如果要使用外部编号,请使用说明性弹性域
RA_CUSTOMER_TRX_LINES_ALL
LINE_ID 行号
INVENTORY_ITEM_ID 可以为空,比如非物料的服务,只在DE script ION中出现 /税行
DE script ION
QUANTITY_INVOICE 开票数量
LINE_TYPE 行类型 (一般/税)
EXTEND_PRICE 本行金额
注意:税行是隐藏行,所以至少会有两行
收款情况
AR_CASH_RECEIPTS_ALL(还包含了非收款信息)
CASH_RECEIPT_ID 内部code
RECEIPT_NUMBER 收款号
RECEIPT_DATE 收款日期
AMOUNT 总额
RECEIPT_TYPE 现金/杂项 Cash/Misc
FUNCTIONAL_AMOUNT 本位币计量金额
UI上为RECEIPTS
核销关系不是一一对应,也不是一次核销100%,UI上右下方的Application 按钮
AR_RECEIVABLE_APPLICATIONS_ALL
APPLIED_CUSTOMER_TRX_ID 发票编号
APPLIED_CUSTOMER_TRX_LINE_ID 发票行编号
STATUS APP表示核销 /UNAPP表示未核销
AMOUNT_APPLIED 匹配金额
注意:红冲收款报表时间跨月的问题;必须联查 AR_CASH_RECEIPTS_ALL和 AR_CASH_RECEIPT_HISTORY_ALL
AP
应付帐款(是我方人员按照供应商提供的纸张发票信息录入)UI 上的invoice
AP_INVOICES_ALL
实际付款PAYMENT
AP_CHECKS_ALL
核销关系 同AR,右下方的Payment 按钮
AP_INVOICE_PAYMENTS_ALL客户余额表,情况比较复杂:比如两个用户合并,应收应付差额,预付款
资产信息FA_ADDITIONS
名称
编号
分类
数量
资产类别
FA_CATEGORIES
资产帐簿
FA_BOOK_CONTROLS 和会计帐簿有什么关系?
FA_BOOKS
UI中的Inquiry
Mothed是折旧方法(直线法/产量法)
FA_DISTRIBUTION_HISTORY分配assignment,给什么部门使用多少
LOCATION_ID 部门 联查FA_LOCATIONS
折旧信息(分摊方法)
FA_DEPRN_DETAIL
period_counter 折旧期间编号
折旧事务(新增、重建、转移、报废)
FA_TRANSACTION_HEADERS
========================华丽的分割线=========================
fnd_user --- 系统用户表
po_vendors --- 供应商信息表
po_vendor_sites --- 供应商地点信息表
hr_organization_units --- 组织及库存组织表
per_people_f --- 员工表
wip_entities --- 作业名信息表
wip_discrete_jobs --- 离散作业表
wip_requirement_operations --- 作业名物料需求发放表
po_headers_all --- 采购订单头表
po_lines_all --- 采购订单行表
po_line_locations_all --- 采购行地点表
rcv_transactions --- 接收交易表
bom_bill_of_materials --- 物料清单表
bom_inventory_components --- 物料清单构成表
mtl_system_items --- 物料主表
mtl_onhand_quantities --- 库存数据表
mtl_item_locations --- 项目货位表
mtl_material_transactions --- 出入库记录表
mtl_supply --- 供应表
mtl_demand --- 需求表
参考二:
1. OU、库存组织
SELECT hou.organization_id ou_org_id, --org_id
hou.name ou_name, --ou 名称
ood.organization_id org_org_id, -- 库存组织 id
ood.organization_code org_org_code, -- 库存组织代码
msi.secondary_inventory_name, -- 子库存名称
msi.description -- 子库存描述
FROM hr_organization_information hoi, -- 组织分类表
hr_operating_units hou, --ou 视图
org_organization_definitions ood, -- 库存组织定义视图
mtl_secondary_inventories msi -- 子库存信息表
WHERE hoi.org_information1 = \'OPERATING_UNIT\'
AND hoi.organization_id = hou.organization_id
AND ood.operating_unit = hoi.organization_id
AND ood.organization_id = msi.organization_id
-- 获取系统 ID
call fnd_global.APPS_INITIALIZE( 1318 , 50583 , 401 )
select fnd_profile.VALUE( \'ORG_ID\' ) FROM DUAL
select * from hr_operating_units hou where hou.organization_id= 204
2. 用户、责任及 HR
-- 系统责任定义 VIEW(FROM FND_RESPONSIBILITY_TL, FND_RESPONSIBILITY)
SELECT APPLICATION_ID,
RESPONSIBILITY_ID,
RESPONSIBILITY_KEY,
END_DATE,
RESPONSIBILITY_NAME,
DESCRIPTION
FROM FND_RESPONSIBILITY_VL;
-- 用户责任关系
SELECT USER_ID, RESPONSIBILITY_ID FROM FND_USER_RESP_GROUPS;
-- 用户表
SELECT USER_ID, USER_NAME, EMPLOYEE_ID, PERSON_PARTY_ID, END_DATE
FROM FND_USER;
-- 人员表 VIEW
SELECT PERSON_ID,
START_DATE,
DATE_OF_BIRTH,
EMPLOYEE_NUMBER,
NATIONAL_IDENTIFIER,
SEX,
FULL_NAME
FROM per_people_f;
-- 综合查询
SELECT USER_NAME, FULL_NAME, RESPONSIBILITY_NAME, CC.DESCRIPTION
FROM FND_USER AA,
FND_USER_RESP_GROUPS BB,
FND_RESPONSIBILITY_VL CC,
per_people_f DD
WHERE AA.USER_ID = BB.USER_ID
AND BB.RESPONSIBILITY_ID = CC.RESPONSIBILITY_ID
AND AA.EMPLOYEE_ID = DD.PERSON_ID
AND RESPONSIBILITY_NAME like \'% 供应处 %\'
ORDER BY USER_NAME;
-- 综合查询
-- 人员状况基本信息表
SELECT PAF.PERSON_ID 系统 ID,
PAF.FULL_NAME 姓名 ,
PAF.DATE_OF_BIRTH 出生日期 ,
PAF.REGION_OF_BIRTH 出生地区 ,
PAF.NATIONAL_IDENTIFIER 身份证号 ,
PAF.ATTRIBUTE1 招工来源 ,
PAF.ATTRIBUTE3 员工类型 ,
PAF.ATTRIBUTE11 集团合同号 ,
PAF.original_date_of_hire 参加工作日期 ,
PAF.PER_INFORMATION17 省份 ,
DECODE (PAF.SEX, \'M\' , \' 男 \' , \'F\' , \' 女 \' , \'NULL\' ) 性别 , --decode 适合和同一值做比较有多种结果,不适合和多种值比较有多种结果
CASE PAF.SEX
WHEN \'M\' THEN \' 男 \'
WHEN \'F\' THEN \' 女 \'
ELSE \'NULL\'
END 性别 1, --case 用法一
CASE WHEN TO_CHAR(PAF.DATE_OF_BIRTH, \'YYYY\' ) < \'1960\' THEN \'50 年代 \'
WHEN TO_CHAR(PAF.DATE_OF_BIRTH, \'YYYY\' ) < \'1970\' THEN \'60 年代 \'
WHEN TO_CHAR(PAF.DATE_OF_BIRTH, \'YYYY\' ) < \'1980\' THEN \'70 年代 \'
WHEN TO_CHAR(PAF.DATE_OF_BIRTH, \'YYYY\' ) < \'1990\' THEN \'80 年代 \'
WHEN TO_CHAR(PAF.DATE_OF_BIRTH, \'YYYY\' ) < \'2000\' THEN \'90 年代 \'
ELSE \'21 世纪 \' --case 用法二
END 出生年代
FROM PER_ALL_PEOPLE_F PAF
3. 供应商 VENDOR
-- 供应商主表数据:
SELECT ass.vendor_id vendor_id,
ass.party_id party_id,
ass.segment1 vendor_code,
ass.vendor_name vendor_name,
ass.vendor_name vendor_short_name,
ass.vendor_type_lookup_code vendor_type,
flv.meaning vendor_type_meaning,
hp.tax_reference tax_registered_name,
ass.payment_method_lookup_code payment_method,
att.name term_name,
att.enabled_flag enabled_flag,
att.end_date_active end_date_active,
ass.creation_date creation_date,
ass.created_by created_by,
ass.last_update_date last_update_date,
ass.last_updated_by last_updated_by,
ass.last_update_login last_update_login
FROM ap_suppliers ass,
fnd_lookup_values flv,
hz_parties hp,
ap_terms_tl att
WHERE ass.vendor_type_lookup_code = flv.lookup_code(+)
AND flv.lookup_type(+) = \'VENDOR TYPE\'
AND flv.language(+) = userenv ( \'LANG\' )
AND ass.party_id = hp.party_id
AND att.language = userenv ( \'LANG\' )
AND ass.terms_id = att.term_id(+)
-- 供应商银行信息
SELECT ass.vendor_id vendor_id,
ass.party_id party_id,
bank.party_id bank_id,
bank.party_name bank_name,
branch.party_id branch_id,
branch.party_name bank_branch_name,
ieba.bank_account_num bank_account_num
FROM ap_suppliers ass,
hz_parties hp,
iby_account_owners iao,
iby_ext_bank_accounts ieba,
hz_parties bank,
hz_parties branch
WHERE ass.party_id = hp.party_id
AND hp.party_id = iao.account_owner_party_id(+)
AND iao.ext_bank_account_id = ieba.ext_bank_account_id(+)
AND ieba.bank_id = bank.party_id(+)
AND ieba.branch_id = branch.party_id(+)
ORDER BY ieba.creation_date;
-- 供应商开户行地址信息
SELECT hps.party_id party_id,
hps.party_site_id party_site_id,
hl.location_id location_id,
hl.country country,
hl.province province,
hl.city city,
hl.address1 address1,
hl.address2 address2,
hl.address3 address3,
hl.address4 address4
FROM hz_party_sites hps, hz_locations hl
WHERE hps.location_id = hl.location_id
ORDER BY hps.creation_date
-- 供应商联系人信息
SELECT hr.subject_id subject_id,
hr.object_id object_id,
hr.party_id party_id,
hp.person_last_name || \' \' || hp.person_middle_name || \' \' ||
hp.person_first_name contact_person,
hcpp.phone_area_code phone_area_code,
hcpp.phone_number phone_number,
hcpp.phone_extension phone_extension,
hcpf.phone_area_code fax_phone_area_code,
hcpf.phone_number fax_phone_number,
hcpe.email_address email_address
FROM hz_relationships hr,
hz_contact_points hcpp,
hz_contact_points hcpf,
hz_contact_points hcpe,
hz_parties hp
WHERE hr.object_id = hp.party_id
AND hcpp.owner_table_id(+) = hr.party_id
AND hcpf.owner_table_id(+) = hr.party_id
AND hcpe.owner_table_id(+) = hr.party_id
AND hr.object_type = \'PERSON\'
AND hr.relationship_code(+) = \'CONTACT\'
AND hcpp.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpf.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpe.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpp.contact_point_type(+) = \'PHONE\'
AND hcpp.phone_line_type(+) = \'GEN\'
AND hcpf.contact_point_type(+) = \'PHONE\'
AND hcpf.phone_line_type(+) = \'FAX\'
AND hcpe.contact_point_type(+) = \'EMAIL\'
AND hcpe.phone_line_type IS NULL
ORDER BY hr.creation_date;
-- 供应商地址主信息
SELECT assa.vendor_site_id vendor_site_id,
assa.vendor_id vendor_id,
assa.vendor_site_code vendor_code,
assa.vendor_site_code address_short_name,
assa.address_line1 address_line1,
assa.address_line2 address_line2,
assa.address_line3 address_line3,
assa.address_line4 address_line4,
assa.org_id org_id,
assa.country country,
assa.province province,
assa.city city,
assa.county county,
assa.zip zip,
assa.pay_site_flag pay_site_flag,
assa.purchasing_site_flag purchasing_site_flag,
assa.inactive_date inactive_date,
assa.creation_date creation_date,
assa.created_by created_by,
assa.last_update_date last_update_date,
assa.last_updated_by last_updated_by,
assa.last_update_login last_update_login
FROM ap_suppliers ass, ap_supplier_sites_all assa
WHERE assa.vendor_id = ass.vendor_id;
-- 供应商地址联系人信息: phone 、 fax 和 Email
SELECT hcpp.phone_area_code phone_area_code,
hcpp.phone_number phone_number,
hcpp.phone_extension phone_extension,
hcpf.phone_area_code fax_phone_area_code,
hcpf.phone_number fax_phone_number,
hcpe.email_address email_address
FROM ap_supplier_sites_all assa,
hz_contact_points hcpp,
hz_contact_points hcpf,
hz_contact_points hcpe,
hz_party_sites hps
WHERE assa.party_site_id = hps.party_site_id
AND hcpp.owner_table_id(+) = assa.party_site_id
AND hcpf.owner_table_id(+) = assa.party_site_id
AND hcpe.owner_table_id(+) = assa.party_site_id
AND hcpp.owner_table_name(+) = \'HZ_PARTY_SITES\'
AND hcpf.owner_table_name(+) = \'HZ_PARTY_SITES\'
AND hcpe.owner_table_name(+) = \'HZ_PARTY_SITES\'
AND hcpp.contact_point_type(+) = \'PHONE\'
AND hcpp.phone_line_type(+) = \'GEN\'
AND hcpf.contact_point_type(+) = \'PHONE\'
AND hcpf.phone_line_type(+) = \'FAX\'
AND hcpe.contact_point_type(+) = \'EMAIL\'
AND hcpe.phone_line_type IS NULL ;
-- 供应商地址收件人信息
SELECT assa.party_site_id
FROM ap_supplier_sites_all assa
-- 根据 party_site_id 得到供应商地址的收件人名称
SELECT hps.addressee FROM hz_party_sites hps;
-- 供应商银行帐户分配层次关系
SELECT * FROM iby_pmt_instr_uses_all;
-- 供应商银行帐户分配层次关系明细 ( 不包括供应商层的分配信息 ):
SELECT * FROM iby_external_payees_all;
SELECT cgac.ap_asset_ccid, --应付款系统选项 现金帐户
cgac.ar_asset_ccid, --AR选项 现金帐户
gcc.segment3,
cba.*
FROM ce_gl_accounts_ccid cgac,
ce_bank_acct_uses_all cbau,
ce_bank_accounts cba,
gl_code_combinations gcc
WHERE cba.bank_account_id = cbau.bank_account_id
AND cbau.bank_acct_use_id = cgac.bank_acct_use_id
and cgac.ap_asset_ccid=gcc.code_combination_id
and gcc.segment3 like \'1002%\'
4. 客户 CUSTOMER
--SQL 查询
-- 客户账户表 以许继 1063 电网客户为例 -->>PARTY_ID = 21302
SELECT * FROM hz_cust_accounts AA WHERE AA.CUST_ACCOUNT_ID = 1063 ;
-- 客户名称及地址全局信息表 -->> PARTY_NUMBER = 19316
SELECT * FROM hz_parties AA WHERE AA.PARTY_ID = 21302 ;
-- 客户地点账户主文件
SELECT * FROM hz_cust_acct_sites_all WHERE CUST_ACCOUNT_ID = 1063 ;
-- 客户地点 ( 关联 hz_cust_acct_sites_all)
SELECT * FROM HZ_PARTY_SITES WHERE PARTY_ID = 21302 ;
-- 地点地址名称 ( 关联 hz_cust_acct_sites_all)
SELECT AA.ADDRESS1, AA.ADDRESS_KEY
FROM HZ_LOCATIONS AA, HZ_PARTY_SITES BB
WHERE AA.LOCATION_ID = BB.LOCATION_ID
AND BB.PARTY_ID = 21302 ;
-- 客户地点业务目的 ( 关联 hz_cust_acct_sites_all 用 CUST_ACCT_SITE_ID)
SELECT * FROM HZ_CUST_SITE_USES_ALL;
-- 客户地点详细信息表,以供应处 OU 的身份 ORG_ID = 119
SELECT AA.PARTY_SITE_ID 客户组织地点 ID,
AA.PARTY_ID 客户组织 ID,
AA.LOCATION_ID 地点 ID,
AA.PARTY_SITE_NUMBER 地点编号 ,
AA.IDENTIFYING_ADDRESS_FLAG 地址标示 ,
AA.STATUS 有效否 ,
AA.PARTY_SITE_NAME,
BB.ORG_ID 业务实体 ,
BB.bill_to_flag 收单标示 ,
BB.ship_to_flag 收货标示 ,
CC.ADDRESS1 地点名称 ,
DD.SITE_USE_ID,
DD.SITE_USE_CODE,
DD.PRIMARY_FLAG,
DD.STATUS,
DD.LOCATION 业务目的 ,
DD.BILL_TO_SITE_USE_ID 收单地 ID,
DD.TAX_CODE
FROM hz_party_sites AA,
hz_cust_acct_sites_all BB,
hz_locations CC,
HZ_CUST_SITE_USES_ALL DD
WHERE AA.PARTY_SITE_ID = BB.PARTY_SITE_ID
AND BB.CUST_ACCOUNT_ID = 1063
AND BB.ORG_ID = 119
AND AA.STATUS = \'A\'
AND AA.LOCATION_ID = CC.LOCATION_ID
AND BB.CUST_ACCT_SITE_ID(+) = DD.CUST_ACCT_SITE_ID
AND DD.STATUS <> \'I\' ;
--************* 综合查询 ************--
-- 客户主数据
SELECT hca.cust_account_id customer_id,
hp.party_number customer_number,
hp.party_name customer_name,
hp.party_name customer_short_name,
hca.customer_type customer_type,
alt.meaning customer_type_meaning,
hca.customer_class_code customer_class,
alc.meaning customer_class_meaning,
hp.tax_reference tax_registered_name,
rt.name term_name,
hca.creation_date creation_date,
hca.created_by created_by,
hca.last_update_date last_update_date,
hca.last_updated_by last_updated_by,
hca.last_update_login last_update_login
FROM hz_parties hp,
hz_cust_accounts hca,
ar_lookups alt,
ar_lookups alc,
hz_customer_profiles hcp,
ra_terms rt
WHERE hp.party_id = hca.party_id
AND hca.customer_type = alt.lookup_code(+)
AND alt.lookup_type = \'CUSTOMER_TYPE\'
AND hca.customer_class_code = alc.lookup_code(+)
AND alc.lookup_type(+) = \'CUSTOMER CLASS\'
AND hca.cust_account_id = hcp.cust_account_id(+)
AND hcp.standard_terms = rt.term_id(+)
-- 客户收款方法 SQL
SELECT arm.name receipt_method_name
FROM hz_cust_accounts hca,
ra_cust_receipt_methods rcrm,
ar_receipt_methods arm
WHERE hca.cust_account_id = rcrm.customer_id
AND rcrm.receipt_method_id = arm.receipt_method_id
ORDER BY rcrm.creation_date;
-- 客户账户层银行账户信息 SQL
SELECT hca.cust_account_id cust_account_id,
hp.party_id party_id,
bank.party_id bank_id,
bank.party_name bank_name,
branch.party_id branch_id,
branch.party_name bank_branch_name,
ieba.bank_account_num bank_account_num
FROM hz_cust_accounts hca,
hz_parties hp,
iby_account_owners iao,
iby_ext_bank_accounts ieba,
hz_parties bank,
hz_parties branch
WHERE hca.party_id = hp.party_id
AND hp.party_id = iao.account_owner_party_id(+)
AND iao.ext_bank_account_id = ieba.ext_bank_account_id(+)
AND ieba.bank_id = bank.party_id(+)
AND ieba.branch_id = branch.party_id(+)
ORDER BY ieba.creation_date;
-- 客户开户行地址信息 SQL
SELECT hl.country || \'-\' || hl.province || \'-\' || hl.city || \'-\' ||
hl.address1 || \'-\' || hl.address2 || \'-\' || hl.address3 || \'-\' ||
hl.address4 bank_address
FROM hz_party_sites hps, hz_locations hl
WHERE hps.location_id = hl.location_id
ORDER BY hps.creation_date;
-- 客户账户层联系人信息:联系人、电话、手机和 Email SQL
SELECT hr.party_id party_id,
hcar.cust_account_id cust_account_id,
hcar.cust_acct_site_id cust_acct_site_id,
hp.person_last_name || \' \' || hp.person_middle_name || \' \' ||
hp.person_first_name contact_person,
hcpp.phone_area_code phone_area_code,
hcpp.phone_number phone_number,
hcpp.phone_extension phone_extension,
hcpm.phone_area_code mobile_phone_area_code,
hcpm.phone_number mobile_phone_number,
hcpe.email_address email_address
FROM hz_relationships hr,
hz_cust_account_roles hcar,
hz_org_contacts hoc,
hz_contact_points hcpp,
hz_contact_points hcpm,
hz_contact_points hcpe,
hz_parties hp,
hz_cust_accounts hca
WHERE hr.object_id = hp.party_id
AND hr.party_id = hcar.party_id
AND hr.relationship_id = hoc.party_relationship_id(+)
AND hcpp.owner_table_id(+) = hr.party_id
AND hcpm.owner_table_id(+) = hr.party_id
AND hcpe.owner_table_id(+) = hr.party_id
AND hr.object_type = \'PERSON\'
AND hr.relationship_code(+) = \'CONTACT\'
AND hcpp.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpm.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpe.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpp.contact_point_type(+) = \'PHONE\'
AND hcpp.phone_line_type(+) = \'GEN\'
AND hcpm.contact_point_type(+) = \'PHONE\'
AND hcpm.phone_line_type(+) = \'MOBILE\'
AND hcpe.contact_point_type(+) = \'EMAIL\'
AND hcpe.phone_line_type IS NULL
AND hr.subject_id = hca.party_id
AND hcar.cust_acct_site_id IS NULL
ORDER BY hr.creation_date;
-- 客户地址
SELECT hcasa.cust_acct_site_id customer_site_id,
hcasa.cust_account_id customer_id,
hps.party_site_number customer_site_code,
hps.party_site_name customer_site_name,
hl.address1 address_line1,
hl.address2 address_line2,
hl.address3 address_line3,
hl.address4 address_line4,
hcasa.org_id org_id,
hl.country country,
hl.province province,
hl.city city,
hl.county county,
hl.postal_code zip,
hcasa.bill_to_flag bill_to_flag,
hcasa.ship_to_flag ship_to_flag,
hca.creation_date creation_date,
hca.created_by created_by,
hca.last_update_date last_update_date,
hca.last_updated_by last_updated_by,
hca.last_update_login last_update_login
FROM hz_cust_accounts hca,
hz_cust_acct_sites_all hcasa,
hz_party_sites hps,
hz_locations hl
WHERE hca.cust_account_id = hcasa.cust_account_id
AND hcasa.party_site_id = hps.party_site_id
AND hps.location_id = hl.location_id;
-- 客户账户层地址 contact person 信息 :phone,mobile,email
SELECT hr.party_id party_id,
hcar.cust_account_id cust_account_id,
hcar.cust_acct_site_id cust_acct_site_id,
hp.person_last_name || \' \' || hp.person_middle_name || \' \' ||
hp.person_first_name contact_person,
hcpp.phone_area_code phone_area_code,
hcpp.phone_number phone_number,
hcpp.phone_extension phone_extension,
hcpm.phone_area_code mobile_phone_area_code,
hcpm.phone_number mobile_phone_number,
hcpe.email_address email_address
FROM hz_relationships hr,
hz_cust_account_roles hcar,
hz_org_contacts hoc,
hz_contact_points hcpp,
hz_contact_points hcpm,
hz_contact_points hcpe,
hz_parties hp,
hz_cust_accounts hca
WHERE hr.object_id = hp.party_id
AND hr.party_id = hcar.party_id
AND hr.relationship_id = hoc.party_relationship_id(+)
AND hcpp.owner_table_id(+) = hr.party_id
AND hcpm.owner_table_id(+) = hr.party_id
AND hcpe.owner_table_id(+) = hr.party_id
AND hr.object_type = \'PERSON\'
AND hr.relationship_code(+) = \'CONTACT\'
AND hcpp.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpm.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpe.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpp.contact_point_type(+) = \'PHONE\'
AND hcpp.phone_line_type(+) = \'GEN\'
AND hcpm.contact_point_type(+) = \'PHONE\'
AND hcpm.phone_line_type(+) = \'MOBILE\'
AND hcpe.contact_point_type(+) = \'EMAIL\'
AND hcpe.phone_line_type IS NULL
AND hr.subject_id = hca.party_id
AND hca.cust_account_id = hcar.cust_account_id
ORDER BY hr.creation_date;
-- 客户账户地点地址
SELECT hp.party_id,
hca.cust_account_id,
hcasa.cust_acct_site_id,
hcasa.bill_to_flag,
hcasa.ship_to_flag,
hcsua.site_use_id,
hcasa.party_site_id,
hcsua.site_use_code,
hcsua.primary_flag,
hcsua.location,
hcsua.org_id
FROM hz_parties hp,
hz_cust_accounts hca,
hz_party_sites hps,
hz_cust_acct_sites_all hcasa,
hz_cust_site_uses_all hcsua
WHERE hp.party_id = hca.party_id
AND hca.cust_account_id = hcasa.cust_account_id
AND hcasa.party_site_id = hps.party_site_id
AND hcsua.cust_acct_site_id = hcasa.cust_acct_site_id
-- 客户主配置文件
SELECT * FROM hz_cust_profile_classes;
SELECT * FROM hz_customer_profiles;
SELECT * FROM hz_cust_prof_class_amts;
SELECT * FROM hz_cust_profile_amts;
5. 订单 OE
--
select * from oe_order_headers_all 销售头
select * from oe_order_lines_all 销售行
select * from wsh_new_deliveries 发送
select * from wsh_delivery_details
select * from wsh_delivery_assignments
-- 综合查询 1- 未结销售订单
SELECT H.ORDER_NUMBER 销售订单 ,
h.cust_po_number 客户 PO,
cust.account_number 客户编码 ,
hp.party_name 客户名称 ,
ship_use.location 收货地 ,
bill_use.location 收单地 ,
h.ordered_date 订单日期 ,
H.ATTRIBUTE1 合同号 ,
h.attribute2 屏号 ,
h.attribute3 来源编码 ,
l.line_number 行号 ,
l.ordered_item 物料 ,
msi.description 物料说明 ,
l.order_quantity_uom 订购单位 ,
l.ordered_quantity 订购数量 ,
l.cancelled_quantity 取消数量 ,
l.shipped_quantity 发运数量 ,
l.schedule_ship_date 计划发运日期 ,
l.booked_flag 登记标记 ,
ol.MEANING 工作流状态 ,
l.cancelled_flag 取消标记
FROM OE_ORDER_HEADERS_ALL H,
OE_ORDER_LINES_ALL L,
HZ_CUST_ACCOUNTS CUST,
hz_parties hp,
hz_cust_site_uses_all ship_use,
hz_cust_site_uses_all bill_use,
mtl_system_items_b msi,
oe_lookups ol
WHERE 1 = 1
AND H.HEADER_ID = L.HEADER_ID
AND H.SOLD_TO_ORG_ID = CUST.CUST_ACCOUNT_ID
and cust.party_id = hp.party_id
and h.ship_to_org_id = ship_use.site_use_id
and h.invoice_to_org_id = bill_use.site_use_id
and l.flow_status_code not in ( \'CLOSED\' , \'CANCELLED\' )
and l.inventory_item_id = msi.inventory_item_id
and msi.organization_id = 141
and l.flow_status_code = ol.LOOKUP_CODE
and ol.LOOKUP_TYPE = \'LINE_FLOW_STATUS\'
AND CUST.ACCOUNT_NUMBER IN ( \'91010072\' , \'91010067\' , \'91010036\' )
order by party_name ,收货地,销售订单 ;
6. 采购申请 PR
-- 申请单头 (以电网组织 ORG_ID=112 内部申请 =14140002781 为例
SELECT PRH.REQUISITION_HEADER_ID 申请单头 ID,
PRH.PREPARER_ID,
PRH.Org_Id OU_ID,
PRH.SEGMENT1 申请单编号 ,
PRH.Creation_Date 创建日期 ,
PRH.Created_By 编制人 ID,
FU.USER_NAME 用户名称 ,
PP.FULL_NAME 用户姓名 ,
PRH.Approved_Date 批准日期 ,
PRH.Description 说明 ,
PRH.Authorization_Status 状态 ,
PRH.Type_Lookup_Code 类型 ,
PRH.Transferred_To_Oe_Flag 传递标示
FROM PO_REQUISITION_HEADERS_ALL PRH, FND_USER FU, per_people_f PP
WHERE PRH.CREATED_BY = FU.USER_ID
AND FU.EMPLOYEE_ID = PP.PERSON_ID
AND PRH.ORG_ID = 112
AND PRH.SEGMENT1 = \'14140002781\' ;
-->> 内部申请 =14140002781 申请单头 ID = 3379
-- 申请单行明细
SELECT PRL.REQUISITION_HEADER_ID 申请单 ID,
PRL.REQUISITION_LINE_ID 行 ID,
PRL.LINE_NUM 行号 ,
PRL.CATEGORY_ID 分类 ID,
PRL.ITEM_ID 物料 ID,
ITEM.SEGMENT1 物料编码 ,
PRL.ITEM_DESCRIPTION 物料说明 ,
PRL.Quantity 需求数 ,
PRL.Quantity_Delivered 送货数 ,
PRL.Quantity_Cancelled 取消数 ,
PRL.Unit_Meas_Lookup_Code 单位 ,
PRL.Unit_Price 参考价 ,
PRL.Need_By_Date 需求日期 ,
PRL.Source_Type_Code 来源类型 ,
PRL.Org_Id OU_ID,
PRL.Source_Organization_Id 对方组织 ID,
PRL.Destination_Organization_Id 本方组织 ID
from PO_REQUISITION_LINES_ALL PRL,MTL_SYSTEM_ITEMS ITEM
WHERE PRL.ORG_ID = 112
AND PRL.ITEM_ID = ITEM.INVENTORY_ITEM_ID
AND PRL.Destination_Organization_Id = ITEM.ORGANIZATION_ID
AND PRL.REQUISITION_HEADER_ID = 3379 ;
-- 申请单头 ( 加对方订单编号 )
SELECT PRH.REQUISITION_HEADER_ID 申请单头 ID,
PRH.PREPARER_ID,
PRH.Org_Id OU_ID,
PRH.SEGMENT1 申请单编号 ,
PRH.Creation_Date 创建日期 ,
PRH.Created_By 编制人 ID,
FU.USER_NAME 用户名称 ,
PP.FULL_NAME 用户姓名 ,
PRH.Approved_Date 批准日期 ,
PRH.Description 说明 ,
PRH.Authorization_Status 状态 ,
PRH.Type_Lookup_Code 类型 ,
PRH.Transferred_To_Oe_Flag 传递标示 ,
OEH.ORDER_NUMBER 对方 CO 编号
FROM PO_REQUISITION_HEADERS_ALL PRH, FND_USER FU, per_people_f PP,OE_ORDER_HEADERS_ALL OEH
WHERE PRH.CREATED_BY = FU.USER_ID
AND FU.EMPLOYEE_ID = PP.PERSON_ID
AND PRH.REQUISITION_HEADER_ID = OEH.SOURCE_DOCUMENT_ID(+)
AND PRH.ORG_ID = 112
AND PRH.SEGMENT1 = \'14140002781\' ;
--( 销售订单记录有对方 OU_ID, 申请单关键字 SOURCE_DOCUMENT_ID 申请单号 SOURCE_DOCEMENT_REF)
******************* 综合查询类 *******************
-- 申请单头综合查询 (进限制只能查询 -- 电网组织 ORG_ID=112)
SELECT PRH.REQUISITION_HEADER_ID 申请单头 ID,
PRH.Org_Id 组织 ID,
PRH.SEGMENT1 申请单编号 ,
PRH.Creation_Date 创建日期 ,
PRH.Created_By 编制人 ID,
FU.USER_NAME 用户名称 ,
PP.FULL_NAME 用户姓名 ,
PRH.Approved_Date 批准日期 ,
PRH.Description 说明 ,
PRH.Authorization_Status 状态 ,
PRH.Type_Lookup_Code 类型 ,
PRH.Transferred_To_Oe_Flag 传递标示 ,
PRL.REQUISITION_LINE_ID 行 ID,
PRL.LINE_NUM 行号 ,
PRL.CATEGORY_ID 分类 ID,
PRL.ITEM_ID 物料 ID,
ITEM.SEGMENT1 物料编码 ,
PRL.ITEM_DESCRIPTION 物料说明 ,
PRL.Quantity 需求数 ,
PRL.Quantity_Delivered 送货数 ,
PRL.Quantity_Cancelled 取消数 ,
PRL.Unit_Meas_Lookup_Code 单位 ,
PRL.Unit_Price 参考价 ,
PRL.Need_By_Date 需求日期 ,
PRL.Source_Type_Code 来源类型 ,
PRL.Source_Organization_Id 对方组织 ID,
PRL.Destination_Organization_Id 本方组织 ID
FROM PO_REQUISITION_HEADERS_ALL PRH,
FND_USER FU,
per_people_f PP,
PO_REQUISITION_LINES_ALL PRL,
MTL_SYSTEM_ITEMS ITEM
WHERE PRH.CREATED_BY = FU.USER_ID
AND FU.EMPLOYEE_ID = PP.PERSON_ID
AND PRH.REQUISITION_HEADER_ID = PRL.REQUISITION_HEADER_ID
AND PRH.Org_Id = PRL.ORG_ID
AND PRL.ITEM_ID = ITEM.INVENTORY_ITEM_ID
AND PRL.Destination_Organization_Id = ITEM.ORGANIZATION_ID
AND PRH.ORG_ID = 112 ;
-- 若需创建视图只需在 SELECT 语句前加上
CREATE OR REPLACE VIEW CUX_INV_PR112 AS
7. 采购订单 PO
-- 采购单头信息 TYPE_LOOKUP_CODE=\'STANDARD\' (以供应处 OU ORG_ID=119 采购单 =\'\' 为例)
-- 类型说明 TYPE_LOOKUP_CODE=\'STANDARD\' 为采购单 TYPE_LOOKUP_CODE=\'BLANKET\' 为采购协议
SELECT POH.ORG_ID OU_ID,
POH.PO_HEADER_ID 采购单头 ID,
POH.TYPE_LOOKUP_CODE 类型 ,
POH.AUTHORIZATION_STATUS 状态 ,
POH.VENDOR_ID 供应商 ID,
VENDOR.VENDOR_NAME 供应商名 ,
POH.VENDOR_SITE_ID 供应商地址 ID,
POH.VENDOR_CONTACT_ID 供应商联系人 ID,
POH.SHIP_TO_LOCATION_ID 本方收货地 ID,
POH.BILL_TO_LOCATION_ID 本方收单地 ID,
POH.CREATION_DATE 创建日期 ,
POH.APPROVED_FLAG 审批 YN,
POH.APPROVED_DATE 审批日期 ,
POH.COMMENTS 采购单说明 ,
POH.TERMS_ID 条款 ID,
POH.AGENT_ID 采购员 ID,
AGT_PP.LAST_NAME 采购员 ,
POH.CREATED_BY 创建者 ID,
FU.USER_NAME 创建用户 ,
PP.FULL_NAME 用户姓名
FROM PO_HEADERS_ALL POH, FND_USER FU, per_people_f PP,PER_ALL_PEOPLE_F AGT_PP,ap_suppliers VENDOR
WHERE POH.CREATED_BY = FU.USER_ID
AND FU.EMPLOYEE_ID = PP.PERSON_ID
AND POH.AGENT_ID = AGT_PP.PERSON_ID
AND POH.VENDOR_ID=VENDOR.VENDOR_ID
AND POH.ORG_ID = 119
AND POH.TYPE_LOOKUP_CODE = \'STANDARD\'
AND POH.SEGMENT1 = \'14730005436\' ;
/*
FND_USER FU, per_people_f PP 用户相关表
po_agents_name_v 采购员视图 ----> PO_AGENTS.AGENT_ID = PER_ALL_PEOPLE_F.PERSON_ID 采购员相关表
ap_suppliers 供应商主表
*/
-->> POH.SEGMENT1 = \'14730005436\' PO_HEADER_ID = 10068
-- 采购单行信息
SELECT POL.ORG_ID OU_ID,
POL.PO_HEADER_ID 采购单头 ID,
POL.PO_LINE_ID 行 ID,
POL.LINE_NUM 行号 ,
POL.ITEM_ID 物料 ID,
ITEM.SEGMENT1 物料编码 ,
POL.ITEM_DESCRIPTION 物料说明 ,
POL.UNIT_MEAS_LOOKUP_CODE 单位 ,
POL.UNIT_PRICE 单价 ,
PO_LCT.QUANTITY 订购数 ,
PO_LCT.QUANTITY_RECEIVED 验收数 ,
PO_LCT.QUANTITY_ACCEPTED 接收数 ,
PO_LCT.QUANTITY_REJECTED 拒绝数 ,
PO_LCT.QUANTITY_CANCELLED 取消数 ,
PO_LCT.QUANTITY_BILLED 到票数 ,
PO_LCT.PROMISED_DATE 承诺日期 ,
PO_LCT.NEED_BY_DATE 需求日期
FROM PO_LINES_ALL POL,
Po_Line_Locations_all PO_LCT,
MTL_SYSTEM_ITEMS ITEM
WHERE POL.ORG_ID = PO_LCT.ORG_ID
AND POL.PO_LINE_ID = PO_LCT.PO_LINE_ID
AND POL.ITEM_ID = ITEM.INVENTORY_ITEM_ID
AND ITEM.ORGANIZATION_ID = 142
AND POL.Org_Id = 119
AND POL.PO_HEADER_ID = 10068 ;
-- 说明: Po_Line_Locations_all 系 “ 发运表 ”
-- 综合查询 1 ,所分配给供应处组织的物料,存在采购协议,但缺失采购员或缺失仓库;
select MSIF.Segment1 物料编码 ,
MSIF.Description 物料描述 ,
MSIF.LONG_DESCRIPTION 物料详细描述 ,
--MSIF.primary_unit_of_measure 计量单位 ,
PRF.LAST_NAME 采购员 ,
MISD.subinventory_code 默认接收库存 ,
PLA.unit_price 未税价 ,
round (PLA.unit_price * ( 1 + ZRB.percentage_rate / 100 ), 2 ) 含税价 ,
PV.VENDOR_NAME 供应商名称
from apps.PO_HEADERS_ALL PHA,
apps.PO_LINES_ALL PLA,
apps.MTL_SYSTEM_ITEMS_FVL MSIF,
apps.MTL_ITEM_SUB_DEFAULTS MISD,
apps.PER_PEOPLE_F PRF,
apps.PO_VENDORS PV,
apps.PO_VENDOR_SITES_ALL PVSA,
apps.ZX_RATES_B ZRB
where PHA.Type_Lookup_Code = \'BLANKET\' and PHA.Org_Id = 119 and
PHA.PO_HEADER_ID = PLA.Po_Header_Id and
PHA.Global_Agreement_Flag = \'Y\' and PHA.Approved_Flag in ( \'Y\' , \'R\' ) and
NVL (PHA.end_Date, sysdate ) >= sysdate and
NVL (PLA.Expiration_Date, sysdate ) >= sysdate and
PLA.Cancel_Flag = \'N\' and PLA.Item_Id = MSIF.INVENTORY_ITEM_ID and
MSIF.ORGANIZATION_ID = 142 and
MSIF.INVENTORY_ITEM_ID = MISD.INVENTORY_ITEM_ID(+) and
MISD.ORGANIZATION_ID(+) = 142 and MISD.default_type(+) = 2 and
MSIF.BUYER_ID = PRF.PERSON_ID(+) and
PRF.EFFECTIVE_END_DATE(+) = to_date( \'4712-12-31\' , \'YYYY-MM-DD\' ) and
PHA.VENDOR_ID = PV.VENDOR_ID and
PHA.Vendor_Site_Id = PVSA.VENDOR_SITE_ID and
PVSA.VAT_CODE = ZRB.tax_rate_code and
(MISD.subinventory_code is null or PRF.LAST_NAME is null )
-- 采购其他相关表
select * from po_distributions_all 分配
select * from po_releases_all
select * from rcv_shipment_headers 采购接收头
select * from rcv_shipment_lines 采购接收行
select * from rcv_transactions 接收事务处理
select * from po_agents
select * from po_vendors
select * from po_vendor_sites_all
8. 库存 INV
-- 物料主表
select MSI.ORGANIZATION_ID 组织 ID,
MSI.INVENTORY_ITEM_ID 物料 ID,
MSI.SEGMENT1 物料编码 ,
MSI.DESCRIPTION 物料说明 ,
MSI.ITEM_TYPE 项目类型 ,
MSI.PLANNING_MAKE_BUY_CODE 制造或购买 ,
MSI.PRIMARY_UNIT_OF_MEASURE 基本度量单位 ,
MSI.BOM_ENABLED_FLAG BOM 标志 ,
MSI.INVENTORY_ASSET_FLAG 库存资产否 ,
MSI.BUYER_ID 采购员 ID,
MSI.PURCHASING_ENABLED_FLAG 可采购否 ,
MSI.PURCHASING_ITEM_FLAG 采购项目 ,
MSI.UNIT_OF_ISSUE 单位 ,
MSI.INVENTORY_ITEM_FLAG 是否为库存 ,
MSI.LOT_CONTROL_CODE 是否批量 ,
MSI.RESERVABLE_TYPE 是否要预留 ,
MSI.STOCK_ENABLED_FLAG 能否库存 ,
MSI.FIXED_DAYS_SUPPLY 固定提前期 ,
MSI.FIXED_LOT_MULTIPLIER 固定批量大小 ,
MSI.INVENTORY_PLANNING_CODE 库存计划方法 ,
MSI.MAXIMUM_ORDER_QUANTITY 最大定单数 ,
MSI.MINIMUM_ORDER_QUANTITY 最小定单数 ,
MSI.FULL_LEAD_TIME 固定提前期 ,
MSI.PLANNER_CODE 计划员码 ,
MISD.SUBINVENTORY_CODE 接收子仓库 ,
MSI.SOURCE_SUBINVENTORY 来源子仓库 ,
MSI.WIP_SUPPLY_SUBINVENTORY 供应子仓库 ,
MSI.ATTRIBUTE12 老编码 ,
MSI.INVENTORY_ITEM_STATUS_CODE 物料状态 ,
MSS.SAFETY_STOCK_QUANTITY 安全库存量
from mtl_system_items MSI, MTL_ITEM_SUB_DEFAULTS MISD,mtl_safety_stocks MSS
where MSI.ORGANIZATION_ID = MISD.ORGANIZATION_ID(+)
and MSI.INVENTORY_ITEM_ID = MISD.INVENTORY_ITEM_ID(+)
and MSI.ORGANIZATION_ID = MSS.ORGANIZATION_ID(+)
and MSI.INVENTORY_ITEM_ID = MSS.INVENTORY_ITEM_ID(+)
and MSI.ORGANIZATION_ID = 1155
and MSI.SEGMENT1 = \'18020200012\'
-- 物料库存数量
SELECT MOQ.ORGANIZATION_ID,
MOQ.INVENTORY_ITEM_ID,
MOQ.SUBINVENTORY_CODE,
SUM (MOQ.TRANSACTION_QUANTITY) QTY
FROM mtl_onhand_quantities MOQ
WHERE MOQ.INVENTORY_ITEM_ID = 12781
AND MOQ.ORGANIZATION_ID = 1155
GROUP BY MOQ.ORGANIZATION_ID, MOQ.INVENTORY_ITEM_ID, MOQ.SUBINVENTORY_CODE;
-- 移动平均成本
SELECT CST.INVENTORY_ITEM_ID ITEM_ID,
CST.ORGANIZATION_ID ORG_ID,
CST.COST_TYPE_ID 成本类型 ,
CST.ITEM_COST 单位成本 ,
CST.MATERIAL_COST 材料成本 ,
CST.MATERIAL_OVERHEAD_COST 间接费 ,
CST.Resource_Cost 人工费 ,
CST.OUTSIDE_PROCESSING_COST 外协费 ,
CST.OVERHEAD_COST 制造费
FROM CST_ITEM_COSTS CST
WHERE CST.COST_TYPE_ID = 2
AND CST.INVENTORY_ITEM_ID = 12781
AND CST.ORGANIZATION_ID = 1155 ;
-- 综合查询 - 库存数量及成本
SELECT MSI.ORGANIZATION_ID 组织 ID,
MSI.INVENTORY_ITEM_ID 物料 ID,
MSI.SEGMENT1 物料编码 ,
MSI.DESCRIPTION 物料说明 ,
MSI.PLANNING_MAKE_BUY_CODE M1P2,
MOQV.SUBINVENTORY_CODE 子库存 ,
MOQV.QTY 当前库存量 ,
CST.ITEM_COST 单位成本 ,
CST.MATERIAL_COST 材料成本 ,
CST.MATERIAL_OVERHEAD_COST 间接费 ,
CST.Resource_Cost 人工费 ,
CST.OUTSIDE_PROCESSING_COST 外协费 ,
CST.OVERHEAD_COST 制造费
FROM MTL_SYSTEM_ITEMS MSI,
CST_ITEM_COSTS CST,
( SELECT MOQ.ORGANIZATION_ID,
MOQ.INVENTORY_ITEM_ID,
MOQ.SUBINVENTORY_CODE,
SUM (MOQ.TRANSACTION_QUANTITY) QTY
FROM mtl_onhand_quantities MOQ
WHERE MOQ.ORGANIZATION_ID = 1155
GROUP BY MOQ.ORGANIZATION_ID,
MOQ.INVENTORY_ITEM_ID,
MOQ.SUBINVENTORY_CODE) MOQV
WHERE MSI.ORGANIZATION_ID = CST.ORGANIZATION_ID(+)
AND MSI.INVENTORY_ITEM_ID = CST.INVENTORY_ITEM_ID(+)
AND MSI.ORGANIZATION_ID = MOQV.ORGANIZATION_ID(+)
AND MSI.INVENTORY_ITEM_ID = MOQV.INVENTORY_ITEM_ID(+)
AND CST.COST_TYPE_ID = 2
AND MSI.ORGANIZATION_ID = 1155
AND MSI.SEGMENT1 = \'18020200012\'
-- 子库存列表
SELECT * FROM mtl_secondary_inventories;
-- 货位列表
SELECT ORGANIZATION_ID 组织代码 ,
INVENTORY_LOCATION_ID 货位内码 ,
SUBINVENTORY_CODE 子库名称 ,
SEGMENT1 货位编码
FROM mtl_item_locations;
-- 计划员表
SELECT PLANNER_CODE 计划员代码 ,
ORGANIZATION_ID 组织代码 ,
DESCRIPTION 计划员描述 ,
MP.EMPLOYEE_ID 员工 ID,
DISABLE_DATE 失效日期
FROM mtl_planners MP;
-- 科目设置等参数
select * from MTL_PARAMETERS MP
9. 物料清单 BOM
--BOM 主表 bom_bill_of_materials
select AA.BILL_SEQUENCE_ID 清单序号 ,
AA.ASSEMBLY_ITEM_ID 装配件内码 ,
AA.ORGANIZATION_ID 组织代码 ,
BB.SEGMENT1 物料编码 ,
BB.DESCRIPTION 物料说明 ,
AA.ASSEMBLY_TYPE 装配类别
from bom_bill_of_materials AA , mtl_system_items BB
where AA.ASSEMBLY_ITEM_ID = BB.INVENTORY_ITEM_ID
and AA.ORGANIZATION_ID = BB.ORGANIZATION_ID;
--BOM 明细表 bom_inventory_components
select BILL_SEQUENCE_ID 清单序号 ,
COMPONENT_SEQUENCE_ID 构件序号 ,
ITEM_NUM 项目序列 ,
OPERATION_SEQ_NUM 操作序列号 ,
COMPONENT_ITEM_ID 子物料内码 ,
COMPONENT_QUANTITY 构件数量 ,
DISABLE_DATE 失效日期 ,
supply_subinventory 供应子库存 ,
BOM_ITEM_TYPE
from bom_inventory_components;
--BOM 明细综合查询 ( 组织 限定供应处 142 装配件 = \'5XJ061988\')
SELECT VBOM.BID 清单序号 ,
VBOM.F_ITEMID 装配件内码 ,
BB.SEGMENT1 物料编码 ,
BB.DESCRIPTION 物料说明 ,
VBOM.OGT_ID 组织内码 ,
VBOM.CID 操作 ID,
VBOM.ITEM_NUM 物料序号 ,
VBOM.OPID 工序 ,
VBOM.C_ITEMID 子物料内码 ,
CC.SEGMENT1 物料编码 ,
CC.DESCRIPTION 物料说明 ,
VBOM.QTY 构件数量 ,
CC.PRIMARY_UOM_CODE 子计量单位码 ,
CC.PRIMARY_UNIT_OF_MEASURE 子计量单位名 ,
VBOM.WHSE 供应子仓库
FROM ( select AA.BILL_SEQUENCE_ID BID,
BB.ASSEMBLY_ITEM_ID F_ITEMID,
BB.ORGANIZATION_ID OGT_ID,
AA.COMPONENT_SEQUENCE_ID CID,
AA.ITEM_NUM ITEM_NUM,
AA.OPERATION_SEQ_NUM OPID,
AA.COMPONENT_ITEM_ID C_ITEMID,
AA.COMPONENT_QUANTITY QTY,
AA.supply_subinventory WHSE
from bom_inventory_components AA, bom_bill_of_materials BB
where AA.BILL_SEQUENCE_ID = BB.BILL_SEQUENCE_ID) VBOM,
mtl_system_items BB,
mtl_system_items CC
WHERE VBOM.F_ITEMID = BB.INVENTORY_ITEM_ID
and VBOM.OGT_ID = BB.ORGANIZATION_ID
and VBOM.C_ITEMID = CC.INVENTORY_ITEM_ID
and VBOM.OGT_ID = CC.ORGANIZATION_ID
and VBOM.OGT_ID = 142
and BB.SEGMENT1 = \'5XJ061988\'
ORDER BY VBOM.ITEM_NUM;
-- 单层 BOM 成本查询 ( 需系统提交请求计算后 )
select inventory_item_id, organization_id, item_cost, program_update_date
from bom.cst_item_costs
where inventory_item_id = 23760
and organization_id = 142 ;
select inventory_item_id, organization_id, item_cost, program_update_date
from cst_item_cost_details
where inventory_item_id = 23760
and organization_id = 142 ;
10. 作业任务 WIP
说明: 查询作业任务头以及作业任务工序和 BOM 情况
-- 作业任务头信息表
-- (以直流 OU_ID=117 ; ORGANIZATION_ID=1155; 及任务 WIP_ENTITY_NAME=\'XJ39562\'; 装配件编码 SEGMENT1 = \'07D9202.92742\' 为例)
SELECT AA.WIP_ENTITY_ID 任务令 ID,
AA.ORGANIZATION_ID 组织 ID,
AA.WIP_ENTITY_NAME 任务名称 ,
AA.ENTITY_TYPE 任务类型 ,
AA.CREATION_DATE 创建日期 ,
AA.CREATED_BY 创建者 ID,
AA.DESCRIPTION 说明 ,
AA.PRIMARY_ITEM_ID 装配件 ID,
BB.SEGMENT1 物料编码 ,
BB.DESCRIPTION 物料说明
FROM wip_entities AA, mtl_system_items BB
WHERE AA.PRIMARY_ITEM_ID = BB.INVENTORY_ITEM_ID
and AA.ORGANIZATION_ID = BB.ORGANIZATION_ID
and AA.ORGANIZATION_ID = 1155
and AA.WIP_ENTITY_NAME = \'XJ39562\' ;
--=> WIP_ENTITY_ID = 48825
-- 离散作业任务详细主信息表
-- 用途 1 )作业任务下达及完成情况查询
-- 说明 1 )此表包括 wip_entities 表大部分信息 2) 重复作业任务表为 wip_repetitive_items, wip_repetitive_schedules
select AA.WIP_ENTITY_ID 任务令 ID,
BB.WIP_ENTITY_NAME 任务名称 ,
AA.ORGANIZATION_ID 组织 ID,
AA.SOURCE_LINE_ID 行 ID,
AA.STATUS_TYPE 状态 TYPE,
AA.PRIMARY_ITEM_ID 装配件 ID,
CC.SEGMENT1 物料编码 ,
CC.DESCRIPTION 物料说明 ,
AA.FIRM_PLANNED_FLAG,
AA.JOB_TYPE 作业类型 ,
AA.WIP_SUPPLY_TYPE 供应 TYPE,
AA.CLASS_CODE 任务类别 ,
AA.SCHEDULED_START_DATE 起始时间 ,
AA.DATE_RELEASED 下达时间 ,
AA.SCHEDULED_COMPLETION_DATE 完工时间 ,
AA.DATE_COMPLETED 完工时间 ,
AA.DATE_CLOSED 关门时间 ,
AA.START_QUANTITY 计划数 ,
AA.QUANTITY_COMPLETED 完工数 ,
AA.QUANTITY_SCRAPPED 报废数 ,
AA.NET_QUANTITY MRP 净值 ,
AA.COMPLETION_SUBINVENTORY 接收子库 ,
AA.COMPLETION_LOCATOR_ID 货位
from wip_discrete_jobs AA, wip.wip_entities BB, mtl_system_items CC
where AA.WIP_ENTITY_ID = BB.WIP_ENTITY_ID
and AA.PRIMARY_ITEM_ID = CC.INVENTORY_ITEM_ID
and AA.ORGANIZATION_ID = CC.ORGANIZATION_ID
and AA.organization_id = 1155
and BB.WIP_ENTITY_NAME = \'XJ39562\' ;
/*
1 )任务状态 TYPE 值说明:
STATUS_TYPE =1 未发放的 - 收费不允许
STATUS_TYPE =3 发入 - 收费允许
STATUS_TYPE =4 完成 - 允许收费
STATUS_TYPE =5 完成 - 不允许收费
STATUS_TYPE =6 暂挂 - 不允许收费
STATUS_TYPE =7 已取消 - 不允许收费
STATUS_TYPE =8 等待物料单加载
STATUS_TYPE =9 失败的物料单加载
STATUS_TYPE =10 等待路线加载
STATUS_TYPE =11 失败的路线加载
STATUS_TYPE =12 关闭 - 不可收费
STATUS_TYPE =13 等待 - 成批加载
STATUS_TYPE =14 等待关闭
STATUS_TYPE =15 关闭失败
2 )供应类型 TYPE 值说明:
WIP_SUPPLY_TYPE =1 推式
WIP_SUPPLY_TYPE =2 装配拉式
WIP_SUPPLY_TYPE =3 操作拉式
WIP_SUPPLY_TYPE =4 大量
WIP_SUPPLY_TYPE =5 供应商
WIP_SUPPLY_TYPE =6 虚拟
WIP_SUPPLY_TYPE =7 以帐单为基础
*/
-- 离散作业任务工序状况表
select AA.ORGANIZATION_ID 组织 ID,
AA.WIP_ENTITY_ID 任务令 ID,
BB.WIP_ENTITY_NAME 任务名称 ,
AA.OPERATION_SEQ_NUM 工序号 ,
AA.DESCRIPTION 工序描述 ,
AA.DEPARTMENT_ID 部门 ID,
AA.SCHEDULED_QUANTITY 计划数量 ,
AA.QUANTITY_IN_QUEUE 排队数量 ,
AA.QUANTITY_RUNNING 运行数量 ,
AA.QUANTITY_WAITING_TO_MOVE 待移动数量 ,
AA.QUANTITY_REJECTED 故障品数量 ,
AA.QUANTITY_SCRAPPED 报废品数量 ,
AA.QUANTITY_COMPLETED 完工数量 ,
AA.FIRST_UNIT_START_DATE 最早一个单位上线时间 ,
AA.FIRST_UNIT_COMPLETION_DATE 最早一个单位完成时间 ,
AA.LAST_UNIT_START_DATE 最后一个单位上线时间 ,
AA.LAST_UNIT_COMPLETION_DATE 最后一个单位完工时间 ,
AA.PREVIOUS_OPERATION_SEQ_NUM 前一工序序号 ,
AA.NEXT_OPERATION_SEQ_NUM 下一工序序号 ,
AA.COUNT_POINT_TYPE 是否自动计费 ,
AA.BACKFLUSH_FLAG 倒冲否 ,
AA.MINIMUM_TRANSFER_QUANTITY 最小传送数量 ,
AA.DATE_LAST_MOVED 最后移动时间
from wip_operations AA,wip_entities BB
where AA.WIP_ENTITY_ID = BB.WIP_ENTITY_ID
and BB.WIP_ENTITY_NAME = \'XJ39562\' ;
-- 离散作业任务子查询 ——— 工单工序状况查询(不单独使用)
select WDJ.ORGANIZATION_ID,
WDJ.WIP_ENTITY_ID,
COUNT ( 1 ) COUNT_OPER,
max ( decode (wo.quantity_completed, 1 , wo.operation_seq_num, 10 )) OPER
from WIP_DISCRETE_JOBS WDJ, WIP_OPERATIONS WO
where 1 = 1
AND WDJ.WIP_ENTITY_ID = WO.WIP_ENTITY_ID
AND WDJ.wip_entity_id = \'48825\'
group by WDJ.ORGANIZATION_ID,WDJ.WIP_ENTITY_ID;
-- 离散作业任务 BOM ( 无材料费 )
SELECT WOP.ORGANIZATION_ID 组织 ID,
WOP.WIP_ENTITY_ID 任务令 ID,
BB.WIP_ENTITY_NAME 装配件名称 ,
BB.PRIMARY_ITEM_ID 装配件 ID,
CC.SEGMENT1 装配件物料编码 ,
CC.DESCRIPTION 装配件说明 ,
WOP.OPERATION_SEQ_NUM 工序号 ,
WOP.DEPARTMENT_ID 部门 ID,
WOP.WIP_SUPPLY_TYPE 供应类型 ,
WOP.DATE_REQUIRED 要求日期 ,
WOP.INVENTORY_ITEM_ID 子物料 ID,
DD.SEGMENT1 子物料编码 ,
DD.DESCRIPTION 子物料说明 ,
WOP.QUANTITY_PER_ASSEMBLY 单位需量 ,
WOP.REQUIRED_QUANTITY 总需求量 ,
WOP.QUANTITY_ISSUED 已发放量 ,
WOP.COMMENTS 注释 ,
WOP.SUPPLY_SUBINVENTORY 供应子库
FROM wip_requirement_operations WOP,
wip_entities BB,
mtl_system_items CC,
mtl_system_items DD
WHERE WOP.WIP_ENTITY_ID = BB.WIP_ENTITY_ID
and BB.PRIMARY_ITEM_ID = CC.INVENTORY_ITEM_ID
and BB.ORGANIZATION_ID = CC.ORGANIZATION_ID
and WOP.INVENTORY_ITEM_ID = DD.INVENTORY_ITEM_ID
and WOP.ORGANIZATION_ID = DD.ORGANIZATION_ID
and WOP.ORGANIZATION_ID = 1155
and BB.WIP_ENTITY_NAME = \'XJ39562\' ;
-- 作业任务已发放材料处理记录清单 0101 (最详细) (内码为 48825 为例)
-- 用途 1 )查询工单发料详细明细,包括发料类型、时间、用户等
select MTL.TRANSACTION_ID 交易 ID,
MTL.INVENTORY_ITEM_ID 项目 ID,
CC.SEGMENT1 物料编码 ,
CC.DESCRIPTION 物料说明 ,
MTL.ORGANIZATION_ID 组织 ID,
MTL.SUBINVENTORY_CODE 子库名称 ,
MTL.TRANSACTION_TYPE_ID 交易类型 ID,
BB.TRANSACTION_TYPE_NAME 交易类型名称 ,
MTL.TRANSACTION_QUANTITY 交易数量 ,
MTL.TRANSACTION_UOM 单位 ,
MTL.TRANSACTION_DATE 交易日期 ,
MTL.TRANSACTION_REFERENCE 交易参考 ,
MTL.TRANSACTION_SOURCE_ID 参考源 ID,
FF.WIP_ENTITY_NAME 任务名称 ,
MTL.DEPARTMENT_ID 部门 ID,
MTL.OPERATION_SEQ_NUM 工序号 ,
ROUND (MTL.PRIOR_COST, 2 ) 原来成本 ,
ROUND (MTL.NEW_COST, 2 ) 新成本 ,
MTL.TRANSACTION_QUANTITY * ROUND (MTL.PRIOR_COST, 2 ) 交易金额 ,
DD.USER_NAME 用户名称 ,
EE.FULL_NAME 用户姓名
from mtl_material_transactions MTL,
mtl_transaction_types BB,
mtl_system_items CC,
FND_USER DD,
per_people_f EE,
wip_entities FF
where MTL.TRANSACTION_TYPE_ID = BB.TRANSACTION_TYPE_ID
and MTL.CREATED_BY = DD.USER_ID
and MTL.INVENTORY_ITEM_ID = CC.INVENTORY_ITEM_ID
and MTL.ORGANIZATION_ID = CC.ORGANIZATION_ID
and DD.EMPLOYEE_ID = EE.PERSON_ID
and MTL.TRANSACTION_SOURCE_ID = FF.WIP_ENTITY_ID
and MTL.Transaction_Type_Id in ( 35 , 38 , 43 , 48 )
and MTL.ORGANIZATION_ID = 1155
and MTL.TRANSACTION_SOURCE_ID = 48825 ;
-- 按工单的材料费汇总(不单独使用)
select MTL.ORGANIZATION_ID,
MTL.TRANSACTION_SOURCE_ID WIP_ENTITY_ID,
ABS ( round ( SUM (MTL.TRANSACTION_QUANTITY * MTL.PRIOR_COST), 2 )) AMT
from mtl_material_transactions MTL
where MTL.Transaction_Type_Id in ( 35 , 38 , 43 , 48 )
and MTL.ORGANIZATION_ID = 1155
and MTL.TRANSACTION_SOURCE_ID = 48825
group by MTL.ORGANIZATION_ID, MTL.TRANSACTION_SOURCE_ID;
-- 离散作业任务子查询 01——— 材料消耗状况及材料费综合查询
-- 用途 1 )查询发料状况 2 )查询材料费物料小计
SELECT WOP.ORGANIZATION_ID 组织 ID,
WOP.WIP_ENTITY_ID 任务令 ID,
BB.WIP_ENTITY_NAME 装配件名称 ,
BB.PRIMARY_ITEM_ID 装配件 ID,
CC.SEGMENT1 装配件物料编码 ,
CC.DESCRIPTION 装配件说明 ,
WOP.OPERATION_SEQ_NUM 工序号 ,
WOP.DEPARTMENT_ID 部门 ID,
WOP.WIP_SUPPLY_TYPE 供应类型 ,
WOP.DATE_REQUIRED 要求日期 ,
WOP.INVENTORY_ITEM_ID 子物料 ID,
DD.SEGMENT1 子物料编码 ,
DD.DESCRIPTION 子物料说明 ,
WOP.QUANTITY_PER_ASSEMBLY 单位需量 ,
WOP.REQUIRED_QUANTITY 总需求量 ,
WOP.QUANTITY_ISSUED 已发放量 ,
CST.AMT 已发生材料费 ,
WOP.COMMENTS 注释 ,
WOP.SUPPLY_SUBINVENTORY 供应子库
FROM wip_requirement_operations WOP,
wip_entities BB,
mtl_system_items CC,
mtl_system_items DD,
( select MTL.ORGANIZATION_ID orgID,
MTL.TRANSACTION_SOURCE_ID wipID,
MTL.OPERATION_SEQ_NUM oprID,
MTL.INVENTORY_ITEM_ID itemID,
sum (MTL.TRANSACTION_QUANTITY * ROUND (MTL.actual_cost, 2 )) amt
from mtl_material_transactions MTL
where MTL.Transaction_Type_Id in ( 35 , 38 , 43 , 48 )
and MTL.ORGANIZATION_ID = 1155
and MTL.TRANSACTION_SOURCE_ID = 48825
group by MTL.ORGANIZATION_ID,
MTL.TRANSACTION_SOURCE_ID,
MTL.OPERATION_SEQ_NUM,
MTL.INVENTORY_ITEM_ID) CST
WHERE WOP.WIP_ENTITY_ID = BB.WIP_ENTITY_ID
and BB.PRIMARY_ITEM_ID = CC.INVENTORY_ITEM_ID
and BB.ORGANIZATION_ID = CC.ORGANIZATION_ID
and WOP.INVENTORY_ITEM_ID = DD.INVENTORY_ITEM_ID
and WOP.ORGANIZATION_ID = DD.ORGANIZATION_ID
and WOP.ORGANIZATION_ID = CST.orgID
and WOP.WIP_ENTITY_ID = CST.wipID
and WOP.OPERATION_SEQ_NUM = CST.oprID
and WOP.INVENTORY_ITEM_ID = CST.itemID
and WOP.ORGANIZATION_ID = 1155
and BB.WIP_ENTITY_NAME = \'XJ39562\' ;
-- 离散作业任务子查询 0201——— 作业资源报工明细表
SELECT WTA.ORGANIZATION_ID 组织代码 ,
WTA.TRANSACTION_ID 交易代码 ,
WTA.REFERENCE_ACCOUNT 参考科目 ,
WTA.TRANSACTION_DATE 报工日期 ,
WTA.WIP_ENTITY_ID 任务令内码 ,
WTA.ACCOUNTING_LINE_TYPE 会计栏类型 ,
WTA.BASE_TRANSACTION_VALUE 费用额 ,
WTA.CONTRA_SET_ID 反方集代码 ,
WTA.PRIMARY_QUANTITY 基本数量 ,
WTA.RATE_OR_AMOUNT 率或金额 ,
WTA.BASIS_TYPE 基本类型 ,
WTA.RESOURCE_ID 资源代码 ,
WTA.COST_ELEMENT_ID 成本要素 ID,
WTA.ACCOUNTING_LINE_TYPE 成本类型 ID,
WTA.OVERHEAD_BASIS_FACTOR 费用因子 ,
WTA.BASIS_RESOURCE_ID 基本资源 ID,
WTA.CREATED_BY 录入人 ID,
DD.USER_NAME 用户名称 ,
EE.FULL_NAME 用户姓名
FROM wip_transaction_accounts WTA, FND_USER DD, per_people_f EE
WHERE WTA.CREATED_BY = DD.USER_ID
and DD.EMPLOYEE_ID = EE.PERSON_ID
and WTA.BASE_TRANSACTION_VALUE <> 0
and WTA.ORGANIZATION_ID = 1155
and WTA.WIP_ENTITY_ID = 48839 ;
-- 成本类型 ID ACCOUNTING_LINE_TYPE
SELECT * FROM MFG_LOOKUPS ML
WHERE ML.LOOKUP_TYPE LIKE \'CST_ACCOUNTING_LINE_TYPE\'
ORDER BY ML.LOOKUP_CODE;
-- 成本要素 ID COST_ELEMENT_ID
--( 待补充 --------------------------------------------------------------------------?)
-- 统计人工费与制造费 ( 不单独应用 )
SELECT ORGANIZATION_ID, WIP_ENTITY_ID, SUM (HR_FEE) HR_FEE, SUM (MD_FEE) MD_FEE
FROM ( Select WTA.ORGANIZATION_ID,
WTA.WIP_ENTITY_ID,
decode (COST_ELEMENT_ID, 3 , WTA.BASE_TRANSACTION_VALUE, 0 ) HR_FEE,
decode (COST_ELEMENT_ID, 5 , WTA.BASE_TRANSACTION_VALUE, 0 ) MD_FEE
from WIP_TRANSACTION_ACCOUNTS WTA
where WTA.ACCOUNTING_LINE_TYPE = 7
and WTA.BASE_TRANSACTION_VALUE <> 0 ) WTA_COST
WHERE WTA_COST.ORGANIZATION_ID = 1155
AND WTA_COST.WIP_ENTITY_ID = \'48839\'
GROUP BY WTA_COST.ORGANIZATION_ID,WTA_COST.WIP_ENTITY_ID;
-- 工单进度及费用信息综合查询 ( 未下达及下达零发料和报工的看不到 )
select WE.WIP_ENTITY_NAME 任务名称 ,
MSI.SEGMENT1 物料 ,
MSI.DESCRIPTION 物料描述 ,
MSI.PRIMARY_UNIT_OF_MEASURE 单位 ,
WDJ.SCHEDULED_START_DATE 计划开始时间 ,
WDJ.SCHEDULED_COMPLETION_DATE 计划完成时间 ,
WDJ.START_QUANTITY 工单数量 ,
WDJ.QUANTITY_COMPLETED 完成数量 ,
WDJ.DATE_RELEASED 实际开始时间 ,
WDJ.DATE_COMPLETED 时间完成时间 ,
WDJ.DESCRIPTION 工单备注 ,
PP.SEGMENT1 项目号 ,
PP.DESCRIPTION 项目描述 ,
PT.TASK_NUMBER 任务号 ,
PT.DESCRIPTION 任务描述 ,
WO.COUNT_OPER 工序数 ,
WO1.OPERATION_SEQ_NUM 当前工序 ,
WO1.DESCRIPTION 当前工序描述 ,
MTA.MT_FEE 材料费 ,
WCT.HR_FEE 人工费 ,
WCT.MD_FEE 制造费 ,
WE.WIP_ENTITY_ID,
WE.ORGANIZATION_ID,
WDJ.PRIMARY_ITEM_ID,
WDJ.PROJECT_ID,
WDJ.TASK_ID
from WIP_ENTITIES WE,
WIP_OPERATIONS WO1,
WIP_DISCRETE_JOBS WDJ,
MTL_SYSTEM_ITEMS_B MSI,
PA_PROJECTS_ALL PP,
PA_TASKS PT,
( select WDJ.ORGANIZATION_ID,
WDJ.WIP_ENTITY_ID,
COUNT ( 1 ) COUNT_OPER,
max ( decode (wo.quantity_completed, 1 , wo.operation_seq_num, 10 )) OPER
from WIP_DISCRETE_JOBS WDJ, WIP_OPERATIONS WO
where WDJ.WIP_ENTITY_ID = WO.WIP_ENTITY_ID
group by WDJ.ORGANIZATION_ID, WDJ.WIP_ENTITY_ID) WO, -- 工序进度
( select MTL.ORGANIZATION_ID,
MTL.TRANSACTION_SOURCE_ID WIP_ENTITY_ID,
ABS ( SUM (MTL.TRANSACTION_QUANTITY * MTL.actual_cost)) MT_FEE
from mtl_material_transactions MTL
where MTL.Transaction_Type_Id in ( 35 , 38 , 43 , 48 )
group by MTL.ORGANIZATION_ID, MTL.TRANSACTION_SOURCE_ID) MTA, -- 材料费
( select WTA_COST.ORGANIZATION_ID,
WTA_COST.WIP_ENTITY_ID,
SUM (WTA_COST.HR_FEE1) HR_FEE,
SUM (WTA_COST.MD_FEE1) MD_FEE
from ( select WTA.ORGANIZATION_ID,
WTA.WIP_ENTITY_ID,
decode (COST_ELEMENT_ID,
3 ,
WTA.BASE_TRANSACTION_VALUE,
0 ) HR_FEE1,
decode (COST_ELEMENT_ID,
5 ,
WTA.BASE_TRANSACTION_VALUE,
0 ) MD_FEE1
from WIP_TRANSACTION_ACCOUNTS WTA
where WTA.ACCOUNTING_LINE_TYPE = 7
and WTA.BASE_TRANSACTION_VALUE <> 0 ) WTA_COST
group by WTA_COST.ORGANIZATION_ID, WTA_COST.WIP_ENTITY_ID) WCT -- 人工与制造
WHERE 1 = 1
AND WE.ORGANIZATION_ID = WDJ.ORGANIZATION_ID
AND WE.WIP_ENTITY_ID = WDJ.WIP_ENTITY_ID
AND WDJ.ORGANIZATION_ID = MSI.ORGANIZATION_ID
AND WDJ.PRIMARY_ITEM_ID = MSI.INVENTORY_ITEM_ID
AND WE.WIP_ENTITY_ID = WO.WIP_ENTITY_ID
AND WO1.WIP_ENTITY_ID = WO.WIP_ENTITY_ID
AND WO.OPER = WO1.OPERATION_SEQ_NUM
AND WE.ORGANIZATION_ID = MTA.ORGANIZATION_ID
AND WE.WIP_ENTITY_ID = MTA.WIP_ENTITY_ID(+)
AND WE.ORGANIZATION_ID = WCT.ORGANIZATION_ID
AND WE.WIP_ENTITY_ID = WCT.WIP_ENTITY_ID(+)
AND WDJ.PROJECT_ID = PP.PROJECT_ID(+)
AND WDJ.TASK_ID = PT.TASK_ID(+)
and we.organization_id = 1155
and we.wip_entity_id = \'48825\' ;
-- 工单进度及费用信息综合查询 ( 不论是否下达和发料都能看到 )
SELECT WDJ.WIP_ENTITY_ID 任务令 ID,
WE.WIP_ENTITY_NAME 任务名称 ,
WDJ.ORGANIZATION_ID 组织 ID,
WDJ.STATUS_TYPE 状态 ,
WDJ.PRIMARY_ITEM_ID 装配件 ID,
MSI.SEGMENT1 物料编码 ,
MSI.DESCRIPTION 物料说明 ,
WDJ.FIRM_PLANNED_FLAG 任务类型 ,
WDJ.JOB_TYPE 作业类型 ,
WDJ.WIP_SUPPLY_TYPE 供应类型 ,
WDJ.CLASS_CODE 任务类别 ,
WDJ.SCHEDULED_START_DATE 起始时间 ,
WDJ.DATE_RELEASED 下达时间 ,
WDJ.DATE_COMPLETED 完工时间 ,
WDJ.DATE_CLOSED 关闭时间 ,
WDJ.START_QUANTITY 计划数 ,
WDJ.QUANTITY_COMPLETED 完工数 ,
WDJ.QUANTITY_SCRAPPED 报废数 ,
WDJ.NET_QUANTITY MRP 净值 ,
WDJ.DESCRIPTION 工单备注 ,
WDJ.COMPLETION_SUBINVENTORY 接收子库 ,
WDJ.COMPLETION_LOCATOR_ID 货位 ID,
WDJ.PROJECT_ID 项目 ID,
WDJ.TASK_ID 项目任务 ID,
PP.SEGMENT1 项目号 ,
PP.DESCRIPTION 项目描述 ,
PT.TASK_NUMBER 任务号 ,
PT.DESCRIPTION 任务描述 ,
WPF.COUNT_OPER 工序数 ,
WPF.CUR_OPER 当前工序 ,
WPF.CUR_OPERNAME 工序名 ,
WPF.MT_FEE 材料费 ,
WPF.HR_FEE 人工费 ,
WPF.MD_FEE 制造费
FROM wip_discrete_jobs WDJ,
wip.wip_entities WE,
mtl_system_items MSI,
PA_PROJECTS_ALL PP,
PA_TASKS PT,
( select WDJ1.WIP_ENTITY_ID,
WDJ1.ORGANIZATION_ID,
WO.COUNT_OPER,
WO1.OPERATION_SEQ_NUM CUR_OPER,
WO1.DESCRIPTION CUR_OPERNAME,
MTA.MT_FEE,
WCT.HR_FEE,
WCT.MD_FEE
from WIP_OPERATIONS WO1,
WIP_DISCRETE_JOBS WDJ1,
( select WDJ.ORGANIZATION_ID,
WDJ.WIP_ENTITY_ID,
COUNT ( 1 ) COUNT_OPER,
max ( decode (wo.quantity_completed,
1 ,
wo.operation_seq_num,
10 )) OPER
from WIP_DISCRETE_JOBS WDJ, WIP_OPERATIONS WO
where WDJ.WIP_ENTITY_ID = WO.WIP_ENTITY_ID
group by WDJ.ORGANIZATION_ID, WDJ.WIP_ENTITY_ID) WO, -- 工序进度
( select MTL.ORGANIZATION_ID,
MTL.TRANSACTION_SOURCE_ID WIP_ENTITY_ID,
ABS ( SUM (MTL.TRANSACTION_QUANTITY * MTL.actual_cost)) MT_FEE
from mtl_material_transactions MTL
where MTL.Transaction_Type_Id in ( 35 , 38 , 43 , 48 )
group by MTL.ORGANIZATION_ID, MTL.TRANSACTION_SOURCE_ID) MTA, -- 材料费
( select WTA_COST.ORGANIZATION_ID,
WTA_COST.WIP_ENTITY_ID,
SUM (WTA_COST.HR_FEE1) HR_FEE,
SUM (WTA_COST.MD_FEE1) MD_FEE
from ( select WTA.ORGANIZATION_ID,
WTA.WIP_ENTITY_ID,
decode (COST_ELEMENT_ID,
3 ,
WTA.BASE_TRANSACTION_VALUE,
0 ) HR_FEE1,
decode (COST_ELEMENT_ID,
5 ,
WTA.BASE_TRANSACTION_VALUE,
0 ) MD_FEE1
from WIP_TRANSACTION_ACCOUNTS WTA
where WTA.ACCOUNTING_LINE_TYPE = 7
and WTA.BASE_TRANSACTION_VALUE <> 0 ) WTA_COST
group by WTA_COST.ORGANIZATION_ID, WTA_COST.WIP_ENTITY_ID) WCT -- 人工与制造
WHERE 1 = 1
AND WDJ1.WIP_ENTITY_ID = WO.WIP_ENTITY_ID(+)
AND WO1.WIP_ENTITY_ID = WO.WIP_ENTITY_ID
AND WO.OPER = WO1.OPERATION_SEQ_NUM
AND WDJ1.ORGANIZATION_ID = MTA.ORGANIZATION_ID
AND WDJ1.WIP_ENTITY_ID = MTA.WIP_ENTITY_ID(+)
AND WDJ1.ORGANIZATION_ID = WCT.ORGANIZATION_ID
AND WDJ1.WIP_ENTITY_ID = WCT.WIP_ENTITY_ID(+)) WPF
WHERE WDJ.WIP_ENTITY_ID = WE.WIP_ENTITY_ID
AND WDJ.ORGANIZATION_ID = WE.ORGANIZATION_ID
AND WDJ.PRIMARY_ITEM_ID = MSI.INVENTORY_ITEM_ID
AND WDJ.ORGANIZATION_ID = MSI.ORGANIZATION_ID
AND WDJ.PROJECT_ID = PP.PROJECT_ID(+)
AND WDJ.TASK_ID = PT.TASK_ID(+)
AND WDJ.ORGANIZATION_ID = WPF.ORGANIZATION_ID(+)
AND WDJ.WIP_ENTITY_ID = WPF.WIP_ENTITY_ID(+)
AND WDJ.organization_id = 1155
and PP.SEGMENT1 = \'07D9202\' ;
11. MRP相关查询
12. 总账 GL
select * from gl_sets_of_books 总帐
select * from gl_code_combinations gcc where gcc.summary_flag=\'Y\' 科目组合
select * from gl_balances 科目余额
select * from gl_je_batches 凭证批
select * from gl_je_headers 凭证头
select * from gl_je_lines 凭证行
select * from gl_je_categories 凭证分类
select * from gl_je_sources 凭证来源
select * from gl_summary_templates 科目汇总模板
select * from gl_account_hierarchies 科目汇总模板层次
13. 应收 AR
select * from ar_batches_all 事务处理批
select * from ra_customer_trx_all 发票头
select * from ra_customer_trx_lines_all 发票行
select * from ra_cust_trx_line_gl_dist_all 发票分配
select * from ar_cash_receipts_all 收款
select * from ar_receivable_applications_all 核销
select * from ar_payment_schedules_all 发票调整
select * from ar_adjustments_all 会计分录
select * from ar_distributions_all 付款计划
14. 应付 AP
select * from ap_invoices_all 发票头
select * from ap_invoice_distributions_all 发票行
select * from ap_payment_schedules_all 付款计划
select * from ap_check_stocks_all 单据
select * from ap_checks_all 付款
select * from ap_bank_branches 银行
select * from ap_bank_accounts_all 银行帐号
select * from ap_invoice_payments_all 核销
15. 应用、值集、弹性域
--fnd
select * from fnd_application
select * from fnd_application_tl where application_id= 101
select * from fnd_application_vl where application_id = 101
-- 值集
select * from fnd_flex_value_sets
select * from fnd_flex_values
select * from fnd_flex_values_vl
-- 弹性域
select * from fnd_id_flexs
select * from fnd_id_flex_structures where id_flex_code= \'GL#\'
select * from fnd_id_flex_segments where id_flex_code= \'GL#\' and id_flex_num= 50671
select * from fnd_profile_options_vl
select * from fnd_concurrent_programs 程序表
select * from fnd_concurrent_requests 请求表
select * from fnd_concurrent_processes 进程表
16. 许继配送管理相关表
--- 为了实现系统内方便的配送发货模式而开发
-- 配送关系 (以供应处角度 ORGANIZATION_ID = 142 )
SELECT AA.CUSTOMER_RELATION_ID 配送关系 ID,
AA.ORGANIZATION_ID 组织 ID,
AA.CUST_ACCOUNT_ID 客户 ID,
CC.PARTY_NAME 客户名称 ,
AA.CUST_ACCT_SITE_ID 配送地 ID,
DD.LOCATION 客户地点 ,
DD.STATUS A 有效 ,
AA.DELIVERY_BY_SO_FLAG 源于 CO,
AA.OUTBOUND_TRX_TYPE_ID 出库类型 ,
AA.OUTBOUND_RET_TRX_TYPE_ID 出库 R 类型 ,
AA.OUTBOUND_COST_CCID 出库账户 ID,
EE.concatenated_segments 出库账户 ,
AA.CUST_ORG_ID 客户库存组织 ID,
AA.INBOUND_TRX_TYPE_ID 入库类型 ,
AA.INBOUND_RET_TRX_TYPE_ID 入库 R 类型 ,
AA.INBOUND_CONFIRM_FLAG 入库确认 ,
AA.INBOUND_COST_CCID 入库账户 ID,
FF.concatenated_segments 入库账户 ,
AA.MANAGE_CHARGE 加价率 ,
AA.SETTLE_MODE 结算模式 ,
AA.INBOUND_SUBIN_CODE 接收子仓库 ,
AA.OUTBOUND_SUBIN_CODE 配送子库存 ,
AA.ATTRIBUTE1 直接生产发料 ,
AA.Creation_Date 创建日期 ,
AA.CREATED_BY 创建者 ,
AA.LAST_UPDATED_BY 更新者 ,
AA.LAST_UPDATE_DATE 更新日期
FROM CUX_INV_CUSTOMER_RELATION_ALL AA,
hz_cust_accounts BB,
hz_parties CC,
HZ_CUST_SITE_USES_ALL DD,
gl_code_combinations_kfv EE,
gl_code_combinations_kfv FF
WHERE AA.ORGANIZATION_ID = 142
AND AA.CUST_ACCOUNT_ID = BB.CUST_ACCOUNT_ID
AND BB.PARTY_ID = CC.PARTY_ID
AND AA.Cust_Acct_Site_Id = DD.Site_Use_Id
AND DD.STATUS = \'A\'
AND AA.OUTBOUND_COST_CCID = EE.code_combination_id
AND AA.INBOUND_COST_CCID = FF.code_combination_id
and CC.PARTY_NAME = \' 许继电气电网保护自动化公司 \' ;
-- 配送单头
SELECT AA.DN_HEADER_ID 配送单 ID,
AA.DN_NUMBER 配送单编号 ,
AA.DN_STATUS_CODE 状态 ,
AA.CUST_ACCOUNT_ID 客户 ID,
CC.PARTY_NAME 客户名称 ,
AA.CUST_ACCT_SITE_ID 配送地址 ID,
DD.LOCATION 客户地点 ,
AA.DELIVERY_ORG_ID 配送方组织 ID,
AA.CUST_ORG_ID 客户组织 ID,
AA.MANAGE_CHARGE 费率 ,
AA.INBOUND_CONFIRM_FLAG 入库确认否 ,
AA.SO_HEADER_ID 销售订单 ID,
EE.ORDER_NUMBER 销售订单 ,
EE.CUST_PO_NUMBER 客户 PO,
ee.attribute1,
ee.attribute2,
AA.PROCESS_FLAG,
AA.COMMENTS 配送单说明
FROM CUX_INV_DN_HEADERS_ALL AA, hz_cust_accounts BB, hz_parties CC, HZ_CUST_SITE_USES_ALL DD,OE_ORDER_HEADERS_ALL EE
WHERE AA.DELIVERY_ORG_ID = 142
AND AA.CUST_ACCOUNT_ID = BB.CUST_ACCOUNT_ID
AND BB.PARTY_ID = CC.PARTY_ID
AND AA.Cust_Acct_Site_Id = DD.Site_Use_Id
AND DD.STATUS = \'A\'
AND AA.SO_HEADER_ID = EE.HEADER_ID
AND AA.DN_NUMBER = \'14780016022\' ;
-- 配送单明细
SELECT AA.DN_HEADER_ID,
AA.DN_LINE_ID,
AA.SO_LINE_ID,
LL.LINE_NUMBER SO 行号 ,
AA.INVENTORY_ITEM_ID 物料 ID,
CC.SEGMENT1 物料编码 ,
CC.DESCRIPTION 物料说明 ,
AA.OUTBOUND_SUBIN_CODE 发出仓 ,
AA.OUTBOUND_LOCATOR_ID 发出货位 ,
AA.REQUIRE_DATE 需求日期 ,
AA.REQUIRE_QTY 需求数 ,
AA.OUTBOUND_QTY 已出库 ,
AA.INBOUND_QTY 已接收 ,
AA.ATTRIBUTE1 最近确认接收数 ,
AA.INBOUND_SUBIN_CODE 入库仓 ,
AA.INBOUND_LOCATOR_ID 入库货位 ,
AA.RETURN_NO_RECEIVE_QTY 退回数 ,
AA.OUTING_QTY,
AA.INING_QTY,
AA.REQUEST_ID 最近打印请求 ID
FROM CUX_INV_DN_LINES_ALL AA, CUX_INV_DN_HEADERS_ALL BB,mtl_system_items CC,OE_ORDER_LINES_ALL LL
WHERE AA.DN_HEADER_ID = BB.DN_HEADER_ID
AND AA.INVENTORY_ITEM_ID = CC.INVENTORY_ITEM_ID
AND BB.DELIVERY_ORG_ID = CC.ORGANIZATION_ID
AND AA.SO_LINE_ID = LL.LINE_ID
AND BB.DN_NUMBER = \'14780016022\' ;
99-其他相关表
1) 会计科目组合表
-- 查询会计科目分段信息
select * from gl_code_combinations;
-- 查询会计科目组合信息
select * from gl_code_combinations_kfv;
2) 查询自定义的客户化相关表和视图
-- 静态数据字典中的视图分为三类,它们分别由三个前缀够成: user_* 、 all_* 、 dba_*
-- user_* 该视图存储了关于当前用户所拥有的对象的信息。(即所有在该用户模式下的对象)
-- all_* 该视图存储了当前用户能够访问的对象的信息。(与 user_* 相比, all_* 并不需要拥有该对象,只需要具有访问该对象的权限即可)
-- dba_* 该视图存储了数据库中所有对象的信息。(前提是当前用户具有访问这些数据库的权限,一般来说必须具有管理员权限
-- 查询该用户拥有哪些表
select * from user_tables where table_name like \'CUX%\' ;
-- 查询该用户拥有哪些视图
select * from user_views where view_name like \'CUX%\' ;
-- 查询该用户拥有哪些索引
select * from user_indexes;
3) 查询物料处理记录
说明: mtl_material_transactions 这个表记录了所有涉及仓库收发的物料交易记录,包括:采购、 WIP 、订单、杂项等多种处理模式的内容。
-- 举例: 查询某用户在电网的账户别名发放清单
select AA.TRANSACTION_ID 交易代码 ,
AA.INVENTORY_ITEM_ID 项目内码 ,
CC.SEGMENT1 物料编码 ,
CC.DESCRIPTION 物料说明 ,
AA.ORGANIZATION_ID 组织代码 ,
AA.SUBINVENTORY_CODE 子库名称 ,
AA.TRANSACTION_TYPE_ID 类型 ID,
BB.TRANSACTION_TYPE_NAME 类型名称 ,
AA.TRANSACTION_QUANTITY 数量 ,
AA.TRANSACTION_UOM 单位 ,
AA.TRANSACTION_DATE 交易日期 ,
AA.TRANSACTION_REFERENCE 交易参考 ,
AA.TRANSACTION_SOURCE_ID 参考源 ID,
AA.DEPARTMENT_ID 部门 ID,
AA.OPERATION_SEQ_NUM 工序号 ,
ROUND (AA.Actual_Cost, 2 ) 实际成本 ,
ROUND (AA.Transaction_Cost, 2 ) 处理成本 ,
ROUND (AA.PRIOR_COST, 2 ) 旧成本 ,
ROUND (AA.NEW_COST, 2 ) 新成本 ,
ROUND (AA.VARIANCE_AMOUNT, 2 ) 差异金额 ,
AA.TRANSACTION_QUANTITY * ROUND (AA.PRIOR_COST, 2 ) 交易金额 ,
DD.USER_NAME 用户名称 ,
EE.FULL_NAME 用户姓名 ,
AA.ATTRIBUTE1 弹性域人名 ,
AA.ATTRIBUTE15 弹性域备注
from mtl_material_transactions AA ,
mtl_transaction_types BB,
mtl_system_items CC,
FND_USER DD,
per_people_f EE
where AA.TRANSACTION_TYPE_ID = BB.TRANSACTION_TYPE_ID and
AA.CREATED_BY = DD.USER_ID and
AA.INVENTORY_ITEM_ID = CC.INVENTORY_ITEM_ID and
AA.ORGANIZATION_ID = CC.ORGANIZATION_ID and
DD.EMPLOYEE_ID = EE.PERSON_ID and
AA.ORGANIZATION_ID = 1155 AND
CC.SEGMENT1= \'07D9202.92742\' and
AA.TRANSACTION_DATE >= TO_DATE( \'2011-01-29 00:00:00\' , \'YYYY-MM-DD HH24:MI:SS\' )
order by aa.TRANSACTION_ID;
/* 物料处理记录 mtl_material_transactions 表,类型与成本说明:
-- 杂项收 TRANSACTION_TYPE_ID = 41 录入价格优先, =Actual_Cost ,移动平均 TRANSACTION_QUANTITY > 0 , 调整类似
注: 1 )如果再接收界面录入了价格,以录入价格计入 Actual_Cost ,进行移动平均
2 )如果没有录入价格,字段 NULL ,则系统会以当前成本接收,计入 Actual_Cost
-- 杂项发 TRANSACTION_TYPE_ID = 31 以出 =Actual_Cost , TRANSACTION_QUANTITY < 0 , 调整类似
-- 采购收 TRANSACTION_TYPE_ID = 18 以 入 =Actual_Cost ,移动平均 TRANSACTION_QUANTITY > 0
-- 采购退 TRANSACTION_TYPE_ID = 36 以 出 =Actual_Cost , TRANSACTION_QUANTITY < 0
注: 1) 系统按采购成本退货和扣除库存金额,不考虑已消耗状况;
2) 如果库存金额够扣除,则扣除后重新计算出一个新成本;
3 )如果库存金额不够扣除,则扣除全部金额,就会出现有库存量而单位成本 =0 的物资,不够扣的部分计入字段 VARIANCE_AMOUNT 。
-- 作业发 TRANSACTION_TYPE_ID = 35 以当前成本出, =Actual_Cost , TRANSACTION_QUANTITY < 0 ,特定组件发料类似
-- 作业退 TRANSACTION_TYPE_ID = 43 以当前成本入, =Actual_Cost ,不移动平均 TRANSACTION_QUANTITY > 0
-- 配送出 TRANSACTION_TYPE_ID = 100 以当前成本出, =Actual_Cost , TRANSACTION_QUANTITY < 0
-- 配送退 TRANSACTION_TYPE_ID = 101 以配送价入 , =Actual_Cost ,移动平均 TRANSACTION_QUANTITY > 0
-- 销售发 TRANSACTION_TYPE_ID = 33 以当前成本出, =Actual_Cost , TRANSACTION_QUANTITY < 0
-- 销售退 TRANSACTION_TYPE_ID = 15 以当前成本入, =Actual_Cost , TRANSACTION_QUANTITY > 0
*/
-- 物料处理记录类型列表
select bb.transaction_type_id 类型 ID,
bb.transaction_type_name 别名 ,
bb.description 说明
from mtl_transaction_types BB
order by bb.transaction_type_id
-- 交易来源类型列表
SELECT *
FROM mtl_txn_source_types
-- 交易原因代码表
SELECT REASON_ID 原因代码 , REASON_NAME 名称 , DESCRIPTION 描述
FROM inv.mtl_transaction_reasons;
工艺路线
SELECT MSIB.SEGMENT1,MSIB.DESCRIPTION,BORV.resource_code,BR.DESCRIPTION
FROM BOM_OPERATIONAL_ROUTINGS_V BOR,
BOM_OPERATION_SEQUENCES_V BOS,
BOM_OPERATION_RESOURCES_V BORV,
BOM_RESOURCES BR,MTL_SYSTEM_ITEMS_B MSIB
WHERE BOR.ORGANIZATION_ID = 86
AND BR.ORGANIZATION_ID = 86
AND BOR.ASSEMBLY_ITEM_ID = MSIB.INVENTORY_ITEM_ID
AND MSIB.ORGANIZATION_ID=86
AND BOR.ROUTING_SEQUENCE_ID = BOS.ROUTING_SEQUENCE_ID
AND BOS.OPERATION_SEQUENCE_ID = BORV.OPERATION_SEQUENCE_ID
AND BR.RESOURCE_ID = BORV.RESOURCE_ID
AND BOS.OPERATION_SEQ_NUM =
(SELECT MAX(BOS1.OPERATION_SEQ_NUM)
FROM BOM_OPERATION_SEQUENCES_V BOS1,
BOM_OPERATIONAL_ROUTINGS_V BOR1
WHERE BOS1.ROUTING_SEQUENCE_ID = BOR1.ROUTING_SEQUENCE_ID
AND BOR1.ROUTING_SEQUENCE_ID = BOR.ROUTING_SEQUENCE_ID
AND BOR1.ALTERNATE_ROUTING_DESIGNATOR IS NULL)
AND BOR.ALTERNATE_ROUTING_DESIGNATOR IS NULL
AND NVL(BR.ATTRIBUTE15, \'N\') = \'Y\';
SELECT U.USER_NAME,
APP.APPLICATION_SHORT_NAME,
FAT.APPLICATION_NAME,
FR.RESPONSIBILITY_KEY,
FRT.RESPONSIBILITY_NAME,
FFF.FUNCTION_NAME,
FFT.USER_FUNCTION_NAME,
ICX.FUNCTION_TYPE,
ICX.FIRST_CONNECT,
ICX.LAST_CONNECT
FROM ICX_SESSIONS ICX,
FND_USER U,
FND_APPLICATION APP,
FND_APPLICATION_TL FAT,
FND_RESPONSIBILITY FR,
FND_RESPONSIBILITY_TL FRT,
FND_FORM_FUNCTIONS FFF,
FND_FORM_FUNCTIONS_TL FFT
WHERE 1 = 1
AND U.USER_ID = ICX.USER_ID
AND ICX.RESPONSIBILITY_APPLICATION_ID = APP.APPLICATION_ID
AND FAT.APPLICATION_ID = ICX.RESPONSIBILITY_APPLICATION_ID
AND FAT.LANGUAGE = \'ZHS\'
AND FR.APPLICATION_ID = ICX.RESPONSIBILITY_APPLICATION_ID
AND FR.RESPONSIBILITY_ID = ICX.RESPONSIBILITY_ID
AND FRT.LANGUAGE = \'ZHS\'
AND FRT.APPLICATION_ID = ICX.RESPONSIBILITY_APPLICATION_ID
AND FRT.RESPONSIBILITY_ID = ICX.RESPONSIBILITY_ID
AND FFF.FUNCTION_ID = ICX.FUNCTION_ID
AND FFT.FUNCTION_ID = ICX.FUNCTION_ID
AND ICX.DISABLED_FLAG != \'Y\'
AND ICX.PSEUDO_FLAG = \'N\'
AND (ICX.LAST_CONNECT +
DECODE(FND_PROFILE.VALUE(\'ICX_SESSION_TIMEOUT\'),
NULL,
ICX.LIMIT_TIME,
0,
ICX.LIMIT_TIME,
FND_PROFILE.VALUE(\'ICX_SESSION_TIMEOUT\') / 60) / 24) >
SYSDATE
AND ICX.COUNTER < ICX.LIMIT_CONNECTS;
PA模块常用表
SELECT * FROM pa_projects_all; --项目
SELECT * FROM pa_project_types; --项目类型
SELECT * FROM pa_project_statuses; --项目状态
SELECT * FROM pa_project_options; --项目选项
SELECT * FROM pa_lookups l WHERE l.lookup_type = \'PA_OPTIONS\' ;
SELECT * FROM pa_project_customers; --项目客户
SELECT h.name
FROM pa_project_set_lines l, pa_project_sets_vl h
WHERE l.project_set_id = h.project_set_id
AND l.project_id = 155242 ; --项目集
--项目预算
Select t. budget_type,
l.project_id,
l.*,
t.*
From pa_budget_versions l,
pa_budget_types t
Where l.budget_type_code = t.budget_type_code
And l.budget_status_code = \'W\'; --活动
--预算状态
SELECT * FROM pa_lookups l WHERE l.lookup_type = \'BUDGET STATUS\' ;
--项目角色(经理)
SELECT * FROM pa_project_role_types_vl;
SELECT l.resource_source_id, he.full_name
FROM pa_project_parties l, pa_project_role_types_b t, hr_employees he
WHERE l.project_role_id = t.project_role_id
AND t.project_role_type = \'PROJECT MANAGER\'
AND l.resource_source_id = he.employee_id
AND l.object_id = 164483 ;
SELECT * FROM pa_role_controls;
--人员默认账户
SELECT l.default_code_comb_id
-- INTO v_code_comb_id
FROM per_all_assignments_f l
WHERE l.person_id = 10995
AND l.effective_start_date <= SYSDATE
AND nvl (l.effective_end_date, SYSDATE + 1 ) >= SYSDATE ;
;
SELECT * FROM pa_expenditure_items_all a where a.project_id=164483;-- 项目支出
select * from pa_transaction_interface;
select * from pa_transaction_interface_all;
select * from pa_transaction_interface_v;
select 1/24 from dual;
select *from pa_cost_distribution_lines_all 支出分配行
select to_char(1.567, \'99999999990.99\')from dual;
SELECT l.project_id, h.project_set_id, h.name, l.project_set_id
FROM pa_project_set_lines l, pa_project_sets_vl h
WHERE l.project_set_id = h.project_set_id; 项目集
SELECT *FROM PA_PROJECT_TYPES_ALL 项目类别
SELECT l.task_id, l.task_number, l.task_name, l.*
FROM pa_tasks l
WHERE l.project_id = 157223; --项目任务
SELECT l.task_name,
l.task_id,
l.resource_class_code, --资源类别
l.task_number,
l.resource_alias,
l.uom_code,
l.uom_description,
l.planned_cost, --计划成本
l.*
FROM pa_tasks_assigns_progress_v l
WHERE l.project_id = 157223
AND l.project_number = \'1901140804\'
AND l.task_id = 246877; --计划资源
SELECT *FROM PA_RESOURCE_CLASSES_vl 资源类型
--取当前核准有用的收入预算版本
SELECT l.project_id,
l.fin_plan_type_id,
l.budget_version_id, --
l.version_number, --版本号
l.budget_status_code, --状态 B 核准, W 活动
l.current_flag, --当前
l.*
FROM pa_budget_versions l
WHERE l.project_id = 162229
AND l.current_flag = \'Y\' --当前的
AND l.budget_status_code = \'B\';
Select distinct jh.je_category,jh.je_source
From Gl_Je_Headers Jh,
Gl_Je_Lines Jl,
Gl_Import_References Gir,
Xla.Xla_Ae_Lines Xal,
Xla.Xla_Ae_Headers Xah,
Xla.Xla_Transaction_Entities Xte
Where Jh.Je_Header_Id = Jl.Je_Header_Id
And Jl.Je_Header_Id = Gir.Je_Header_Id
And Jl.Je_Line_Num = Gir.Je_Line_Num
And Gir.Gl_Sl_Link_Id = Xal.Gl_Sl_Link_Id
And Gir.Gl_Sl_Link_Table = Xal.Gl_Sl_Link_Table
And Xal.Application_Id = Xah.Application_Id
And Xal.Ae_Header_Id = Xah.Ae_Header_Id
And Xah.Application_Id = Xte.Application_Id
And Xah.Entity_Id = Xte.Entity_Id
and jl.period_name=\'2019-12\'
;
Select Distinct a.Je_Category,
a.Je_Source
From Gl_Je_Headers a
Join Gl_Je_Lines b On (a.Je_Header_Id = b.Je_Header_Id)
Join Gl_Import_References Gir On (b.Je_Header_Id = Gir.Je_Header_Id And
b.Je_Line_Num = Gir.Je_Line_Num)
--xla.xla_ae_headers aeh
--join xla.xla_transaction_entities xte
--join xla.xla_ae_headers aeh
Where a.je_header_id=136868
a.Period_Name = \'2019-12\'
and (a.je_source=\'1\' or a.je_source=\'21\');
Select distinct xh.je_category_name,xt.entity_code
From Xla.Xla_Ae_Headers Xh,
Xla.Xla_Transaction_Entities Xt,
Xla.Xla_Ae_Lines Xx,
Gl_Code_Combinations Gcc
Where Xh.Entity_Id = Xt.Entity_Id
And Xh.Application_Id = Xt.Application_Id
--And xt.application_id = 200
--And (xt.entity_code = \'AP_INVOICES\')
And Xh.Ae_Header_Id = Xx.Ae_Header_Id
And Xt.Application_Id = Xx.Application_Id
--And xt.source_id_int_1 = ivh.invoice_id
--And Xt.Security_Id_Int_1 = 82
And Xx.Code_Combination_Id = Gcc.Code_Combination_Id;
AND xah.entity_code = :p1
AND xah.source_id_int_1 = :p2
SELECT distinct
jh.je_category,
jh.je_source
FROM gl_je_lines jl,
gl_je_headers jh,
gl_import_references gir,
xla.xla_ae_lines ael,
xla.xla_ae_headers aeh,
xla.xla_transaction_entities xte--,
--ap_invoices_all aia
WHERE jl.je_header_id = jh.je_header_id
and jh.je_header_id=136868
AND jl.ledger_id = jh.ledger_id
AND jl.je_header_id = gir.je_header_id
AND jl.je_line_num = gir.je_line_num
-- AND jl.je_header_id = p_header_id
-- AND jl.je_line_num = p_line_num
AND jh.je_batch_id = gir.je_batch_id
--AND jh.je_category = \'Purchase Invoices\'
-- AND jh.je_source = \'Payables\'
AND gir.gl_sl_link_id = ael.gl_sl_link_id
AND gir.gl_sl_link_table = ael.gl_sl_link_table
AND ael.ae_header_id = aeh.ae_header_id
AND ael.application_id = aeh.application_id
AND aeh.entity_id = xte.entity_id
AND aeh.application_id = xte.application_id
--and jh.period_name=\'2019-12\'
-- and xte.ledger_Id = p_ledger_id
--AND xte.entity_code = \'AP_INVOICES\'
--AND NVL (xte.source_id_int_1, (-99)) = aia.invoice_id
--AND xte.application_id = 200
;
4. GL追溯子模块(各模块表与xla.xla_transaction_entities 表的关联可以参数此表中的关系 xla.xla_entity_id_mappings)
4.1 GL追溯AP发票(关联PO表可以用invoice_id,event_id)
当source是Payables,category 是Purchase Invoices 用这段SQL追溯
SELECT NVL (ael.accounted_dr, ael.entered_dr) account_dr,
NVL (ael.accounted_cr, ael.entered_cr) account_cr,
aia.invoice_num,
aia.invoice_date,
aia.org_id,
aia.invoice_id,ael.ae_header_id, ael.ae_line_num,
aeh.event_id
FROM gl_je_lines jl,
gl_je_headers jh,
gl_import_references gir,
xla_ae_lines ael,
xla_ae_headers aeh,
xla.xla_transaction_entities xte,
ap_invoices_all aia
WHERE jl.je_header_id = jh.je_header_id
AND jl.ledger_id = jh.ledger_id
AND jl.je_header_id = gir.je_header_id
AND jl.je_line_num = gir.je_line_num
AND jl.je_header_id = p_header_id
AND jl.je_line_num = p_line_num
AND jh.je_batch_id = gir.je_batch_id
AND jh.je_category = \'Purchase Invoices\'
AND jh.je_source = \'Payables\'
AND gir.gl_sl_link_id = ael.gl_sl_link_id
AND gir.gl_sl_link_table = ael.gl_sl_link_table
AND ael.ae_header_id = aeh.ae_header_id
AND ael.application_id = aeh.application_id
AND aeh.entity_id = xte.entity_id
AND aeh.application_id = xte.application_id
and xte.ledger_Id = p_ledger_id
AND xte.entity_code = \'AP_INVOICES\'
AND NVL (xte.source_id_int_1, (-99)) = aia.invoice_id
AND xte.application_id = 200;
4.2 GL追溯AP付款
当source是Payables,category 是payments,则使用下面这个SQL来取出追朔的数据
SELECT DISTINCT aca.bank_account_name l_ref2,
pd.payment_document_name
|| \'-\'
|| aca.doc_sequence_value l_ref3,
TO_CHAR (aca.check_date, \'yyyy/mm/dd\') l_ref4,
aca.check_id trx_hdr_id,
ael.accounting_class_code acct_line_type_name,
pd.payment_document_name NAME,
NVL (ael.accounted_cr, ael.entered_cr) account_cr,
NVL (ael.accounted_dr, ael.entered_dr) account_dr,
ael.ae_header_id, ael.ae_line_num
FROM gl_je_lines jl,
gl_je_headers jh,
gl_import_references gir,
xla_ae_lines ael,
xla_ae_headers aeh,
xla.xla_transaction_entities xte,
ap_checks_all aca,
ce_payment_documents pd,
po_vendor_sites_all pvs
WHERE jl.je_header_id = jh.je_header_id
AND jl.ledger_id = jh.ledger_id
AND jl.je_header_id = gir.je_header_id
AND jl.je_line_num = gir.je_line_num
AND jl.je_header_id = p_header_id
AND jl.je_line_num = p_line_num
AND jh.je_batch_id = gir.je_batch_id
AND jh.je_category = \'Payments\'
AND jh.je_source = \'Payables\'
AND gir.gl_sl_link_id = ael.gl_sl_link_id
AND gir.gl_sl_link_table = ael.gl_sl_link_table
AND ael.ae_header_id = aeh.ae_header_id
AND ael.application_id = aeh.application_id
AND aeh.entity_id = xte.entity_id
AND aeh.application_id = xte.application_id
AND NVL (xte.source_id_int_1, (-99)) = aca.check_id
AND xte.application_id = 200
AND xte.entity_code = \'AP_PAYMENTS\'
AND aca.payment_document_id = pd.payment_document_id
AND aca.vendor_id = pvs.vendor_id
AND aca.vendor_site_id = pvs.vendor_site_id;
4.3 GL追溯AR 发票
当source 是Receivables,category是(\'Sales Invoices\',\'Credit Memos\',\'Debit Memos\')
SELECT DISTINCT NVL (rc.tax_reference, rc.customer_name) l_ref2,
NVL (rcta.interface_header_attribute1,
rcta.trx_number) l_ref3,
TO_CHAR (rcta.trx_date, \'YYYY/MM/DD\') l_ref4,
NVL (rcta.purchase_order, rcta.comments) l_ref5,
rcta.customer_trx_id trx_hdr_id,
ael.accounting_class_code acct_line_type_name,
NVL (ael.accounted_cr, ael.entered_cr) account_cr,
NVL (ael.accounted_dr, ael.entered_dr) account_dr,
ael.ae_header_id, ael.ae_line_num
FROM gl_je_lines jl,
gl_je_headers jh,
gl_import_references gir,
xla_ae_lines ael,
xla_ae_headers aeh,
xla.xla_transaction_entities xte,
ra_customer_trx_all rcta,
ar_customers rc,
ar_site_uses_v rsua
WHERE jl.je_header_id = jh.je_header_id
AND jl.ledger_id = jh.ledger_id
AND jl.je_header_id = gir.je_header_id
AND jl.je_line_num = gir.je_line_num
AND jl.je_header_id = p_header_id
AND jl.je_line_num = p_line_num
AND jh.je_batch_id = gir.je_batch_id
AND jh.je_category IN
(\'Credit Memos\', \'Sales Invoices\', \'Debit Memos\')
AND jh.je_source = \'Receivables\'
AND gir.gl_sl_link_id = ael.gl_sl_link_id
AND gir.gl_sl_link_table = ael.gl_sl_link_table
AND ael.ae_header_id = aeh.ae_header_id
AND ael.application_id = aeh.application_id
AND aeh.entity_id = xte.entity_id
AND aeh.application_id = xte.application_id
AND xte.source_id_int_1 = rcta.customer_trx_id
AND xte.transaction_number = rcta.trx_number
AND xte.application_id = 222
AND xte.entity_code = \'TRANSACTIONS\'
AND rcta.bill_to_site_use_id = rsua.site_use_id(+)
AND rcta.bill_to_customer_id = rc.customer_id(+)
AND rsua.site_use_code(+) = \'BILL_TO\';
4.4 GL追溯AR 收款
当source是Receivables,category是(\'Trade Receipts\',\'Misc Receipts\')
SELECT DISTINCT aba.bank_account_num l_ref2,
NVL (acra.customer_receipt_reference,
acra.receipt_number
) l_ref3,
TO_CHAR (acra.receipt_date, \'YYYY/MM/DD\') l_ref4,
acra.comments, acra.cash_receipt_id trx_hdr_id,
ael.accounting_class_code acct_line_type_name,
NVL (ael.accounted_cr, ael.entered_cr) account_cr,
NVL (ael.accounted_dr, ael.entered_dr) account_dr,
ael.ae_header_id, ael.ae_line_num
FROM gl_je_lines jl,
gl_je_headers jh,
gl_import_references gir,
xla_ae_lines ael,
xla_ae_headers aeh,
xla.xla_transaction_entities xte,
ar_cash_receipts_all acra,
ce_bank_acct_uses_all cbau,
ce_bank_accounts aba,
ar_site_uses_v rsua,
ar_addresses_v raa,
ar_customers rc
WHERE jl.je_header_id = jh.je_header_id
AND jl.ledger_id = jh.ledger_id
AND jl.je_header_id = gir.je_header_id
AND jl.je_line_num = gir.je_line_num
AND jl.je_header_id = p_header_id
AND jl.je_line_num = p_line_num
AND jh.je_batch_id = gir.je_batch_id
AND jh.je_category IN (\'Misc Receipts\', \'Trade Receipts\')
AND jh.je_source = \'Receivables\'
AND gir.gl_sl_link_id = ael.gl_sl_link_id
AND gir.gl_sl_link_table = ael.gl_sl_link_table
AND ael.ae_header_id = aeh.ae_header_id
AND ael.application_id = aeh.application_id
AND aeh.entity_id = xte.entity_id
AND aeh.application_id = xte.application_id
AND NVL (xte.source_id_int_1, (-99)) = acra.cash_receipt_id
AND xte.application_id = 222
AND xte.entity_code = \'RECEIPTS\'
AND acra.remit_bank_acct_use_id = cbau.bank_acct_use_id
AND cbau.bank_account_id = aba.bank_account_id
AND acra.customer_site_use_id = rsua.site_use_id(+)
AND rsua.address_id = raa.address_id(+)
AND raa.customer_id = rc.customer_id(+);
4.5 GL追溯INV
当source是Cost Management, category是\'Inventory\'
SELECT distinct mmt.transaction_id, mmt.source_code, mmt.source_line_id,
mmt.trx_source_line_id,
mtst.transaction_source_type_name trx_source_type_name,
NVL (ael.accounted_cr, ael.entered_cr) account_cr,
NVL (ael.accounted_dr, ael.entered_dr) account_dr,
ael.ae_header_id ,ael.ae_line_num
FROM gl_je_lines jl,
gl_je_headers jh,
gl_import_references gir,
xla_ae_lines ael,
xla_ae_headers aeh,
xla.xla_transaction_entities xte,
mtl_material_transactions mmt,
mtl_txn_source_types mtst
WHERE jl.je_header_id = jh.je_header_id
AND jl.ledger_id = jh.ledger_id
AND jl.je_header_id = gir.je_header_id
AND jl.je_line_num = gir.je_line_num
AND jl.je_header_id = p_header_id
AND jl.je_line_num = p_line_num
AND jh.je_batch_id = gir.je_batch_id
AND jh.je_category in (\'Inventory\',\'MTL\')
AND jh.je_source = \'Cost Management\'
AND gir.gl_sl_link_id = ael.gl_sl_link_id
AND gir.gl_sl_link_table = ael.gl_sl_link_table
AND ael.ae_header_id = aeh.ae_header_id
AND ael.application_id = aeh.application_id
AND aeh.entity_id = xte.entity_id
and aeh.application_id = xte.application_id
AND nvl(xte.source_id_int_1,(-99)) = mmt.transaction_id
AND xte.application_id = 707
AND xte.entity_code = \'MTL_ACCOUNTING_EVENTS\'
AND mtst.transaction_source_type_id = mmt.transaction_source_type_id
4.6 GL追溯PO
当source是Cost Management, category是RECEIVING
SELECT xte.SOURCE_ID_INT_1 source_line_id,
nvl(ael.accounted_cr ,ael.entered_cr) account_cr,
nvl(ael.accounted_dr ,ael.entered_dr) account_dr
FROM gl_je_lines jl,
gl_je_headers jh,
gl_import_references gir,
xla_ae_lines ael,
xla_ae_headers aeh,
xla.xla_transaction_entities xte,
rcv_transactions rt
WHERE jl.je_header_id = jh.je_header_id
AND jl.ledger_id = jh.ledger_id
AND jl.je_header_id = gir.je_header_id
AND jl.je_line_num = gir.je_line_num
AND jl.je_header_id =p_header_id
AND jl.je_line_num = p_line_num
AND jh.je_batch_id = gir.je_batch_id
AND jh.je_category = \'Receiving\'
AND jh.je_source = \'Cost Management\'
AND gir.gl_sl_link_id = ael.gl_sl_link_id
AND gir.gl_sl_link_table = ael.gl_sl_link_table
AND ael.ae_header_id = aeh.ae_header_id
AND ael.ledger_id = aeh.ledger_id
and aeh.ENTITY_ID = xte.entity_id
and aeh.APPLICATION_ID = xte.APPLICATION_ID
AND xte.application_id = 707
AND xte.entity_code = \'RCV_ACCOUNTING_EVENTS\'
and AND nvl(xte.source_id_int_1,(-99)) = rt.transaction_id
4.7 GL追溯WIP
当source是Cost Management, category是WIP
SELECT xte.SOURCE_ID_INT_1 source_line_id,
nvl(ael.accounted_cr ,ael.entered_cr) account_cr,
nvl(ael.accounted_dr ,ael.entered_dr) account_dr
FROM gl_je_lines jl,
gl_je_headers jh,
gl_import_references gir,
xla_ae_lines ael,
xla_ae_headers aeh,
xla.xla_transaction_entities xte,
wip_transactions rt
WHERE jl.je_header_id = jh.je_header_id
AND jl.ledger_id = jh.ledger_id
AND jl.je_header_id = gir.je_header_id
AND jl.je_line_num = gir.je_line_num
AND jl.je_header_id =p_header_id
AND jl.je_line_num = p_line_num
AND jh.je_batch_id = gir.je_batch_id
AND jh.je_category = \'Receiving\'
AND jh.je_source = \'Cost Management\'
AND gir.gl_sl_link_id = ael.gl_sl_link_id
AND gir.gl_sl_link_table = ael.gl_sl_link_table
AND ael.ae_header_id = aeh.ae_header_id
AND ael.ledger_id = aeh.ledger_id
and aeh.ENTITY_ID = xte.entity_id
and aeh.APPLICATION_ID = xte.APPLICATION_ID
AND xte.application_id = 707
AND xte.entity_code = \'WIP_ACCOUNTING_EVENTS\'
and AND nvl(xte.source_id_int_1,(-99)) = rt.transaction_id
4.8 GL追溯FA
SELECT distinct ad.description asset_description,
NVL (ael.accounted_cr, ael.entered_cr) account_cr,
NVL (ael.accounted_dr, ael.entered_dr) account_dr,
fl.meaning||\'-\'||th.transaction_header_id l_ref16
FROM gl_je_lines jl,
gl_je_headers jh,
gl_import_references gir,
xla_ae_lines ael,
xla_ae_headers aeh,
xla.xla_transaction_entities xte,
fa_transaction_headers th,
fa_additions ad,
fa_lookups fl
WHERE jl.je_header_id = jh.je_header_id
AND jl.ledger_id = jh.ledger_id
AND jl.je_header_id = gir.je_header_id
AND jl.je_line_num = gir.je_line_num
AND jl.je_header_id = p_header_id
AND jl.je_line_num = p_line_num
AND jh.je_batch_id = gir.je_batch_id
AND jh.je_category IN (\'Addition\', \'Adjustment\', \'Retirement\', \'Transfer\')
AND jh.je_source = \'Assets\'
AND gir.gl_sl_link_id = ael.gl_sl_link_id
AND gir.gl_sl_link_table = ael.gl_sl_link_table
AND ael.ae_header_id = aeh.ae_header_id
AND ael.application_id = aeh.application_id
and ael.application_id = 140
AND aeh.entity_id = xte.entity_id
and aeh.application_id = xte.application_id
and aeh.application_id = 140
and xte.ledger_id = :p_sob_id
and xte.entity_code = \'TRANSACTIONS\'
AND NVL(xte.source_id_int_1,(-99)) = th.transaction_header_id
AND xte.application_id = 140
AND th.asset_id = ad.asset_id
AND fl.lookup_type = \'FAXOLTRX\'
AND fl.lookup_code = th.transaction_type_code
UNION ALL
SELECT distinct ad.description asset_description,
NVL (ael.accounted_cr, ael.entered_cr) account_cr,
NVL (ael.accounted_dr, ael.entered_dr) account_dr,
null l_ref16
FROM gl_je_lines jl,
gl_je_headers jh,
gl_import_references gir,
xla_ae_lines ael,
xla_ae_headers aeh,
xla.xla_transaction_entities xte,
fa_deprn_detail dd,
fa_additions ad
WHERE jl.je_header_id = jh.je_header_id
AND jl.ledger_id = jh.ledger_id
AND jl.je_header_id = gir.je_header_id
AND jl.je_line_num = gir.je_line_num
AND jl.je_header_id = p_header_id
AND jl.je_line_num = p_line_num
AND jh.je_batch_id = gir.je_batch_id
AND jh.je_category = \'Depreciation\'
AND jh.je_source = \'Assets\'
AND gir.gl_sl_link_id = ael.gl_sl_link_id
AND gir.gl_sl_link_table = ael.gl_sl_link_table
AND ael.ae_header_id = aeh.ae_header_id
AND ael.application_id = aeh.application_id
and ael.application_id = 140
AND aeh.entity_id = xte.entity_id
and aeh.application_id = xte.application_id
and aeh.application_id = 140
and xte.ledger_id = :p_sob_id
and xte.entity_code = \'DEPRECIATION\'
AND NVL(xte.source_id_int_1,(-99)) = dd.asset_id
and NVL (xte.source_id_int_2, (-99)) = dd.period_counter
AND xte.application_id = 140
AND dd.asset_id = ad.asset_id;
--取当前核准有用的收入预算金额
SELECT SUM(decode(bv.version_type,
\'ORG_FORECAST\',
nvl(revenue, 0),
nvl(bv.total_project_revenue, 0))) +
SUM(nvl(bv.total_tp_revenue_in, 0)) +
SUM(nvl(bv.total_borrowed_revenue, 0)) +
SUM(nvl(bv.total_revenue_adj, 0)) -
SUM(nvl(bv.total_tp_revenue_out, 0)) sss
FROM pa_fin_plan_types_vl pt,
pa_budget_versions bv,
pa_proj_fp_options pfo
WHERE pfo.project_id = bv.project_id(+)
AND pfo.fin_plan_type_id = bv.fin_plan_type_id(+)
AND pfo.fin_plan_type_id = pt.fin_plan_type_id
AND pt.plan_class_code IN (\'BUDGET\', \'FORECAST\')
AND pfo.fin_plan_option_level_code = \'PLAN_TYPE\'
AND bv.ci_id IS NULL
AND bv.current_flag(+) = \'Y\'
AND nvl(pt.use_for_workplan_flag, \'N\') = \'N\'
AND bv.fin_plan_type_id = 10020 --FBS预算
AND bv.project_id = 162229;
--计划类型
SELECT pt.fin_plan_type_id, pt.name, pt.description
FROM pa_fin_plan_types_vl pt
WHERE pt.plan_class_code IN (\'BUDGET\', \'FORECAST\')
AND nvl(pt.use_for_workplan_flag, \'N\') = \'N\'; --FBS预算 10020
https://blog.****.net/cai_xingyun/article/details/38016687算法
参考一: 数据库
call fnd_global.APPS_INITIALIZE(1318,50583,401)安全
select fnd_profile.VALUE(\'ORG_ID\') FROM DUALapp
select * from hr_operating_units hou where hou.organization_id=204post
--fndflex
select * from fnd_application ui
select * from fnd_application_tl where application_id=101编码
select * from fnd_application_vl where application_id = 101.net
----值集code
select * from fnd_flex_value_sets
select * from fnd_flex_values
select * from fnd_flex_values_vl
----弹性域
select * from fnd_id_flexs
select * from fnd_id_flex_structures where id_flex_code=\'GL#\'
select * from fnd_id_flex_segments where id_flex_code=\'GL#\' and id_flex_num=50671
select * from fnd_profile_options_vl
select * from fnd_concurrent_programs 程序表
select * from fnd_concurrent_requests 请求表
select * from fnd_concurrent_processes 进程表
--inv(库存)
select * from org_organization_definitions 库存组织
select * from mtl_parameters 组织参数
select * from mtl_system_items_b where inventory_item_id = 171 and organization_id=204 物料表
select * from mtl_secondary_inventories 子库存
select * from mtl_item_locations 货位
select * from mtl_lot_numbers 批次
select * from mtl_onhand_quantities 现有量表
select * from mtl_serial_numbers 序列
select * from mtl_material_transactions 物料事务记录
select * from mtl_transaction_accounts 会计分录
select * from mtl_transaction_types 事务类型
select * from mtl_txn_source_types 事务来源类型
select * from mfg_lookups ml where ml.LOOKUP_TYPE = \'MTL_TRANSACTION_ACTION\'
--po(采购订单)
select * from po_requisition_headers_all 请求头
select * from po_requisition_lines_all 请求行
select * from po_headers_all 订单头
select * from po_lines_all 订单行
select * from po_line_locations_all
select * from po_distributions_all 分配
select * from po_releases_all 发送
select * from rcv_shipment_headers 采购接收头
select * from rcv_shipment_lines 采购接收行
select * from rcv_transactions 接收事务处理
select * from po_agents
select * from po_vendors 订单
select * from po_vendor_sites_all
--oe(销售)
select * from ra_customers 客户
select * from ra_addresses_all 地址
select * from ra_site_uses_all 用户
select * from oe_order_headers_all 销售头
select * from oe_order_lines_all 销售行
select * from wsh_new_deliveries 发送
select * from wsh_delivery_details
select * from wsh_delivery_assignments
--gl(总帐)
select * from gl_sets_of_books 总账
select * from gl_code_combinations gcc where gcc.summary_flag=\'Y\' 科目组合
select * from gl_balances 科目余额
select * from gl_je_batches 凭证批
select * from gl_je_headers 凭证头
select * from gl_je_lines 凭证行
select * from gl_je_categories 凭证分类
select * from gl_je_sources 凭证来源
select * from gl_summary_templates 科目汇总模板
select * from gl_account_hierarchies 科目汇总模板层次
--ar(应收)
select * from ar_batches_all 事务处理批
select * from ra_customer_trx_all 发票头
select * from ra_customer_trx_lines_all 发票行
select * from ra_cust_trx_line_gl_dist_all 发票分配
select * from ar_cash_receipts_all 收款
select * from ar_receivable_applications_all 核销
select * from ar_payment_schedules_all 发票调整
select * from ar_adjustments_all 会计分录
select * from ar_distributions_all 付款计划
--ap(应付)
select * from ap_invoices_all 发票头
select * from ap_invoice_distributions_all 发票行
select * from ap_payment_schedules_all 付款计划
select * from ap_check_stocks_all 单据
select * from ap_checks_all 付款
select * from ap_bank_branches 银行
select * from ap_bank_accounts_all 银行账号
select * from ap_invoice_payments_all 核销
========================华丽的分割线=========================
INV库存
organization 两个含义:
1. 经营单位,A/B/C分公司,A下面有A1,A2等工厂,主题目标是为了独立核算此组织
ORG,ORG_ID;
2. 库存组织,例如制造商的仓库,例如A1,A2等工厂
Organization_id;
HR_ORGANIZATION_UNITS -
Org_organization_definitions
Mtl_subinventory_ 库存组织单位
MTL_PARAMETERS -库存组织参数(没有用ID,直接用name)
MTL_SYSTEM_ITEMS_b -物料信息(同上,应用了库存组织name)
MTL_SECONDARY_INVENTORIES -子库存组织 -
MTL_ITEM_LOCATTIONS -货位 - SUBINVENTROY_CODE
Mtl_Material_Transactions - (库存)物料事物表
成本 mtl_transaction_accounts
transaction_cost是事物成本;
ACTUAL_COST是经过成本算法计算出来的实际成本,主计量单位
现有量
汇总历史记录(正负合计)
Mtl_Material_Transactions
MTL_ONHAND_QUANTITIES现有量表,组织/子库存/货位/物品 summary可能按照挑库先进先出统计,若是设置了"不容许负库存",这样就不可能出现负数
PO
请购单头表
Po_Requisition_Headers_all
行表
Po_Requisition_lines_all
采购订单
PO_HEADER_ALL
PO_LINES_ALL
采购接收-退货/组织间转移/正常状态 都须要使用这个模块
RCV_TRANSACTIONS
1. 接收100单位货物,放入“待质检”货位
2. 接受/拒绝
3. 库存/退回
有三个不一样的状态!例如:接收100个,80个接受入库,20个退回,那么有80个接受事务/20个退回事物
select TRANSACTION_TYPE,DESTINATION_TYPE_CODE from RCV_TRANSACTIONS
能够看出如下阶段:
A1.RECEIVE – RECEIVING
A2.ACCEPT – RECEIVING
A3.DELIERY – INVETORY(影响库存现有量)
若是按照正常模式,最后会触发产生MTL_MATERIAL_TRANSACTIONS
销售订单
OE_ORDER_headers_all
SOLD_FROM_ORG_ID
SOLD_TO_ORG_ID 就是客户层
SHIP_FROM_ORG_ID
SHIP_TO_ORG_ID 就是客户收货层
INVOICE_TO_ORG_ID 就是客户收单层
DELIVER_TO_ORG_ID
和客户结构有关
客户 RA_customers
客户Address Ra_Addresses
Address 货品抵达 site RA_SITE_USES_ALL
Address 发票抵达 site
OE_ORDER_LINEs_all
GL凭证
gl_je_batches
凭证日期: DEFAULT_EFFECTIVE_DATE
会计期间: DEFAULT_PERIOD_NAME
原币种凭证批借贷方汇总: RUNNING_TOTAL_DR/CR 好比美圆
本位币凭证批借贷方汇总: RUNNING_TOTAL_ACCOUNTED_DR/CR
gl_je_headers日记帐头信息
批号: JE_BATCH_ID
会计期间: PERIOD_NAME
币种: CURRENCY_CODE
汇率类型: CURRENCY_CONVERSION_TYPE
汇率日期: CURRENCY_CONVERSION_DATE
账套: SET_OF_BOOKS_ID 参考 GL_SETS_OF_BOOKS
凭证类型: JE_CATEGORY 参考 GL_JE_SOURCES
凭证来源: JE_SOURCE
gl_je_lines日记帐体信息
CODE_COMBINATION_ID 科目组合编号
GL_BALANCES 总账余额
PERIOD_NET_DR/CR 净值
BEGIN_BALANCE_DR/CR 期初额
AR应收发票
RA_CUSTOMER_TRX_ALL
CUSTOMER_TRX_ID 发票编号
BILL_TO_SITE_USE_ID 客户收单方编号
PRIMARY_SALES_ID销售员
REFERENCE是Oracle提供的外部编号输入框,可是因为版本问题和长度(<=30),不建议用户使用,若是要使用外部编号,请使用说明性弹性域
RA_CUSTOMER_TRX_LINES_ALL
LINE_ID 行号
INVENTORY_ITEM_ID 能够为空,好比非物料的服务,只在DE script ION中出现 /税行
DE script ION
QUANTITY_INVOICE 开票数量
LINE_TYPE 行类型 (通常/税)
EXTEND_PRICE 本行金额
注意:税行是隐藏行,因此至少会有两行
收款状况
AR_CASH_RECEIPTS_ALL(还包含了非收款信息)
CASH_RECEIPT_ID 内部code
RECEIPT_NUMBER 收款号
RECEIPT_DATE 收款日期
AMOUNT 总额
RECEIPT_TYPE 现金/杂项 Cash/Misc
FUNCTIONAL_AMOUNT 本位币计量金额
UI上为RECEIPTS
核销关系不是一一对应,也不是一次核销100%,UI上右下方的Application 按钮
AR_RECEIVABLE_APPLICATIONS_ALL
APPLIED_CUSTOMER_TRX_ID 发票编号
APPLIED_CUSTOMER_TRX_LINE_ID 发票行编号
STATUS APP表示核销 /UNAPP表示未核销
AMOUNT_APPLIED 匹配金额
注意:红冲收款报表时间跨月的问题;必须联查 AR_CASH_RECEIPTS_ALL和 AR_CASH_RECEIPT_HISTORY_ALL
AP
应付账款(是我方人员按照供应商提供的纸张发票信息录入)UI 上的invoice
AP_INVOICES_ALL
实际付款PAYMENT
AP_CHECKS_ALL
核销关系 同AR,右下方的Payment 按钮
AP_INVOICE_PAYMENTS_ALL客户余额表,状况比较复杂:好比两个用户合并,应收应付差额,预付款
资产信息FA_ADDITIONS
名称
编号
分类
数量
资产类别
FA_CATEGORIES
资产账簿
FA_BOOK_CONTROLS 和会计账簿有什么关系?
FA_BOOKS
UI中的Inquiry
Mothed是折旧方法(直线法/产量法)
FA_DISTRIBUTION_HISTORY分配assignment,给什么部门使用多少
LOCATION_ID 部门 联查FA_LOCATIONS
折旧信息(分摊方法)
FA_DEPRN_DETAIL
period_counter 折旧期间编号
折旧事务(新增、重建、转移、报废)
FA_TRANSACTION_HEADERS
========================华丽的分割线=========================
fnd_user --- 系统用户表
po_vendors --- 供应商信息表
po_vendor_sites --- 供应商地点信息表
hr_organization_units --- 组织及库存组织表
per_people_f --- 员工表
wip_entities --- 做业名信息表
wip_discrete_jobs --- 离散做业表
wip_requirement_operations --- 做业名物料需求发放表
po_headers_all --- 采购订单头表
po_lines_all --- 采购订单行表
po_line_locations_all --- 采购行地点表
rcv_transactions --- 接收交易表
bom_bill_of_materials --- 物料清单表
bom_inventory_components --- 物料清单构成表
mtl_system_items --- 物料主表
mtl_onhand_quantities --- 库存数据表
mtl_item_locations --- 项目货位表
mtl_material_transactions --- 出入库记录表
mtl_supply --- 供应表
mtl_demand --- 需求表
参考二:
1. OU、库存组织
SELECT hou.organization_id ou_org_id, --org_id
hou.name ou_name, --ou 名称
ood.organization_id org_org_id, -- 库存组织 id
ood.organization_code org_org_code, -- 库存组织代码
msi.secondary_inventory_name, -- 子库存名称
msi.description -- 子库存描述
FROM hr_organization_information hoi, -- 组织分类表
hr_operating_units hou, --ou 视图
org_organization_definitions ood, -- 库存组织定义视图
mtl_secondary_inventories msi -- 子库存信息表
WHERE hoi.org_information1 = \'OPERATING_UNIT\'
AND hoi.organization_id = hou.organization_id
AND ood.operating_unit = hoi.organization_id
AND ood.organization_id = msi.organization_id
-- 获取系统 ID
call fnd_global.APPS_INITIALIZE( 1318 , 50583 , 401 )
select fnd_profile.VALUE( \'ORG_ID\' ) FROM DUAL
select * from hr_operating_units hou where hou.organization_id= 204
2. 用户、责任及 HR
-- 系统责任定义 VIEW(FROM FND_RESPONSIBILITY_TL, FND_RESPONSIBILITY)
SELECT APPLICATION_ID,
RESPONSIBILITY_ID,
RESPONSIBILITY_KEY,
END_DATE,
RESPONSIBILITY_NAME,
DESCRIPTION
FROM FND_RESPONSIBILITY_VL;
-- 用户责任关系
SELECT USER_ID, RESPONSIBILITY_ID FROM FND_USER_RESP_GROUPS;
-- 用户表
SELECT USER_ID, USER_NAME, EMPLOYEE_ID, PERSON_PARTY_ID, END_DATE
FROM FND_USER;
-- 人员表 VIEW
SELECT PERSON_ID,
START_DATE,
DATE_OF_BIRTH,
EMPLOYEE_NUMBER,
NATIONAL_IDENTIFIER,
SEX,
FULL_NAME
FROM per_people_f;
-- 综合查询
SELECT USER_NAME, FULL_NAME, RESPONSIBILITY_NAME, CC.DESCRIPTION
FROM FND_USER AA,
FND_USER_RESP_GROUPS BB,
FND_RESPONSIBILITY_VL CC,
per_people_f DD
WHERE AA.USER_ID = BB.USER_ID
AND BB.RESPONSIBILITY_ID = CC.RESPONSIBILITY_ID
AND AA.EMPLOYEE_ID = DD.PERSON_ID
AND RESPONSIBILITY_NAME like \'% 供应处 %\'
ORDER BY USER_NAME;
-- 综合查询
-- 人员情况基本信息表
SELECT PAF.PERSON_ID 系统 ID,
PAF.FULL_NAME 姓名 ,
PAF.DATE_OF_BIRTH 出生日期 ,
PAF.REGION_OF_BIRTH 出生地区 ,
PAF.NATIONAL_IDENTIFIER 身份证号 ,
PAF.ATTRIBUTE1 招工来源 ,
PAF.ATTRIBUTE3 员工类型 ,
PAF.ATTRIBUTE11 集团合同号 ,
PAF.original_date_of_hire 参加工做日期 ,
PAF.PER_INFORMATION17 省份 ,
DECODE (PAF.SEX, \'M\' , \' 男 \' , \'F\' , \' 女 \' , \'NULL\' ) 性别 , --decode 适合和同一值作比较有多种结果,不适合和多种值比较有多种结果
CASE PAF.SEX
WHEN \'M\' THEN \' 男 \'
WHEN \'F\' THEN \' 女 \'
ELSE \'NULL\'
END 性别 1, --case 用法一
CASE WHEN TO_CHAR(PAF.DATE_OF_BIRTH, \'YYYY\' ) < \'1960\' THEN \'50 年代 \'
WHEN TO_CHAR(PAF.DATE_OF_BIRTH, \'YYYY\' ) < \'1970\' THEN \'60 年代 \'
WHEN TO_CHAR(PAF.DATE_OF_BIRTH, \'YYYY\' ) < \'1980\' THEN \'70 年代 \'
WHEN TO_CHAR(PAF.DATE_OF_BIRTH, \'YYYY\' ) < \'1990\' THEN \'80 年代 \'
WHEN TO_CHAR(PAF.DATE_OF_BIRTH, \'YYYY\' ) < \'2000\' THEN \'90 年代 \'
ELSE \'21 世纪 \' --case 用法二
END 出生年代
FROM PER_ALL_PEOPLE_F PAF
3. 供应商 VENDOR
-- 供应商主表数据:
SELECT ass.vendor_id vendor_id,
ass.party_id party_id,
ass.segment1 vendor_code,
ass.vendor_name vendor_name,
ass.vendor_name vendor_short_name,
ass.vendor_type_lookup_code vendor_type,
flv.meaning vendor_type_meaning,
hp.tax_reference tax_registered_name,
ass.payment_method_lookup_code payment_method,
att.name term_name,
att.enabled_flag enabled_flag,
att.end_date_active end_date_active,
ass.creation_date creation_date,
ass.created_by created_by,
ass.last_update_date last_update_date,
ass.last_updated_by last_updated_by,
ass.last_update_login last_update_login
FROM ap_suppliers ass,
fnd_lookup_values flv,
hz_parties hp,
ap_terms_tl att
WHERE ass.vendor_type_lookup_code = flv.lookup_code(+)
AND flv.lookup_type(+) = \'VENDOR TYPE\'
AND flv.language(+) = userenv ( \'LANG\' )
AND ass.party_id = hp.party_id
AND att.language = userenv ( \'LANG\' )
AND ass.terms_id = att.term_id(+)
-- 供应商银行信息
SELECT ass.vendor_id vendor_id,
ass.party_id party_id,
bank.party_id bank_id,
bank.party_name bank_name,
branch.party_id branch_id,
branch.party_name bank_branch_name,
ieba.bank_account_num bank_account_num
FROM ap_suppliers ass,
hz_parties hp,
iby_account_owners iao,
iby_ext_bank_accounts ieba,
hz_parties bank,
hz_parties branch
WHERE ass.party_id = hp.party_id
AND hp.party_id = iao.account_owner_party_id(+)
AND iao.ext_bank_account_id = ieba.ext_bank_account_id(+)
AND ieba.bank_id = bank.party_id(+)
AND ieba.branch_id = branch.party_id(+)
ORDER BY ieba.creation_date;
-- 供应商开户行地址信息
SELECT hps.party_id party_id,
hps.party_site_id party_site_id,
hl.location_id location_id,
hl.country country,
hl.province province,
hl.city city,
hl.address1 address1,
hl.address2 address2,
hl.address3 address3,
hl.address4 address4
FROM hz_party_sites hps, hz_locations hl
WHERE hps.location_id = hl.location_id
ORDER BY hps.creation_date
-- 供应商联系人信息
SELECT hr.subject_id subject_id,
hr.object_id object_id,
hr.party_id party_id,
hp.person_last_name || \' \' || hp.person_middle_name || \' \' ||
hp.person_first_name contact_person,
hcpp.phone_area_code phone_area_code,
hcpp.phone_number phone_number,
hcpp.phone_extension phone_extension,
hcpf.phone_area_code fax_phone_area_code,
hcpf.phone_number fax_phone_number,
hcpe.email_address email_address
FROM hz_relationships hr,
hz_contact_points hcpp,
hz_contact_points hcpf,
hz_contact_points hcpe,
hz_parties hp
WHERE hr.object_id = hp.party_id
AND hcpp.owner_table_id(+) = hr.party_id
AND hcpf.owner_table_id(+) = hr.party_id
AND hcpe.owner_table_id(+) = hr.party_id
AND hr.object_type = \'PERSON\'
AND hr.relationship_code(+) = \'CONTACT\'
AND hcpp.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpf.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpe.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpp.contact_point_type(+) = \'PHONE\'
AND hcpp.phone_line_type(+) = \'GEN\'
AND hcpf.contact_point_type(+) = \'PHONE\'
AND hcpf.phone_line_type(+) = \'FAX\'
AND hcpe.contact_point_type(+) = \'EMAIL\'
AND hcpe.phone_line_type IS NULL
ORDER BY hr.creation_date;
-- 供应商地址主信息
SELECT assa.vendor_site_id vendor_site_id,
assa.vendor_id vendor_id,
assa.vendor_site_code vendor_code,
assa.vendor_site_code address_short_name,
assa.address_line1 address_line1,
assa.address_line2 address_line2,
assa.address_line3 address_line3,
assa.address_line4 address_line4,
assa.org_id org_id,
assa.country country,
assa.province province,
assa.city city,
assa.county county,
assa.zip zip,
assa.pay_site_flag pay_site_flag,
assa.purchasing_site_flag purchasing_site_flag,
assa.inactive_date inactive_date,
assa.creation_date creation_date,
assa.created_by created_by,
assa.last_update_date last_update_date,
assa.last_updated_by last_updated_by,
assa.last_update_login last_update_login
FROM ap_suppliers ass, ap_supplier_sites_all assa
WHERE assa.vendor_id = ass.vendor_id;
-- 供应商地址联系人信息: phone 、 fax 和 Email
SELECT hcpp.phone_area_code phone_area_code,
hcpp.phone_number phone_number,
hcpp.phone_extension phone_extension,
hcpf.phone_area_code fax_phone_area_code,
hcpf.phone_number fax_phone_number,
hcpe.email_address email_address
FROM ap_supplier_sites_all assa,
hz_contact_points hcpp,
hz_contact_points hcpf,
hz_contact_points hcpe,
hz_party_sites hps
WHERE assa.party_site_id = hps.party_site_id
AND hcpp.owner_table_id(+) = assa.party_site_id
AND hcpf.owner_table_id(+) = assa.party_site_id
AND hcpe.owner_table_id(+) = assa.party_site_id
AND hcpp.owner_table_name(+) = \'HZ_PARTY_SITES\'
AND hcpf.owner_table_name(+) = \'HZ_PARTY_SITES\'
AND hcpe.owner_table_name(+) = \'HZ_PARTY_SITES\'
AND hcpp.contact_point_type(+) = \'PHONE\'
AND hcpp.phone_line_type(+) = \'GEN\'
AND hcpf.contact_point_type(+) = \'PHONE\'
AND hcpf.phone_line_type(+) = \'FAX\'
AND hcpe.contact_point_type(+) = \'EMAIL\'
AND hcpe.phone_line_type IS NULL ;
-- 供应商地址收件人信息
SELECT assa.party_site_id
FROM ap_supplier_sites_all assa
-- 根据 party_site_id 获得供应商地址的收件人名称
SELECT hps.addressee FROM hz_party_sites hps;
-- 供应商银行账户分配层次关系
SELECT * FROM iby_pmt_instr_uses_all;
-- 供应商银行账户分配层次关系明细 ( 不包括供应商层的分配信息 ):
SELECT * FROM iby_external_payees_all;
4. 客户 CUSTOMER
--SQL 查询
-- 客户帐户表 以许继 1063 电网客户为例 -->>PARTY_ID = 21302
SELECT * FROM hz_cust_accounts AA WHERE AA.CUST_ACCOUNT_ID = 1063 ;
-- 客户名称及地址全局信息表 -->> PARTY_NUMBER = 19316
SELECT * FROM hz_parties AA WHERE AA.PARTY_ID = 21302 ;
-- 客户地点帐户主文件
SELECT * FROM hz_cust_acct_sites_all WHERE CUST_ACCOUNT_ID = 1063 ;
-- 客户地点 ( 关联 hz_cust_acct_sites_all)
SELECT * FROM HZ_PARTY_SITES WHERE PARTY_ID = 21302 ;
-- 地点地址名称 ( 关联 hz_cust_acct_sites_all)
SELECT AA.ADDRESS1, AA.ADDRESS_KEY
FROM HZ_LOCATIONS AA, HZ_PARTY_SITES BB
WHERE AA.LOCATION_ID = BB.LOCATION_ID
AND BB.PARTY_ID = 21302 ;
-- 客户地点业务目的 ( 关联 hz_cust_acct_sites_all 用 CUST_ACCT_SITE_ID)
SELECT * FROM HZ_CUST_SITE_USES_ALL;
-- 客户地点详细信息表,以供应处 OU 的身份 ORG_ID = 119
SELECT AA.PARTY_SITE_ID 客户组织地点 ID,
AA.PARTY_ID 客户组织 ID,
AA.LOCATION_ID 地点 ID,
AA.PARTY_SITE_NUMBER 地点编号 ,
AA.IDENTIFYING_ADDRESS_FLAG 地址标示 ,
AA.STATUS 有效否 ,
AA.PARTY_SITE_NAME,
BB.ORG_ID 业务实体 ,
BB.bill_to_flag 收单标示 ,
BB.ship_to_flag 收货标示 ,
CC.ADDRESS1 地点名称 ,
DD.SITE_USE_ID,
DD.SITE_USE_CODE,
DD.PRIMARY_FLAG,
DD.STATUS,
DD.LOCATION 业务目的 ,
DD.BILL_TO_SITE_USE_ID 收单地 ID,
DD.TAX_CODE
FROM hz_party_sites AA,
hz_cust_acct_sites_all BB,
hz_locations CC,
HZ_CUST_SITE_USES_ALL DD
WHERE AA.PARTY_SITE_ID = BB.PARTY_SITE_ID
AND BB.CUST_ACCOUNT_ID = 1063
AND BB.ORG_ID = 119
AND AA.STATUS = \'A\'
AND AA.LOCATION_ID = CC.LOCATION_ID
AND BB.CUST_ACCT_SITE_ID(+) = DD.CUST_ACCT_SITE_ID
AND DD.STATUS <> \'I\' ;
--************* 综合查询 ************--
-- 客户主数据
SELECT hca.cust_account_id customer_id,
hp.party_number customer_number,
hp.party_name customer_name,
hp.party_name customer_short_name,
hca.customer_type customer_type,
alt.meaning customer_type_meaning,
hca.customer_class_code customer_class,
alc.meaning customer_class_meaning,
hp.tax_reference tax_registered_name,
rt.name term_name,
hca.creation_date creation_date,
hca.created_by created_by,
hca.last_update_date last_update_date,
hca.last_updated_by last_updated_by,
hca.last_update_login last_update_login
FROM hz_parties hp,
hz_cust_accounts hca,
ar_lookups alt,
ar_lookups alc,
hz_customer_profiles hcp,
ra_terms rt
WHERE hp.party_id = hca.party_id
AND hca.customer_type = alt.lookup_code(+)
AND alt.lookup_type = \'CUSTOMER_TYPE\'
AND hca.customer_class_code = alc.lookup_code(+)
AND alc.lookup_type(+) = \'CUSTOMER CLASS\'
AND hca.cust_account_id = hcp.cust_account_id(+)
AND hcp.standard_terms = rt.term_id(+)
-- 客户收款方法 SQL
SELECT arm.name receipt_method_name
FROM hz_cust_accounts hca,
ra_cust_receipt_methods rcrm,
ar_receipt_methods arm
WHERE hca.cust_account_id = rcrm.customer_id
AND rcrm.receipt_method_id = arm.receipt_method_id
ORDER BY rcrm.creation_date;
-- 客户帐户层银行帐户信息 SQL
SELECT hca.cust_account_id cust_account_id,
hp.party_id party_id,
bank.party_id bank_id,
bank.party_name bank_name,
branch.party_id branch_id,
branch.party_name bank_branch_name,
ieba.bank_account_num bank_account_num
FROM hz_cust_accounts hca,
hz_parties hp,
iby_account_owners iao,
iby_ext_bank_accounts ieba,
hz_parties bank,
hz_parties branch
WHERE hca.party_id = hp.party_id
AND hp.party_id = iao.account_owner_party_id(+)
AND iao.ext_bank_account_id = ieba.ext_bank_account_id(+)
AND ieba.bank_id = bank.party_id(+)
AND ieba.branch_id = branch.party_id(+)
ORDER BY ieba.creation_date;
-- 客户开户行地址信息 SQL
SELECT hl.country || \'-\' || hl.province || \'-\' || hl.city || \'-\' ||
hl.address1 || \'-\' || hl.address2 || \'-\' || hl.address3 || \'-\' ||
hl.address4 bank_address
FROM hz_party_sites hps, hz_locations hl
WHERE hps.location_id = hl.location_id
ORDER BY hps.creation_date;
-- 客户帐户层联系人信息:联系人、电话、手机和 Email SQL
SELECT hr.party_id party_id,
hcar.cust_account_id cust_account_id,
hcar.cust_acct_site_id cust_acct_site_id,
hp.person_last_name || \' \' || hp.person_middle_name || \' \' ||
hp.person_first_name contact_person,
hcpp.phone_area_code phone_area_code,
hcpp.phone_number phone_number,
hcpp.phone_extension phone_extension,
hcpm.phone_area_code mobile_phone_area_code,
hcpm.phone_number mobile_phone_number,
hcpe.email_address email_address
FROM hz_relationships hr,
hz_cust_account_roles hcar,
hz_org_contacts hoc,
hz_contact_points hcpp,
hz_contact_points hcpm,
hz_contact_points hcpe,
hz_parties hp,
hz_cust_accounts hca
WHERE hr.object_id = hp.party_id
AND hr.party_id = hcar.party_id
AND hr.relationship_id = hoc.party_relationship_id(+)
AND hcpp.owner_table_id(+) = hr.party_id
AND hcpm.owner_table_id(+) = hr.party_id
AND hcpe.owner_table_id(+) = hr.party_id
AND hr.object_type = \'PERSON\'
AND hr.relationship_code(+) = \'CONTACT\'
AND hcpp.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpm.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpe.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpp.contact_point_type(+) = \'PHONE\'
AND hcpp.phone_line_type(+) = \'GEN\'
AND hcpm.contact_point_type(+) = \'PHONE\'
AND hcpm.phone_line_type(+) = \'MOBILE\'
AND hcpe.contact_point_type(+) = \'EMAIL\'
AND hcpe.phone_line_type IS NULL
AND hr.subject_id = hca.party_id
AND hcar.cust_acct_site_id IS NULL
ORDER BY hr.creation_date;
-- 客户地址
SELECT hcasa.cust_acct_site_id customer_site_id,
hcasa.cust_account_id customer_id,
hps.party_site_number customer_site_code,
hps.party_site_name customer_site_name,
hl.address1 address_line1,
hl.address2 address_line2,
hl.address3 address_line3,
hl.address4 address_line4,
hcasa.org_id org_id,
hl.country country,
hl.province province,
hl.city city,
hl.county county,
hl.postal_code zip,
hcasa.bill_to_flag bill_to_flag,
hcasa.ship_to_flag ship_to_flag,
hca.creation_date creation_date,
hca.created_by created_by,
hca.last_update_date last_update_date,
hca.last_updated_by last_updated_by,
hca.last_update_login last_update_login
FROM hz_cust_accounts hca,
hz_cust_acct_sites_all hcasa,
hz_party_sites hps,
hz_locations hl
WHERE hca.cust_account_id = hcasa.cust_account_id
AND hcasa.party_site_id = hps.party_site_id
AND hps.location_id = hl.location_id;
-- 客户帐户层地址 contact person 信息 :phone,mobile,email
SELECT hr.party_id party_id,
hcar.cust_account_id cust_account_id,
hcar.cust_acct_site_id cust_acct_site_id,
hp.person_last_name || \' \' || hp.person_middle_name || \' \' ||
hp.person_first_name contact_person,
hcpp.phone_area_code phone_area_code,
hcpp.phone_number phone_number,
hcpp.phone_extension phone_extension,
hcpm.phone_area_code mobile_phone_area_code,
hcpm.phone_number mobile_phone_number,
hcpe.email_address email_address
FROM hz_relationships hr,
hz_cust_account_roles hcar,
hz_org_contacts hoc,
hz_contact_points hcpp,
hz_contact_points hcpm,
hz_contact_points hcpe,
hz_parties hp,
hz_cust_accounts hca
WHERE hr.object_id = hp.party_id
AND hr.party_id = hcar.party_id
AND hr.relationship_id = hoc.party_relationship_id(+)
AND hcpp.owner_table_id(+) = hr.party_id
AND hcpm.owner_table_id(+) = hr.party_id
AND hcpe.owner_table_id(+) = hr.party_id
AND hr.object_type = \'PERSON\'
AND hr.relationship_code(+) = \'CONTACT\'
AND hcpp.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpm.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpe.owner_table_name(+) = \'HZ_PARTIES\'
AND hcpp.contact_point_type(+) = \'PHONE\'
AND hcpp.phone_line_type(+) = \'GEN\'
AND hcpm.contact_point_type(+) = \'PHONE\'
AND hcpm.phone_line_type(+) = \'MOBILE\'
AND hcpe.contact_point_type(+) = \'EMAIL\'
AND hcpe.phone_line_type IS NULL
AND hr.subject_id = hca.party_id
AND hca.cust_account_id = hcar.cust_account_id
ORDER BY hr.creation_date;
-- 客户帐户地点地址
SELECT hp.party_id,
hca.cust_account_id,
hcasa.cust_acct_site_id,
hcasa.bill_to_flag,
hcasa.ship_to_flag,
hcsua.site_use_id,
hcasa.party_site_id,
hcsua.site_use_code,
hcsua.primary_flag,
hcsua.location,
hcsua.org_id
FROM hz_parties hp,
hz_cust_accounts hca,
hz_party_sites hps,
hz_cust_acct_sites_all hcasa,
hz_cust_site_uses_all hcsua
WHERE hp.party_id = hca.party_id
AND hca.cust_account_id = hcasa.cust_account_id
AND hcasa.party_site_id = hps.party_site_id
AND hcsua.cust_acct_site_id = hcasa.cust_acct_site_id
-- 客户主配置文件
SELECT * FROM hz_cust_profile_classes;
SELECT * FROM hz_customer_profiles;
SELECT * FROM hz_cust_prof_class_amts;
SELECT * FROM hz_cust_profile_amts;
5. 订单 OE
--
select * from oe_order_headers_all 销售头
select * from oe_order_lines_all 销售行
select * from wsh_new_deliveries 发送
select * from wsh_delivery_details
select * from wsh_delivery_assignments
-- 综合查询 1- 未结销售订单
SELECT H.ORDER_NUMBER 销售订单 ,
h.cust_po_number 客户 PO,
cust.account_number 客户编码 ,
hp.party_name 客户名称 ,
ship_use.location 收货地 ,
bill_use.location 收单地 ,
h.ordered_date 订单日期 ,
H.ATTRIBUTE1 合同号 ,
h.attribute2 屏号 ,
h.attribute3 来源编码 ,
l.line_number 行号 ,
l.ordered_item 物料 ,
msi.description 物料说明 ,
l.order_quantity_uom 订购单位 ,
l.ordered_quantity 订购数量 ,
l.cancelled_quantity 取消数量 ,
l.shipped_quantity 发运数量 ,
l.schedule_ship_date 计划发运日期 ,
l.booked_flag 登记标记 ,
ol.MEANING 工做流状态 ,
l.cancelled_flag 取消标记
FROM OE_ORDER_HEADERS_ALL H,
OE_ORDER_LINES_ALL L,
HZ_CUST_ACCOUNTS CUST,
hz_parties hp,
hz_cust_site_uses_all ship_use,
hz_cust_site_uses_all bill_use,
mtl_system_items_b msi,
oe_lookups ol
WHERE 1 = 1
AND H.HEADER_ID = L.HEADER_ID
AND H.SOLD_TO_ORG_ID = CUST.CUST_ACCOUNT_ID
and cust.party_id = hp.party_id
and h.ship_to_org_id = ship_use.site_use_id
and h.invoice_to_org_id = bill_use.site_use_id
and l.flow_status_code not in ( \'CLOSED\' , \'CANCELLED\' )
and l.inventory_item_id = msi.inventory_item_id
and msi.organization_id = 141
and l.flow_status_code = ol.LOOKUP_CODE
and ol.LOOKUP_TYPE = \'LINE_FLOW_STATUS\'
AND CUST.ACCOUNT_NUMBER IN ( \'91010072\' , \'91010067\' , \'91010036\' )
order by party_name ,收货地,销售订单 ;
6. 采购申请 PR
-- 申请单头 (以电网组织 ORG_ID=112 内部申请 =14140002781 为例
SELECT PRH.REQUISITION_HEADER_ID 申请单头 ID,
PRH.PREPARER_ID,
PRH.Org_Id OU_ID,
PRH.SEGMENT1 申请单编号 ,
PRH.Creation_Date 建立日期 ,
PRH.Created_By 编制人 ID,
FU.USER_NAME 用户名称 ,
PP.FULL_NAME 用户姓名 ,
PRH.Approved_Date 批准日期 ,
PRH.Description 说明 ,
PRH.Authorization_Status 状态 ,
PRH.Type_Lookup_Code 类型 ,
PRH.Transferred_To_Oe_Flag 传递标示
FROM PO_REQUISITION_HEADERS_ALL PRH, FND_USER FU, per_people_f PP
WHERE PRH.CREATED_BY = FU.USER_ID
AND FU.EMPLOYEE_ID = PP.PERSON_ID
AND PRH.ORG_ID = 112
AND PRH.SEGMENT1 = \'14140002781\' ;
-->> 内部申请 =14140002781 申请单头 ID = 3379
-- 申请单行明细
SELECT PRL.REQUISITION_HEADER_ID 申请单 ID,
PRL.REQUISITION_LINE_ID 行 ID,
PRL.LINE_NUM 行号 ,
PRL.CATEGORY_ID 分类 ID,
PRL.ITEM_ID 物料 ID,
ITEM.SEGMENT1 物料编码 ,
PRL.ITEM_DESCRIPTION 物料说明 ,
PRL.Quantity 需求数 ,
PRL.Quantity_Delivered 送货数 ,
PRL.Quantity_Cancelled 取消数 ,
PRL.Unit_Meas_Lookup_Code 单位 ,
PRL.Unit_Price 参考价 ,
PRL.Need_By_Date 需求日期 ,
PRL.Source_Type_Code 来源类型 ,
PRL.Org_Id OU_ID,
PRL.Source_Organization_Id 对方组织 ID,
PRL.Destination_Organization_Id 本方组织 ID
from PO_REQUISITION_LINES_ALL PRL,MTL_SYSTEM_ITEMS ITEM
WHERE PRL.ORG_ID = 112
AND PRL.ITEM_ID = ITEM.INVENTORY_ITEM_ID
AND PRL.Destination_Organization_Id = ITEM.ORGANIZATION_ID
AND PRL.REQUISITION_HEADER_ID = 3379 ;
-- 申请单头 ( 加对方订单编号 )
SELECT PRH.REQUISITION_HEADER_ID 申请单头 ID,
PRH.PREPARER_ID,
PRH.Org_Id OU_ID,
PRH.SEGMENT1 申请单编号 ,
PRH.Creation_Date 建立日期 ,
PRH.Created_By 编制人 ID,
FU.USER_NAME 用户名称 ,
PP.FULL_NAME 用户姓名 ,
PRH.Approved_Date 批准日期 ,
PRH.Description 说明 ,
PRH.Authorization_Status 状态 ,
PRH.Type_Lookup_Code 类型 ,
PRH.Transferred_To_Oe_Flag 传递标示 ,
OEH.ORDER_NUMBER 对方 CO 编号
FROM PO_REQUISITION_HEADERS_ALL PRH, FND_USER FU, per_people_f PP,OE_ORDER_HEADERS_ALL OEH
WHERE PRH.CREATED_BY = FU.USER_ID
AND FU.EMPLOYEE_ID = PP.PERSON_ID
AND PRH.REQUISITION_HEADER_ID = OEH.SOURCE_DOCUMENT_ID(+)
AND PRH.ORG_ID = 112
AND PRH.SEGMENT1 = \'14140002781\' ;
--( 销售订单记录有对方 OU_ID, 申请单关键字 SOURCE_DOCUMENT_ID 申请单号 SOURCE_DOCEMENT_REF)
******************* 综合查询类 *******************
-- 申请单头综合查询 (进限制只能查询 -- 电网组织 ORG_ID=112)
SELECT PRH.REQUISITION_HEADER_ID 申请单头 ID,
PRH.Org_Id 组织 ID,
PRH.SEGMENT1 申请单编号 ,
PRH.Creation_Date 建立日期 ,
PRH.Created_By 编制人 ID,
FU.USER_NAME 用户名称 ,
PP.FULL_NAME 用户姓名 ,
PRH.Approved_Date 批准日期 ,
PRH.Description 说明 ,
PRH.Authorization_Status 状态 ,
PRH.Type_Lookup_Code 类型 ,
PRH.Transferred_To_Oe_Flag 传递标示 ,
PRL.REQUISITION_LINE_ID 行 ID,
PRL.LINE_NUM 行号 ,
PRL.CATEGORY_ID 分类 ID,
PRL.ITEM_ID 物料 ID,
ITEM.SEGMENT1 物料编码 ,
PRL.ITEM_DESCRIPTION 物料说明 ,
PRL.Quantity 需求数 ,
PRL.Quantity_Delivered 送货数 ,
PRL.Quantity_Cancelled 取消数 ,
PRL.Unit_Meas_Lookup_Code 单位 ,
PRL.Unit_Price 参考价 ,
PRL.Need_By_Date 需求日期 ,
PRL.Source_Type_Code 来源类型 ,
PRL.Source_Organization_Id 对方组织 ID,
PRL.Destination_Organization_Id 本方组织 ID
FROM PO_REQUISITION_HEADERS_ALL PRH,
FND_USER FU,
per_people_f PP,
PO_REQUISITION_LINES_ALL PRL,
MTL_SYSTEM_ITEMS ITEM
WHERE PRH.CREATED_BY = FU.USER_ID
AND FU.EMPLOYEE_ID = PP.PERSON_ID
AND PRH.REQUISITION_HEADER_ID = PRL.REQUISITION_HEADER_ID
AND PRH.Org_Id = PRL.ORG_ID
AND PRL.ITEM_ID = ITEM.INVENTORY_ITEM_ID
AND PRL.Destination_Organization_Id = ITEM.ORGANIZATION_ID
AND PRH.ORG_ID = 112 ;
-- 若需建立视图只需在 SELECT 语句前加上
CREATE OR REPLACE VIEW CUX_INV_PR112 AS
7. 采购订单 PO
-- 采购单头信息 TYPE_LOOKUP_CODE=\'STANDARD\' (以供应处 OU ORG_ID=119 采购单 =\'\' 为例)
-- 类型说明 TYPE_LOOKUP_CODE=\'STANDARD\' 为采购单 TYPE_LOOKUP_CODE=\'BLANKET\' 为采购协议
SELECT POH.ORG_ID OU_ID,
POH.PO_HEADER_ID 采购单头 ID,
POH.TYPE_LOOKUP_CODE 类型 ,
POH.AUTHORIZATION_STATUS 状态 ,
POH.VENDOR_ID 供应商 ID,
VENDOR.VENDOR_NAME 供应商名 ,
POH.VENDOR_SITE_ID 供应商地址 ID,
POH.VENDOR_CONTACT_ID 供应商联系人 ID,
POH.SHIP_TO_LOCATION_ID 本方收货地 ID,
POH.BILL_TO_LOCATION_ID 本方收单地 ID,
POH.CREATION_DATE 建立日期 ,
POH.APPROVED_FLAG 审批 YN,
POH.APPROVED_DATE 审批日期 ,
POH.COMMENTS 采购单说明 ,
POH.TERMS_ID 条款 ID,
POH.AGENT_ID 采购员 ID,
AGT_PP.LAST_NAME 采购员 ,
POH.CREATED_BY 建立者 ID,
FU.USER_NAME 建立用户 ,
PP.FULL_NAME 用户姓名
FROM PO_HEADERS_ALL POH, FND_USER FU, per_people_f PP,PER_ALL_PEOPLE_F AGT_PP,ap_suppliers VENDOR
WHERE POH.CREATED_BY = FU.USER_ID
AND FU.EMPLOYEE_ID = PP.PERSON_ID
AND POH.AGENT_ID = AGT_PP.PERSON_ID
AND POH.VENDOR_ID=VENDOR.VENDOR_ID
AND POH.ORG_ID = 119
AND POH.TYPE_LOOKUP_CODE = \'STANDARD\'
AND POH.SEGMENT1 = \'14730005436\' ;
/*
FND_USER FU, per_people_f PP 用户相关表
po_agents_name_v 采购员视图 ----> PO_AGENTS.AGENT_ID = PER_ALL_PEOPLE_F.PERSON_ID 采购员相关表
ap_suppliers 供应商主表
*/
-->> POH.SEGMENT1 = \'14730005436\' PO_HEADER_ID = 10068
-- 采购单行信息
SELECT POL.ORG_ID OU_ID,
POL.PO_HEADER_ID 采购单头 ID,
POL.PO_LINE_ID 行 ID,
POL.LINE_NUM 行号 ,
POL.ITEM_ID 物料 ID,
ITEM.SEGMENT1 物料编码 ,
POL.ITEM_DESCRIPTION 物料说明 ,
POL.UNIT_MEAS_LOOKUP_CODE 单位 ,
POL.UNIT_PRICE 单价 ,
PO_LCT.QUANTITY 订购数 ,
PO_LCT.QUANTITY_RECEIVED 验收数 ,
PO_LCT.QUANTITY_ACCEPTED 接收数 ,
PO_LCT.QUANTITY_REJECTED 拒绝数 ,
PO_LCT.QUANTITY_CANCELLED 取消数 ,
PO_LCT.QUANTITY_BILLED 到票数 ,
PO_LCT.PROMISED_DATE 承诺日期 ,
PO_LCT.NEED_BY_DATE 需求日期
FROM PO_LINES_ALL POL,
Po_Line_Locations_all PO_LCT,
MTL_SYSTEM_ITEMS ITEM
WHERE POL.ORG_ID = PO_LCT.ORG_ID
AND POL.PO_LINE_ID = PO_LCT.PO_LINE_ID
AND POL.ITEM_ID = ITEM.INVENTORY_ITEM_ID
AND ITEM.ORGANIZATION_ID = 142
AND POL.Org_Id = 119
AND POL.PO_HEADER_ID = 10068 ;
-- 说明: Po_Line_Locations_all 系 “ 发运表 ”
-- 综合查询 1 ,所分配给供应处组织的物料,存在采购协议,但缺失采购员或缺失仓库;
select MSIF.Segment1 物料编码 ,
MSIF.Description 物料描述 ,
MSIF.LONG_DESCRIPTION 物料详细描述 ,
--MSIF.primary_unit_of_measure 计量单位 ,
PRF.LAST_NAME 采购员 ,
MISD.subinventory_code 默认接收库存 ,
PLA.unit_price 未税价 ,
round (PLA.unit_price * ( 1 + ZRB.percentage_rate / 100 ), 2 ) 含税价 ,
PV.VENDOR_NAME 供应商名称
from apps.PO_HEADERS_ALL PHA,
apps.PO_LINES_ALL PLA,
apps.MTL_SYSTEM_ITEMS_FVL MSIF,
apps.MTL_ITEM_SUB_DEFAULTS MISD,
apps.PER_PEOPLE_F PRF,
apps.PO_VENDORS PV,
apps.PO_VENDOR_SITES_ALL PVSA,
apps.ZX_RATES_B ZRB
where PHA.Type_Lookup_Code = \'BLANKET\' and PHA.Org_Id = 119 and
PHA.PO_HEADER_ID = PLA.Po_Header_Id and
PHA.Global_Agreement_Flag = \'Y\' and PHA.Approved_Flag in ( \'Y\' , \'R\' ) and
NVL (PHA.end_Date, sysdate ) >= sysdate and
NVL (PLA.Expiration_Date, sysdate ) >= sysdate and
PLA.Cancel_Flag = \'N\' and PLA.Item_Id = MSIF.INVENTORY_ITEM_ID and
MSIF.ORGANIZATION_ID = 142 and
MSIF.INVENTORY_ITEM_ID = MISD.INVENTORY_ITEM_ID(+) and
MISD.ORGANIZATION_ID(+) = 142 and MISD.default_type(+) = 2 and
MSIF.BUYER_ID = PRF.PERSON_ID(+) and
PRF.EFFECTIVE_END_DATE(+) = to_date( \'4712-12-31\' , \'YYYY-MM-DD\' ) and
PHA.VENDOR_ID = PV.VENDOR_ID and
PHA.Vendor_Site_Id = PVSA.VENDOR_SITE_ID and
PVSA.VAT_CODE = ZRB.tax_rate_code and
(MISD.subinventory_code is null or PRF.LAST_NAME is null )
-- 采购其余相关表
select * from po_distributions_all 分配
select * from po_releases_all
select * from rcv_shipment_headers 采购接收头
select * from rcv_shipment_lines 采购接收行
select * from rcv_transactions 接收事务处理
select * from po_agents
select * from po_vendors
select * from po_vendor_sites_all
8. 库存 INV
-- 物料主表
select MSI.ORGANIZATION_ID 组织 ID,
MSI.INVENTORY_ITEM_ID 物料 ID,
MSI.SEGMENT1 物料编码 ,
MSI.DESCRIPTION 物料说明 ,
MSI.ITEM_TYPE 项目类型 ,
MSI.PLANNING_MAKE_BUY_CODE 制造或购买 ,
MSI.PRIMARY_UNIT_OF_MEASURE 基本度量单位 ,
MSI.BOM_ENABLED_FLAG BOM 标志 ,
MSI.INVENTORY_ASSET_FLAG 库存资产否 ,
MSI.BUYER_ID 采购员 ID,
MSI.PURCHASING_ENABLED_FLAG 可采购否 ,
MSI.PURCHASING_ITEM_FLAG 采购项目 ,
MSI.UNIT_OF_ISSUE 单位 ,
MSI.INVENTORY_ITEM_FLAG 是否为库存 ,
MSI.LOT_CONTROL_CODE 是否批量 ,
MSI.RESERVABLE_TYPE 是否要预留 ,
MSI.STOCK_ENABLED_FLAG 可否库存 ,
MSI.FIXED_DAYS_SUPPLY 固定提早期 ,
MSI.FIXED_LOT_MULTIPLIER 固定批量大小 ,
MSI.INVENTORY_PLANNING_CODE 库存计划方法 ,
MSI.MAXIMUM_ORDER_QUANTITY 最大定单数 ,
MSI.MINIMUM_ORDER_QUANTITY 最小定单数 ,
MSI.FULL_LEAD_TIME 固定提早期 ,
MSI.PLANNER_CODE 计划员码 ,
MISD.SUBINVENTORY_CODE 接收子仓库 ,
MSI.SOURCE_SUBINVENTORY 来源子仓库 ,
MSI.WIP_SUPPLY_SUBINVENTORY 供应子仓库 ,
MSI.ATTRIBUTE12 老编码 ,
MSI.INVENTORY_ITEM_STATUS_CODE 物料状态 ,
MSS.SAFETY_STOCK_QUANTITY 安全库存量
from mtl_system_items MSI, MTL_ITEM_SUB_DEFAULTS MISD,mtl_safety_stocks MSS
where MSI.ORGANIZATION_ID = MISD.ORGANIZATION_ID(+)
and MSI.INVENTORY_ITEM_ID = MISD.INVENTORY_ITEM_ID(+)
and MSI.ORGANIZATION_ID = MSS.ORGANIZATION_ID(+)
and MSI.INVENTORY_ITEM_ID = MSS.INVENTORY_ITEM_ID(+)
and MSI.ORGANIZATION_ID = 1155
and MSI.SEGMENT1 = \'18020200012\'
-- 物料库存数量
SELECT MOQ.ORGANIZATION_ID,
MOQ.INVENTORY_ITEM_ID,
MOQ.SUBINVENTORY_CODE,
SUM (MOQ.TRANSACTION_QUANTITY) QTY
FROM mtl_onhand_quantities MOQ
WHERE MOQ.INVENTORY_ITEM_ID = 12781
AND MOQ.ORGANIZATION_ID = 1155
GROUP BY MOQ.ORGANIZATION_ID, MOQ.INVENTORY_ITEM_ID, MOQ.SUBINVENTORY_CODE;
-- 移动平均成本
SELECT CST.INVENTORY_ITEM_ID ITEM_ID,
CST.ORGANIZATION_ID ORG_ID,
CST.COST_TYPE_ID 成本类型 ,
CST.ITEM_COST 单位成本 ,
CST.MATERIAL_COST 材料成本 ,
CST.MATERIAL_OVERHEAD_COST 间接费 ,
CST.Resource_Cost 人工费 ,
CST.OUTSIDE_PROCESSING_COST 外协费 ,
CST.OVERHEAD_COST 制造费
FROM CST_ITEM_COSTS CST
WHERE CST.COST_TYPE_ID = 2
AND CST.INVENTORY_ITEM_ID = 12781
AND CST.ORGANIZATION_ID = 1155 ;
-- 综合查询 - 库存数量及成本
SELECT MSI.ORGANIZATION_ID 组织 ID,
MSI.INVENTORY_ITEM_ID 物料 ID,
MSI.SEGMENT1 物料编码 ,
MSI.DESCRIPTION 物料说明 ,
MSI.PLANNING_MAKE_BUY_CODE M1P2,
MOQV.SUBINVENTORY_CODE 子库存 ,
MOQV.QTY 当前库存量 ,
CST.ITEM_COST 单位成本 ,
CST.MATERIAL_COST 材料成本 ,
CST.MATERIAL_OVERHEAD_COST 间接费 ,
CST.Resource_Cost 人工费 ,
CST.OUTSIDE_PROCESSING_COST 外协费 ,
CST.OVERHEAD_COST 制造费
FROM MTL_SYSTEM_ITEMS MSI,
CST_ITEM_COSTS CST,
( SELECT MOQ.ORGANIZATION_ID,
MOQ.INVENTORY_ITEM_ID,
MOQ.SUBINVENTORY_CODE,
SUM (MOQ.TRANSACTION_QUANTITY) QTY
FROM mtl_onhand_quantities MOQ
WHERE MOQ.ORGANIZATION_ID = 1155
GROUP BY MOQ.ORGANIZATION_ID,
MOQ.INVENTORY_ITEM_ID,
MOQ.SUBINVENTORY_CODE) MOQV
WHERE MSI.ORGANIZATION_ID = CST.ORGANIZATION_ID(+)
AND MSI.INVENTORY_ITEM_ID = CST.INVENTORY_ITEM_ID(+)
AND MSI.ORGANIZATION_ID = MOQV.ORGANIZATION_ID(+)
AND MSI.INVENTORY_ITEM_ID = MOQV.INVENTORY_ITEM_ID(+)
AND CST.COST_TYPE_ID = 2
AND MSI.ORGANIZATION_ID = 1155
AND MSI.SEGMENT1 = \'18020200012\'
-- 子库存列表
SELECT * FROM mtl_secondary_inventories;
-- 货位列表
SELECT ORGANIZATION_ID 组织代码 ,
INVENTORY_LOCATION_ID 货位内码 ,
SUBINVENTORY_CODE 子库名称 ,
SEGMENT1 货位编码
FROM mtl_item_locations;
-- 计划员表
SELECT PLANNER_CODE 计划员代码 ,
ORGANIZATION_ID 组织代码 ,
DESCRIPTION 计划员描述 ,
MP.EMPLOYEE_ID 员工 ID,
DISABLE_DATE 失效日期
FROM mtl_planners MP;
-- 科目设置等参数
select * from MTL_PARAMETERS MP
9. 物料清单 BOM
--BOM 主表 bom_bill_of_materials
select AA.BILL_SEQUENCE_ID 清单序号 ,
AA.ASSEMBLY_ITEM_ID 装配件内码 ,
AA.ORGANIZATION_ID 组织代码 ,
BB.SEGMENT1 物料编码 ,
BB.DESCRIPTION 物料说明 ,
AA.ASSEMBLY_TYPE 装配类别
from bom_bill_of_materials AA , mtl_system_items BB
where AA.ASSEMBLY_ITEM_ID = BB.INVENTORY_ITEM_ID
and AA.ORGANIZATION_ID = BB.ORGANIZATION_ID;
--BOM 明细表 bom_inventory_components
select BILL_SEQUENCE_ID 清单序号 ,
COMPONENT_SEQUENCE_ID 构件序号 ,
ITEM_NUM 项目序列 ,
OPERATION_SEQ_NUM 操做序列号 ,
COMPONENT_ITEM_ID 子物料内码 ,
COMPONENT_QUANTITY 构件数量 ,
DISABLE_DATE 失效日期 ,
supply_subinventory 供应子库存 ,
BOM_ITEM_TYPE
from bom_inventory_components;
--BOM 明细综合查询 ( 组织 限定供应处 142 装配件 = \'5XJ061988\')
SELECT VBOM.BID 清单序号 ,
VBOM.F_ITEMID 装配件内码 ,
BB.SEGMENT1 物料编码 ,
BB.DESCRIPTION 物料说明 ,
VBOM.OGT_ID 组织内码 ,
VBOM.CID 操做 ID,
VBOM.ITEM_NUM 物料序号 ,
VBOM.OPID 工序 ,
VBOM.C_ITEMID 子物料内码 ,
CC.SEGMENT1 物料编码 ,
CC.DESCRIPTION 物料说明 ,
VBOM.QTY 构件数量 ,
CC.PRIMARY_UOM_CODE 子计量单位码 ,
CC.PRIMARY_UNIT_OF_MEASURE 子计量单位名 ,
VBOM.WHSE 供应子仓库
FROM ( select AA.BILL_SEQUENCE_ID BID,
BB.ASSEMBLY_ITEM_ID F_ITEMID,
BB.ORGANIZATION_ID OGT_ID,
AA.COMPONENT_SEQUENCE_ID CID,
AA.ITEM_NUM ITEM_NUM,
AA.OPERATION_SEQ_NUM OPID,
AA.COMPONENT_ITEM_ID C_ITEMID,
AA.COMPONENT_QUANTITY QTY,
AA.supply_subinventory WHSE
from bom_inventory_components AA, bom_bill_of_materials BB
where AA.BILL_SEQUENCE_ID = BB.BILL_SEQUENCE_ID) VBOM,
mtl_system_items BB,
mtl_system_items CC
WHERE VBOM.F_ITEMID = BB.INVENTORY_ITEM_ID
and VBOM.OGT_ID = BB.ORGANIZATION_ID
and VBOM.C_ITEMID = CC.INVENTORY_ITEM_ID
and VBOM.OGT_ID = CC.ORGANIZATION_ID
and VBOM.OGT_ID = 142
and BB.SEGMENT1 = \'5XJ061988\'
ORDER BY VBOM.ITEM_NUM;
-- 单层 BOM 成本查询 ( 需系统提交请求计算后 )
select inventory_item_id, organization_id, item_cost, program_update_date
from bom.cst_item_costs
where inventory_item_id = 23760
and organization_id = 142 ;
select inventory_item_id, organization_id, item_cost, program_update_date
from cst_item_cost_details
where inventory_item_id = 23760
and organization_id = 142 ;
10. 做业任务 WIP
说明: 查询做业任务头以及做业任务工序和 BOM 状况
-- 做业任务头信息表
-- (以直流 OU_ID=117 ; ORGANIZATION_ID=1155; 及任务 WIP_ENTITY_NAME=\'XJ39562\'; 装配件编码 SEGMENT1 = \'07D9202.92742\' 为例)
SELECT AA.WIP_ENTITY_ID 任务令 ID,
AA.ORGANIZATION_ID 组织 ID,
AA.WIP_ENTITY_NAME 任务名称 ,
AA.ENTITY_TYPE 任务类型 ,
AA.CREATION_DATE 建立日期 ,
AA.CREATED_BY 建立者 ID,
AA.DESCRIPTION 说明 ,
AA.PRIMARY_ITEM_ID 装配件 ID,
BB.SEGMENT1 物料编码 ,
BB.DESCRIPTION 物料说明
FROM wip_entities AA, mtl_system_items BB
WHERE AA.PRIMARY_ITEM_ID = BB.INVENTORY_ITEM_ID
and AA.ORGANIZATION_ID = BB.ORGANIZATION_ID
and AA.ORGANIZATION_ID = 1155
and AA.WIP_ENTITY_NAME = \'XJ39562\' ;
--=> WIP_ENTITY_ID = 48825
-- 离散做业任务详细主信息表
-- 用途 1 )做业任务下达及完成状况查询
-- 说明 1 )此表包括 wip_entities 表大部分信息 2) 重复做业任务表为 wip_repetitive_items, wip_repetitive_schedules
select AA.WIP_ENTITY_ID 任务令 ID,
BB.WIP_ENTITY_NAME 任务名称 ,
AA.ORGANIZATION_ID 组织 ID,
AA.SOURCE_LINE_ID 行 ID,
AA.STATUS_TYPE 状态 TYPE,
AA.PRIMARY_ITEM_ID 装配件 ID,
CC.SEGMENT1 物料编码 ,
CC.DESCRIPTION 物料说明 ,
AA.FIRM_PLANNED_FLAG,
AA.JOB_TYPE 做业类型 ,
AA.WIP_SUPPLY_TYPE 供应 TYPE,
AA.CLASS_CODE 任务类别 ,
AA.SCHEDULED_START_DATE 起始时间 ,
AA.DATE_RELEASED 下达时间 ,
AA.SCHEDULED_COMPLETION_DATE 完工时间 ,
AA.DATE_COMPLETED 完工时间 ,
AA.DATE_CLOSED 关门时间 ,
AA.START_QUANTITY 计划数 ,
AA.QUANTITY_COMPLETED 完工数 ,
AA.QUANTITY_SCRAPPED 报废数 ,
AA.NET_QUANTITY MRP 净值 ,
AA.COMPLETION_SUBINVENTORY 接收子库 ,
AA.COMPLETION_LOCATOR_ID 货位
from wip_discrete_jobs AA, wip.wip_entities BB, mtl_system_items CC
where AA.WIP_ENTITY_ID = BB.WIP_ENTITY_ID
and AA.PRIMARY_ITEM_ID = CC.INVENTORY_ITEM_ID
and AA.ORGANIZATION_ID = CC.ORGANIZATION_ID
and AA.organization_id = 1155
and BB.WIP_ENTITY_NAME = \'XJ39562\' ;
/*
1 )任务状态 TYPE 值说明:
STATUS_TYPE =1 未发放的 - 收费不容许
STATUS_TYPE =3 发入 - 收费容许
STATUS_TYPE =4 完成 - 容许收费
STATUS_TYPE =5 完成 - 不容许收费
STATUS_TYPE =6 暂挂 - 不容许收费
STATUS_TYPE =7 已取消 - 不容许收费
STATUS_TYPE =8 等待物料单加载
STATUS_TYPE =9 失败的物料单加载
STATUS_TYPE =10 等待路线加载
STATUS_TYPE =11 失败的路线加载
STATUS_TYPE =12 关闭 - 不可收费
STATUS_TYPE =13 等待 - 成批加载
STATUS_TYPE =14 等待关闭
STATUS_TYPE =15 关闭失败
2 )供应类型 TYPE 值说明:
WIP_SUPPLY_TYPE =1 推式
WIP_SUPPLY_TYPE =2 装配拉式
WIP_SUPPLY_TYPE =3 操做拉式
WIP_SUPPLY_TYPE =4 大量
WIP_SUPPLY_TYPE =5 供应商
WIP_SUPPLY_TYPE =6 虚拟
WIP_SUPPLY_TYPE =7 以账单为基础
*/
-- 离散做业任务工序情况表
select AA.ORGANIZATION_ID 组织 ID,
AA.WIP_ENTITY_ID 任务令 ID,
BB.WIP_ENTITY_NAME 任务名称 ,
AA.OPERATION_SEQ_NUM 工序号 ,
AA.DESCRIPTION 工序描述 ,
AA.DEPARTMENT_ID 部门 ID,
AA.SCHEDULED_QUANTITY 计划数量 ,
AA.QUANTITY_IN_QUEUE 排队数量 ,
AA.QUANTITY_RUNNING 运行数量 ,
AA.QUANTITY_WAITING_TO_MOVE 待移动数量 ,
AA.QUANTITY_REJECTED 故障品数量 ,
AA.QUANTITY_SCRAPPED 报废品数量 ,
AA.QUANTITY_COMPLETED 完工数量 ,
AA.FIRST_UNIT_START_DATE 最先一个单位上线时间 ,
AA.FIRST_UNIT_COMPLETION_DATE 最先一个单位完成时间 ,
AA.LAST_UNIT_START_DATE 最后一个单位上线时间 ,
AA.LAST_UNIT_COMPLETION_DATE 最后一个单位完工时间 ,
AA.PREVIOUS_OPERATION_SEQ_NUM 前一工序序号 ,
AA.NEXT_OPERATION_SEQ_NUM 下一工序序号 ,
AA.COUNT_POINT_TYPE 是否自动计费 ,
AA.BACKFLUSH_FLAG 倒冲否 ,
AA.MINIMUM_TRANSFER_QUANTITY 最小传送数量 ,
AA.DATE_LAST_MOVED 最后移动时间
from wip_operations AA,wip_entities BB
where AA.WIP_ENTITY_ID = BB.WIP_ENTITY_ID
and BB.WIP_ENTITY_NAME = \'XJ39562\' ;
-- 离散做业任务子查询 ——— 工单工序情况查询(不单独使用)
select WDJ.ORGANIZATION_ID,
WDJ.WIP_ENTITY_ID,
COUNT ( 1 ) COUNT_OPER,
max ( decode (wo.quantity_completed, 1 , wo.operation_seq_num, 10 )) OPER
from WIP_DISCRETE_JOBS WDJ, WIP_OPERATIONS WO
where 1 = 1
AND WDJ.WIP_ENTITY_ID = WO.WIP_ENTITY_ID
AND WDJ.wip_entity_id = \'48825\'
group by WDJ.ORGANIZATION_ID,WDJ.WIP_ENTITY_ID;
-- 离散做业任务 BOM ( 无材料费 )
SELECT WOP.ORGANIZATION_ID 组织 ID,
WOP.WIP_ENTITY_ID 任务令 ID,
BB.WIP_ENTITY_NAME 装配件名称 ,
BB.PRIMARY_ITEM_ID 装配件 ID,
CC.SEGMENT1 装配件物料编码 ,
CC.DESCRIPTION 装配件说明 ,
WOP.OPERATION_SEQ_NUM 工序号 ,
WOP.DEPARTMENT_ID 部门 ID,
WOP.WIP_SUPPLY_TYPE 供应类型 ,
WOP.DATE_REQUIRED 要求日期 ,
WOP.INVENTORY_ITEM_ID 子物料 ID,
DD.SEGMENT1 子物料编码 ,
DD.DESCRIPTION 子物料说明 ,
WOP.QUANTITY_PER_ASSEMBLY 单位需量 ,
WOP.REQUIRED_QUANTITY 总需求量 ,
WOP.QUANTITY_ISSUED 已发放量 ,
WOP.COMMENTS 注释 ,
WOP.SUPPLY_SUBINVENTORY 供应子库
FROM wip_requirement_operations WOP,
wip_entities BB,
mtl_system_items CC,
mtl_system_items DD
WHERE WOP.WIP_ENTITY_ID = BB.WIP_ENTITY_ID
and BB.PRIMARY_ITEM_ID = CC.INVENTORY_ITEM_ID
and BB.ORGANIZATION_ID = CC.ORGANIZATION_ID
and WOP.INVENTORY_ITEM_ID = DD.INVENTORY_ITEM_ID
and WOP.ORGANIZATION_ID = DD.ORGANIZATION_ID
and WOP.ORGANIZATION_ID = 1155
and BB.WIP_ENTITY_NAME = \'XJ39562\' ;
-- 做业任务已发放材料处理记录清单 0101 (最详细) (内码为 48825 为例)
-- 用途 1 )查询工单发料详细明细,包括发料类型、时间、用户等
select MTL.TRANSACTION_ID 交易 ID,
MTL.INVENTORY_ITEM_ID 项目 ID,
CC.SEGMENT1 物料编码 ,
CC.DESCRIPTION 物料说明 ,
MTL.ORGANIZATION_ID 组织 ID,
MTL.SUBINVENTORY_CODE 子库名称 ,
MTL.TRANSACTION_TYPE_ID 交易类型 ID,
BB.TRANSACTION_TYPE_NAME 交易类型名称 ,
MTL.TRANSACTION_QUANTITY 交易数量 ,
MTL.TRANSACTION_UOM 单位 ,
MTL.TRANSACTION_DATE 交易日期 ,
MTL.TRANSACTION_REFERENCE 交易参考 ,
MTL.TRANSACTION_SOURCE_ID 参考源 ID,
FF.WIP_ENTITY_NAME 任务名称 ,
MTL.DEPARTMENT_ID 部门 ID,
MTL.OPERATION_SEQ_NUM 工序号 ,
ROUND (MTL.PRIOR_COST, 2 ) 原来成本 ,
ROUND (MTL.NEW_COST, 2 ) 新成本 ,
MTL.TRANSACTION_QUANTITY * ROUND (MTL.PRIOR_COST, 2 ) 交易金额 ,
DD.USER_NAME 用户名称 ,
EE.FULL_NAME 用户姓名
from mtl_material_transactions MTL,
mtl_transaction_types BB,
mtl_system_items CC,
FND_USER DD,
per_people_f EE,
wip_entities FF
where MTL.TRANSACTION_TYPE_ID = BB.TRANSACTION_TYPE_ID
and MTL.CREATED_BY = DD.USER_ID
and MTL.INVENTORY_ITEM_ID = CC.INVENTORY_ITEM_ID
and MTL.ORGANIZATION_ID = CC.ORGANIZATION_ID
and DD.EMPLOYEE_ID = EE.PERSON_ID
and MTL.TRANSACTION_SOURCE_ID = FF.WIP_ENTITY_ID
and MTL.Transaction_Type_Id in ( 35 , 38 , 43 , 48 )
and MTL.ORGANIZATION_ID = 1155
and MTL.TRANSACTION_SOURCE_ID = 48825 ;
-- 按工单的材料费汇总(不单独使用)
select MTL.ORGANIZATION_ID,
MTL.TRANSACTION_SOURCE_ID WIP_ENTITY_ID,
ABS ( round ( SUM (MTL.TRANSACTION_QUANTITY * MTL.PRIOR_COST), 2 )) AMT
from mtl_material_transactions MTL
where MTL.Transaction_Type_Id in ( 35 , 38 , 43 , 48 )
and MTL.ORGANIZATION_ID = 1155
and MTL.TRANSACTION_SOURCE_ID = 48825
group by MTL.ORGANIZATION_ID, MTL.TRANSACTION_SOURCE_ID;
-- 离散做业任务子查询 01——— 材料消耗情况及材料费综合查询
-- 用途 1 )查询发料情况 2 )查询材料费物料小计
SELECT WOP.ORGANIZATION_ID 组织 ID,
WOP.WIP_ENTITY_ID 任务令 ID,
BB.WIP_ENTITY_NAME 装配件名称 ,
BB.PRIMARY_ITEM_ID 装配件 ID,
CC.SEGMENT1 装配件物料编码 ,
CC.DESCRIPTION 装配件说明 ,
WOP.OPERATION_SEQ_NUM 工序号 ,
WOP.DEPARTMENT_ID 部门 ID,
WOP.WIP_SUPPLY_TYPE 供应类型 ,
WOP.DATE_REQUIRED 要求日期 ,
WOP.INVENTORY_ITEM_ID 子物料 ID,
DD.SEGMENT1 子物料编码 ,
DD.DESCRIPTION 子物料说明 ,
WOP.QUANTITY_PER_ASSEMBLY 单位需量 ,
WOP.REQUIRED_QUANTITY 总需求量 ,
WOP.QUANTITY_ISSUED 已发放量 ,
CST.AMT 已发生材料费 ,
WOP.COMMENTS 注释 ,
WOP.SUPPLY_SUBINVENTORY 供应子库
FROM wip_requirement_operations WOP,
wip_entities BB,
mtl_system_items CC,
mtl_system_items DD,
( select MTL.ORGANIZATION_ID orgID,
MTL.TRANSACTION_SOURCE_ID wipID,
MTL.OPERATION_SEQ_NUM oprID,
MTL.INVENTORY_ITEM_ID itemID,
sum (MTL.TRANSACTION_QUANTITY * ROUND (MTL.actual_cost, 2 )) amt
from mtl_material_transactions MTL
where MTL.Transaction_Type_Id in ( 35 , 38 , 43 , 48 )
and MTL.ORGANIZATION_ID = 1155
and MTL.TRANSACTION_SOURCE_ID = 48825
group by MTL.ORGANIZATION_ID,
MTL.TRANSACTION_SOURCE_ID,
MTL.OPERATION_SEQ_NUM,
MTL.INVENTORY_ITEM_ID) CST
WHERE WOP.WIP_ENTITY_ID = BB.WIP_ENTITY_ID
and BB.PRIMARY_ITEM_ID = CC.INVENTORY_ITEM_ID
and BB.ORGANIZATION_ID = CC.ORGANIZATION_ID
and WOP.INVENTORY_ITEM_ID = DD.INVENTORY_ITEM_ID
and WOP.ORGANIZATION_ID = DD.ORGANIZATION_ID
and WOP.ORGANIZATION_ID = CST.orgID
and WOP.WIP_ENTITY_ID = CST.wipID
and WOP.OPERATION_SEQ_NUM = CST.oprID
and WOP.INVENTORY_ITEM_ID = CST.itemID
and WOP.ORGANIZATION_ID = 1155
and BB.WIP_ENTITY_NAME = \'XJ39562\' ;
-- 离散做业任务子查询 0201——— 做业资源报工明细表
SELECT WTA.ORGANIZATION_ID 组织代码 ,
WTA.TRANSACTION_ID 交易代码 ,
WTA.REFERENCE_ACCOUNT 参考科目 ,
WTA.TRANSACTION_DATE 报工日期 ,
WTA.WIP_ENTITY_ID 任务令内码 ,
WTA.ACCOUNTING_LINE_TYPE 会计栏类型 ,
WTA.BASE_TRANSACTION_VALUE 费用额 ,
WTA.CONTRA_SET_ID 反方集代码 ,
WTA.PRIMARY_QUANTITY 基本数量 ,
WTA.RATE_OR_AMOUNT 率或金额 ,
WTA.BASIS_TYPE 基本类型 ,
WTA.RESOURCE_ID 资源代码 ,
WTA.COST_ELEMENT_ID 成本要素 ID,
WTA.ACCOUNTING_LINE_TYPE 成本类型 ID,
WTA.OVERHEAD_BASIS_FACTOR 费用因子 ,
WTA.BASIS_RESOURCE_ID 基本资源 ID,
WTA.CREATED_BY 录入人 ID,
DD.USER_NAME 用户名称 ,
EE.FULL_NAME 用户姓名
FROM wip_transaction_accounts WTA, FND_USER DD, per_people_f EE
WHERE WTA.CREATED_BY = DD.USER_ID
and DD.EMPLOYEE_ID = EE.PERSON_ID
and WTA.BASE_TRANSACTION_VALUE <> 0
and WTA.ORGANIZATION_ID = 1155
and WTA.WIP_ENTITY_ID = 48839 ;
-- 成本类型 ID ACCOUNTING_LINE_TYPE
SELECT * FROM MFG_LOOKUPS ML
WHERE ML.LOOKUP_TYPE LIKE \'CST_ACCOUNTING_LINE_TYPE\'
ORDER BY ML.LOOKUP_CODE;
-- 成本要素 ID COST_ELEMENT_ID
--( 待补充 --------------------------------------------------------------------------?)
-- 统计人工费与制造费 ( 不单独应用 )
SELECT ORGANIZATION_ID, WIP_ENTITY_ID, SUM (HR_FEE) HR_FEE, SUM (MD_FEE) MD_FEE
FROM ( Select WTA.ORGANIZATION_ID,
WTA.WIP_ENTITY_ID,
decode (COST_ELEMENT_ID, 3 , WTA.BASE_TRANSACTION_VALUE, 0 ) HR_FEE,
decode (COST_ELEMENT_ID, 5 , WTA.BASE_TRANSACTION_VALUE, 0 ) MD_FEE
from WIP_TRANSACTION_ACCOUNTS WTA
where WTA.ACCOUNTING_LINE_TYPE = 7
and WTA.BASE_TRANSACTION_VALUE <> 0 ) WTA_COST
WHERE WTA_COST.ORGANIZATION_ID = 1155
AND WTA_COST.WIP_ENTITY_ID = \'48839\'
GROUP BY WTA_COST.ORGANIZATION_ID,WTA_COST.WIP_ENTITY_ID;
-- 工单进度及费用信息综合查询 ( 未下达及下达零发料和报工的看不到 )
select WE.WIP_ENTITY_NAME 任务名称 ,
MSI.SEGMENT1 物料 ,
MSI.DESCRIPTION 物料描述 ,
MSI.PRIMARY_UNIT_OF_MEASURE 单位 ,
WDJ.SCHEDULED_START_DATE 计划开始时间 ,
WDJ.SCHEDULED_COMPLETION_DATE 计划完成时间 ,
WDJ.START_QUANTITY 工单数量 ,
WDJ.QUANTITY_COMPLETED 完成数量 ,
WDJ.DATE_RELEASED 实际开始时间 ,
WDJ.DATE_COMPLETED 时间完成时间 ,
WDJ.DESCRIPTION 工单备注 ,
PP.SEGMENT1 项目号 ,
PP.DESCRIPTION 项目描述 ,
PT.TASK_NUMBER 任务号 ,
PT.DESCRIPTION 任务描述 ,
WO.COUNT_OPER 工序数 ,
WO1.OPERATION_SEQ_NUM 当前工序 ,
WO1.DESCRIPTION 当前工序描述 ,
MTA.MT_FEE 材料费 ,
WCT.HR_FEE 人工费 ,
WCT.MD_FEE 制造费 ,
WE.WIP_ENTITY_ID,
WE.ORGANIZATION_ID,
WDJ.PRIMARY_ITEM_ID,
WDJ.PROJECT_ID,
WDJ.TASK_ID
from WIP_ENTITIES WE,
WIP_OPERATIONS WO1,
WIP_DISCRETE_JOBS WDJ,
MTL_SYSTEM_ITEMS_B MSI,
PA_PROJECTS_ALL PP,
PA_TASKS PT,
( select WDJ.ORGANIZATION_ID,
WDJ.WIP_ENTITY_ID,
COUNT ( 1 ) COUNT_OPER,
max ( decode (wo.quantity_completed, 1 , wo.operation_seq_num, 10 )) OPER
from WIP_DISCRETE_JOBS WDJ, WIP_OPERATIONS WO
where WDJ.WIP_ENTITY_ID = WO.WIP_ENTITY_ID
group by WDJ.ORGANIZATION_ID, WDJ.WIP_ENTITY_ID) WO, -- 工序进度
( select MTL.ORGANIZATION_ID,
MTL.TRANSACTION_SOURCE_ID WIP_ENTITY_ID,
ABS ( SUM (MTL.TRANSACTION_QUANTITY * MTL.actual_cost)) MT_FEE
from mtl_material_transactions MTL
where MTL.Transaction_Type_Id in ( 35 , 38 , 43 , 48 )
group by MTL.ORGANIZATION_ID, MTL.TRANSACTION_SOURCE_ID) MTA, -- 材料费
( select WTA_COST.ORGANIZATION_ID,
WTA_COST.WIP_ENTITY_ID,
SUM (WTA_COST.HR_FEE1) HR_FEE,
SUM (WTA_COST.MD_FEE1) MD_FEE
from ( select WTA.ORGANIZATION_ID,
WTA.WIP_ENTITY_ID,
decode (COST_ELEMENT_ID,
3 ,
WTA.BASE_TRANSACTION_VALUE,
0 ) HR_FEE1,
decode (COST_ELEMENT_ID,
5 ,
WTA.BASE_TRANSACTION_VALUE,
0 ) MD_FEE1
from WIP_TRANSACTION_ACCOUNTS WTA
where WTA.ACCOUNTING_LINE_TYPE = 7
and WTA.BASE_TRANSACTION_VALUE <> 0 ) WTA_COST
group by WTA_COST.ORGANIZATION_ID, WTA_COST.WIP_ENTITY_ID) WCT -- 人工与制造
WHERE 1 = 1
AND WE.ORGANIZATION_ID = WDJ.ORGANIZATION_ID
AND WE.WIP_ENTITY_ID = WDJ.WIP_ENTITY_ID
AND WDJ.ORGANIZATION_ID = MSI.ORGANIZATION_ID
AND WDJ.PRIMARY_ITEM_ID = MSI.INVENTORY_ITEM_ID
AND WE.WIP_ENTITY_ID = WO.WIP_ENTITY_ID
AND WO1.WIP_ENTITY_ID = WO.WIP_ENTITY_ID
AND WO.OPER = WO1.OPERATION_SEQ_NUM
AND WE.ORGANIZATION_ID = MTA.ORGANIZATION_ID
AND WE.WIP_ENTITY_ID = MTA.WIP_ENTITY_ID(+)
AND WE.ORGANIZATION_ID = WCT.ORGANIZATION_ID
AND WE.WIP_ENTITY_ID = WCT.WIP_ENTITY_ID(+)
AND WDJ.PROJECT_ID = PP.PROJECT_ID(+)
AND WDJ.TASK_ID = PT.TASK_ID(+)
and we.organization_id = 1155
and we.wip_entity_id = \'48825\' ;
-- 工单进度及费用信息综合查询 ( 不管是否下达和发料都能看到 )
SELECT WDJ.WIP_ENTITY_ID 任务令 ID,
WE.WIP_ENTITY_NAME 任务名称 ,
WDJ.ORGANIZATION_ID 组织 ID,
WDJ.STATUS_TYPE 状态 ,
WDJ.PRIMARY_ITEM_ID 装配件 ID,
MSI.SEGMENT1 物料编码 ,
MSI.DESCRIPTION 物料说明 ,
WDJ.FIRM_PLANNED_FLAG 任务类型 ,
WDJ.JOB_TYPE 做业类型 ,
WDJ.WIP_SUPPLY_TYPE 供应类型 ,
WDJ.CLASS_CODE 任务类别 ,
WDJ.SCHEDULED_START_DATE 起始时间 ,
WDJ.DATE_RELEASED 下达时间 ,
WDJ.DATE_COMPLETED 完工时间 ,
WDJ.DATE_CLOSED 关闭时间 ,
WDJ.START_QUANTITY 计划数 ,
WDJ.QUANTITY_COMPLETED 完工数 ,
WDJ.QUANTITY_SCRAPPED 报废数 ,
WDJ.NET_QUANTITY MRP 净值 ,
WDJ.DESCRIPTION 工单备注 ,
WDJ.COMPLETION_SUBINVENTORY 接收子库 ,
WDJ.COMPLETION_LOCATOR_ID 货位 ID,
WDJ.PROJECT_ID 项目 ID,
WDJ.TASK_ID 项目任务 ID,
PP.SEGMENT1 项目号 ,
PP.DESCRIPTION 项目描述 ,
PT.TASK_NUMBER 任务号 ,
PT.DESCRIPTION 任务描述 ,
WPF.COUNT_OPER 工序数 ,
WPF.CUR_OPER 当前工序 ,
WPF.CUR_OPERNAME 工序名 ,
WPF.MT_FEE 材料费 ,
WPF.HR_FEE 人工费 ,
WPF.MD_FEE 制造费
FROM wip_discrete_jobs WDJ,
wip.wip_entities WE,
mtl_system_items MSI,
PA_PROJECTS_ALL PP,
PA_TASKS PT,
( select WDJ1.WIP_ENTITY_ID,
WDJ1.ORGANIZATION_ID,
WO.COUNT_OPER,
WO1.OPERATION_SEQ_NUM CUR_OPER,
WO1.DESCRIPTION CUR_OPERNAME,
MTA.MT_FEE,
WCT.HR_FEE,
WCT.MD_FEE
from WIP_OPERATIONS WO1,
WIP_DISCRETE_JOBS WDJ1,
( select WDJ.ORGANIZATION_ID,
WDJ.WIP_ENTITY_ID,
COUNT ( 1 ) COUNT_OPER,
max ( decode (wo.quantity_completed,
1 ,
wo.operation_seq_num,
10 )) OPER
from WIP_DISCRETE_JOBS WDJ, WIP_OPERATIONS WO
where WDJ.WIP_ENTITY_ID = WO.WIP_ENTITY_ID
group by WDJ.ORGANIZATION_ID, WDJ.WIP_ENTITY_ID) WO, -- 工序进度
( select MTL.ORGANIZATION_ID,
MTL.TRANSACTION_SOURCE_ID WIP_ENTITY_ID,
ABS ( SUM (MTL.TRANSACTION_QUANTITY * MTL.actual_cost)) MT_FEE
from mtl_material_transactions MTL
where MTL.Transaction_Type_Id in ( 35 , 38 , 43 , 48 )
group by MTL.ORGANIZATION_ID, MTL.TRANSACTION_SOURCE_ID) MTA, -- 材料费
( select WTA_COST.ORGANIZATION_ID,
WTA_COST.WIP_ENTITY_ID,
SUM (WTA_COST.HR_FEE1) HR_FEE,
SUM (WTA_COST.MD_FEE1) MD_FEE
from ( select WTA.ORGANIZATION_ID,
WTA.WIP_ENTITY_ID,
decode (COST_ELEMENT_ID,
3 ,
WTA.BASE_TRANSACTION_VALUE,
0 ) HR_FEE1,
decode (COST_ELEMENT_ID,
5 ,
WTA.BASE_TRANSACTION_VALUE,
0 ) MD_FEE1
from WIP_TRANSACTION_ACCOUNTS WTA
where WTA.ACCOUNTING_LINE_TYPE = 7
and WTA.BASE_TRANSACTION_VALUE <> 0 ) WTA_COST
group by WTA_COST.ORGANIZATION_ID, WTA_COST.WIP_ENTITY_ID) WCT -- 人工与制造
WHERE 1 = 1
AND WDJ1.WIP_ENTITY_ID = WO.WIP_ENTITY_ID(+)
AND WO1.WIP_ENTITY_ID = WO.WIP_ENTITY_ID
AND WO.OPER = WO1.OPERATION_SEQ_NUM
AND WDJ1.ORGANIZATION_ID = MTA.ORGANIZATION_ID
AND WDJ1.WIP_ENTITY_ID = MTA.WIP_ENTITY_ID(+)
AND WDJ1.ORGANIZATION_ID = WCT.ORGANIZATION_ID
AND WDJ1.WIP_ENTITY_ID = WCT.WIP_ENTITY_ID(+)) WPF
WHERE WDJ.WIP_ENTITY_ID = WE.WIP_ENTITY_ID
AND WDJ.ORGANIZATION_ID = WE.ORGANIZATION_ID
AND WDJ.PRIMARY_ITEM_ID = MSI.INVENTORY_ITEM_ID
AND WDJ.ORGANIZATION_ID = MSI.ORGANIZATION_ID
AND WDJ.PROJECT_ID = PP.PROJECT_ID(+)
AND WDJ.TASK_ID = PT.TASK_ID(+)
AND WDJ.ORGANIZATION_ID = WPF.ORGANIZATION_ID(+)
AND WDJ.WIP_ENTITY_ID = WPF.WIP_ENTITY_ID(+)
AND WDJ.organization_id = 1155
and PP.SEGMENT1 = \'07D9202\' ;
11. MRP相关查询
12. 总帐 GL
select * from gl_sets_of_books 总账
select * from gl_code_combinations gcc where gcc.summary_flag=\'Y\' 科目组合
select * from gl_balances 科目余额
select * from gl_je_batches 凭证批
select * from gl_je_headers 凭证头
select * from gl_je_lines 凭证行
select * from gl_je_categories 凭证分类
select * from gl_je_sources 凭证来源
select * from gl_summary_templates 科目汇总模板
select * from gl_account_hierarchies 科目汇总模板层次
13. 应收 AR
select * from ar_batches_all 事务处理批
select * from ra_customer_trx_all 发票头
select * from ra_customer_trx_lines_all 发票行
select * from ra_cust_trx_line_gl_dist_all 发票分配
select * from ar_cash_receipts_all 收款
select * from ar_receivable_applications_all 核销
select * from ar_payment_schedules_all 发票调整
select * from ar_adjustments_all 会计分录
select * from ar_distributions_all 付款计划
14. 应付 AP
select * from ap_invoices_all 发票头
select * from ap_invoice_distributions_all 发票行
select * from ap_payment_schedules_all 付款计划
select * from ap_check_stocks_all 单据
select * from ap_checks_all 付款
select * from ap_bank_branches 银行
select * from ap_bank_accounts_all 银行账号
select * from ap_invoice_payments_all 核销
15. 应用、值集、弹性域
--fnd
select * from fnd_application
select * from fnd_application_tl where application_id= 101
select * from fnd_application_vl where application_id = 101
-- 值集
select * from fnd_flex_value_sets
select * from fnd_flex_values
select * from fnd_flex_values_vl
-- 弹性域
select * from fnd_id_flexs
select * from fnd_id_flex_structures where id_flex_code= \'GL#\'
select * from fnd_id_flex_segments where id_flex_code= \'GL#\' and id_flex_num= 50671
select * from fnd_profile_options_vl
select * from fnd_concurrent_programs 程序表
select * from fnd_concurrent_requests 请求表
select * from fnd_concurrent_processes 进程表
16. 许继配送管理相关表
--- 为了实现系统内方便的配送发货模式而开发
-- 配送关系 (以供应处角度 ORGANIZATION_ID = 142 )
SELECT AA.CUSTOMER_RELATION_ID 配送关系 ID,
AA.ORGANIZATION_ID 组织 ID,
AA.CUST_ACCOUNT_ID 客户 ID,
CC.PARTY_NAME 客户名称 ,
AA.CUST_ACCT_SITE_ID 配送地 ID,
DD.LOCATION 客户地点 ,
DD.STATUS A 有效 ,
AA.DELIVERY_BY_SO_FLAG 源于 CO,
AA.OUTBOUND_TRX_TYPE_ID 出库类型 ,
AA.OUTBOUND_RET_TRX_TYPE_ID 出库 R 类型 ,
AA.OUTBOUND_COST_CCID 出库帐户 ID,
EE.concatenated_segments 出库帐户 ,
AA.CUST_ORG_ID 客户库存组织 ID,
AA.INBOUND_TRX_TYPE_ID 入库类型 ,
AA.INBOUND_RET_TRX_TYPE_ID 入库 R 类型 ,
AA.INBOUND_CONFIRM_FLAG 入库确认 ,
AA.INBOUND_COST_CCID 入库帐户 ID,
FF.concatenated_segments 入库帐户 ,
AA.MANAGE_CHARGE 加价率 ,
AA.SETTLE_MODE 结算模式 ,
AA.INBOUND_SUBIN_CODE 接收子仓库 ,
AA.OUTBOUND_SUBIN_CODE 配送子库存 ,
AA.ATTRIBUTE1 直接生产发料 ,
AA.Creation_Date 建立日期 ,
AA.CREATED_BY 建立者 ,
AA.LAST_UPDATED_BY 更新者 ,
AA.LAST_UPDATE_DATE 更新日期
FROM CUX_INV_CUSTOMER_RELATION_ALL AA,
hz_cust_accounts BB,
hz_parties CC,
HZ_CUST_SITE_USES_ALL DD,
gl_code_combinations_kfv EE,
gl_code_combinations_kfv FF
WHERE AA.ORGANIZATION_ID = 142
AND AA.CUST_ACCOUNT_ID = BB.CUST_ACCOUNT_ID
AND BB.PARTY_ID = CC.PARTY_ID
AND AA.Cust_Acct_Site_Id = DD.Site_Use_Id
AND DD.STATUS = \'A\'
AND AA.OUTBOUND_COST_CCID = EE.code_combination_id
AND AA.INBOUND_COST_CCID = FF.code_combination_id
and CC.PARTY_NAME = \' 许继电气电网保护自动化公司 \' ;
-- 配送单头
SELECT AA.DN_HEADER_ID 配送单 ID,
AA.DN_NUMBER 配送单编号 ,
AA.DN_STATUS_CODE 状态 ,
AA.CUST_ACCOUNT_ID 客户 ID,
CC.PARTY_NAME 客户名称 ,
AA.CUST_ACCT_SITE_ID 配送地址 ID,
DD.LOCATION 客户地点 ,
AA.DELIVERY_ORG_ID 配送方组织 ID,
AA.CUST_ORG_ID 客户组织 ID,
AA.MANAGE_CHARGE 费率 ,
AA.INBOUND_CONFIRM_FLAG 入库确认否 ,
AA.SO_HEADER_ID 销售订单 ID,
EE.ORDER_NUMBER 销售订单 ,
EE.CUST_PO_NUMBER 客户 PO,
ee.attribute1,
ee.attribute2,
AA.PROCESS_FLAG,
AA.COMMENTS 配送单说明
FROM CUX_INV_DN_HEADERS_ALL AA, hz_cust_accounts BB, hz_parties CC, HZ_CUST_SITE_USES_ALL DD,OE_ORDER_HEADERS_ALL EE
WHERE AA.DELIVERY_ORG_ID = 142
AND AA.CUST_ACCOUNT_ID = BB.CUST_ACCOUNT_ID
AND BB.PARTY_ID = CC.PARTY_ID
AND AA.Cust_Acct_Site_Id = DD.Site_Use_Id
AND DD.STATUS = \'A\'
AND AA.SO_HEADER_ID = EE.HEADER_ID
AND AA.DN_NUMBER = \'14780016022\' ;
-- 配送单明细
SELECT AA.DN_HEADER_ID,
AA.DN_LINE_ID,
AA.SO_LINE_ID,
LL.LINE_NUMBER SO 行号 ,
AA.INVENTORY_ITEM_ID 物料 ID,
CC.SEGMENT1 物料编码 ,
CC.DESCRIPTION 物料说明 ,
AA.OUTBOUND_SUBIN_CODE 发出仓 ,
AA.OUTBOUND_LOCATOR_ID 发出货位 ,
AA.REQUIRE_DATE 需求日期 ,
AA.REQUIRE_QTY 需求数 ,
AA.OUTBOUND_QTY 已出库 ,
AA.INBOUND_QTY 已接收 ,
AA.ATTRIBUTE1 最近确认接收数 ,
AA.INBOUND_SUBIN_CODE 入库仓 ,
AA.INBOUND_LOCATOR_ID 入库货位 ,
AA.RETURN_NO_RECEIVE_QTY 退回数 ,
AA.OUTING_QTY,
AA.INING_QTY,
AA.REQUEST_ID 最近打印请求 ID
FROM CUX_INV_DN_LINES_ALL AA, CUX_INV_DN_HEADERS_ALL BB,mtl_system_items CC,OE_ORDER_LINES_ALL LL
WHERE AA.DN_HEADER_ID = BB.DN_HEADER_ID
AND AA.INVENTORY_ITEM_ID = CC.INVENTORY_ITEM_ID
AND BB.DELIVERY_ORG_ID = CC.ORGANIZATION_ID
AND AA.SO_LINE_ID = LL.LINE_ID
AND BB.DN_NUMBER = \'14780016022\' ;
99-其余相关表
1) 会计科目组合表
-- 查询会计科目分段信息
select * from gl_code_combinations;
-- 查询会计科目组合信息
select * from gl_code_combinations_kfv;
2) 查询自定义的客户化相关表和视图
-- 静态数据字典中的视图分为三类,它们分别由三个前缀够成: user_* 、 all_* 、 dba_*
-- user_* 该视图存储了关于当前用户所拥有的对象的信息。(即全部在该用户模式下的对象)
-- all_* 该视图存储了当前用户可以访问的对象的信息。(与 user_* 相比, all_* 并不须要拥有该对象,只须要具备访问该对象的权限便可)
-- dba_* 该视图存储了数据库中全部对象的信息。(前提是当前用户具备访问这些数据库的权限,通常来讲必须具备管理员权限
-- 查询该用户拥有哪些表
select * from user_tables where table_name like \'CUX%\' ;
-- 查询该用户拥有哪些视图
select * from user_views where view_name like \'CUX%\' ;
-- 查询该用户拥有哪些索引
select * from user_indexes;
3) 查询物料处理记录
说明: mtl_material_transactions 这个表记录了全部涉及仓库收发的物料交易记录,包括:采购、 WIP 、订单、杂项等多种处理模式的内容。
-- 举例: 查询某用户在电网的帐户别名发放清单
select AA.TRANSACTION_ID 交易代码 ,
AA.INVENTORY_ITEM_ID 项目内码 ,
CC.SEGMENT1 物料编码 ,
CC.DESCRIPTION 物料说明 ,
AA.ORGANIZATION_ID 组织代码 ,
AA.SUBINVENTORY_CODE 子库名称 ,
AA.TRANSACTION_TYPE_ID 类型 ID,
BB.TRANSACTION_TYPE_NAME 类型名称 ,
AA.TRANSACTION_QUANTITY 数量 ,
AA.TRANSACTION_UOM 单位 ,
AA.TRANSACTION_DATE 交易日期 ,
AA.TRANSACTION_REFERENCE 交易参考 ,
AA.TRANSACTION_SOURCE_ID 参考源 ID,
AA.DEPARTMENT_ID 部门 ID,
AA.OPERATION_SEQ_NUM 工序号 ,
ROUND (AA.Actual_Cost, 2 ) 实际成本 ,
ROUND (AA.Transaction_Cost, 2 ) 处理成本 ,
ROUND (AA.PRIOR_COST, 2 ) 旧成本 ,
ROUND (AA.NEW_COST, 2 ) 新成本 ,
ROUND (AA.VARIANCE_AMOUNT, 2 ) 差别金额 ,
AA.TRANSACTION_QUANTITY * ROUND (AA.PRIOR_COST, 2 ) 交易金额 ,
DD.USER_NAME 用户名称 ,
EE.FULL_NAME 用户姓名 ,
AA.ATTRIBUTE1 弹性域人名 ,
AA.ATTRIBUTE15 弹性域备注
from mtl_material_transactions AA ,
mtl_transaction_types BB,
mtl_system_items CC,
FND_USER DD,
per_people_f EE
where AA.TRANSACTION_TYPE_ID = BB.TRANSACTION_TYPE_ID and
AA.CREATED_BY = DD.USER_ID and
AA.INVENTORY_ITEM_ID = CC.INVENTORY_ITEM_ID and
AA.ORGANIZATION_ID = CC.ORGANIZATION_ID and
DD.EMPLOYEE_ID = EE.PERSON_ID and
AA.ORGANIZATION_ID = 1155 AND
CC.SEGMENT1= \'07D9202.92742\' and
AA.TRANSACTION_DATE >= TO_DATE( \'2011-01-29 00:00:00\' , \'YYYY-MM-DD HH24:MI:SS\' )
order by aa.TRANSACTION_ID;
/* 物料处理记录 mtl_material_transactions 表,类型与成本说明:
-- 杂项收 TRANSACTION_TYPE_ID = 41 录入价格优先, =Actual_Cost ,移动平均 TRANSACTION_QUANTITY > 0 , 调整相似
注: 1 )若是再接收界面录入了价格,以录入价格计入 Actual_Cost ,进行移动平均
2 )若是没有录入价格,字段 NULL ,则系统会以当前成本接收,计入 Actual_Cost
-- 杂项发 TRANSACTION_TYPE_ID = 31 以出 =Actual_Cost , TRANSACTION_QUANTITY < 0 , 调整相似
-- 采购收 TRANSACTION_TYPE_ID = 18 以 入 =Actual_Cost ,移动平均 TRANSACTION_QUANTITY > 0
-- 采购退 TRANSACTION_TYPE_ID = 36 以 出 =Actual_Cost , TRANSACTION_QUANTITY < 0
注: 1) 系统按采购成本退货和扣除库存金额,不考虑已消耗情况;
2) 若是库存金额够扣除,则扣除后从新计算出一个新成本;
3 )若是库存金额不够扣除,则扣除所有金额,就会出现有库存量而单位成本 =0 的物资,不够扣的部分计入字段 VARIANCE_AMOUNT 。
-- 做业发 TRANSACTION_TYPE_ID = 35 以当前成本出, =Actual_Cost , TRANSACTION_QUANTITY < 0 ,特定组件发料相似
-- 做业退 TRANSACTION_TYPE_ID = 43 以当前成本入, =Actual_Cost ,不移动平均 TRANSACTION_QUANTITY > 0
-- 配送出 TRANSACTION_TYPE_ID = 100 以当前成本出, =Actual_Cost , TRANSACTION_QUANTITY < 0
-- 配送退 TRANSACTION_TYPE_ID = 101 以配送价入 , =Actual_Cost ,移动平均 TRANSACTION_QUANTITY > 0
-- 销售发 TRANSACTION_TYPE_ID = 33 以当前成本出, =Actual_Cost , TRANSACTION_QUANTITY < 0
-- 销售退 TRANSACTION_TYPE_ID = 15 以当前成本入, =Actual_Cost , TRANSACTION_QUANTITY > 0
*/
-- 物料处理记录类型列表
select bb.transaction_type_id 类型 ID,
bb.transaction_type_name 别名 ,
bb.description 说明
from mtl_transaction_types BB
order by bb.transaction_type_id
-- 交易来源类型列表
SELECT *
FROM mtl_txn_source_types
-- 交易缘由代码表
SELECT REASON_ID 缘由代码 , REASON_NAME 名称 , DESCRIPTION 描述
FROM inv.mtl_transaction_reasons;
工艺路线
SELECT MSIB.SEGMENT1,MSIB.DESCRIPTION,BORV.resource_code,BR.DESCRIPTION FROM BOM_OPERATIONAL_ROUTINGS_V BOR, BOM_OPERATION_SEQUENCES_V BOS, BOM_OPERATION_RESOURCES_V BORV, BOM_RESOURCES BR,MTL_SYSTEM_ITEMS_B MSIB WHERE BOR.ORGANIZATION_ID = 86 AND BR.ORGANIZATION_ID = 86 AND BOR.ASSEMBLY_ITEM_ID = MSIB.INVENTORY_ITEM_ID AND MSIB.ORGANIZATION_ID=86 AND BOR.ROUTING_SEQUENCE_ID = BOS.ROUTING_SEQUENCE_ID AND BOS.OPERATION_SEQUENCE_ID = BORV.OPERATION_SEQUENCE_ID AND BR.RESOURCE_ID = BORV.RESOURCE_ID AND BOS.OPERATION_SEQ_NUM = (SELECT MAX(BOS1.OPERATION_SEQ_NUM) FROM BOM_OPERATION_SEQUENCES_V BOS1, BOM_OPERATIONAL_ROUTINGS_V BOR1 WHERE BOS1.ROUTING_SEQUENCE_ID = BOR1.ROUTING_SEQUENCE_ID AND BOR1.ROUTING_SEQUENCE_ID = BOR.ROUTING_SEQUENCE_ID AND BOR1.ALTERNATE_ROUTING_DESIGNATOR IS NULL) AND BOR.ALTERNATE_ROUTING_DESIGNATOR IS NULL AND NVL(BR.ATTRIBUTE15, \'N\') = \'Y\'