由系统自动生成单号(日期+流水),用户新增、修改时不允许编辑单号;
范例(cxmt631):
1)在#单头栏位开启设定#中,即 cxmt631_set_entry(p_cmd)下:
#add-point:Function前置處理 name="set_entry.pre_function"
{
#end add-point
IF p_cmd = "a" THEN
CALL cl_set_comp_entry("xmabucdocno",TRUE)
#根據azzi850使用者身分開關特定欄位
IF NOT cl_null(g_no_entry) THEN
CALL cl_set_comp_entry(g_no_entry,TRUE)
END IF
#add-point:set_entry段欄位控制 name="set_entry.field_control"
}
IF p_cmd = "a" THEN
CALL cl_set_comp_entry("xmabucdocno",FALSE)
#根據azzi850使用者身分開關特定欄位
IF NOT cl_null(g_no_entry) THEN
CALL cl_set_comp_entry(g_no_entry,TRUE)
END IF
#end add-point
END IF
a表示新增, CALL cl_set_comp_entry("xmabucdocno",FALSE) 表示设定控件是否可输入;原先是true允许输入,被注释掉改为false;
2)在#单头栏位关闭设定#,即 cxmt631_set_no_entry(p_cmd)下(以下代码原本就有,非客制):
IF p_cmd = 'u' AND g_chkey = 'N' THEN
CALL cl_set_comp_entry("xmabucdocno",FALSE)
#根據azzi850使用者身分開關特定欄位
IF NOT cl_null(g_no_entry) THEN
CALL cl_set_comp_entry(g_no_entry,FALSE)
END IF
#add-point:set_no_entry段欄位控制 name="set_no_entry.field_control"
#end add-point
END IF
u表示修改;
r表示复制;
以上两个函数均为在cxmt631_input 中被调用;
3)在cxmt631_input 中,置入当新增时,调用自定义函数生成单号的指令:
#add-point:input開始前 name="input.before.input"
IF p_cmd = 'a' THEN
call cxmt631_test_xmabucdocno()
END IF
#end add-point
4)自定义函数 cxmt631_test_xmabucdocno()
PRIVATE FUNCTION cxmt631_test_xmabucdocno()
DEFINE
l_slip LIKE type_t.chr30,
l_yy LIKE type_t.chr30,
l_date LIKE type_t.chr30,
l_chr LIKE type_t.chr30,
l_verno LIKE type_t.chr30,
l_sql string
#LET l_slip = "cxm-"
LET l_yy = g_today USING 'YYYY'
let l_yy = g_today using 'mm'
LET l_yy = g_today USING 'dd'
LET l_date = g_today using 'yyyymmdd'
LET l_chr = l_date CLIPPED
LET l_sql = "SELECT MAX(SUBSTR(xmabucdocno,LENGTH(xmabucdocno)-2,3)) ",
" FROM xmabuc_t ",
" WHERE SUBSTR(xmabucdocno,1,LENGTH(xmabucdocno)-3) = '",l_chr,"'"
PREPARE t101_pr2 FROM l_sql
EXECUTE t101_pr2 INTO l_verno
IF cl_null(l_verno) THEN
LET g_xmabuc_m.xmabucdocno = l_chr,"001"
ELSE
LET l_verno = l_verno + 1
LET g_xmabuc_m.xmabucdocno = l_chr,l_verno USING '&&&'
END IF
END FUNCTION