您的位置:首页 > 运维架构

TOPGP5.3:combobox动态下拉

2017-09-04 21:20 549 查看

一、前言

开发和维护TOPGP多年,一直觉得这个系统中的下拉框直接固定写死在4fd画面档中,是个非常恶心的设计,这个过程中也一直有浮现过想要自己写一个动态下拉框动态配置档的想法,但是一直拖着,终于在前段时间写了。

以下就按部就班,将开发过程写出来,其实非常简单的一个东西,早在几年前就应该做了。

二、建立数据表

/*
================================================================================
檔案代號:tc_dic_file
檔案名稱:下拉列表数据字典
檔案目的:
上游檔案:
下游檔案:
檔案類型:B
多語系檔案:N
============.========================.==========================================
*/
create table tc_dic_file
(
tc_dic001   varchar2(10) NOT NULL,   /*所属程序代号                           */
tc_dic002   varchar2(10) NOT NULL,   /*字段代号                               */
tc_dic003   number(5) NOT NULL,      /*序号                                   */
tc_dic004   varchar2(10),            /*Value                                  */
tc_dic005   varchar2(255),           /*Item                                   */
tc_dicacti  varchar2(1)              /*资料有效码                             */
);

alter table tc_dic_file add  constraint tpc_dic_pk primary key  (tc_dic001,tc_dic002,tc_dic003) enable validate;
grant select on tc_dic_file to tiptopgp;
grant update on tc_dic_file to tiptopgp;
grant delete on tc_dic_file to tiptopgp;
grant insert on tc_dic_file to tiptopgp;
grant index on tc_dic_file to public;
grant select on tc_dic_file to ods;


三、建立画面档4fd

注:整合在文章尾部资源下载链接中

四、建立程序代码4gl

注:整合在文章尾部资源下载链接中

五、共用初始化函数4gl

1、代码片段

# Prog. Version..: '5.30.15-14.10.14(00000)'     #
#
# Program name...: cl_set_combo_items_gae.4gl
# Descriptions...: 動態設定ComboBox的Item.
# Date & Author..: 17/07/24 by zhengzr

DATABASE ds

GLOBALS "../../config/top.global"

FUNCTION cl_set_combo_items_plus(ps_field_name,p_tc_dic001,p_tc_dic002)
DEFINE ps_field_name    STRING
DEFINE p_tc_dic001      LIKE tc_dic_file.tc_dic001
DEFINE p_tc_dic002      LIKE tc_dic_file.tc_dic002
DEFINE l_sql            STRING
DEFINE ps_values        LIKE ze_file.ze03
DEFINE ps_items         LIKE ze_file.ze03

WHENEVER ERROR CALL cl_err_msg_log

LET l_sql =
"SELECT to_char(wm_concat(tc_dic004)),to_char(wm_concat(tc_dic004||':'||tc_dic005)) ",
"  FROM tc_dic_file ",
" WHERE tc_dic001='",p_tc_dic001,"' ",
"   AND tc_dic002 = '",p_tc_dic002,"' ",
" ORDER BY tc_dic003 "
PREPARE pre_001 FROM l_sql
EXECUTE pre_001 INTO ps_values,ps_items

CALL cl_set_combo_items(ps_field_name, ps_values, ps_items)
END FUNCTION


2、函数说明

cl_set_combo_items_plus(ps_field_name,p_tc_dic001,p_tc_dic002)

参数说明:

ps_field_name:当前画面上需要设置动态下拉的“字段代号”

p_tc_dic001:cooi800中设置的“所属程序代号”

p_tc_dic002:cooi800中设置的“字段代号”

六、使用演示

1、设置动态下拉项目



2、在4GL代码中增加初始化代码



3、效果展示



七、下载链接

1、动态下拉框数据表建立schema

2、动态下拉框配置档4gl逻辑代码

3、动态下拉框配置档4fd画面代码

4、动态下拉框公用初始化函数4gl代码
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  topgp tiptop 4gl combobox