Reportno和reportgrp都是内置的系统参数,在session的script中可以直接引用。这里有一个最近的例子做一个介绍:使用reportno来控制程序执行的逻辑。
我们经常用到在一个session中有多个report的情况,在这些report中会有一些数据是来源于不同的程序,而不是仅仅是layout的不同。
那么这时候我们可以采用的一个方法就是通过reportno来控制程序的执行。当然了你可以采用其他的更好的方法来实现这种需求,这里是为了介绍reportno的需要来做一个session。
需求如下:
1、Logistic Department要求建立一个session用来导出Item bonded percentage(采购料件的进口比例)用来报关,用户可以输入Currency来定义non-bonded BP,同时可以选择Item Range.
2、导出的report有两个,其中一个从AML中取出数据,并且同时导出Multi-Level BOM List(包括FG和Purchase Item即可)。
3、第二个report从ISI(Item Suppliers Information)取出所有采购件的进口比例数据。
4、报表的格式必须包含如下信息:
Item Code Bonded Percentage
——————————————–
ALC-04000001 20%
程序主要用到的表:
Report1:
tcibd001 Item General Data
fifam003 Item Supplier’s by Approved Manufacturer
tibom010 Production BOMs
tccom100 Business Partners
Report2:
tcidb001 Item General Data
tdipu010 Item Supplier Information
tccom100 Business Partners
可以看到第一个report是要先导出BOM的多级物料单(底层物料只要采购件),然后再从AML中读出每个Supplier的Volume,并且对非本地货币的供应商的Volume进行累加。
第二个report直接导出Purchase Item的列表,然后再从ISI里找出每个item\supplier对应的Sourcing Percentage,并且对非本地货币的供应商的Sourcing Percentage进行累加。
这两个报表的逻辑和数据表没有办法统一在一个逻辑里,这里只好写出不同的逻辑,根据报表类型进行判断。
报表的判断程序如下:
|***************************** choice sections *********************************<br/>choice.print.data:<br/>on.choice:<br/>| message("reportno is %d",reportno) | Troy 2006-02-23<br/> if reportno = 1 then | Troy 2006-02-23<br/> convert.print.selection.data()<br/> START.DLL.UI(print.report, IFERRMSG, "tccom99997")<br/> else | Troy 2006-02-23<br/> rprt_open() | Troy 2006-02-23<br/> get.purchase.item() | Troy 2006-02-23<br/> rprt_close() | Troy 2006-02-23<br/> endif | Troy 2006-02-23
报表1的主要程序:
导出BOM的主程序略过,
function get.kitm()<br/>{<br/> select tcibd001.kitm,tcibd001.item<br/> from tcibd001<br/> where tcibd001._index1 = {:tibom010.sitm}<br/> as set with 1 rows<br/> selectdo<br/> kitm.g=tcibd001.kitm<br/> kitm.out=enum.descr$("tckitm",kitm.g,"2")<br/>| message("Item Type is %s",kitm.out)<br/> if tcibd001.kitm = tckitm.purchase then<br/>| message("%s",currency)<br/> get.currency.percentage.g()<br/> endif<br/> selectempty<br/> endselect<br/>}
function get.currency.Percentage.g()<br/>{<br/> Percentage.Out = ""<br/> select fifam003.volu<br/> from fifam003,tccom100<br/> where fifam003._index1 = {:tcibd001.item}<br/> and tccom100.bpid = fifam003.bpid<br/> and fifam003.stat = fistat.actv<br/> and fifam003.sern <> 1<br/> as set with 1 rows<br/> selectdo<br/><br/> Percentage.g = 0<br/> select fifam003.volu<br/> from fifam003,tccom100<br/> where fifam003._index1 = {:tcibd001.item}<br/> and tccom100.bpid = fifam003.bpid<br/> and fifam003.stat = fistat.actv<br/> and tccom100.ccur <> :currency<br/> and fifam003.sern <> 1<br/> selectdo<br/> Percentage.g = Percentage.g + fifam003.volu<br/> selectempty<br/> Percentage.g = 0<br/> endselect<br/> Percentage.Out = str$(Percentage.g)<br/> Percentage.Out = concat$("%",Percentage.Out,"")<br/> selectempty<br/> Percentage.Out = "No AVL"<br/> endselect<br/><br/><br/>}
报表2的主要程序:
function get.purchase.item()<br/>{<br/>| message("From:%s,to:%s",item.f,item.t)<br/> select tcibd001.item,tcibd001.kitm,tcibd001.dsca<br/> from tcibd001<br/> where tcibd001.kitm = tckitm.purchase | Item Type Purchase<br/> and tcibd001.item >= :item.f | Item Range<br/> and tcibd001.item <= :item.t | Item Range<br/> selectdo<br/> item.pur = tcibd001.item<br/> get.isi.bonded.percentage.g()<br/> selectempty<br/> endselect<br/>}
function get.isi.bonded.percentage.g()<br/>{<br/>| message("Pur Item:%s",item.pur)<br/> Percentage.Out = ""<br/>| eff.date=utc.num() | Redefine the Effective Date<br/> select tdipu010.item<br/> from tdipu010,tcibd001<br/> where tdipu010.item =&
nbsp;:item.pur | Item Range<br/> and tdipu010.item = tcibd001.item | Item Code<br/> and tdipu010.citg = tcibd001.citg | Item Group<br/> and tdipu010.efdt <= :eff.date | Effective Date<br/> and tdipu010.exdt >= :eff.date | Expiration Date<br/> as set with 1 rows<br/> selectdo<br/>| message("Pur Item:%s",item.pur)<br/> Percentage.g = 0<br/> select tdipu010.srcp<br/> from tdipu010,tcibd001,tccom100<br/> where tdipu010.item = :item.pur | Item Range<br/> and tdipu010.item = tcibd001.item | Item Code<br/> and tdipu010.citg = tcibd001.citg | Item Group<br/> and tdipu010.efdt <= :eff.date | Effective Date<br/> and tdipu010.exdt >= :eff.date | Expiration Date<br/> and tdipu010.otbp = tccom100.bpid | BP Code<br/> and tccom100.ccur <>:currency | Currency<br/> selectdo<br/> Percentage.g = Percentage.g + tdipu010.srcp<br/> selectempty<br/> Percentage.g = Percentage.g<br/> endselect<br/> Percentage.Out = str$(Percentage.g)<br/> Percentage.Out = concat$("%",Percentage.Out,"")<br/> selectempty<br/> Percentage.Out = "No ISI!"<br/> endselect<br/> rprt_send() |Troy 2006-02-23<br/><br/>}
版权所有,转载请注明出处:[URL=http://www.cuiwenyuan.com/baan]http://www.cuiwenyuan.com/baan/[/URL],本文同时发在[URL=http://www.xihome.com]西山之家[/URL]