在一些情况如审核状态开启单身其中一个栏位可编辑,或者某些用户权限只能编辑其中几个栏位等等。如果使用cl_set_comp_entry来控制代码非常的不简洁。
如在b()函数使用 只允许 x,msbud22栏位输入 #CALL cl_set_table_entry("x,msbud22","s_msb") RETURNING l_entry CALL cl_set_table_entry("x,msbud22","") RETURNING l_entry 在b()函数结束编辑以后恢复之前的状态 CALL cl_set_restore_entry(l_entry) ## Prog. Version..: '5.10.08-09.06.11(00003)' # ## ## Program name...: cl_set_table_entry.4gl ## Descriptions...: 传入的栏位可输入其他不可输入 ## Date & Author..: 2021/4/18 21:06:55 wq DATABASE ds GLOBALS "../../config/top.global" ## Descriptions...: 設定元件是否可輸入. ## Date & Author..: 2021/4/18 21:09:16 ## Input Parameter: ps_fields STRING 要設定元件是否可輸入的欄位名稱字串(中間以逗點分隔) ## ps_table 为空值 那么将控制单身所有的table输入状态 ## Usage..........: CALL cl_set_comp_entry("m01,m03,m07", "") ## 输入table name控制指定的单身 ## Usage..........: CALL cl_set_comp_entry("m01,m03,m07", "s_table") ## Return Code....: 返回编辑状态前的原始 编辑记录方便后面恢复之前的状态 FUNCTION cl_set_table_entry(ps_fields,ps_table) DEFINE ps_fields,ps_table STRING DEFINE n1,n2 om.NodeList DEFINE r,r1,n om.DomNode DEFINE i,j INTEGER DEFINE l_name,l_name1,l_name2 STRING DEFINE lst_fields base.StringTokenizer, ls_field_name STRING DEFINE r_entry STRING LET r = ui.Interface.getRootNode() IF cl_null(ps_table) THEN LET n1 = r.selectByTagName("TableColumn") ELSE LET n2 = r.selectByPath("//Table[@name="" || ps_table || ""]") LET r1 = n2.item(1) LET n1 = r1.selectByTagName("TableColumn") END IF FOR i=1 to n1.getLength() LET n = n1.item(i) LET l_name = n.getAttribute("name") LET j = n.getAttribute("noEntry") IF j IS NULL THEN LET j= 0 END IF LET r_entry = r_entry, l_name||','||j||'|' LET lst_fields = base.StringTokenizer.create(ps_fields, ",") WHILE lst_fields.hasMoreTokens() LET ls_field_name = lst_fields.nextToken() LET ls_field_name = ls_field_name.trim() LET l_name1 = "formonly."||ls_field_name LET l_name2 = "formonly.b_"||ls_field_name IF l_name = ls_field_name OR l_name = l_name1 OR l_name = l_name2 THEN CALL n.setAttribute("noEntry",0) EXIT WHILE ELSE CALL n.setAttribute("noEntry",1) END IF END WHILE END FOR RETURN r_entry END FUNCTION ##Descriptions...: 恢复之前的状态. ##Date & Author..: 2021/4/18 21:09:16 ##Input Parameter: ps_fields STRING ##Usage..........: CALL cl_set_restore_entry(r_entry) ##Return Code....: no FUNCTION cl_set_restore_entry(ps_fields) DEFINE ps_fields STRING DEFINE n1 om.NodeList DEFINE r,n om.DomNode DEFINE i,spos,epos,j INTEGER DEFINE l_name STRING DEFINE lst_fields base.StringTokenizer, ls_field_name STRING LET r = ui.Interface.getRootNode() LET lst_fields = base.StringTokenizer.create(ps_fields, "|") WHILE lst_fields.hasMoreTokens() LET ls_field_name = lst_fields.nextToken() LET l_name = ls_field_name.trim() LET spos = l_name.getIndexOf(",",1) LET epos = l_name.getLength() LET ls_field_name = l_name.subString(1,spos-1) LET j = l_name.subString(spos+1,epos) LET n1 = r.selectByPath("//TableColumn[@name="" || ls_field_name || ""]") IF n1 IS NOT NULL THEN LET n = n1.item(1) CALL n.setAttribute("noEntry",j) END IF END WHILE END FUNCTION |
|
沙发#
发布于:2021-04-19 19:24
不错不错
|
|
板凳#
发布于:2021-04-20 16:46
汝之秀,吾不及也
|
|
地板#
发布于:2021-04-21 17:34
|
|
4楼#
发布于:2022-03-17 11:22
汝之秀,吾不及也
|
|
5楼#
发布于:2023-02-28 09:00
汝之秀,吾不及也
|
|