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;
--日记帐批 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)));