TOPGP5.3:combobox动态下拉

来源:互联网 发布:erp系统属于数据库 编辑:程序博客网 时间:2024/06/01 22:10

一、前言

开发和维护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 zhengzrDATABASE 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代码