#-------------------------
#实现程序模糊查询功能
#-------------------------
FUNCTION udmtree_getcmdrun(ps_cmd_line)
DEFINE ps_cmd_line LIKE type_file.chr1000
DEFINE l_cnt LIKE type_file.num5
DEFINE ls_were LIKE type_file.chr1000
DEFINE l_sql STRING
LET l_cnt = 0
SELECT count(gaz01) INTO l_cnt FROM gaz_file,zz_file
WHERE zz01 = gaz01 AND gaz02 = '2' AND zz011 <> 'MENU' AND gaz01=ps_cmd_line
IF cl_null(l_cnt) THEN LET l_cnt = 0 END IF #
IF l_cnt >0 THEN
RETURN ps_cmd_line
ELSE
LET l_sql =" SELECT count(gaz01) FROM gaz_file,zz_file ",
" WHERE zz01 = gaz01 AND gaz02 = '",g_lang,"' AND zz011 <> 'MENU' ",
" AND (gaz01 LIKE '%",ps_cmd_line,"%' OR gaz03 LIKE '%",ps_cmd_line,"%') "
PREPARE q002_cus102 FROM l_sql
EXECUTE q002_cus102 INTO l_cnt
IF cl_null(l_cnt) THEN LET l_cnt = 0 END IF #
IF l_cnt = 0 THEN
RETURN ps_cmd_line
END IF
END IF
CALL cl_init_qry_var()
LET g_qryparam.form = "q_gaz"
LET g_qryparam.state = "i"
LET g_qryparam.CONSTRUCT = 'N'
LET g_qryparam.arg1 = g_lang
LET g_qryparam.where = " gaz01 LIKE '%",ps_cmd_line,"%' OR gaz03 LIKE '%",ps_cmd_line,"%' "
CALL cl_create_qry() RETURNING g_qryparam.multiret
IF NOT cl_null(g_qryparam.multiret) THEN
LET ps_cmd_line = g_qryparam.multiret
END IF
RETURN ps_cmd_line
END FUNCTION
使用方式:
在程序调用cl_cmdrun((ls_cmd_line) 之前,调用上面这个函数即可
# by caozq
CALL udmtree_getcmdrun(ls_cmd_line) RETURNING ls_cmd_line
# by caozq
#同理,在Ctrol+G 调用cl_cmdask()这个函数的时候加入这一段,也可实现模糊查询功能