本人从事Tiptop 二次开发有两年的时间,类属于 菜鸟级别, 今天整理出之前写过的一类报表,
仅是笔记整理,和对以后开发做参考。欢迎指正。
一、 时间2012-09月份, 遇到生管工程师报表需求;
每一个料件,对应的每一个工作站的前置工时等资料。抓取出并导成excle,供经理查看。
由需求和数据资料总结、平常报表实现不了他要的报表格式。需通过把行数据转换成列实现。
二、画面档制作,跟平时其他报表制作方法一样,不需要做其他额外特别操作。
画面的操作无需说明, 主要是程序逻辑的控制修改。
三、4gl修改。
4gl 列字段整理
LET g_sql = "ecb01.ecb_file.ecb01,", #料号 -- 对应的视图表stb
"ecb02.ecb_file.ecb02,", #工艺编号
"UC1.ecb_file.ecb19,", #UC 前置工时
"UC2.ecb_file.ecb19,",
"UB1.ecb_file.ecb19,", #UB 前置工时
"UB2.ecb_file.ecb19,",
"UA1.ecb_file.ecb19,", #UA 前置工时
"UA2.ecb_file.ecb19,",
"D1.ecb_file.ecb19,", #D 前置工时
"D2.ecb_file.ecb19,",
"UE1.ecb_file.ecb19,", #UE 前置工时
"UE2.ecb_file.ecb19,",
"UI1.ecb_file.ecb19,", #UI 前置工时
"UI2.ecb_file.ecb19,",
"F1.ecb_file.ecb19,", #D 前置工时
"F2.ecb_file.ecb19,", # 等 所需的所有字段。
四:报表 主函数说明:
设定两个 临时表:sr1 , sr2。
主程序逻辑 部分。 查询 表中数据,塞入sr1, 如果是第一个次读数据,则清空对应栏位的值为0.
否则,更新对应料件的 每个工作站 对应的 前置工时,直到循环结束每个工作站的工时资料。
=============================================================================
FUNCTION asfr714()
DEFINE l_name LIKE type_file.chr20, #No.FUN-680121 VARCHAR(20)# External(Disk)
file name
# l_time LIKE type_file.chr8 #No.FUN-6A0090
l_sql LIKE type_file.chr1000, # RDSQL STATEMENT #No.FUN-680121
VARCHAR(1100)
l_chr LIKE type_file.chr1, #No.FUN-680121 VARCHAR(1)
l_ecm14 LIKE ecm_file.ecm14,
l_shb05 LIKE shb_file.shb05,
l_shb10 LIKE shb_file.shb10,
l_tot LIKE shb_file.shb111, #No.FUN-680121 DEC(12,3)
l_count,l_i LIKE type_file.num5, #No.FUN-680121 SMALLINT
l_cmd,l_cmd1 LIKE type_file.chr1000, #No.FUN-680121 VARCHAR(300)
l_cnt LIKE type_file.num5,
l_ecb01 LIKE ecb_file.ecb01, #add by chenqb 2012-9-20
l_ecb02 LIKE ecb_file.ecb02, #add by chenqb 2012-9-20
l_flag LIKE type_file.chr1, #add by chenqb 2012-9-20
sr1 RECORD
ecb01 LIKE ecb_file.ecb01, #料号
ecb02 LIKE ecb_file.ecb02, #工艺编号
ecb08 LIKE ecb_file.ecb08, #工作站
u1 LIKE ecb_file.ecb19,
u2 LIKE ecb_file.ecb19
END RECORD,
sr2 RECORD
ecb01 LIKE ecb_file.ecb01, #料号
ecb02 LIKE ecb_file.ecb02, #工艺编号
UC1 LIKE ecb_file.ecb19,
UC2 LIKE ecb_file.ecb19,
UB1 LIKE ecb_file.ecb19,
UB2 LIKE ecb_file.ecb19,
UA1 LIKE ecb_file.ecb19,
UA2 LIKE ecb_file.ecb19,
D1 LIKE ecb_file.ecb19,
D2 LIKE ecb_file.ecb19,
UE1 LIKE ecb_file.ecb19,
UE2 LIKE ecb_file.ecb19,
UI1 LIKE ecb_file.ecb19,
UI2 LIKE ecb_file.ecb19,
F1 LIKE ecb_file.ecb19,
F2 LIKE ecb_file.ecb19,
UV1 LIKE ecb_file.ecb19,
UV2 LIKE ecb_file.ecb19,
UW1 LIKE ecb_file.ecb19,
UW2 LIKE ecb_file.ecb19,
UX1 LIKE ecb_file.ecb19,
UX2 LIKE ecb_file.ecb19,
UY1 LIKE ecb_file.ecb19,
UY2 LIKE ecb_file.ecb19,
UG1 LIKE ecb_file.ecb19,
UG2 LIKE ecb_file.ecb19,
UJ1 LIKE ecb_file.ecb19,
UJ2 LIKE ecb_file.ecb19,
U1_null LIKE ecb_file.ecb19,
U2_null LIKE ecb_file.ecb19
END RECORD
CALL cl_del_data(l_table)
#------------------------------ CR (2) ------------------------------#
#end FUN-720005 add
SELECT zo02 INTO g_company FROM zo_file WHERE zo01 = g_rlang
SELECT zz05 INTO g_zz05 FROM zz_file WHERE zz01 = g_prog ### FUN-720005 add ###
#----------------------by gaozk 2012-09-18 sql 中抓取 表中的数据 ----------------
LET l_sql = " SELECT ecb01,ecb02,ecb08,(sum(ecb18))/60 u1,sum(ecb21) u2 ",
" FROM ecb_file ",
" WHERE ecb08!='FQC' AND ",tm.wc CLIPPED ,
" GROUP BY ecb01,ecb02,ecb08",
" order by ecb01,ecb02,ecb08 "
#---------------------------END -------------------------
PREPARE r714_prepare1 FROM l_sql
IF SQLCA.sqlcode != 0 THEN
CALL cl_err('prepare:',SQLCA.sqlcode,1)
CALL cl_used(g_prog,g_time,2) RETURNING g_time #No.FUN-690123
EXIT PROGRAM
END IF
#--------------------by gaozk 12-09-18-------
LET l_flag = 'N' #表示第一次读取数据
DECLARE r718_curs1 CURSOR FOR r714_prepare1
FOREACH r718_curs1 INTO sr1.*
IF SQLCA.sqlcode != 0 THEN
CALL cl_err('foreach:',SQLCA.sqlcode,1)
EXIT FOREACH
END IF
#-------------------
IF l_flag = 'N' THEN
LET sr2.ecb01 = sr1.ecb01
LET sr2.ecb02 = sr1.ecb02
LET sr2.D1 = 0
LET sr2.D2 = 0
LET sr2.F1 = 0
LET sr2.F2 = 0
LET sr2.UA1 = 0
LET sr2.UA2 = 0
LET sr2.UB1 = 0
LET sr2.UB2 = 0
LET sr2.UC1 = 0
LET sr2.UC2 = 0
LET sr2.UE1 = 0
LET sr2.UE2 = 0
LET sr2.UG1 = 0
LET sr2.UG2 = 0
LET sr2.UI1 = 0
LET sr2.UI2 = 0
LET sr2.UJ1 = 0
LET sr2.UJ2 = 0
LET sr2.UV1 = 0
LET sr2.UV2 = 0
LET sr2.UW1 = 0
LET sr2.UW2 = 0
LET sr2.UX1 = 0
LET sr2.UX2 = 0
LET sr2.UY1 = 0
LET sr2.UY2 = 0
LET sr2.U1_null = 0
LET sr2.U2_null = 0
LET l_flag = 'Y'
END IF
IF sr2.ecb01=sr1.ecb01 AND sr2.ecb02=sr1.ecb02 THEN
CASE sr1.ecb08
WHEN "D"
LET sr2.D1 = sr1.u1
LET sr2.D2 = sr1.u2
WHEN "F"
LET sr2.F1 = sr1.u1
LET sr2.F2 = sr1.u2
WHEN "UA"
LET sr2.UA1 = sr1.u1
LET sr2.UA2 = sr1.u2
WHEN "UB"
LET sr2.UB1 = sr1.u1
LET sr2.UB2 = sr1.u2
WHEN "UC"
LET sr2.UC1 = sr1.u1
LET sr2.UC2 = sr1.u2
WHEN "UE"
LET sr2.UE1 = sr1.u1
LET sr2.UE2 = sr1.u2
WHEN "UG"
LET sr2.UG1 = sr1.u1
LET sr2.UG2 = sr1.u2
WHEN "UI"
LET sr2.UI1 = sr1.u1
LET sr2.UI2 = sr1.u2
WHEN "UJ"
LET sr2.UJ1 = sr1.u1
LET sr2.UJ2 = sr1.u2
WHEN "UV"
LET sr2.UV1 = sr1.u1
LET sr2.UV2 = sr1.u2
WHEN "UW"
LET sr2.UW1 = sr1.u1
LET sr2.UW2 = sr1.u2
WHEN "UX"
LET sr2.UX1 = sr1.u1
LET sr2.UX2 = sr1.u2
WHEN "UY"
LET sr2.UY1 = sr1.u1
LET sr2.UY2 = sr1.u2
OTHERWISE
LET sr2.U1_null = sr2.U1_null + sr1.u1
LET sr2.U2_null = sr2.U2_null + sr1.u2
END CASE
ELSE
# *** 與 Crystal Reports 串聯段 - <<<< 寫入暫存檔 >>>>
EXECUTE insert_prep USING
sr2.ecb01,sr2.ecb02,sr2.UC1,sr2.UC2,sr2.UB1,sr2.UB2,
sr2.UA1,sr2.UA2,sr2.D1,sr2.D2,sr2.UE1,sr2.UE2,sr2.UI1,
sr2.UI2,sr2.F1,sr2.F2,sr2.UV1,sr2.UV2,sr2.UW1,sr2.UW2,
sr2.UX1,sr2.UX2,sr2.UY1,sr2.UY2,sr2.UG1,sr2.UG2,sr2.UJ1,
sr2.UJ2,sr2.U1_null,sr2.U2_null
LET sr2.ecb01 = sr1.ecb01
LET sr2.ecb02 = sr1.ecb02
LET sr2.D1 = 0
LET sr2.D2 = 0
LET sr2.F1 = 0
LET sr2.F2 = 0
LET sr2.UA1 = 0
LET sr2.UA2 = 0
LET sr2.UB1 = 0
LET sr2.UB2 = 0
LET sr2.UC1 = 0
LET sr2.UC2 = 0
LET sr2.UE1 = 0
LET sr2.UE2 = 0
LET sr2.UG1 = 0
LET sr2.UG2 = 0
LET sr2.UI1 = 0
LET sr2.UI2 = 0
LET sr2.UJ1 = 0
LET sr2.UJ2 = 0
LET sr2.UV1 = 0
LET sr2.UV2 = 0
LET sr2.UW1 = 0
LET sr2.UW2 = 0
LET sr2.UX1 = 0
LET sr2.UX2 = 0
LET sr2.UY1 = 0
LET sr2.UY2 = 0
LET sr2.U1_null = 0
LET sr2.U2_null = 0
CASE sr1.ecb08
WHEN "D"
LET sr2.D1 = sr1.u1
LET sr2.D2 = sr1.u2
WHEN "F"
LET sr2.F1 = sr1.u1
LET sr2.F2 = sr1.u2
WHEN "UA"
LET sr2.UA1 = sr1.u1
LET sr2.UA2 = sr1.u2
WHEN "UB"
LET sr2.UB1 = sr1.u1
LET sr2.UB2 = sr1.u2
WHEN "UC"
LET sr2.UC1 = sr1.u1
LET sr2.UC2 = sr1.u2
WHEN "UE"
LET sr2.UE1 = sr1.u1
LET sr2.UE2 = sr1.u2
WHEN "UG"
LET sr2.UG1 = sr1.u1
LET sr2.UG2 = sr1.u2
WHEN "UI"
LET sr2.UI1 = sr1.u1
LET sr2.UI2 = sr1.u2
WHEN "UJ"
LET sr2.UJ1 = sr1.u1
LET sr2.UJ2 = sr1.u2
WHEN "UV"
LET sr2.UV1 = sr1.u1
LET sr2.UV2 = sr1.u2
WHEN "UW"
LET sr2.UW1 = sr1.u1
LET sr2.UW2 = sr1.u2
WHEN "UX"
LET sr2.UX1 = sr1.u1
LET sr2.UX2 = sr1.u2
WHEN "UY"
LET sr2.UY1 = sr1.u1
LET sr2.UY2 = sr1.u2
OTHERWISE
LET sr2.U1_null = sr2.U1_null + sr1.u1
LET sr2.U2_null = sr2.U2_null + sr1.u2
END CASE
END IF
END FOREACH
# *** 與 Crystal Reports 串聯段 - <<<< 寫入暫存檔 >>>>
EXECUTE insert_prep USING
sr2.ecb01,sr2.ecb02,sr2.UC1,sr2.UC2,sr2.UB1,sr2.UB2,
sr2.UA1,sr2.UA2,sr2.D1,sr2.D2,sr2.UE1,sr2.UE2,sr2.UI1,
sr2.UI2,sr2.F1,sr2.F2,sr2.UV1,sr2.UV2,sr2.UW1,sr2.UW2,
sr2.UX1,sr2.UX2,sr2.UY1,sr2.UY2,sr2.UG1,sr2.UG2,sr2.UJ1,
sr2.UJ2,sr2.U1_null,sr2.U2_null
#str FUN-720005 add
## **** 與 Crystal Reports 串聯段 - <<<< CALL cs3() >>>> FUN-720005 **** ##
LET l_sql = "SELECT * FROM ",g_cr_db_str CLIPPED,l_table CLIPPED #FUN-710080 modify
#是否列印選擇條件
IF g_zz05 = 'Y' THEN
CALL cl_wcchp(tm.wc,'ecb01,ecb02')
RETURNING tm.wc
LET g_str = tm.wc
END IF
CALL cl_prt_cs3('csfr718','csfr718',l_sql,g_str) #FUN-710080 modify
#------------------------------ CR (4) ------------------------------#
#end FUN-720005 add
END FUNCTION
五、CR报表 XML档 字段与4gl 里字段对应。
=========================== END bygaozk2012-09 ============================
日子会继续,技术也要不停的学习,每一次的回头,都看到自己走过的每一个昨天、
尽管艰辛,但自己都觉得值得、
以后会越来越好,加油!