oracle sqr之不同判斷寫入不同的.LIS檔案

wisdomone1發表於2011-12-19
!標頭檔案,公有模板的預定義
#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檔案,否則不會產生


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-713575/,如需轉載,請註明出處,否則將追究法律責任。

相關文章