#define addtlsetup
#include 'Rptstub.lib'
#include '{libpath}tkit_batchstartup.inc'
#include '{libpath}tkit_rptheader.inc'
#include '{libpath}tkit_queappl.inc'
#include '{libpath}tkit_vars_opts.inc'
#include '{libpath}tkit_Sqrfunc.inc'
!配置报表整体特征,即格式布局
begin-setup
Declare-layout batch-land
rientation=landscape
left-margin=0
top-margin=0
max-lines=60
max-columns=180
end-declare
end-setup
!主过程调用其它子过程
begin-procedure osi-main
do query_a_1 !子过程
do query_a_2
end-procedure
!查询a=1 子过程,用于主过程osi-main调用,此类思想同于java及oracle
begin-procedure query_a_1
let $out1='查询1'||'.LIS'
new-report $out1
begin-select
position (+1)
a &a1
move &a1 to #a1
print #a1 (,20,10) edit 9
b &b1
move &b1 to #b1
print #b1 (,40,10) edit 9
from osibank.zxytestsqr z where z.a=1
end-select
end-procedure
!查询a=2
begin-procedure query_a_2
let $out2='查询2'||'.LIS'
new-report $out2
begin-select
position (+1)
a &a2
move &a2 to #a2
print #a2 (,60,10) edit 9
b &b2
move &b2 to #b2
print #b2 (,80,10) edit 9
from osibank.zxytestsqr z where z.a=2
end-select
end-procedure
begin-procedure OSI-Startup
End-procedure
示例结果:
生成2个文件分别为:
查询1.lis
查询2.lis
| --在上述代码基础上,添加判断分支,根据不同判断决定是否打印不同的LIS文件 代码如下: #define addtlsetup #include 'Rptstub.lib' #include '{libpath}tkit_batchstartup.inc' #include '{libpath}tkit_rptheader.inc' #include '{libpath}tkit_queappl.inc' #include '{libpath}tkit_vars_opts.inc' #include '{libpath}tkit_Sqrfunc.inc' begin-setup Declare-layout batch-land rientation=landscape left-margin=0 top-margin=0 max-lines=60 max-columns=180 end-declare end-setup !主过程调用其它子过程 begin-procedure osi-main begin-select count(*) &a_1_rowcount from osibank.zxytestsqr z where z.a=1 end-select begin-select count(*) &a_2_rowcount from osibank.zxytestsqr z where z.a=2 end-select if &a_1_rowcount>0 do query_a_1 end-if if &a_2_rowcount>0 do query_a_2 end-if end-procedure !查询a=1 begin-procedure query_a_1 let $out1='查询1'||'.LIS' new-report $out1 begin-select position (+1) a &a1 move &a1 to #a1 print #a1 (,20,10) edit 9 b &b1 move &b1 to #b1 print #b1 (,40,10) edit 9 from osibank.zxytestsqr z where z.a=1 end-select end-procedure !查询a=2 begin-procedure query_a_2 let $out2='查询2'||'.LIS' new-report $out2 begin-select position (+1) a &a2 move &a2 to #a2 print #a2 (,60,10) edit 9 b &b2 move &b2 to #b2 print #b2 (,80,10) edit 9 from osibank.zxytestsqr z where z.a=2 end-select end-procedure begin-procedure OSI-Startup End-procedure |
上述代码产生的结果,就会变成:
如果判断有值,就产生对应的报表lis文件,否则不会产生