Oracle EBS ERP之报表开发—嵌入Web中的报表预览、报表打印
传统的EBS报表非常的不美观,并且会有很多毛病,比如报表超出A4纸大小,元素被错页打印、不美观、操作很不方便、无法一次输出分别打印多个报表等等毛病,
对于这些毛病,常常需要开发人员手动去调整格式,甚至是需要开发新的功能去调整到正规的格式。现如今基于HTML的内置元素与组件,我们可以轻松解决传统报表带来的一切不利因素,使得报表的预览与打印更加的智能和美观。
比如HTML自带的设置参数:元素不可被页面分割,只需设置一下fnd_file.put_line(2, ' page-break-inside: avoid !important;');就可以避免。
给一套模板去仿造写吧,也没什么好说的:
❀主函数打印
PROCEDURE main(errbuf OUT VARCHAR2,retcode OUT NUMBER,p_set_of_books_id IN NUMBER DEFAULT NULL,p_org_id IN NUMBER DEFAULT NULL,p_chart_of_accounts_id IN NUMBER DEFAULT NULL,p_customer_id IN NUMBER DEFAULT NULL,p_date_begin IN VARCHAR2 DEFAULT NULL,p_date_end IN VARCHAR2 DEFAULT NULL,p_sale_per_val IN VARCHAR2 DEFAULT NULL,p_recon_mode IN VARCHAR2 DEFAULT NULL) ISBEGIN-- Begin 日志头 --fnd_file.put_line(1, '[INFO]: 开始打印传入参数,时间:' || TO_CHAR(SYSDATE, 'YYYYMMDD HH24:MI:SS'));fnd_file.put_line(1, 'p_set_of_books_id = ' || NVL(TO_CHAR(p_set_of_books_id), 'NULL'));fnd_file.put_line(1, 'p_org_id = ' || NVL(TO_CHAR(p_org_id), 'NULL'));fnd_file.put_line(1, 'p_chart_of_accounts_id = ' || NVL(TO_CHAR(p_chart_of_accounts_id), 'NULL'));fnd_file.put_line(1, 'p_customer_id = ' || NVL(TO_CHAR(p_customer_id), 'NULL'));fnd_file.put_line(1, 'p_date_begin = ' || NVL(p_date_begin, 'NULL'));fnd_file.put_line(1, 'p_date_end = ' || NVL(p_date_end, 'NULL'));fnd_file.put_line(1, 'p_sale_per_val = ' || NVL(p_sale_per_val, 'NULL'));fnd_file.put_line(1, 'p_recon_mode = ' || NVL(p_recon_mode, 'NULL'));fnd_file.put_line(1, '[INFO]: 传入参数打印结束,时间:' || TO_CHAR(SYSDATE, 'YYYYMMDD HH24:MI:SS'));-- end --IF p_recon_mode = '陶熙慧鱼胶条模式' THEN-- 输出HTML头部 - 使用五金模式风格fnd_file.put_line(2, '<!DOCTYPE html>');fnd_file.put_line(2, '<html>');fnd_file.put_line(2, '<head>');fnd_file.put_line(2, '<meta charset="UTF-8">');fnd_file.put_line(2, '<title>陶熙慧鱼胶条模式 - 应收客户对账单</title>');fnd_file.put_line(2, '<style>');-- CSS样式 - 使用五金模式样式fnd_file.put_line(2, '* { margin: 0; padding: 0; box-sizing: border-box; }');fnd_file.put_line(2, 'body { font-family: "Microsoft YaHei", "微软雅黑", "宋体", SimSun, serif; font-size: 14px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; }');fnd_file.put_line(2, '.container { max-width: 1400px; margin: 0 auto; background-color: white; min-height: 100vh; box-shadow: 0 0 30px rgba(0,0,0,0.3); }');-- 导航栏样式fnd_file.put_line(2, '.navbar { background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%); color: white; padding: 20px 30px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); position: relative; }');fnd_file.put_line(2, '.navbar::before { content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: url("data:image/svg+xml,%3Csvg width=''60'' height=''60'' viewBox=''0 0 60 60'' xmlns=''http://www.w3.org/2000/svg''%3E%3Cg fill=''none'' fill-rule=''evenodd''%3E%3Cg fill=''%23ffffff'' fill-opacity=''0.05''%3E%3Ccircle cx=''30'' cy=''30'' r=''2''/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); }');fnd_file.put_line(2, '.navbar h1 { margin: 0; display: inline-block; font-size: 28px; font-weight: 300; letter-spacing: 2px; position: relative; z-index: 1; }');fnd_file.put_line(2, '.nav-buttons { float: right; margin-top: 8px; position: relative; z-index: 1; }');fnd_file.put_line(2, '.nav-btn { background: rgba(255,255,255,0.2); color: white; border: 2px solid rgba(255,255,255,0.3); padding: 12px 25px; margin-left: 15px; border-radius: 25px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease; backdrop-filter: blur(10px); }');fnd_file.put_line(2, '.nav-btn:hover { background: rgba(255,255,255,0.3); border-color: rgba(255,255,255,0.6); transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.2); }');fnd_file.put_line(2, '.nav-btn.active { background: #e74c3c; border-color: #e74c3c; box-shadow: 0 5px 15px rgba(231,76,60,0.4); }');-- 页面内容样式fnd_file.put_line(2, '.page { display: none; padding: 40px; }');fnd_file.put_line(2, '.page.active { display: block; }');-- 首页样式fnd_file.put_line(2, '.welcome-section { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 60px 40px; border-radius: 15px; margin-bottom: 40px; text-align: center; position: relative; overflow: hidden; }');fnd_file.put_line(2, '.welcome-section::before { content: ""; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px); background-size: 50px 50px; animation: float 20s infinite linear; }');fnd_file.put_line(2, '@keyframes float { 0% { transform: translate(-50%, -50%) rotate(0deg); } 100% { transform: translate(-50%, -50%) rotate(360deg); } }');fnd_file.put_line(2, '.welcome-section h2 { font-size: 36px; margin-bottom: 20px; font-weight: 300; letter-spacing: 3px; position: relative; z-index: 1; }');fnd_file.put_line(2, '.welcome-section p { font-size: 18px; margin-bottom: 15px; opacity: 0.9; position: relative; z-index: 1; }');-- info-grid布局fnd_file.put_line(2, '.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 40px; }');fnd_file.put_line(2, '.info-card { background: white; padding: 35px; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); border: 1px solid #e0e0e0; transition: all 0.3s ease; position: relative; overflow: hidden; }');fnd_file.put_line(2, '.info-card::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: linear-gradient(90deg, #667eea, #764ba2); }');fnd_file.put_line(2, '.info-card:hover { transform: translateY(-5px); box-shadow: 0 15px 40px rgba(0,0,0,0.15); }');fnd_file.put_line(2, '.info-card h3 { color: #2c3e50; margin-top: 0; margin-bottom: 20px; font-size: 22px; font-weight: 600; }');fnd_file.put_line(2, '.info-card p { color: #666; line-height: 1.8; font-size: 15px; }');fnd_file.put_line(2, '.quick-actions { text-align: center; margin-top: 50px; }');fnd_file.put_line(2, '.quick-actions h3 { color: #2c3e50; margin-bottom: 30px; font-size: 24px; font-weight: 300; }');fnd_file.put_line(2, '.action-btn { background: linear-gradient(135deg, #27ae60, #2ecc71); color: white; border: none; padding: 18px 40px; margin: 0 15px; border-radius: 30px; cursor: pointer; font-size: 16px; font-weight: 500; transition: all 0.3s ease; box-shadow: 0 5px 15px rgba(39,174,96,0.3); }');fnd_file.put_line(2, '.action-btn:hover { background: linear-gradient(135deg, #229954, #27ae60); transform: translateY(-3px); box-shadow: 0 8px 25px rgba(39,174,96,0.4); }');-- 表格样式 - 统一背景色fnd_file.put_line(2, '.table-container { background: white; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); overflow: hidden; margin-bottom: 30px; }');fnd_file.put_line(2, '.table-header { background: linear-gradient(135deg, #34495e, #2c3e50); color: white; padding: 25px 30px; display: flex; justify-content: space-between; align-items: center; }');fnd_file.put_line(2, '.table-header h3 { margin: 0; font-size: 22px; font-weight: 300; letter-spacing: 1px; }');fnd_file.put_line(2, '.print-btn { background: linear-gradient(135deg, #e67e22, #f39c12); color: white; border: none; padding: 12px 25px; border-radius: 25px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease; }');fnd_file.put_line(2, '.print-btn:hover { background: linear-gradient(135deg, #d35400, #e67e22); transform: translateY(-2px); box-shadow: 0 5px 15px rgba(230,126,34,0.4); }');fnd_file.put_line(2, '.table-content { padding: 30px; }');-- 表格样式 - 去掉斑马纹fnd_file.put_line(2, 'table { border-collapse: collapse; width: 100%; margin-bottom: 20px; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }');fnd_file.put_line(2, 'th, td { border: 1px solid #e0e0e0; padding: 15px 12px; text-align: left; }');fnd_file.put_line(2, 'th { background: linear-gradient(135deg, #f8f9fa, #e9ecef); font-weight: 600; text-align: center; color: #2c3e50; font-size: 14px; letter-spacing: 0.5px; }');fnd_file.put_line(2, 'td { background: white; color: #333; }');fnd_file.put_line(2, 'tr:hover td { background-color: #f0f8ff; }');fnd_file.put_line(2, '.number { text-align: right; font-family: "Consolas", "Monaco", monospace; }');fnd_file.put_line(2, '.center { text-align: center; }');-- 报表信息样式fnd_file.put_line(2, '.report-info { background: linear-gradient(135deg, #f8f9fa, #e9ecef); padding: 25px; border-radius: 10px; margin-bottom: 25px; border-left: 5px solid #667eea; }');fnd_file.put_line(2, '.report-info h4 { color: #2c3e50; margin-bottom: 15px; font-size: 20px; font-weight: 600; }');fnd_file.put_line(2, '.report-info p { color: #555; margin-bottom: 8px; font-size: 14px; }');-- 打印样式fnd_file.put_line(2, '@media print { ');fnd_file.put_line(2, ' * { -webkit-print-color-adjust: exact !important; color-adjust: exact !important; }');fnd_file.put_line(2, ' body { background: white !important; margin: 0; padding: 20px; }');fnd_file.put_line(2, ' .container { box-shadow: none !important; max-width: none !important; }');fnd_file.put_line(2, ' .navbar, .nav-buttons, .print-btn, .action-btn { display: none !important; }');fnd_file.put_line(2, ' .page { display: none !important; padding: 0 !important; }');fnd_file.put_line(2, ' .page.print-active { display: block !important; }');fnd_file.put_line(2, ' .table-header { display: none !important; }');fnd_file.put_line(2, ' .table-container { box-shadow: none !important; border-radius: 0 !important; margin-bottom: 0 !important; }');fnd_file.put_line(2, ' .table-content { padding: 0 !important; }');fnd_file.put_line(2, ' .welcome-section, .info-grid, .quick-actions { display: none !important; }');-- 分页控制样式fnd_file.put_line(2, ' table { ');fnd_file.put_line(2, ' box-shadow: none !important; ');fnd_file.put_line(2, ' border-radius: 0 !important; ');fnd_file.put_line(2, ' page-break-inside: auto !important; ');fnd_file.put_line(2, ' break-inside: auto !important; ');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' tr { ');fnd_file.put_line(2, ' page-break-inside: avoid !important; ');fnd_file.put_line(2, ' break-inside: avoid !important; ');fnd_file.put_line(2, ' orphans: 2; ');fnd_file.put_line(2, ' widows: 2; ');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' thead { ');fnd_file.put_line(2, ' display: table-header-group !important; ');fnd_file.put_line(2, ' page-break-after: avoid !important; ');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' tbody { ');fnd_file.put_line(2, ' display: table-row-group !important; ');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' th, td { ');fnd_file.put_line(2, ' page-break-inside: avoid !important; ');fnd_file.put_line(2, ' break-inside: avoid !important; ');fnd_file.put_line(2, ' }');-- 页面设置fnd_file.put_line(2, ' @page { ');fnd_file.put_line(2, ' size: A4; ');fnd_file.put_line(2, ' margin: 1cm; ');fnd_file.put_line(2, ' }');fnd_file.put_line(2, '}');-- @media print 部分添加:fnd_file.put_line(2, ' .table-footer-container {');fnd_file.put_line(2, ' page-break-inside: avoid !important;');fnd_file.put_line(2, ' break-inside: avoid !important;');fnd_file.put_line(2, ' page-break-before: auto !important;');fnd_file.put_line(2, ' margin-top: 10px !important;');fnd_file.put_line(2, ' }');-- 确保容器内的表格无间隙fnd_file.put_line(2, ' .table-footer-container table {');fnd_file.put_line(2, ' margin: 0 !important;');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' .table-footer-container table:first-child {');fnd_file.put_line(2, ' margin-bottom: 0 !important;');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' .table-footer-container table:last-child {');fnd_file.put_line(2, ' margin-top: 0 !important;');fnd_file.put_line(2, ' }');fnd_file.put_line(2, '</style>');fnd_file.put_line(2, '</head>');fnd_file.put_line(2, '<body>');fnd_file.put_line(2, '<div class="container">');-- 导航栏 - 陶熙慧鱼胶条模式只保留首页和报表两个按钮fnd_file.put_line(2, '<div class="navbar">');fnd_file.put_line(2, '<h1>陶熙慧鱼胶条模式 - 应收客户对账单</h1>');fnd_file.put_line(2, '<div class="nav-buttons">');fnd_file.put_line(2, '<button class="nav-btn active" onclick="showPage(''home'')">首页</button>');fnd_file.put_line(2, '<button class="nav-btn" onclick="showPage(''report'')">报表</button>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div style="clear: both;"></div>');fnd_file.put_line(2, '</div>');-- 首页fnd_file.put_line(2, '<div id="home" class="page active">');fnd_file.put_line(2, '<div class="welcome-section">');fnd_file.put_line(2, '<h2>欢迎使用陶熙慧鱼胶条模式对账报表</h2>');fnd_file.put_line(2, '<p>查询期间:' || NVL(p_date_begin, '未指定') || ' 至 ' || NVL(p_date_end, '未指定') || '</p>');fnd_file.put_line(2, '<p>生成时间:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') || '</p>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div class="info-grid">');fnd_file.put_line(2, '<div class="info-card">');fnd_file.put_line(2, '<h3>陶熙慧鱼胶条报表</h3>');fnd_file.put_line(2, '<p>展示陶熙慧鱼胶条报表的完整应收账款信息,包含交易明细、收款记录及余额情况,帮助管理层全面掌握财务状况。</p>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div class="info-card">');fnd_file.put_line(2, '<h3>数据特点</h3>');fnd_file.put_line(2, '<p>专门针对鱼胶条业务模式设计,数据展示清晰直观,支持快速查询和核对,满足财务对账需求。</p>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div class="info-card">');fnd_file.put_line(2, '<h3>打印功能</h3>');fnd_file.put_line(2, '<p>支持专业打印功能,打印时自动隐藏导航栏,保证打印效果清晰且专业,适配A4纸张。</p>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div class="info-card">');fnd_file.put_line(2, '<h3>使用说明</h3>');fnd_file.put_line(2, '<p>1. 点击导航按钮切换页面<br>2. 在报表页面点击"打印报表"按钮进行打印<br>3. 数据实时生成,确保准确无误</p>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div class="quick-actions">');fnd_file.put_line(2, '<h3>快速操作</h3>');fnd_file.put_line(2, '<button class="action-btn" onclick="showPage(''report'')">查看完整报表</button>');fnd_file.put_line(2, '<button class="action-btn" onclick="printTable(''report'')">直接打印报表</button>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '</div>');-- 报表页面 - 陶熙慧鱼胶条模式只有一个报表页面fnd_file.put_line(2, '<div id="report" class="page">');fnd_file.put_line(2, '<div class="table-container">');fnd_file.put_line(2, '<div class="table-header">');fnd_file.put_line(2, '<h3>陶熙慧鱼胶条模式 - 应收客户对账单</h3>');fnd_file.put_line(2, '<button class="print-btn" onclick="printTable(''report'')">打印报表</button>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div class="table-content">');-- 调用陶熙慧鱼胶条模式过程 - 只调用一次proc_taoxihui_mode(errbuf => errbuf,retcode => retcode,p_set_of_books_id => p_set_of_books_id,p_org_id => p_org_id,p_chart_of_accounts_id => p_chart_of_accounts_id,p_customer_id => p_customer_id,p_date_begin => p_date_begin,p_date_end => p_date_end,p_sale_per_val => p_sale_per_val);fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '</div>'); -- container结束-- JavaScript 控制页面切换和打印 - 使用五金模式的JS逻辑fnd_file.put_line(2, '<script>');fnd_file.put_line(2, 'function showPage(pageId) {');fnd_file.put_line(2, ' var pages = document.getElementsByClassName("page");');fnd_file.put_line(2, ' var buttons = document.getElementsByClassName("nav-btn");');fnd_file.put_line(2, ' for (var i = 0; i < pages.length; i++) {');fnd_file.put_line(2, ' pages[i].classList.remove("active");');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' for (var i = 0; i < buttons.length; i++) {');fnd_file.put_line(2, ' buttons[i].classList.remove("active");');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' document.getElementById(pageId).classList.add("active");');fnd_file.put_line(2, ' event.target.classList.add("active");');fnd_file.put_line(2, '}');fnd_file.put_line(2, '');fnd_file.put_line(2, 'function printTable(tableType) {');fnd_file.put_line(2, ' // 移除所有页面的active类');fnd_file.put_line(2, ' var pages = document.getElementsByClassName("page");');fnd_file.put_line(2, ' for (var i = 0; i < pages.length; i++) {');fnd_file.put_line(2, ' pages[i].classList.remove("active");');fnd_file.put_line(2, ' pages[i].classList.remove("print-active");');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' ');fnd_file.put_line(2, ' // 只给要打印的页面添加print-active类');fnd_file.put_line(2, ' var targetPage = document.getElementById(tableType);');fnd_file.put_line(2, ' if (targetPage) {');fnd_file.put_line(2, ' targetPage.classList.add("print-active");');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' ');fnd_file.put_line(2, ' // 执行打印');fnd_file.put_line(2, ' window.print();');fnd_file.put_line(2, ' ');fnd_file.put_line(2, ' // 打印完成后恢复页面状态');fnd_file.put_line(2, ' setTimeout(function() {');fnd_file.put_line(2, ' for (var i = 0; i < pages.length; i++) {');fnd_file.put_line(2, ' pages[i].classList.remove("print-active");');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' // 恢复当前页面的显示');fnd_file.put_line(2, ' if (targetPage) {');fnd_file.put_line(2, ' targetPage.classList.add("active");');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' }, 100);');fnd_file.put_line(2, '}');fnd_file.put_line(2, '</script>');fnd_file.put_line(2, '</body>');fnd_file.put_line(2, '</html>');COMMIT;ELSIF p_recon_mode = '五金模式' THEN-- 输出HTML头部fnd_file.put_line(2, '<!DOCTYPE html>');fnd_file.put_line(2, '<html>');fnd_file.put_line(2, '<head>');fnd_file.put_line(2, '<meta charset="UTF-8">');fnd_file.put_line(2, '<title>CUX:应收客户对账单(深圳专用)</title>');fnd_file.put_line(2, '<style>');-- CSS样式 fnd_file.put_line(2, '* { margin: 0; padding: 0; box-sizing: border-box; }');fnd_file.put_line(2, 'body { font-family: "Microsoft YaHei", "微软雅黑", "宋体", SimSun, serif; font-size: 14px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; }');fnd_file.put_line(2, '.container { max-width: 1400px; margin: 0 auto; background-color: white; min-height: 100vh; box-shadow: 0 0 30px rgba(0,0,0,0.3); }');-- 导航栏样式fnd_file.put_line(2, '.navbar { background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%); color: white; padding: 20px 30px; box-shadow: 0 4px 15px rgba(0,0,0,0.2); position: relative; }');fnd_file.put_line(2, '.navbar::before { content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: url("data:image/svg+xml,%3Csvg width=''60'' height=''60'' viewBox=''0 0 60 60'' xmlns=''http://www.w3.org/2000/svg''%3E%3Cg fill=''none'' fill-rule=''evenodd''%3E%3Cg fill=''%23ffffff'' fill-opacity=''0.05''%3E%3Ccircle cx=''30'' cy=''30'' r=''2''/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); }');fnd_file.put_line(2, '.navbar h1 { margin: 0; display: inline-block; font-size: 28px; font-weight: 300; letter-spacing: 2px; position: relative; z-index: 1; }');fnd_file.put_line(2, '.nav-buttons { float: right; margin-top: 8px; position: relative; z-index: 1; }');fnd_file.put_line(2, '.nav-btn { background: rgba(255,255,255,0.2); color: white; border: 2px solid rgba(255,255,255,0.3); padding: 12px 25px; margin-left: 15px; border-radius: 25px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease; backdrop-filter: blur(10px); }');fnd_file.put_line(2, '.nav-btn:hover { background: rgba(255,255,255,0.3); border-color: rgba(255,255,255,0.6); transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.2); }');fnd_file.put_line(2, '.nav-btn.active { background: #e74c3c; border-color: #e74c3c; box-shadow: 0 5px 15px rgba(231,76,60,0.4); }');-- 页面内容样式fnd_file.put_line(2, '.page { display: none; padding: 40px; }');fnd_file.put_line(2, '.page.active { display: block; }');-- 首页样式fnd_file.put_line(2, '.welcome-section { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 60px 40px; border-radius: 15px; margin-bottom: 40px; text-align: center; position: relative; overflow: hidden; }');fnd_file.put_line(2, '.welcome-section::before { content: ""; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px); background-size: 50px 50px; animation: float 20s infinite linear; }');fnd_file.put_line(2, '@keyframes float { 0% { transform: translate(-50%, -50%) rotate(0deg); } 100% { transform: translate(-50%, -50%) rotate(360deg); } }');fnd_file.put_line(2, '.welcome-section h2 { font-size: 36px; margin-bottom: 20px; font-weight: 300; letter-spacing: 3px; position: relative; z-index: 1; }');fnd_file.put_line(2, '.welcome-section p { font-size: 18px; margin-bottom: 15px; opacity: 0.9; position: relative; z-index: 1; }');-- 修改info-grid为2列布局fnd_file.put_line(2, '.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 40px; }');fnd_file.put_line(2, '.info-card { background: white; padding: 35px; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); border: 1px solid #e0e0e0; transition: all 0.3s ease; position: relative; overflow: hidden; }');fnd_file.put_line(2, '.info-card::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: linear-gradient(90deg, #667eea, #764ba2); }');fnd_file.put_line(2, '.info-card:hover { transform: translateY(-5px); box-shadow: 0 15px 40px rgba(0,0,0,0.15); }');fnd_file.put_line(2, '.info-card h3 { color: #2c3e50; margin-top: 0; margin-bottom: 20px; font-size: 22px; font-weight: 600; }');fnd_file.put_line(2, '.info-card p { color: #666; line-height: 1.8; font-size: 15px; }');fnd_file.put_line(2, '.quick-actions { text-align: center; margin-top: 50px; }');fnd_file.put_line(2, '.quick-actions h3 { color: #2c3e50; margin-bottom: 30px; font-size: 24px; font-weight: 300; }');fnd_file.put_line(2, '.action-btn { background: linear-gradient(135deg, #27ae60, #2ecc71); color: white; border: none; padding: 18px 40px; margin: 0 15px; border-radius: 30px; cursor: pointer; font-size: 16px; font-weight: 500; transition: all 0.3s ease; box-shadow: 0 5px 15px rgba(39,174,96,0.3); }');fnd_file.put_line(2, '.action-btn:hover { background: linear-gradient(135deg, #229954, #27ae60); transform: translateY(-3px); box-shadow: 0 8px 25px rgba(39,174,96,0.4); }');-- 表格样式 - 统一背景色fnd_file.put_line(2, '.table-container { background: white; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); overflow: hidden; margin-bottom: 30px; }');fnd_file.put_line(2, '.table-header { background: linear-gradient(135deg, #34495e, #2c3e50); color: white; padding: 25px 30px; display: flex; justify-content: space-between; align-items: center; }');fnd_file.put_line(2, '.table-header h3 { margin: 0; font-size: 22px; font-weight: 300; letter-spacing: 1px; }');fnd_file.put_line(2, '.print-btn { background: linear-gradient(135deg, #e67e22, #f39c12); color: white; border: none; padding: 12px 25px; border-radius: 25px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.3s ease; }');fnd_file.put_line(2, '.print-btn:hover { background: linear-gradient(135deg, #d35400, #e67e22); transform: translateY(-2px); box-shadow: 0 5px 15px rgba(230,126,34,0.4); }');fnd_file.put_line(2, '.table-content { padding: 30px; }');-- 表格样式 - 去掉斑马纹fnd_file.put_line(2, 'table { border-collapse: collapse; width: 100%; margin-bottom: 20px; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }');fnd_file.put_line(2, 'th, td { border: 1px solid #e0e0e0; padding: 15px 12px; text-align: left; }');fnd_file.put_line(2, 'th { background: linear-gradient(135deg, #f8f9fa, #e9ecef); font-weight: 600; text-align: center; color: #2c3e50; font-size: 14px; letter-spacing: 0.5px; }');fnd_file.put_line(2, 'td { background: white; color: #333; }'); -- 统一背景色fnd_file.put_line(2, 'tr:hover td { background-color: #f0f8ff; }'); -- 悬停效果fnd_file.put_line(2, '.number { text-align: right; font-family: "Consolas", "Monaco", monospace; }');fnd_file.put_line(2, '.center { text-align: center; }');-- 报表信息样式fnd_file.put_line(2, '.report-info { background: linear-gradient(135deg, #f8f9fa, #e9ecef); padding: 25px; border-radius: 10px; margin-bottom: 25px; border-left: 5px solid #667eea; }');fnd_file.put_line(2, '.report-info h4 { color: #2c3e50; margin-bottom: 15px; font-size: 20px; font-weight: 600; }');fnd_file.put_line(2, '.report-info p { color: #555; margin-bottom: 8px; font-size: 14px; }');-- 统计信息样式fnd_file.put_line(2, '.summary-stats { background: linear-gradient(135deg, #f8f9fa, #e9ecef); padding: 25px; border-radius: 10px; margin-top: 25px; }');fnd_file.put_line(2, '.summary-stats h4 { color: #2c3e50; margin-bottom: 20px; font-size: 18px; font-weight: 600; }');-- 打印样式 - 隐藏表格标题fnd_file.put_line(2, '@media print { ');fnd_file.put_line(2, ' * { -webkit-print-color-adjust: exact !important; color-adjust: exact !important; }');fnd_file.put_line(2, ' body { background: white !important; margin: 0; padding: 20px; }');fnd_file.put_line(2, ' .container { box-shadow: none !important; max-width: none !important; }');fnd_file.put_line(2, ' .navbar, .nav-buttons, .print-btn, .action-btn { display: none !important; }');fnd_file.put_line(2, ' .page { display: none !important; padding: 0 !important; }');fnd_file.put_line(2, ' .page.print-active { display: block !important; }');fnd_file.put_line(2, ' .table-header { display: none !important; }');fnd_file.put_line(2, ' .table-container { box-shadow: none !important; border-radius: 0 !important; margin-bottom: 0 !important; }');fnd_file.put_line(2, ' .table-content { padding: 0 !important; }');fnd_file.put_line(2, ' .welcome-section, .info-grid, .quick-actions { display: none !important; }');-- 关键的分页控制样式fnd_file.put_line(2, ' table { ');fnd_file.put_line(2, ' box-shadow: none !important; ');fnd_file.put_line(2, ' border-radius: 0 !important; ');fnd_file.put_line(2, ' page-break-inside: auto !important; ');fnd_file.put_line(2, ' break-inside: auto !important; ');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' tr { ');fnd_file.put_line(2, ' page-break-inside: avoid !important; ');fnd_file.put_line(2, ' break-inside: avoid !important; ');fnd_file.put_line(2, ' orphans: 2; ');fnd_file.put_line(2, ' widows: 2; ');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' thead { ');fnd_file.put_line(2, ' display: table-header-group !important; ');fnd_file.put_line(2, ' page-break-after: avoid !important; ');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' tbody { ');fnd_file.put_line(2, ' display: table-row-group !important; ');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' th, td { ');fnd_file.put_line(2, ' page-break-inside: avoid !important; ');fnd_file.put_line(2, ' break-inside: avoid !important; ');fnd_file.put_line(2, ' }');-- 页面设置fnd_file.put_line(2, ' @page { ');fnd_file.put_line(2, ' size: A4; ');fnd_file.put_line(2, ' margin: 1cm; ');fnd_file.put_line(2, ' }');fnd_file.put_line(2, '}');-- @media print 部分添加:fnd_file.put_line(2, ' .table-footer-container {');fnd_file.put_line(2, ' page-break-inside: avoid !important;');fnd_file.put_line(2, ' break-inside: avoid !important;');fnd_file.put_line(2, ' page-break-before: auto !important;');fnd_file.put_line(2, ' margin-top: 10px !important;');fnd_file.put_line(2, ' }');-- 确保容器内的表格无间隙fnd_file.put_line(2, ' .table-footer-container table {');fnd_file.put_line(2, ' margin: 0 !important;');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' .table-footer-container table:first-child {');fnd_file.put_line(2, ' margin-bottom: 0 !important;');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' .table-footer-container table:last-child {');fnd_file.put_line(2, ' margin-top: 0 !important;');fnd_file.put_line(2, ' }');fnd_file.put_line(2, '</style>');fnd_file.put_line(2, '</head>');fnd_file.put_line(2, '<body>');fnd_file.put_line(2, '<div class="container">');-- 导航栏fnd_file.put_line(2, '<div class="navbar">');fnd_file.put_line(2, '<h1>CUX:应收客户对账单(深圳专用)</h1>');fnd_file.put_line(2, '<div class="nav-buttons">');fnd_file.put_line(2, '<button class="nav-btn active" onclick="showPage(''home'')">首页</button>');fnd_file.put_line(2, '<button class="nav-btn" onclick="showPage(''summary'')">汇总表</button>');fnd_file.put_line(2, '<button class="nav-btn" onclick="showPage(''detail'')">明细表</button>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div style="clear: both;"></div>');fnd_file.put_line(2, '</div>');-- 首页fnd_file.put_line(2, '<div id="home" class="page active">');fnd_file.put_line(2, '<div class="welcome-section">');fnd_file.put_line(2, '<h2>欢迎使用五金模式对账报表</h2>');fnd_file.put_line(2, '<p>查询期间:' || NVL(p_date_begin, '未指定') || ' 至 ' || NVL(p_date_end, '未指定') || '</p>');fnd_file.put_line(2, '<p>生成时间:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') || '</p>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div class="info-grid">');fnd_file.put_line(2, '<div class="info-card">');fnd_file.put_line(2, '<h3>汇总表</h3>');fnd_file.put_line(2, '<p>提供客户应收账款的汇总信息,包括期初余额、发票金额、收款金额和期末余额等关键财务数据。适合管理层快速了解整体应收状况。</p>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div class="info-card">');fnd_file.put_line(2, '<h3>明细表</h3>');fnd_file.put_line(2, '<p>展示详细的交易记录,包括每笔销售的具体信息:日期、产品、数量、金额等。便于财务人员进行详细的对账工作。</p>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div class="info-card">');fnd_file.put_line(2, '<h3>打印功能</h3>');fnd_file.put_line(2, '<p>每个表格都支持独立打印,打印时会自动隐藏导航元素,确保打印效果清晰美观。支持A4纸张格式。</p>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div class="info-card">');fnd_file.put_line(2, '<h3>使用说明</h3>');fnd_file.put_line(2, '<p>1. 点击导航栏切换不同报表<br>2. 在表格页面点击"打印"按钮进行打印<br>3. 数据实时生成,确保准确性</p>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div class="quick-actions">');fnd_file.put_line(2, '<h3>快速操作</h3>');fnd_file.put_line(2, '<button class="action-btn" onclick="showPage(''summary'')">查看汇总表</button>');fnd_file.put_line(2, '<button class="action-btn" onclick="showPage(''detail'')">查看明细表</button>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '</div>');-- 汇总表页面fnd_file.put_line(2, '<div id="summary" class="page">');fnd_file.put_line(2, '<div class="table-container">');fnd_file.put_line(2, '<div class="table-header">');fnd_file.put_line(2, '<h3>应收客户对账单 - 汇总表</h3>');fnd_file.put_line(2, '<button class="print-btn" onclick="printTable(''summary'')">打印汇总表</button>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div class="table-content">');-- 调用汇总表过程proc_wujin_mode_summary_sheet(errbuf => errbuf,retcode => retcode,p_set_of_books_id => p_set_of_books_id,p_org_id => p_org_id,p_chart_of_accounts_id => p_chart_of_accounts_id,p_customer_id => p_customer_id,p_date_begin => p_date_begin,p_date_end => p_date_end,p_sale_per_val => p_sale_per_val);fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '</div>');-- 明细表页面fnd_file.put_line(2, '<div id="detail" class="page">');fnd_file.put_line(2, '<div class="table-container">');fnd_file.put_line(2, '<div class="table-header">');fnd_file.put_line(2, '<h3>应收客户对账单 - 明细表</h3>');fnd_file.put_line(2, '<button class="print-btn" onclick="printTable(''detail'')">打印明细表</button>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '<div class="table-content">');-- 调用明细表过程proc_wujin_mode_detail_sheet(errbuf => errbuf,retcode => retcode,p_set_of_books_id => p_set_of_books_id,p_org_id => p_org_id,p_chart_of_accounts_id => p_chart_of_accounts_id,p_customer_id => p_customer_id,p_date_begin => p_date_begin,p_date_end => p_date_end,p_sale_per_val => p_sale_per_val);fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '</div>');fnd_file.put_line(2, '</div>'); -- container结束-- JavaScript - 修复打印问题fnd_file.put_line(2, '<script>');fnd_file.put_line(2, 'function showPage(pageId) {');fnd_file.put_line(2, ' var pages = document.getElementsByClassName("page");');fnd_file.put_line(2, ' var buttons = document.getElementsByClassName("nav-btn");');fnd_file.put_line(2, ' for (var i = 0; i < pages.length; i++) {');fnd_file.put_line(2, ' pages[i].classList.remove("active");');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' for (var i = 0; i < buttons.length; i++) {');fnd_file.put_line(2, ' buttons[i].classList.remove("active");');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' document.getElementById(pageId).classList.add("active");');fnd_file.put_line(2, ' event.target.classList.add("active");');fnd_file.put_line(2, '}');fnd_file.put_line(2, '');fnd_file.put_line(2, 'function printTable(tableType) {');fnd_file.put_line(2, ' // 移除所有页面的active类');fnd_file.put_line(2, ' var pages = document.getElementsByClassName("page");');fnd_file.put_line(2, ' for (var i = 0; i < pages.length; i++) {');fnd_file.put_line(2, ' pages[i].classList.remove("active");');fnd_file.put_line(2, ' pages[i].classList.remove("print-active");');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' ');fnd_file.put_line(2, ' // 只给要打印的页面添加print-active类');fnd_file.put_line(2, ' var targetPage = document.getElementById(tableType);');fnd_file.put_line(2, ' if (targetPage) {');fnd_file.put_line(2, ' targetPage.classList.add("print-active");');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' ');fnd_file.put_line(2, ' // 执行打印');fnd_file.put_line(2, ' window.print();');fnd_file.put_line(2, ' ');fnd_file.put_line(2, ' // 打印完成后恢复页面状态');fnd_file.put_line(2, ' setTimeout(function() {');fnd_file.put_line(2, ' for (var i = 0; i < pages.length; i++) {');fnd_file.put_line(2, ' pages[i].classList.remove("print-active");');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' // 恢复当前页面的显示');fnd_file.put_line(2, ' if (targetPage) {');fnd_file.put_line(2, ' targetPage.classList.add("active");');fnd_file.put_line(2, ' }');fnd_file.put_line(2, ' }, 100);');fnd_file.put_line(2, '}');fnd_file.put_line(2, '</script>');fnd_file.put_line(2, '</body>');fnd_file.put_line(2, '</html>');COMMIT;ELSEerrbuf := '未知的对账模式';retcode := -1;END IF;END;
❀表格打印
PROCEDURE proc_taoxihui_mode(errbuf OUT VARCHAR2,retcode OUT NUMBER-- 默认参数,p_set_of_books_id IN NUMBER DEFAULT NULL -- 2022 不知道是啥 反正每次有值,p_org_id IN NUMBER DEFAULT NULL -- 默认职责权限可访问的默认业务实体 ,p_chart_of_accounts_id IN NUMBER DEFAULT NULL -- 50388 不知道是啥 反正每次有值,p_customer_id IN NUMBER DEFAULT NULL -- 3398 不知道是啥 反正每次有值-- 手录参数,p_date_begin IN VARCHAR2 DEFAULT NULL -- 开始日期,p_date_end IN VARCHAR2 DEFAULT NULL -- 结束日期,p_sale_per_val IN VARCHAR2 DEFAULT NULL -- 销售人员:000013) IS/* ┌───────────────────────────────┐* │ 兼容性参数说明 │* ├─────────────────-─────────────┤* │ 部分旧版输入参数已停止使用! │* │ 为保障兼容性,这些参数的值仍被保留│* │ 以避免影响现有业务逻辑的正常运行。│* └───────────────────────────────┘*/p_project_flag VARCHAR2(5) := 'N'; --项目模式P_INCLUDE_INTERFACE_FLAG VARCHAR2(5) := 'N'; --包括已销货未开票数据p_exclude_mold_trx VARCHAR2(5) := 'N'; --是否排除模具发票p_WJXS_ou_exclude_other VARCHAR2(5) := 'N'; --销售公司排除非合和出货单p_accounted_amount_flag VARCHAR2(5) := 'N'; --显示本位币p_DZD_function_flag VARCHAR2(5) := 'N'; --对账单功能flagp_output_type VARCHAR2(5) := 'N'; --输出格式 Y:excel N:htmlp_multiorg_flag VARCHAR2(5) := 'N'; --多OU查询?p_zero_include_flag VARCHAR2(5) := 'N'; --包括零额客户p_active_flag VARCHAR2(5) := 'N'; --仅包括有效客户p_detail_flag VARCHAR2(5) := 'Y'; --明细对账单p_combinesite_flag VARCHAR2(5) := 'N'; --合并开单地址p_accounting_affect_flag VARCHAR2(5) := 'Y'; --仅未结应收款?p_currency_code VARCHAR2(100) := NULL; -- 例如默认币种p_site_use_id NUMBER := NULL; -- 默认站点使用IDp_sales_territory VARCHAR2(100) := NULL; -- 默认销售区域p_salesrep_id NUMBER := NULL; -- 默认销售代表IDp_customer_type_code VARCHAR2(100) := NULL; -- 默认客户类型p_customer_class_code VARCHAR2(100) := NULL; -- 默认客户分类p_customer_profile_id NUMBER := NULL; -- 默认客户配置文件IDp_account_flexfield VARCHAR2(100) := NULL; -- 默认会计科目p_sale_dep_val VARCHAR2(100) := NULL; -- 默认销售部门p_project_num VARCHAR2(100) := NULL; -- 默认项目编号p_project_name VARCHAR2(100) := NULL; -- 默认项目名称-- end --v_begin_date DATE;v_end_date DATE;v_customer_tab t_customer_tab;v_begin_amount_total NUMBER := 0;v_invoice_amount_total NUMBER := 0;v_receipt_amount_total NUMBER := 0;v_apply_amount_total NUMBER := 0;v_end_amount_total NUMBER := 0;v_begin_amount_total_accounted NUMBER := 0;v_invoice_amount_total_accounted NUMBER := 0;v_receipt_amount_total_accounted NUMBER := 0;v_apply_amount_total_accounted NUMBER := 0;v_end_amount_total_accounted NUMBER := 0;v_all_act_tab t_all_act_tab;v_amount_applied NUMBER;v_quantity_applied NUMBER;v_act_tab t_act_tab;v_act_count NUMBER := 0;v_act_colnum NUMBER := 0;v_all_act_count NUMBER := 0;v_all_act_colnum NUMBER := 0;v_act_begin_amount NUMBER := 0;v_act_begin_quantity NUMBER := 0;v_c_index NUMBER := 0;v_c_count NUMBER := 0;v_index NUMBER := 0;v_prev_org_id NUMBER;v_op_unit VARCHAR2(100) := fnd_profile.value('CUX_OP_UNIT');x_app_journal_number VARCHAR2(100);x_tran_journal_number VARCHAR2(100);v_sale_dep_desc VARCHAR2(240);v_sale_per_desc VARCHAR2(240);v_cux_nums number; --特定客户、部门、业务员、项目号,在对账单客户化表中的行数v_cux_nums_approval number; --特定客户、部门、业务员、项目号,且已审批,在对账单客户化表中的行数v_CREDIT_LIMIT number; --客户授信额度(固定)-- 换页逻辑——明细对账单相关v_page_width NUMBER := 900; --明细对账单的宽度 原为850v_page_max_lines NUMBER := 46; --限定一页body+bottom的最大行数 原为:47 下移动了一行v_bottom_lines NUMBER := 27; --明细对账单表尾需要的行数 原为21v_top_lines NUMBER := 8; --add by jzl 2025.09.11 第一页存在表头 占据18行空间v_lines_num NUMBER ; --一张对账单body的总行数v_pages_num NUMBER ; --一张对账单的总页数v_page_count NUMBER ; --一张对账单的当前页码v_total_remark_breaks NUMBER := 0; -- 备注换行总数v_total_lines_space NUMBER := 0; -- 遍历单据 记录迭代单据的占总空间行数v_current_line_space NUMBER := 0; -- 用于记录单据中每一行数据占据空间行数的变量v_current_doc_total_space NUMBER := 0; -- 用于记录每个单据总占据空间行数的变量v_company_name varchar2(240); --对账单上的本方名称v_tel varchar2(240); --对账单上的本方telv_fax varchar2(240); --对账单上的本方faxdetail_balance number; --明细对账单行余额detail_sale_total number; --明细对账单发货金额合计detail_receipt_total number; --明细对账单收款金额合计daxie_cost varchar2(240);--金额大写 v_tern_name varchar2(30); l_userid VARCHAR2(100); -- add by jzl 2025.09.09 新增申请人名字-- 购货方联系人和TELv_buyer_contact_person VARCHAR2(100);v_buyer_tel VARCHAR2(100);-- 临时使用变量temp NUMBER;-- 币种v_transactional_curr_code VARCHAR2(20);CURSOR cur_customers ISselect a.org_id,null org_short_name --nvl(org.attribute9 ,org.name),null org_print_title --nvl(org.attribute10 ,org.name) ,a.customer_id,a.customer_number,a.customer_name,a.location,a.site_use_id,a.territory_province,a.territory_companyfrom (SELECT l.org_id,null org_short_name --nvl(org.attribute9 ,org.name),null org_print_title --nvl(org.attribute10 ,org.name),ac.customer_id,ac.customer_number,ac.customer_name,decode(p_combinesite_flag,'Y', NULL,l.LOCATION) location,decode(p_combinesite_flag,'Y', NULL,l.site_use_id) site_use_id,fvv2.description territory_province,fvv3.description territory_companyFROM cux_customers_v ac,hz_cust_acct_sites_all ad,hz_cust_site_uses_all l,ra_territories t,hr_operating_units h,hr_organization_units_v org--,fnd_flex_values_vl fvv2,fnd_flex_value_sets fvs2,fnd_flex_values_vl fvv3,fnd_flex_value_sets fvs3WHERE ac.customer_id = ad.cust_account_idAND ad.cust_acct_site_id = l.cust_acct_site_idAND l.territory_id = t.territory_id(+)AND l.site_use_code = 'BILL_TO'AND ad.org_id = h.organization_idAND l.org_id = h.organization_id--AND t.segment1 = fvv2.flex_value(+)AND fvv2.flex_value_set_id(+) = fvs2.flex_value_set_idAND fvs2.flex_value_set_name(+) = 'HH_COM'AND t.segment2 = fvv3.flex_value(+)AND fvv3.flex_value_set_id(+) = fvs3.flex_value_set_idAND fvs3.flex_value_set_name(+) = 'HH_SALE_DEP'AND h.set_of_books_id = p_set_of_books_idAND h.organization_id = org.organization_idAND l.site_use_id = nvl(p_site_use_id,l.site_use_id)AND ac.customer_id = nvl(p_customer_id,ac.customer_id)AND nvl(l.primary_salesrep_id,-3) = nvl(p_salesrep_id,nvl(l.primary_salesrep_id,-3))AND nvl(ac.status,'A') = decode(p_active_flag,'Y','A',nvl(ac.status,'A'))AND nvl(ad.status,'A') = decode(p_active_flag,'Y','A',nvl(ad.status,'A'))AND nvl(l.status,'A') = decode(p_active_flag,'Y','A',nvl(l.status,'A'))AND nvl(ac.customer_type,'X') = nvl(p_customer_type_code,nvl(ac.customer_type,'X'))AND nvl(ac.customer_class_code,'X') = nvl(p_customer_class_code,nvl(ac.customer_class_code,'X'))AND nvl(ac.customer_profile_class_id,-1) = nvl(p_customer_profile_id,nvl(ac.customer_profile_class_id,-1))AND check_flex_combinations('CT#',NULL,l.territory_id,'ra_territories','territory_id',p_sales_territory) = 1AND check_flex_combinations('GL#',p_chart_of_accounts_id,l.gl_id_rec,'gl_code_combinations','code_combination_id',p_account_flexfield) = 1AND (p_multiorg_flag = 'Y' OR p_multiorg_flag = 'N' AND h.organization_id = p_org_id)) agroup by a.org_id,a.customer_id,a.customer_number,a.customer_name,a.location,a.site_use_id,a.territory_province,a.territory_companyORDER BY a.org_id,a.customer_number ,a.location;--获取应收单据涉及的币种、销售部门、销售人员、项目CURSOR cur_sale --currency_dep_per_project(x_org_id NUMBER,x_customer_id NUMBER,x_site_use_id NUMBER,x_end_date DATE,x_currency_code VARCHAR2,x_sale_dep VARCHAR2,x_sale_per VARCHAR2,x_project_num VARCHAR2) ISSELECT trx.INVOICE_CURRENCY_CODE currency_code,trx.attribute4 sale_dep_value,trx.attribute5 sale_per_value,decode(p_project_flag,'Y',trx.attribute6,NULL) project_numFROM ra_cust_trx_line_gl_dist_all d,ra_customer_trx_all trxWHERE trx.customer_trx_id = d.customer_trx_idAND d.account_class IN ('REC')AND d.gl_date <= x_end_dateAND trx.bill_to_customer_id = x_customer_idAND trx.bill_to_site_use_id =nvl(x_site_use_id ,trx.bill_to_site_use_id)AND d.org_id = x_org_idAND trx.org_id = x_org_idAND trx.invoice_currency_code = nvl(x_currency_code, trx.invoice_currency_code)AND trx.complete_flag = 'Y'AND check_affect_flag(trx.cust_trx_type_id,NULL) = 1AND (p_sale_dep_val IS NULL OR nvl(trx.attribute4,-999) = p_sale_dep_val)AND (p_sale_per_val IS NULL OR nvl(trx.attribute5,-999) = p_sale_per_val)AND (p_project_num IS NULL OR nvl(trx.attribute6,-999) = p_project_num)GROUP BY trx.INVOICE_CURRENCY_CODE,trx.attribute4,trx.attribute5,decode(p_project_flag,'Y',trx.attribute6,NULL)UNIONSELECT cash.CURRENCY_CODE currency_code,cash.attribute1 sale_dep,cash.attribute2 sale_per,decode(p_project_flag,'Y',cash.attribute3,NULL) project_numFROM ar_cash_receipt_history_all his,ar_cash_receipts_all cashWHERE cash.cash_receipt_id = his.cash_receipt_idAND his.status IN ('REVERSED','CLEARED','REMITTED','CONFIRMED')AND nvl(his.current_record_flag,'Y') = 'Y'AND his.gl_date <= x_end_dateAND cash.pay_from_customer = x_customer_idAND cash.customer_site_use_id =nvl(x_site_use_id ,cash.customer_site_use_id)AND his.org_id = x_org_idAND cash.org_id = x_org_idAND (nvl(his.factor_discount_amount,0) = 0 OR his.status = 'REVERSED')AND (his.reversal_created_from <> 'RATE ADJUSTMENT TRIGGER' ORhis.reversal_created_from IS NULL)AND cash.currency_code = nvl(x_currency_code, cash.currency_code)AND (p_sale_dep_val IS NULL OR nvl(cash.attribute1,-999) = p_sale_dep_val)AND (p_sale_per_val IS NULL OR nvl(cash.attribute2,-999) = p_sale_per_val)AND (p_project_num IS NULL OR nvl(cash.attribute3,-999) = p_project_num)GROUP BY cash.CURRENCY_CODE,cash.attribute1,cash.attribute2,decode(p_project_flag,'Y',cash.attribute3,NULL) --加取应收接口表销售人员 begin union select rila.currency_code currency_code,rila.header_attribute4 sale_dep_value,rila.header_attribute5 sale_per_value,decode(p_project_flag,'Y',rila.header_attribute6,null) project_numfrom ra_interface_lines_all rilawhere rila.interface_status is nulland rila.ship_date_actual <= trunc(x_end_date)+0.99999and rila.orig_system_bill_customer_id = x_customer_idand rila.org_id = x_org_idand rila.currency_code =nvl(x_currency_code,rila.currency_code)and (p_sale_dep_val is null or nvl(rila.header_attribute4,-1) = p_sale_dep_val)and (p_sale_per_val is null or nvl(rila.header_attribute5,-1) = p_sale_per_val)and (p_project_num is null or nvl(rila.header_attribute6,-1) = p_project_num)group by rila.currency_code,rila.header_attribute4,rila.header_attribute5,decode(p_project_flag,'Y',rila.header_attribute6,null);TYPE t_table_emp IS TABLE OF cur_sale%ROWTYPE INDEX BY BINARY_INTEGER;l_table_emp t_table_emp;-- 收款核销CURSOR cur_all_applications(x_org_id NUMBER,x_customer_id NUMBER,x_site_use_id NUMBER,x_receivables_trx_id NUMBER,x_item_id VARCHAR2) ISSELECT app.attribute1 item_id,act.name act_name,act.receivables_trx_id,nvl(act.attribute7,'N') quantity_flag,SUM(app.amount_applied) amount_applied,SUM(to_number(app.attribute2) * sign(app.amount_applied)) quantity_appliedFROM ar_receivable_applications_all app,ar_cash_receipts_all cash,ar_receivables_trx_all actWHERE app.receivables_trx_id = act.receivables_trx_idAND app.cash_receipt_id = cash.cash_receipt_idAND cash.currency_code = NVL(p_currency_code,cash.currency_code)AND cash.pay_from_customer =nvl(x_customer_id,cash.pay_from_customer)AND cash.customer_site_use_id =nvl(x_site_use_id,cash.customer_site_use_id)AND (nvl(act.attribute3,'N') = 'Y' OR act.attribute8 = 'HK')AND app.org_id = x_org_idAND cash.org_id = x_org_idAND act.org_id = x_org_idAND act.receivables_trx_id =nvl(x_receivables_trx_id,act.receivables_trx_id)AND nvl(app.attribute1,'-1') = nvl(x_item_id,nvl(app.attribute1,'-1'))AND app.gl_date <= v_end_dateGROUP BY app.attribute1,act.name,act.receivables_trx_id,nvl(act.attribute7,'N'),get_item_num(app.attribute1)HAVING SUM(app.amount_applied) <> 0 OR SUM(to_number(app.attribute2) * sign(app.amount_applied)) <> 0ORDER BY act.name,get_item_num(app.attribute1),nvl(act.attribute7,'N') DESC;var_all_applications cur_all_applications%ROWTYPE;-- 明细对账单行数据。模式1——陶熙慧鱼胶条模式 CURSOR cur_transactions1 ( x_org_id NUMBER,x_customer_id NUMBER,x_site_use_id NUMBER,x_currency_code VARCHAR2,x_sale_dep VARCHAR2,x_sale_per VARCHAR2,x_project_num IN VARCHAR2,x_customer_number IN VARCHAR2,x_begin_date date,x_end_date date) ISSELECT日期,摘要,物料编码,产品名称,规格型号,单位,数量,单价,价税合计,收款金额,应收款余额,订单号,备注,产品米重,产品长度FROM(--1、销货、发票数据--1.1、已开票发货数据。(1)比对日期是发货日期。(2)不要求发票已完成。--1.2、接口行数据,不含应税外加的税额。--1.3、接口行数据,应税外加的税额。--1.4、非销货发票。SELECT ola.actual_shipment_date AS 日期, -- 实际发运日期MAX(mmt.attribute15) AS 摘要, -- 销货单号(最大值)ola.ordered_item AS 物料编码, -- 物料编码msi.attribute19 AS 产品名称, -- 品名(物料属性19)msi.attribute24 AS 规格型号, -- 规格(物料属性24)ola.order_quantity_uom AS 单位, -- 单位decode(ola.line_category_code, 'ORDER', 1, -1) * ola.shipped_quantity AS 数量, -- 实际发运数量ola.unit_selling_price_per_pqty AS 单价, -- 单价(每包装单位)decode(ola.line_category_code, 'ORDER', 1, -1) * round(ola.shipped_quantity * ola.unit_selling_price * CASE WHEN ola.actual_shipment_date IS NULL THEN NULLWHEN oha.transactional_curr_code = 'CNY' THEN 1ELSE get_conversion_rate(oha.transactional_curr_code, ola.actual_shipment_date) END, 2) AS 价税合计,-- 本位币发运金额NULL AS 收款金额,NULL AS 应收款余额, -- 应收款余额substr(oha.cust_po_number, instr(oha.cust_po_number, '-', 1) + 1) AS 订单号,oha.attribute1 AS 备注, -- 项目名称ola.ATTRIBUTE18 AS 产品米重,msi.UNIT_WEIGHT * 1000 AS 产品长度FROM oe_order_headers_all oha,oe_order_lines_all ola,hz_cust_accounts hca,mtl_system_items_b msi,mtl_material_transactions mmt,oe_transaction_types_all tta,oe_transaction_types_tl ttt,fnd_lookup_values_vl flv,ra_terms_vl term,ra_customer_trx_lines_all rctl,ra_customer_trx_lines_all tax,ra_customer_trx_all rcta,jtf_rs_salesreps srp,gl_code_combinations gccWHERE oha.org_id = x_org_idAND ola.actual_shipment_date >= NVL(x_begin_date, ola.actual_shipment_date)AND ola.actual_shipment_date < NVL(x_end_date, ola.actual_shipment_date) + 1AND hca.account_number = x_customer_numberAND hca.cust_account_id = oha.sold_to_org_idAND oha.header_id = ola.header_idAND ola.inventory_item_id = msi.inventory_item_idAND msi.organization_id = ola.ship_from_org_idAND mmt.trx_source_line_id(+) = ola.line_idAND mmt.organization_id(+) = ola.ship_from_org_idAND mmt.inventory_item_id(+) = ola.inventory_item_idAND mmt.transaction_type_id(+) = decode(ola.line_category_code,'ORDER',33,15)AND tta.org_id = oha.org_idAND tta.transaction_type_id = oha.order_type_idAND tta.transaction_type_code = 'ORDER'AND tta.transaction_type_id = ttt.transaction_type_idAND ttt.LANGUAGE = 'ZHS'AND ola.salesrep_id = srp.salesrep_id(+)AND srp.org_id(+) = x_org_idAND srp.gl_id_rec = gcc.code_combination_idAND flv.lookup_type = 'LINE_FLOW_STATUS'AND flv.lookup_code = ola.flow_status_codeAND ola.payment_term_id = term.term_id(+)AND rctl.sales_order(+) = oha.order_numberAND rctl.sales_order_line(+) = ola.line_numberAND rctl.interface_line_attribute12(+) = ola.shipment_numberAND rctl.interface_line_attribute6(+) = ola.line_idAND rctl.line_type(+) = 'LINE'AND tax.link_to_cust_trx_line_id(+) = rctl.customer_trx_line_idAND tax.line_type(+) = 'TAX'AND rcta.customer_trx_id(+) = rctl.customer_trx_id--groupby是因为发货物料事务处理可能会多个GROUP BY ola.line_category_code,hca.account_number,hca.account_name,oha.org_id,oha.salesrep_id,oha.ordered_date,oha.attribute3,oha.attribute10,oha.attribute11,oha.attribute13,oha.attribute20,term.NAME,ola.tax_code,ttt.NAME,oha.transactional_curr_code,oha.attribute14,oha.attribute1,oha.attribute2,oha.order_number,(ola.line_number || '.' || ola.shipment_number),ola.ordered_item,msi.attribute19, msi.attribute24, ola.order_quantity_uom,decode(ola.line_category_code,'ORDER',1,-1) * ola.ordered_quantity,ola.unit_selling_price_per_pqty,ola.unit_selling_price,oha.conversion_rate,decode(ola.line_category_code,'ORDER',1,-1) * round((ola.unit_selling_price * ola.ordered_quantity),2),decode(ola.line_category_code,'ORDER',1,-1) * round((ola.unit_selling_price * decode(oha.transactional_curr_code,'CNY',1,oha.conversion_rate) * ola.ordered_quantity),2),flv.description,ola.request_date,ola.promise_date,ola.schedule_ship_date,ola.actual_shipment_date,decode(ola.line_category_code,'ORDER',1,-1) * ola.shipped_quantity,decode(ola.line_category_code,'ORDER',1,-1) * round(ola.unit_selling_price * ola.shipped_quantity,2),ola.packing_instructions,rcta.trx_number,rctl.extended_amount + nvl(tax.extended_amount,0),ola.line_id,msi.attribute1,ola.line_number,ola.attribute3,ola.orig_sys_document_ref,ola.orig_sys_line_ref,oha.cust_po_number,oha.order_category_code,mmt.attribute2,mmt.attribute3,oha.shipping_instructions,oha.attribute19,substr(oha.cust_po_number, instr(oha.cust_po_number, '-', 1) + 1), -- 订单号oha.attribute1, -- 备注ola.ATTRIBUTE18, -- 产品米重msi.UNIT_WEIGHT * 1000, -- 产品长度decode(ola.line_category_code, 'ORDER', 1, -1) * round(ola.shipped_quantity * ola.unit_selling_price * CASE WHEN ola.actual_shipment_date IS NULL THEN NULLWHEN oha.transactional_curr_code = 'CNY' THEN 1ELSE get_conversion_rate(oha.transactional_curr_code, ola.actual_shipment_date) END, 2)UNION ALL --2、收款数据--2.1、收款单。无需group bySELECT his.GL_DATE AS 日期,'销售回款' || decode(his.STATUS, 'REVERSED', cash.RECEIPT_NUMBER || '冲销', cash.RECEIPT_NUMBER) as 摘要,NULL AS 物料编码,NULL AS 产品名称,NULL AS 规格型号,NULL AS 单位,NULL AS 数量,NULL AS 单价,NULL AS 价税合计,decode(his.STATUS,'REVERSED', his.AMOUNT*-1, his.AMOUNT) 收款金额,NULL AS 应收款余额,NULL AS 订单号,cash.ATTRIBUTE5 AS 备注,cash.COMMENTS AS 产品米重,NULL AS 产品长度FROM ar_cash_receipt_history_all his,AR_CASH_RECEIPTS_V cashWHERE cash.CASH_RECEIPT_ID = his.CASH_RECEIPT_IDAND cash.TYPE = 'CASH'AND his.STATUS IN ('REVERSED', 'CLEARED', 'CONFIRMED')AND NVL(his.CURRENT_RECORD_FLAG, 'Y') = 'Y'AND (NVL(his.FACTOR_DISCOUNT_AMOUNT, 0) = 0 OR his.STATUS = 'REVERSED')AND (his.REVERSAL_CREATED_FROM <> 'RATE ADJUSTMENT TRIGGER' OR his.REVERSAL_CREATED_FROM IS NULL)AND his.GL_DATE BETWEEN NVL(x_begin_date, his.GL_DATE) AND NVL(x_end_date, his.GL_DATE)AND cash.CUSTOMER_ID = x_customer_idAND cash.CUSTOMER_SITE_USE_ID = NVL(x_site_use_id, cash.CUSTOMER_SITE_USE_ID)AND his.ORG_ID = x_org_idAND cash.ORG_ID = x_org_idAND cash.CURRENCY_CODE = x_currency_codeAND NVL(cash.ATTRIBUTE1, 1) = NVL(x_sale_dep, 1)AND NVL(cash.ATTRIBUTE2, 1) = NVL(x_sale_per, 1)AND (cash.ATTRIBUTE3 = x_project_num OR x_project_num IS NULL)UNION ALL--减2.2、收款活动(收款注销等)。暂不group bySELECT app.GL_DATE 日期,cash.RECEIPT_NUMBER || app.TYPE 摘要,NULL AS 物料编码,NULL AS 产品名称,NULL AS 规格型号,NULL AS 单位,NULL AS 数量,NULL AS 单价,NULL AS 价税合计,-app.AMOUNT 收款金额 --加负号,null 应收款余额,NULL AS 订单号,app.COMMENTS 备注,cash.COMMENTS AS 产品米重,NULL AS 产品长度FROM AR_APP_ADJ_V app,AR_CASH_RECEIPTS_V cashWHERE 0=0AND app.cash_receipt_id = cash.cash_receipt_idAND app.status = 'ACTIVITY'AND app.gl_date BETWEEN nvl(x_begin_date ,app.gl_date) AND nvl(x_end_date, app.gl_date) AND cash.customer_id = x_customer_idAND cash.customer_site_use_id =nvl(x_site_use_id ,cash.customer_site_use_id)AND cash.currency_code = x_currency_codeAND cash.org_id = x_org_idAND nvl(cash.attribute1, 1) = nvl(x_sale_dep, 1)AND nvl(cash.attribute2, 1) = nvl(x_sale_per, 1) AND (cash.attribute3 = x_project_num OR x_project_num IS NULL))ORDER BY 日期;curl_trans1 cur_transactions1%rowtype;BEGIN--模拟登录beginmo_global.set_policy_context('S', fnd_profile.value('ORG_ID'));end;v_acounting_affect_flag := p_accounting_affect_flag;v_begin_date := to_date(p_date_begin, 'yyyymmdd');v_end_date := to_date(p_date_end, 'yyyymmdd') +0.9999; --end_date必须要加0.999……。因为要和业务日期比较,而发运日期有时分秒。l_userid := fnd_global.user_id;-- add by jzl 2025.09.09 加入申请人名字write_reportheader;fnd_file.put_line(2 ,'<table x:str border=0 cellpadding=0 cellspacing=0 width=985 style="border-collapse: collapse;table-layout:fixed;width:630pt">');fnd_file.put_line(2 ,' <col class=xl24 width=50 style="mso-width-source:userset;mso-width-alt:1600; width:38pt">');fnd_file.put_line(2 ,' <col class=xl24 width=180 style="mso-width-source:userset;mso-width-alt:5760; width:111pt">');fnd_file.put_line(2 ,' <col class=xl24 width=65 style="mso-width-source:userset;mso-width-alt:2080; width:40pt">');fnd_file.put_line(2 ,' <col class=xl24 width=40 style="mso-width-source:userset;mso-width-alt:1280; width:20pt">');fnd_file.put_line(2 ,' <col class=xl24 width=60 style="mso-width-source:userset;mso-width-alt:1920; width:45pt">');fnd_file.put_line(2 ,' <col class=xl24 width=90 style="mso-width-source:userset;mso-width-alt:2944; width:45pt">');fnd_file.put_line(2 ,' <col class=xl24 width=90 style="mso-width-source:userset;mso-width-alt:2944; width:69pt">');fnd_file.put_line(2 ,' <col class=xl24 width=90 style="mso-width-source:userset;mso-width-alt:2944; width:69pt">');fnd_file.put_line(2 ,' <col class=xl24 width=60 style="mso-width-source:userset;mso-width-alt:2944; width:69pt">');fnd_file.put_line(2 ,' <col class=xl24 width=90 style="mso-width-source:userset;mso-width-alt:2944; width:69pt">');fnd_file.put_line(2 ,' <tr height=18 style="mso-height-source:userset;height:13.5pt">');fnd_file.put_line(2 --colspan=12,' <td colspan=10 align=center height=18 class=xl41 style="">应收客户对帐单</td>');fnd_file.put_line(2,' </tr>');fnd_file.put_line(2,' <tr height=18 style="mso-height-source:userset;height:13.5pt">');fnd_file.put_line(2,' <td colspan=2 height=18 class=xl41 style="">报表日期:' ||to_char(SYSDATE,'yyyy.mm.dd') || '</td>');fnd_file.put_line(2,' </tr>');fnd_file.put_line(2,' <tr height=18 style="mso-height-source:userset;height:13.5pt">');fnd_file.put_line(2,' <td colspan=3 height=18 class=xl41 style="">开始GL日期/发运日期:' ||to_char(v_begin_date,'yyyy.mm.dd') || '</td>');fnd_file.put_line(2,' <td colspan=5 height=18 class=xl41 style="">截止GL日期/发运日期:' ||to_char(v_end_date,'yyyy.mm.dd') || '</td>');fnd_file.put_line(2,' <td colspan=2 height=18 class=xl41 style="">币种:' || p_currency_code ||'</td>');fnd_file.put_line(2,' </tr>');fnd_file.put_line(2,'</table>');v_c_index := 0;FOR a IN cur_customers LOOPfnd_file.put_line(1 --打印日志,'--[BEGIN]--' || to_char(SYSDATE,'YYYYMMDD :HH24:MI:SS') || '。 客户编码: ' || a.customer_number || ', 客户名称:' || a.customer_name ); IF v_prev_org_id IS NULL THEN--第一个组织fnd_file.put_line(2 --第1个width原值900,第2个width原值742pt+。,'<table x:str border=0 cellpadding=0 cellspacing=0 width=' ||to_char(900 + v_all_act_colnum * 80) ||' style="border-collapse: collapse;table-layout:fixed;width:' ||to_char(630 + v_all_act_colnum * 60) || 'pt">');fnd_file.put_line(2 ,' <col class=xl24 width=55 style="mso-width-source:userset;mso-width-alt:1600; width:38pt">');fnd_file.put_line(2 --第1个width原值160,第2个width原值136pt。,' <col class=xl24 width=160 style="mso-width-source:userset;mso-width-alt:5760; width:111pt">');fnd_file.put_line(2 --第1个width原值55,第2个width原值49pt。,' <col class=xl24 width=55 style="mso-width-source:userset;mso-width-alt:2080; width:40pt">');fnd_file.put_line(2 --第1个width原值35,第2个width原值30pt。,' <col class=xl24 width=35 style="mso-width-source:userset;mso-width-alt:1280; width:20pt">');fnd_file.put_line(2,' <col class=xl24 width=60 style="mso-width-source:userset;mso-width-alt:1920; width:45pt">');fnd_file.put_line(2,' <col class=xl24 width=90 style="mso-width-source:userset;mso-width-alt:2944; width:30pt">');--69IF nvl(p_project_flag,'N') = 'Y' THENfnd_file.put_line(2,' <col class=xl24 width=100 style="mso-width-source:userset;mso-width-alt:1920; width:50pt">');fnd_file.put_line(2,' <col class=xl24 width=100 style="mso-width-source:userset;mso-width-alt:1920; width:50pt">');END IF;fnd_file.put_line(2,' <col class=xl24 width=90 style="mso-width-source:userset;mso-width-alt:2944; width:69pt">');fnd_file.put_line(2,' <col class=xl24 width=90 style="mso-width-source:userset;mso-width-alt:2944; width:69pt">');fnd_file.put_line(2 --第1个width原值60,第2个width原值69pt。,' <col class=xl24 width=60 style="mso-width-source:userset;mso-width-alt:2944; width:69pt">');fnd_file.put_line(2,' <col class=xl24 width=90 style="mso-width-source:userset;mso-width-alt:2944; width:69pt">');--不显示注销行合计fnd_file.put_line(1,'不显示注销行合计');fnd_file.put_line(2,' <tr class=xl33 height=18 style="mso-height-source:userset;height:13.5pt">');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">客户编码</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">客户名称</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">收单地点</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">币种</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">销售部门</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">业务员</td>');IF nvl(p_project_flag,'N') = 'Y' THENfnd_file.put_line(2,' <td class=xl36 style="border-left:none;">项目编码</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">项目名称</td>');END IF;--输出本位币的判断条件:(1)显示本位币Y。且(2)打印明细对账单N。IF nvl(p_accounted_amount_flag, 'N') = 'N' or p_detail_flag = 'Y' THENfnd_file.put_line(2,' <td class=xl36 style="border-left:none;">期初余额</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">发票/发货金额</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">收款金额(含注销)</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">期末余额</td>');ELSEfnd_file.put_line(2,' <td class=xl36 style="border-left:none;">期初余额原币</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">期初余额本位币</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">发票/发货金额原币</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">发票/发货金额本位币</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">收款金额(含注销)原币</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">收款金额(含注销)本位币</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">期末余额原币</td>');fnd_file.put_line(2,' <td class=xl36 style="border-left:none;">期末余额本位币</td>'); END IF;fnd_file.put_line(2 ,' </tr>');END IF;v_prev_org_id := a.org_id;OPEN cur_sale(a.org_id,a.customer_id,a.site_use_id,v_end_date,p_currency_code,p_sale_dep_val,p_sale_per_val,p_project_num);LOOPFETCH cur_sale BULK COLLECTINTO l_table_emp LIMIT 10000;FOR i IN 1 .. l_table_emp.COUNTLOOPfnd_file.put_line(1,'[INFO] start cur_sale...');v_c_index := v_c_index + 1;v_customer_tab(v_c_index).org_id := a.org_id;v_customer_tab(v_c_index).org_short_name := a.org_short_name;v_customer_tab(v_c_index).org_print_title := a.org_print_title;v_customer_tab(v_c_index).customer_id := a.customer_id;v_customer_tab(v_c_index).customer_name := a.customer_name;v_customer_tab(v_c_index).customer_number := a.customer_number;v_customer_tab(v_c_index).location := a.location;v_customer_tab(v_c_index).site_use_id := a.site_use_id;v_customer_tab(v_c_index).territory_province := a.territory_province;v_customer_tab(v_c_index).territory_company := a.territory_company;v_customer_tab(v_c_index).currency_code := l_table_emp(i).currency_code;v_customer_tab(v_c_index).sale_dep_value := l_table_emp(i).sale_dep_value;v_customer_tab(v_c_index).sale_per_value := l_table_emp(i).sale_per_value;v_customer_tab(v_c_index).project_num := l_table_emp(i).project_num;v_customer_tab(v_c_index).begin_amount := get_period_end_amount(p_org_id => a.org_id,p_customer_id => a.customer_id,p_site_use_id => a.site_use_id,p_end_date => (v_begin_date - 1),p_currency_code => v_customer_tab(v_c_index).currency_code --p_currency_code,p_sale_dep => l_table_emp(i).sale_dep_value,p_sale_per => l_table_emp(i).sale_per_value,p_project_num => l_table_emp(i).project_num--,p_project_name => rec_sale.project_name,P_INCLUDE_INTERFACE_FLAG => P_INCLUDE_INTERFACE_FLAG,p_exclude_mold_trx => p_exclude_mold_trx--'entered'或空参则求原币余额,'accounted'则求本币余额 ,P_ACCTD_AMOUNT_FLAG => 'entered' );v_customer_tab(v_c_index).invoice_amount := get_period_total_amount(p_org_id => a.org_id,p_customer_id => a.customer_id,p_site_use_id => a.site_use_id,p_begin_date => v_begin_date,p_end_date => v_end_date,p_currency_code => v_customer_tab(v_c_index).currency_code --p_currency_code--1发票,2收款单,3应收款活动核销(注销等)、核销汇兑损益,p_mode => 1,p_receivables_trx_id => NULL,p_sale_dep => l_table_emp(i).sale_dep_value,p_sale_per => l_table_emp(i).sale_per_value,p_project_num => l_table_emp(i).project_num--,p_project_name => rec_sale.project_name,P_INCLUDE_INTERFACE_FLAG => P_INCLUDE_INTERFACE_FLAG,p_exclude_mold_trx => p_exclude_mold_trx--'entered'或空参则求原币余额,'accounted'则求本币余额,P_ACCTD_AMOUNT_FLAG => 'entered' );v_customer_tab(v_c_index).receipt_amount := get_period_total_amount(p_org_id => a.org_id,p_customer_id => a.customer_id,p_site_use_id => a.site_use_id,p_begin_date => v_begin_date,p_end_date => v_end_date,p_currency_code => v_customer_tab(v_c_index).currency_code --p_currency_code--1发票,2收款单,3应收款活动核销(注销等)、核销汇兑损益,p_mode => 2,p_receivables_trx_id => NULL,p_sale_dep => l_table_emp(i).sale_dep_value,p_sale_per => l_table_emp(i).sale_per_value,p_project_num => l_table_emp(i).project_num--,p_project_name => rec_sale.project_name,P_INCLUDE_INTERFACE_FLAG => P_INCLUDE_INTERFACE_FLAG,p_exclude_mold_trx => p_exclude_mold_trx--'entered'或空参则求原币余额,'accounted'则求本币余额,P_ACCTD_AMOUNT_FLAG => 'entered' );v_customer_tab(v_c_index).apply_amount := get_period_total_amount(p_org_id => a.org_id,p_customer_id => a.customer_id,p_site_use_id => a.site_use_id,p_begin_date => v_begin_date,p_end_date => v_end_date,p_currency_code => v_customer_tab(v_c_index).currency_code --p_currency_code--1发票,2收款单,3应收款活动核销(注销等)、核销汇兑损益,p_mode => 3,p_receivables_trx_id => NULL,p_sale_dep => l_table_emp(i).sale_dep_value,p_sale_per => l_table_emp(i).sale_per_value,p_project_num => l_table_emp(i).project_num--,p_project_name => rec_sale.project_name,P_INCLUDE_INTERFACE_FLAG => P_INCLUDE_INTERFACE_FLAG,p_exclude_mold_trx => p_exclude_mold_trx--'entered'或空参则求原币余额,'accounted'则求本币余额,P_ACCTD_AMOUNT_FLAG => 'entered' );v_customer_tab(v_c_index).end_amount := get_period_end_amount(p_org_id => a.org_id,p_customer_id => a.customer_id,p_site_use_id => a.site_use_id,p_end_date => v_end_date,p_currency_code => v_customer_tab(v_c_index).currency_code --p_currency_code,p_sale_dep => l_table_emp(i).sale_dep_value,p_sale_per => l_table_emp(i).sale_per_value,p_project_num => l_table_emp(i).project_num--,p_project_name => rec_sale.project_name,P_INCLUDE_INTERFACE_FLAG => P_INCLUDE_INTERFACE_FLAG,p_exclude_mold_trx => p_exclude_mold_trx--'entered'或空参则求原币余额,'accounted'则求本币余额 ,P_ACCTD_AMOUNT_FLAG => 'entered');IF p_zero_include_flag = 'N'AND nvl(v_customer_tab(v_c_index).begin_amount,0) = 0AND nvl(v_customer_tab(v_c_index).invoice_amount,0) = 0AND nvl(v_customer_tab(v_c_index).receipt_amount,0) = 0AND nvl(v_customer_tab(v_c_index).apply_amount,0) = 0AND nvl(v_customer_tab(v_c_index).end_amount,0) = 0 THEN--2) levelv_customer_tab(v_c_index).display_flag := 'N';ELSE--2) levelv_customer_tab(v_c_index).display_flag := 'Y';--获取销售部门 销售人员描述BEGINSELECT fvv.descriptionINTO v_sale_dep_descFROM fnd_flex_values_vl fvv,fnd_flex_value_sets fvsWHERE fvv.flex_value_set_id = fvs.flex_value_set_idAND fvs.flex_value_set_name =cux_ws_cons.glpartyset(fnd_profile.value('GL_SET_OF_BKS_ID'),'FA_COST_CTR')AND fvv.flex_value = v_customer_tab(v_c_index).sale_dep_value;EXCEPTIONWHEN OTHERS THENv_sale_dep_desc := NULL;END;BEGINSELECT fvv.descriptionINTO v_sale_per_descFROM fnd_flex_values_vl fvv,fnd_flex_value_sets fvsWHERE fvv.flex_value_set_id = fvs.flex_value_set_idAND fvs.flex_value_set_name =cux_ws_cons.glpartyset(fnd_profile.value('GL_SET_OF_BKS_ID'),'GL_PER')AND fvv.flex_value = v_customer_tab(v_c_index).sale_per_value;EXCEPTIONWHEN OTHERS THENv_sale_per_desc := NULL;END;IF l_table_emp(i).project_num is not null THENbeginselect fv.DESCRIPTIONinto v_customer_tab(v_c_index).project_namefrom FND_FLEX_VALUE_SETS fvs,FND_FLEX_VALUES_VL fvwhere fvs.FLEX_VALUE_SET_ID = fv.FLEX_VALUE_SET_IDand fvs.FLEX_VALUE_SET_NAME = cux_ws_util.get_ProjSet_by_org(p_org_id => p_org_id)and fv.FLEX_VALUE = l_table_emp(i).project_numand rownum = 1;exceptionWHEN OTHERS THENnull;end;end IF;if p_DZD_function_flag = 'Y'then select COUNT(*)INTO v_cux_numsfrom CUX.CUX_RTDUICHECK_TABLE CRTWHERE CRT.BEGIN_DATE = v_begin_dateand crt.end_date = trunc(v_end_date)and crt.org_id = v_customer_tab(v_c_index).org_idAND CRT.CUSTOMER_NUM = v_customer_tab(v_c_index).customer_number AND crt.sale_dep_value = v_customer_tab(v_c_index).sale_dep_valueAND crt.sale_per_value = v_customer_tab(v_c_index).sale_per_valueAND nvl(crt.project_num, '-1') = nvl(v_customer_tab(v_c_index).project_num, '-1')--v_customer_tab(v_c_index).project_name := rec_sale.project_name; select COUNT(*)INTO v_cux_nums_approvalfrom CUX.CUX_RTDUICHECK_TABLE CRTWHERE CRT.BEGIN_DATE = v_begin_dateand crt.end_date = v_end_dateand crt.org_id = v_customer_tab(v_c_index).org_idAND CRT.CUSTOMER_NUM = v_customer_tab(v_c_index).customer_number AND crt.sale_dep_value = v_customer_tab(v_c_index).sale_dep_valueAND crt.sale_per_value = v_customer_tab(v_c_index).sale_per_valueAND nvl(crt.project_num, '-1') = nvl(v_customer_tab(v_c_index).project_num, '-1')--v_customer_tab(v_c_index).project_name := rec_sale.project_nameand crt.approval_flag = 'Y'; BEGIN--客户授信额度。不需要判断部门select nvl(a.amount,0)into v_CREDIT_LIMITfrom cux_customer_credits_all2 awhere a.org_id = p_org_idand a.customer_number = v_customer_tab(v_c_index).customer_numberand a.salesperson_code = v_customer_tab(v_c_index).sale_per_valueand nvl(a.end_date,to_date('2099-12-31','yyyy-mm-dd') ) >= trunc(v_end_date)and nvl(a.start_date,to_date('2000-01-01','yyyy-mm-dd') ) <= trunc(v_end_date) --v_begin_date;EXCEPTIONWHEN OTHERS THENv_CREDIT_LIMIT := 0;END;dbms_output.put_line('v_cux_nums ' || v_cux_nums);--plsql输出数据--情况1、在cux表没有记录。则往对账单审核表插入数据IF v_cux_nums = 0 THENinsert into CUX.CUX_RTDUICHECK_TABLE (customer_id,customer_num,customer_name,site_use_id,location,sale_dep_value,sale_per_value,sale_dep_desc,sale_per_desc,begin_amount,invoice_amount,receipt_amount,apply_amount,end_amount,APPROVAL_FLAG,SURE_FLAG,CREDIT_LIMIT,org_id,BEGIN_DATE,end_date,SHOW_TYPE, --?SAVE_FLAG,PRINT_FLAG,currency,project_num,project_name,created_date-- created_by)values(v_customer_tab(v_c_index).customer_id,v_customer_tab(v_c_index).customer_number,v_customer_tab(v_c_index).customer_name,v_customer_tab(v_c_index).site_use_id,v_customer_tab(v_c_index).location,l_table_emp(i).sale_dep_value,l_table_emp(i).sale_per_value,v_sale_dep_desc,v_sale_per_desc,nvl(v_customer_tab(v_c_index).begin_amount, 0),v_customer_tab(v_c_index).invoice_amount,v_customer_tab(v_c_index).receipt_amount,v_customer_tab(v_c_index).apply_amount,v_customer_tab(v_c_index).end_amount,'N','N',v_CREDIT_LIMIT,p_org_id,v_begin_date,trunc(v_end_date),'R', 'N','N',v_customer_tab(v_c_index).currency_code,v_customer_tab(v_c_index).project_num,v_customer_tab(v_c_index).project_name,SYSDATE-- fnd_global.user_id );commit; --情况2、已有记录,且未审批,则update。--情况3、已有记录,且已审批,则不对数据做操作。ELSIF v_cux_nums > 0 and v_cux_nums_approval = 0 THENUPDATE CUX.CUX_RTDUICHECK_TABLE CRTSET begin_amount = nvl(v_customer_tab(v_c_index).begin_amount, 0),invoice_amount = v_customer_tab(v_c_index).invoice_amount,receipt_amount = v_customer_tab(v_c_index).receipt_amount,apply_amount = v_customer_tab(v_c_index).apply_amount,end_amount = v_customer_tab(v_c_index).end_amount,CREDIT_LIMIT = v_CREDIT_LIMITWHERE CRT.BEGIN_DATE = v_begin_dateand crt.end_date = v_end_dateand crt.org_id = v_customer_tab(v_c_index).org_idAND CRT.CUSTOMER_NUM = v_customer_tab(v_c_index).customer_number AND crt.sale_dep_value = v_customer_tab(v_c_index).sale_dep_valueAND crt.sale_per_value = v_customer_tab(v_c_index).sale_per_valueAND nvl(crt.project_num, '-1') = nvl(v_customer_tab(v_c_index).project_num, '-1');COMMIT;END IF; end if;fnd_file.put_line(2,' <tr class=xl33 height=18 style="mso-height-source:userset;height:13.5pt">');fnd_file.put_line(2,' <td class=xl25 style="vnd.ms-excel.numberformat:@">' ||nvl(v_customer_tab(v_c_index).customer_number,'&' || 'nbsp;') || '</td>');IF p_detail_flag = 'Y' THENfnd_file.put_line(2,' <td class=xl25><a href="#C' || v_c_index || '">' ||nvl(v_customer_tab(v_c_index).customer_name,'&' || 'nbsp;') || '</a></td>');ELSEfnd_file.put_line(2,' <td class=xl25>' ||nvl(v_customer_tab(v_c_index).customer_name,'&' || 'nbsp;') || '</td>');END IF;fnd_file.put_line(2,' <td class=xl25>' ||nvl(v_customer_tab(v_c_index).location,'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl25>' ||nvl(v_customer_tab(v_c_index).currency_code --p_currency_code,'&' || 'nbsp;') || '</td>'); fnd_file.put_line(2,' <td class=xl25>' ||nvl(v_sale_dep_desc,'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl25>' ||nvl(v_sale_per_desc,'&' || 'nbsp;') || '</td>');IF nvl(p_project_flag,'N') = 'Y' THENfnd_file.put_line(2,' <td class=xl25>' ||nvl(v_customer_tab(v_c_index).project_num,'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl25>' ||nvl(v_customer_tab(v_c_index).project_name,'&' || 'nbsp;') || '</td>');END IF;IF nvl(p_accounted_amount_flag, 'N') = 'N' or p_detail_flag = 'Y' THENfnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_customer_tab(v_c_index).begin_amount || '">' ||nvl(to_char( nvl(v_customer_tab(v_c_index).begin_amount, 0),'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_customer_tab(v_c_index).invoice_amount || '">' ||nvl(to_char(v_customer_tab(v_c_index).invoice_amount,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');--收款金额和收款注销金额合并显示v_customer_tab(v_c_index).receipt_amount := nvl(v_customer_tab(v_c_index).receipt_amount,0)- nvl(v_customer_tab(v_c_index).apply_amount,0);fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_customer_tab(v_c_index).receipt_amount || '">' ||nvl(to_char(v_customer_tab(v_c_index).receipt_amount,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_customer_tab(v_c_index).end_amount || '">' ||nvl(to_char(v_customer_tab(v_c_index).end_amount,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');ELSEfnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_customer_tab(v_c_index).begin_amount || '">' ||nvl(to_char( nvl(v_customer_tab(v_c_index).begin_amount, 0),'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_customer_tab(v_c_index).begin_amount || '">' ||nvl(to_char( nvl(v_customer_tab(v_c_index).begin_amount_accounted, 0),'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_customer_tab(v_c_index).invoice_amount || '">' ||nvl(to_char(v_customer_tab(v_c_index).invoice_amount,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_customer_tab(v_c_index).invoice_amount || '">' ||nvl(to_char(v_customer_tab(v_c_index).invoice_amount_accounted,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');--收款金额和收款注销金额合并显示v_customer_tab(v_c_index).receipt_amount := nvl(v_customer_tab(v_c_index).receipt_amount,0)- nvl(v_customer_tab(v_c_index).apply_amount,0); fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_customer_tab(v_c_index).receipt_amount || '">' ||nvl(to_char(v_customer_tab(v_c_index).receipt_amount,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');v_customer_tab(v_c_index).receipt_amount_accounted := nvl(v_customer_tab(v_c_index).receipt_amount_accounted,0)- nvl(v_customer_tab(v_c_index).apply_amount_accounted,0); fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_customer_tab(v_c_index).receipt_amount || '">' ||nvl(to_char(v_customer_tab(v_c_index).receipt_amount_accounted,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_customer_tab(v_c_index).end_amount || '">' ||nvl(to_char(v_customer_tab(v_c_index).end_amount,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>'); fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_customer_tab(v_c_index).end_amount || '">' ||nvl(to_char(v_customer_tab(v_c_index).end_amount_accounted,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>'); END IF;fnd_file.put_line(2,' </tr>');v_begin_amount_total := v_begin_amount_total + nvl(v_customer_tab(v_c_index).begin_amount,0);v_invoice_amount_total := v_invoice_amount_total +nvl(v_customer_tab(v_c_index).invoice_amount,0);v_receipt_amount_total := v_receipt_amount_total +nvl(v_customer_tab(v_c_index).receipt_amount,0);v_apply_amount_total := v_apply_amount_total + nvl(v_customer_tab(v_c_index).apply_amount,0);v_end_amount_total := v_end_amount_total + nvl(v_customer_tab(v_c_index).end_amount,0);END IF; --2) level END LOOP;EXIT WHEN cur_sale%NOTFOUND;END LOOP;CLOSE cur_sale;--end by zhaojun 2025.06.11END LOOP; --av_c_count := v_c_index;fnd_file.put_line(2,' <tr class=xl33 height=18 style="mso-height-source:userset;height:13.5pt">');IF nvl(p_project_flag,'N') = 'Y' THENfnd_file.put_line(2 --原值10,' <td colspan=8 class=xl25 style="font-size:11pt">合计</td>');ELSEfnd_file.put_line(2 --原值8,' <td colspan=6 class=xl25 style="font-size:11pt">合计</td>');END IF;IF nvl(p_accounted_amount_flag, 'N') = 'N' or p_detail_flag = 'Y' THENfnd_file.put_line(2,' <td class=xl28 align=center x:num="' || v_begin_amount_total || '">' ||nvl(to_char(v_begin_amount_total,'999,999,999,990.99'),'-') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=center x:num="' || v_invoice_amount_total || '">' ||nvl(to_char(v_invoice_amount_total,'999,999,999,990.99'),'-') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=center x:num="' || v_receipt_amount_total || '">' ||nvl(to_char(v_receipt_amount_total,'999,999,999,990.99'),'-') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=center x:num="' || v_end_amount_total || '">' ||nvl(to_char(v_end_amount_total,'999,999,999,990.99'),'-') || '</td>');ELSEfnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_begin_amount_total || '">' ||nvl(to_char(v_begin_amount_total,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_begin_amount_total || '">' ||nvl(to_char(v_begin_amount_total_accounted,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_invoice_amount_total || '">' ||nvl(to_char(v_invoice_amount_total,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_invoice_amount_total || '">' ||nvl(to_char(v_invoice_amount_total_accounted,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_receipt_amount_total || '">' ||nvl(to_char(v_receipt_amount_total,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_receipt_amount_total || '">' ||nvl(to_char(v_receipt_amount_total_accounted,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>');fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_end_amount_total || '">' ||nvl(to_char(v_end_amount_total,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>'); fnd_file.put_line(2,' <td class=xl28 align=right x:num="' || v_end_amount_total || '">' ||nvl(to_char(v_end_amount_total_accounted,'999,999,999,990.99'),'&' || 'nbsp;') || '</td>'); END IF;fnd_file.put_line(2,' </tr>');fnd_file.put_line(2,'</table>');fnd_file.put_line(2,'<br clear=all style="page-break-before:always;mso-break-TYPE:section-break">');--勾选 明细对账单IF p_detail_flag = 'Y'AND nvl(v_c_count --?,0) > 0 THENBEGINSELECT hou.attribute2, hou.attribute12, hou.attribute13INTO v_company_name, v_tel, v_faxFROM HR_ORGANIZATION_UNITS_V houWHERE hou.organization_id = p_org_id;EXCEPTIONWHEN OTHERS THENnull;END;--1) level ;明细报表fnd_file.put_line(1 --打印日志,'BEGIN 31:开始打印明细对账单 ' || to_char(SYSDATE,'YYYYMMDD :HH24:MI:SS'));FOR v_c_index IN 1 .. v_c_count LOOPfnd_file.put_line(1 --打印日志,'BEGIN 32 ' || '对账单表行号:' ||v_c_count || '。' || to_char(SYSDATE, 'YYYYMMDD :HH24:MI:SS'));IF v_customer_tab(v_c_index).display_flag = 'N' --2) levelTHEN--2) levelNULL;ELSE--2) levelBEGINSELECT fvv.descriptionINTO v_sale_per_descFROM fnd_flex_values_vl fvv,fnd_flex_value_sets fvsWHERE fvv.flex_value_set_id = fvs.flex_value_set_idAND fvs.flex_value_set_name =cux_ws_cons.glpartyset(fnd_profile.value('GL_SET_OF_BKS_ID'),'GL_PER')AND fvv.flex_value = v_customer_tab(v_c_index).sale_per_value;EXCEPTIONWHEN OTHERS THENv_sale_per_desc := NULL;END;-- 清空备注总换行数v_total_remark_breaks := 0;-- 当前页数v_page_count := 0;v_current_doc_total_space := 0;-- begin需传入打印表头的参数赋值区域 ---- 1.购货方的联系人和电话SELECT temp.attribute2, temp.attribute3INTO v_buyer_contact_person, v_buyer_telFROM (SELECT hcas.*FROM HZ_CUST_ACCT_SITES_ALL hcasWHERE hcas.CUST_ACCOUNT_ID = p_customer_idAND hcas.ORG_ID = p_org_idORDER BY hcas.LAST_UPDATE_DATE DESC) tempWHERE ROWNUM = 1;-- end --open cur_transactions1(v_customer_tab(v_c_index).org_id,v_customer_tab(v_c_index).customer_id,v_customer_tab(v_c_index).site_use_id,v_customer_tab(v_c_index).currency_code,v_customer_tab(v_c_index).sale_dep_value --部门,v_customer_tab(v_c_index).sale_per_value,v_customer_tab(v_c_index).project_num,v_customer_tab(v_c_index).customer_number,v_begin_date,v_end_date);LOOPfetch cur_transactions1 into curl_trans1;--打印分页、表头。--分页条件1:单身没有数据。--分页条件2:单身有数据,行数到v_page_max_lines+1,且未到游标结尾时分页。fnd_file.put_line(1, '[INFO]查看打印分页、表头:当前参数值:cur_transactions1%ROWCOUNT=' || TO_CHAR(cur_transactions1%ROWCOUNT) || ', cur_transactions1%FOUND=' || CASE WHEN cur_transactions1%FOUND THEN 'TRUE' ELSE 'FALSE' END || ', cur_transactions1%ROWCOUNT - 1=' || TO_CHAR(cur_transactions1%ROWCOUNT - 1));IF cur_transactions1%ROWCOUNT in (0) OR (cur_transactions1%FOUND --避免总行数是1(等)时,重复分页。AND cur_transactions1%ROWCOUNT - 1 = 0) -- THENfnd_file.put_line(1, '[INFO]进入账单表头打印!');--页数++v_page_count := v_page_count + 1; print_detail_title(v_page_width => v_page_width,p_page_number => (v_page_count || '/' || v_pages_num),p_customer_name => v_customer_tab(v_c_index).customer_name,p_company_name => v_company_name,p_tel => v_tel,p_fax => v_fax,p_sale_per_desc => v_sale_per_desc,p_customer_number => v_customer_tab(v_c_index).customer_number,p_account_num => null,p_created_by => l_userid,p_created_date => null,p_body_title_flag => 'Y',p_bill_header_flag=> 'Y',p_buyer_contact_person=> v_buyer_contact_person, p_buyer_tel => v_buyer_tel,p_summary_sheet_cls=> '1.1'); END IF; --打印期初余额行IF cur_transactions1%ROWCOUNT in (0) orcur_transactions1%ROWCOUNT in (1) and cur_transactions1%FOUND THENfnd_file.put_line(2 --原值height:13.5pt,' <tr class=xl33 height=18 style="mso-height-source:userset;height:19pt">');fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td class=xl39 style="border-right:.5pt solid black;border-left:none;font-size:11pt">期初余额</td>');fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td class=xl26">&' || 'nbsp;</td>'); fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td class=xl26">&' || 'nbsp;</td>'); fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td class=xl26">&' || 'nbsp;</td>'); fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td class=xl26">&' || 'nbsp;</td>'); fnd_file.put_line(2, format_number_cell(v_customer_tab(v_c_index).begin_amount)); fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td class=xl26">&' || 'nbsp;</td>'); fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td class=xl26">&' || 'nbsp;</td>'); fnd_file.put_line(2,' </tr>');detail_balance := nvl(v_customer_tab(v_c_index).begin_amount, 0); --v_balance detail_sale_total := 0;detail_receipt_total :=0;END IF;exit when cur_transactions1%NOTFOUND;detail_balance := detail_balance + nvl(curl_trans1.价税合计,0) - nvl(curl_trans1.收款金额,0); --g_costdetail_sale_total := detail_sale_total + nvl(curl_trans1.价税合计,0); --h_costdetail_receipt_total := detail_receipt_total + nvl(curl_trans1.收款金额,0); --z_costfnd_file.put_line(2 ,' <tr class=xl33 style="mso-height-source:userset;">');--------------------------------------------------------------------------------------------------------------if p_output_type = 'Y' then fnd_file.put_line(2 ,' <td class=xl29 style="font-size:11pt">' ||'=T("' ||nvl(to_char(curl_trans1.日期, 'yyyy-mm-dd'),'&' || 'nbsp;') || '")'|| '</td>'); else fnd_file.put_line(2 ,' <td class=xl29 style="font-size:11pt">' ||nvl(to_char(curl_trans1.日期, 'yyyy-mm-dd'),'&' || 'nbsp;') || '</td>');end if; fnd_file.put_line(2, ' <td class=xl29 style="font-size:11pt">' ||NVL(curl_trans1.摘要, ' ') || '</td>');fnd_file.put_line(2, ' <td class=xl29 style="font-size:11pt">' ||NVL(curl_trans1.物料编码, ' ') || '</td>');fnd_file.put_line(2, ' <td class=xl29 style="font-size:11pt; white-space:normal; word-wrap:break-word;">' ||
NVL (curl_trans1.产品名称, ' ') || '</td>');fnd_file.put_line(2, ' <td class=xl29 style="font-size:11pt">' ||NVL(curl_trans1.规格型号, ' ') || '</td>');fnd_file.put_line(2, ' <td class=xl29 style="font-size:11pt">' ||NVL(curl_trans1.单位, ' ') || '</td>');fnd_file.put_line(2, format_number_cell(curl_trans1.数量));fnd_file.put_line(2, format_number_cell(curl_trans1.单价));fnd_file.put_line(2, format_number_cell(curl_trans1.价税合计));fnd_file.put_line(2, format_number_cell(curl_trans1.收款金额)); fnd_file.put_line(2, format_number_cell(detail_balance)); fnd_file.put_line(2, ' <td class=xl29 style="font-size:11pt">' ||NVL(TO_CHAR(curl_trans1.订单号), ' ') || '</td>');fnd_file.put_line(2, ' <td class=xl29 style="font-size:11pt">' ||NVL(curl_trans1.备注, ' ') || '</td>');-- start 产品米重 可能是CHAR 也可能是 NUMBER 财务说这是正常情况 数字需要使用会计模式打印 不能一起转换为CHAR BEGINtemp := TO_NUMBER(curl_trans1.产品米重);fnd_file.put_line(2, format_number_cell(curl_trans1.产品米重));EXCEPTIONWHEN VALUE_ERROR THENfnd_file.put_line(2, ' <td class=xl29 style="font-size:11pt">' ||NVL(curl_trans1.产品米重, ' ') || '</td>');END;-- end -- fnd_file.put_line(2, format_number_cell(curl_trans1.产品长度)); -------------------------------------------------------------------------------------------------------------- fnd_file.put_line(2,' </tr>');END LOOP; --transaction1close cur_transactions1; fnd_file.put_line(2 --原值height:13.5pt,' <tr class=xl33 height=18 style="mso-height-source:userset;height:19pt;font-size:11pt">');-- 打印空行 X 1fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td colspan=1 class=xl39 style="font-size:11pt">合计</td>');-- 打印空行 X 6 fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>'); fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>'); fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>'); -- 打印值 (使用通用数字格式,避免会计专用格式的影响)fnd_file.put_line(2, format_number_cell(detail_sale_total));fnd_file.put_line(2, format_number_cell(detail_receipt_total));fnd_file.put_line(2, format_number_cell(detail_balance));-- 打印空行 X 4 fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>'); fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td class=xl26>&' || 'nbsp;</td>');fnd_file.put_line(2,' </tr>');fnd_file.put_line(2,'</table>'); -- end by jzl 2025.09.17-- 开始表尾容器(不可分割) - 包装所有表尾内容fnd_file.put_line(2, '<div class="table-footer-container">');--表尾区域 fnd_file.put_line(2, '<table width=' || v_page_width || ' border="1" cellspacing="0" bordercolor="black" style="border-collapse:collapse;border-width:0.3mm; ">'); fnd_file.put_line(2 --原值height:13.5pt,' <tr class=xl33 height=18 style="mso-height-source:userset;height:19pt">');-- modified by jzl 2025.09.10 修改 对账结果 标题格式/*fnd_file.put_line(2 --原值colspan=8.5,' <td width="100%" colspan=8 class=xl39 style="font-size:11pt">对账结果</td>');*/fnd_file.put_line(2,' <td width="100%" colspan=15 class=xl39 style="font-size:11pt">' ||'对' || ' ' || '账' || ' ' || '结' || ' ' || '果' ||'</td>');-- end by jzl 2025.09.10 fnd_file.put_line(2,' </tr>');fnd_file.put_line(2 --原值height:100.5pt,' <tr class=xl33 height=18 style="mso-height-source:userset;height:170pt">');fnd_file.put_line(2 --原值class=xl28 style="border-top:none;border-left:none",' <td width="50%" colspan=8 class=xl29 style="vertical-align:top;font-size:11pt;line-height: 1.545;border-right: none;">'|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || '1、对账信息相符。<br><br><br><br><br><br><br><br><br> '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ''|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' 购货单位(公章或财务章)<br>'|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ''|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ''|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '
年'|| '&' || 'nbsp;' || ''|| '&' || 'nbsp;' || '月'|| '&' || 'nbsp;' || ''|| '&' || 'nbsp;' || '日<br> '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || 'x'|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ''|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '||' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' '|| '经办人:</td>');fnd_file.put_line(2 --原值height:23.5pt -> 19pt -> 34pt,' <tr class=xl33 height=36 style="mso-height-source:userset;height:36pt">');daxie_cost :=fsc_apinv2tr_rep_pkg.Amt2Chn(abs(detail_balance)); --g_costif detail_balance < 0 thenfnd_file.put_line(2 --原值style="border-top:none;border-left:none",' <td align="left" colspan=15 class=xl29 style="border-bottom;none;font-size:11pt;line-height:1.6"> '|| '&' || 'nbsp;' || '截止至'||cux_num4chn(v_end_date) || v_customer_tab(v_c_index).customer_name ||'实欠'||v_company_name||'款项合计¥' ||nvl(to_char(detail_balance --g_cost,'999,999,999,990.99'),'&' || 'nbsp;') || '(大写负'||daxie_cost||')。<br>'|| '&' || 'nbsp;' || ' 请贵司收到此对账单7天内给予核对,根据实际对账结果分别填入“对账结果”栏次,盖上贵司公章或财务章回寄至我司。此对账单作为贵司授信额度评级的依据,请贵司给予重视,谢谢! </td>');elsefnd_file.put_line(2 --原值style="border-top:none;border-left:none",' <td align="left" colspan=15 class=xl29 style="border-bottom:none;font-size:11pt;line-height:1.6"> '|| '&' || 'nbsp;' || '截止至'||cux_num4chn(v_end_date) || v_customer_tab(v_c_index).customer_name ||'实欠'||v_company_name||'款项合计¥' ||nvl(to_char(detail_balance --g_cost,'999,999,999,990.99'),'&' || 'nbsp;') || '(大写'||daxie_cost||')。<br>'|| '&' || 'nbsp;' || ' 请贵司收到此对账单7天内给予核对,根据实际对账结果分别填入“对账结果”栏次,盖上贵司公章或财务章回寄至我司。此对账单作为贵司授信额度评级的依据,请贵司给予重视,谢谢! </td>');end if;fnd_file.put_line(2,' </tr>');fnd_file.put_line(2,'</table>');--表尾区域2fnd_file.put_line(2,'<table width=' ||v_page_width || ' border="1" cellspacing="0" bordercolor="black" style="border-collapse:collapse;border-width:0mm; ">');fnd_file.put_line(2 -- 原值class=xl33。height:13.5pt -> 15pt,' <tr height=18 style="mso-height-source:userset;height:19pt">');fnd_file.put_line(2 -- 原值class=xl41,' <td colspan=15 class=xl24 style="font-size:11pt">备注:1、表格中数据不允许作改动,如对数据有异议,经双方协商后重新出具对账单。</td>');fnd_file.put_line(2,' </tr>'); fnd_file.put_line(2 --原值class=xl33。height:13.5pt ->15pt,' <tr height=18 style="mso-height-source:userset;height:19pt">');fnd_file.put_line(2 -- 原值class=xl41,' <td colspan=8 class=xl24 style="font-size:11pt">'|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || '2、以双方签定的对账单为结算货款的凭据,上述所列单据号的送货单据也可作为结算凭据。</td>');fnd_file.put_line(2,' </tr>');begin select rt.nameinto v_tern_namefrom hz_cust_site_uses_all hcsu,RA_TERMS_VL rtwhere hcsu.PAYMENT_TERM_ID = rt.TERM_IDand hcsu.SITE_USE_ID = v_customer_tab(v_c_index).site_use_id;EXCEPTIONWHEN OTHERS THENnull;end;fnd_file.put_line(2,'</table>');--fnd_file.put_line(2 --空1行。原值两行。--,'<br>');END IF; --2) levelEND LOOP; --aEND IF; --1) levelfnd_file.put_line(1 --打印日志,'BEGIN 62 ' || to_char(SYSDATE,'YYYYMMDD :HH24:MI:SS'));-- 结束表尾容器 - 确保所有表尾内容都在容器内fnd_file.put_line(2, '</div>');-- end --fnd_file.put_line(2,'</body>');fnd_file.put_line(2,'</html>');END;
❀表结构打印
PROCEDURE print_detail_title(v_page_width NUMBER,p_page_number VARCHAR2,p_customer_name VARCHAR2,p_company_name VARCHAR2,p_tel VARCHAR2,p_fax VARCHAR2,p_sale_per_desc VARCHAR2,p_customer_number VARCHAR2,p_account_num VARCHAR2 --对账单号,p_created_by NUMBER,p_created_date DATE,p_body_title_flag VARCHAR2 --Y则打印表格表头列名,p_bill_header_flag VARCHAR2 --Y则打印表格上方的单头-- add by jzl 2025.09.23 新增参数,p_buyer_contact_person VARCHAR2,p_buyer_tel VARCHAR2,p_summary_sheet_cls VARCHAR2-- end --) IS-- 变量名字声明区域v_created_by_name VARCHAR2(100);v_request_create_date DATE;BEGIN-- 添加全局样式fnd_file.put_line(2, '<style type="text/css">');fnd_file.put_line(2, 'body { margin: 0; padding: 0; }');fnd_file.put_line(2, 'table { border-collapse: collapse; width: 100%; margin: 0 auto; }');fnd_file.put_line(2, 'td, th { vertical-align: middle; word-wrap: break-word; word-break: break-all; white-space: normal; padding: 2px; }');fnd_file.put_line(2, '/* 表格内容居中 */');fnd_file.put_line(2, '.data-table td, .data-table th { text-align: center !important; }');fnd_file.put_line(2, '/* 表头和表尾保持原有对齐方式(通常是左对齐) */');fnd_file.put_line(2, '.header-table td, .header-table th, .footer-table td, .footer-table th { text-align: left !important; }');fnd_file.put_line(2, '/* 数字列特殊处理 */');fnd_file.put_line(2, '.xl28 { text-align: center !important; }');fnd_file.put_line(2, '</style>');--换页fnd_file.put_line(2 ,'<table><tr height=1 style="page-break-before:always;mso-height-source:userset;height:1pt"></table>');--单头fnd_file.put_line(2 ,'<table class="header-table" width=' ||v_page_width || ' border="1" cellspacing="0" bordercolor="white" style="border-collapse:collapse;border-width:0mm; ">');--增加colgroupfnd_file.put_line(2,' <col class=xl24 width=10%>');fnd_file.put_line(2,' <col class=xl24 width=12%>');fnd_file.put_line(2,' <col class=xl24 width=12%>');fnd_file.put_line(2,' <col class=xl24 width=12%>');fnd_file.put_line(2,' <col class=xl24 width=12%>');fnd_file.put_line(2,' <col class=xl24 width=12%>'); fnd_file.put_line(2,' <col class=xl24 width=15%>');fnd_file.put_line(2,' <col class=xl24 width=15%>'); -- add by jzl 2025.09.17 业务往来对账单标题上面增加一行空白行fnd_file.put_line(2, '<tr><td colspan="8"> </td></tr>'); -- end by jzl 2025.09.17-- add by jzl 2025.09.17 增加取消单头打印IF p_bill_header_flag IN ('Y', 'y') THENIF p_summary_sheet_cls = '0.1' THEN-- 空3列fnd_file.put_line(2,' <td>&' || 'nbsp;</td>'); fnd_file.put_line(2,' <td>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td>&' || 'nbsp;</td>'); ---------------------- fnd_file.put_line(2, '<td colspan="3" style="text-align:center"><font size="5"><strong>业务往来对账单</strong></font></td>');ELSIF p_summary_sheet_cls = '0.2' THEN-- 空5列fnd_file.put_line(2,' <td>&' || 'nbsp;</td>'); fnd_file.put_line(2,' <td>&' || 'nbsp;</td>'); fnd_file.put_line(2,' <td>&' || 'nbsp;</td>');---------------------- fnd_file.put_line(2, '<td colspan="8" style="text-align:center"><font size="5"><strong>业务往来对账单</strong></font></td>');ELSIF p_summary_sheet_cls = '1.1' THEN-- 空8列fnd_file.put_line(2,' <td>&' || 'nbsp;</td>'); fnd_file.put_line(2,' <td>&' || 'nbsp;</td>');fnd_file.put_line(2,' <td>&' || 'nbsp;</td>'); ---------------------- fnd_file.put_line(2, '<td colspan="8" style="text-align:center"><font size="5"><strong>业务往来对账单</strong></font></td>');ELSEfnd_file.put_line(2, '<td colspan="8" style="text-align:center"><font size="5"><strong></strong></font></td>');END IF;ELSEfnd_file.put_line(2, '<td colspan="8" style="text-align:center"><font size="5"><strong></strong></font></td>');END IF;-- end by jzl 2025.09.17 fnd_file.put_line(2,' </tr>'); fnd_file.put_line(2 ,' <tr align="left" height=18 style="mso-height-source:userset;height:19pt">');IF p_bill_header_flag IN ('Y', 'y') THEN-- add by jzl 2025.09.17 增加取消单头打印-- 购货方实现逻辑fnd_file.put_line(2 ,' <td colspan=5 class=xl41 style="height:13.5pt;font-size:11pt" >购货方:' || p_customer_name ||'</td>');fnd_file.put_line(2,' </tr>'); fnd_file.put_line(2 ,' <tr height=18 style="mso-height-source:userset;height:19pt">'); fnd_file.put_line(2,' <td colspan=3 class=xl41 style="font-size:11pt"> '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' 联系人:'|| p_buyer_contact_person ||' </td>'); fnd_file.put_line(2,' <td colspan=3 class=xl41 style="font-size:11pt">TEL:'|| p_buyer_tel ||' </td>'); fnd_file.put_line(2,' </tr>'); fnd_file.put_line(2 ,' <tr height=18 style="mso-height-source:userset;height:19pt">');-- 销货方实现逻辑fnd_file.put_line(2,' <td colspan=5 class=xl41 style="font-size:11pt">销货方:'||p_company_name||'</td>'); fnd_file.put_line(2,' </tr>'); fnd_file.put_line(2 ,' <tr align="left" height=18 style="mso-height-source:userset;height:19pt">'); -- add by jzl 2025.09.09 jzl 新增获取申请人名字IF p_created_by IS NOT NULL THENBEGINSELECT NVL(u.DESCRIPTION, u.USER_NAME)INTO v_created_by_nameFROM fnd_user uWHERE u.USER_ID = p_created_by;fnd_file.put_line(1, '[INFO]:成功找到用户 ' || p_created_by || ' 的描述信息,时间:' || to_char(SYSDATE,'YYYYMMDD :HH24:MI:SS'));EXCEPTIONWHEN NO_DATA_FOUND THENv_created_by_name := '';fnd_file.put_line(1, '[WARING]:未找到用户 ' || p_created_by || ' 的描述信息,时间:' || to_char(SYSDATE,'YYYYMMDD :HH24:MI:SS'));WHEN OTHERS THENv_created_by_name := '';fnd_file.put_line(1, '[ERROR]:查询用户 ' || p_created_by || ' 时发生异常,错误信息:' || SQLERRM || ',时间:' || to_char(SYSDATE,'YYYYMMDD :HH24:MI:SS'));END;ELSEv_created_by_name := '';END IF;-- end by jzl 2025.09.09 jzl fnd_file.put_line(2,' <td colspan=3 class=xl41 style="font-size:11pt"> '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' 制单人:' || v_created_by_name ||' </td>');fnd_file.put_line(2,' <td colspan=3 class=xl41 style="font-size:11pt">TEL:' || p_tel ||' </td>'); fnd_file.put_line(2 ,' <td colspan=3 class=xl41 style="font-size:11pt">邮箱:' || p_fax || '</td>'); fnd_file.put_line(2,' </tr>'); fnd_file.put_line(2 ,' <tr align="left" height=18 style="mso-height-source:userset;height:19pt">');fnd_file.put_line(2,' <td colspan=3 class=xl41 style="font-size:11pt"> '|| '&' || 'nbsp;' || ' '|| '&' || 'nbsp;' || ' ' || '业务员:' ||p_sale_per_desc || '</td>'); fnd_file.put_line(2,' </tr>'); fnd_file.put_line(2,'</table>');END IF;-- 单身标题行 表格列名IF p_body_title_flag IN ('Y', 'y') THENIF p_summary_sheet_cls = '0.1' THENfnd_file.put_line(2, '<table class="data-table" width="' || v_page_width || '" border="1" cellspacing="0" bordercolor="black" style="border-collapse:collapse;border-width:0.3mm;">');fnd_file.put_line(2, ' <tr class="xl33" style="mso-height-source:userset;">');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="font-size:11pt">日期</td>');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">摘要</td>');fnd_file.put_line(2, ' <td width="6%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">发货金额</td>');fnd_file.put_line(2, ' <td width="6%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">收款金额</td>');fnd_file.put_line(2, ' <td width="6%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">应收款余额</td>');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">备注</td>');fnd_file.put_line(2, ' </tr>');ELSIF p_summary_sheet_cls = '0.2' THENfnd_file.put_line(2, '<table class="data-table" width="' || v_page_width || '" border="1" cellspacing="0" bordercolor="black" style="border-collapse:collapse;border-width:0.3mm;">');fnd_file.put_line(2, ' <tr class="xl33" style="mso-height-source:userset;">');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="font-size:11pt">日期</td>');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">摘要</td>');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">物料编码</td>');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">产品名称</td>');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">规格型号</td>');fnd_file.put_line(2, ' <td width="6%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">单位</td>');fnd_file.put_line(2, ' <td width="6%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">数量</td>');fnd_file.put_line(2, ' <td width="6%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">单价</td>');fnd_file.put_line(2, ' <td width="6%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">金额</td>');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">订单号</td>');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">备注</td>');fnd_file.put_line(2, ' <td width="4%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">产品米重</td>');fnd_file.put_line(2, ' <td width="4%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">产品长度</td>');fnd_file.put_line(2, ' </tr>');ELSIF p_summary_sheet_cls = '1.1' THENfnd_file.put_line(2, '<table class="data-table" width="' || v_page_width || '" border="1" cellspacing="0" bordercolor="black" style="border-collapse:collapse;border-width:0.3mm;">');fnd_file.put_line(2, ' <tr class="xl33" style="mso-height-source:userset;">');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="font-size:11pt">日期</td>');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">摘要</td>');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">物料编码</td>');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">产品名称</td>');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">规格型号</td>');fnd_file.put_line(2, ' <td width="6%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">单位</td>');fnd_file.put_line(2, ' <td width="6%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">数量</td>');fnd_file.put_line(2, ' <td width="6%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">单价</td>');fnd_file.put_line(2, ' <td width="6%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">价税合计</td>');fnd_file.put_line(2, ' <td width="6%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">收款金额</td>');fnd_file.put_line(2, ' <td width="6%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">应收款余额</td>');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">订单号</td>');fnd_file.put_line(2, ' <td width="8%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">备注</td>');fnd_file.put_line(2, ' <td width="4%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">产品米重</td>');fnd_file.put_line(2, ' <td width="4%" class="xl36" style="border-bottom:.5pt solid black;font-size:11pt">产品长度</td>');fnd_file.put_line(2, ' </tr>');ELSEfnd_file.put_line(2, '<table class="data-table" width="' || v_page_width || '" border="1" cellspacing="0" bordercolor="black" style="border-collapse:collapse;border-width:0.3mm;">');fnd_file.put_line(2, ' <tr class="xl33" style="mso-height-source:userset;">');fnd_file.put_line(2, ' </tr>');END IF;END IF;END print_detail_title;