鼎捷T100
本次在开发双档作业时,参照样板设计用开窗多选批量插入单身数据
一、设置开窗程式
ON ACTION controlp INFIELD xmybuc001
INITIALIZE g_qryparam.* TO NULL
#判断是否新增,新增则开窗多选,否则视为修改,则单选
IF l_cmd = 'a' THEN
LET g_qryparam.state = 'm' #设为多选
ELSE
LET g_qryparam.state = 'i' #设为单选
END IF
#调用开窗
CALL cq_imaa001()
#根据输出的笔数,来判断是否批量新增
IF l_cmd = 'a' THEN
IF g_qryparam.str_array.getLength() <= 1 THEN
IF g_qryparam.str_array.getLength() = 1 THEN #如果只有一笔是,则取【1】
#将开窗取得的值回传到
LET g_xmybuc_d[l_ac].xmybuc001 = g_qryparam.str_array[1]
ELSE
LET g_xmybuc_d[l_ac].xmybuc001 = g_qryparam.default1
END IF
ELSE
LET l_multi_xmybuc_ins = TRUE #批量插入的标志
CALL cxmt100_unlock_b("xmybuc_t","'1'") #解开单身的锁
CALL s_transaction_end('Y','0')
EXIT DIALOG
END IF
END IF
二、批量插入设置
1、定义标志
#add-point:input段define (請盡量不要在客製環境修改此段落內容, 否則將後續patch的調整需人工處理) name="input.define"
DEFINE l_multi_xmybuc_ins LIKE type_t.num5 #是否有開窗多選料號
#end add-point
2、初始化标志
#add-point:資料輸入前 name="input.before_input"
WHILE TRUE
LET l_multi_xmybuc_ins = FALSE #默认标志为FALSE
#end add-point
3、捕捉标志为TRUE时,调用批量插入程式
#add-point:input段after input name="input.after_input"
#處理料號開窗多選整批新增至單身資料
IF l_multi_xmybuc_ins THEN
LET g_errshow = 0
CALL s_transaction_begin()
IF cxmt100_multi_xmybuc_ins(g_xmyauc_m.xmyaucdocno) THEN #將料號開窗勾選資料,整批寫入訂單單身
CALL s_transaction_end('Y',0)
ELSE
CALL s_transaction_end('N',0)
END IF
LET g_errshow = 1
CALL cxmt100_b_fill()
CONTINUE WHILE
END IF
EXIT WHILE
END WHILE
#end add-point
三、料号开窗多选整批新增至单身资料程式
PRIVATE FUNCTION cxmt100_multi_xmybuc_ins(p_xmyaucdocno)
DEFINE p_xmyaucdocno LIKE xmyauc_t.xmyaucdocno
DEFINE r_success LIKE type_t.num5
DEFINE l_xmybuc_key RECORD
xmybuc001 LIKE xmybuc_t.xmybuc001 #料号
END RECORD
DEFINE l_xmybuc RECORD
xmybucent LIKE xmybuc_t.xmybucent,
xmybucsite LIKE xmybuc_t.xmybucsite,
xmybucdocno LIKE xmybuc_t.xmybucdocno,
xmybucseq LIKE xmybuc_t.xmybucseq,
xmybuc001 LIKE xmybuc_t.xmybuc001,
xmybuc002 LIKE xmybuc_t.xmybuc002,
xmybuc003 LIKE xmybuc_t.xmybuc003,
xmybuc004 LIKE xmybuc_t.xmybuc004,
xmybuc005 LIKE xmybuc_t.xmybuc005
END RECORD
DEFINE l_xmybuc_def RECORD
xmybucent LIKE xmybuc_t.xmybucent,
xmybucsite LIKE xmybuc_t.xmybucsite,
xmybucdocno LIKE xmybuc_t.xmybucdocno,
xmybucseq LIKE xmybuc_t.xmybucseq,
xmybuc001 LIKE xmybuc_t.xmybuc001,
xmybuc002 LIKE xmybuc_t.xmybuc002,
xmybuc003 LIKE xmybuc_t.xmybuc003,
xmybuc004 LIKE xmybuc_t.xmybuc004,
xmybuc005 LIKE xmybuc_t.xmybuc005
END RECORD
DEFINE l_xmybucseq LIKE xmybuc_t.xmybucseq
DEFINE l_i LIKE type_t.num5
DEFINE l_j LIKE type_t.num5
DEFINE l_success LIKE type_t.num5
DEFINE l_imaf016 LIKE imaf_t.imaf016
LET r_success = TRUE
#取得项次资料
SELECT MAX(xmybucseq)
INTO l_xmybucseq FROM xmybuc_t
WHERE xmybucent = g_enterprise
AND xmybucdocno = p_xmyaucdocno
IF cl_null(l_xmybucseq) THEN LET l_xmybucseq = 0 END IF
LET g_error_show = 1
FOR l_i = 1 TO g_qryparam.str_array.getLength()
INITIALIZE l_xmybuc.* TO NULL
INITIALIZE l_xmybuc_key.* TO NULL
LET l_xmybuc_key.xmybuc001 = g_qryparam.str_array[l_i]
LET l_xmybuc.xmybuc001 = l_xmybuc_key.xmybuc001
#料号检查-可以忽略
IF NOT cxmt100_xmybuc001_chk(l_xmybuc_key.xmybuc001) THEN
CONTINUE FOR
ELSE
LET l_imaf016 = ''
SELECT imaf016 INTO l_imaf016
FROM imaf_t
WHERE imafent = g_enterprise
AND imafsite = g_site
AND imaf001 = l_xmybuc_key.xmybuc001
INITIALIZE g_chkparam.* TO NULL
LET g_chkparam.err_str[1] = "abm-00250|",l_imaf016,"|",l_xmybuc_key.xmybuc001
LET g_chkparam.arg1 = l_imaf016
IF NOT cl_chk_exist("v_oocq002_210_1") THEN
LET r_success = FALSE
CONTINUE FOR
END IF
END IF
#料号检查可以忽略
#调用单身初始化程序-比如数量设为0等
CALL cxmt100_xmybuc_default(l_xmybuc.xmybuc001) RETURNING l_xmybuc_def.*
LET l_xmybuc.* = l_xmybuc_def.*
LET l_xmybuc.xmybucseq = l_xmybucseq + 1
INSERT INTO xmybuc_t(xmybucent,xmybucsite,xmybucdocno,xmybucseq,
xmybuc001,xmybuc002,xmybuc003,xmybuc004,xmybuc005)
VALUES(l_xmybuc.xmybucent,l_xmybuc.xmybucsite,l_xmybuc.xmybucdocno,l_xmybuc.xmybucseq,
l_xmybuc.xmybuc001,l_xmybuc.xmybuc002,l_xmybuc.xmybuc003,l_xmybuc.xmybuc004,l_xmybuc.xmybuc005)
IF sqlca.sqlcode THEN
INITIALIZE g_errparam TO NULL
LET g_errparam.code = SQLCA.sqlcode
LET g_errparam.extend = "INSERT xmybuc_t ERROR: xmybuc001:",l_xmybuc.xmybuc001,"xmybucseq:",l_xmybuc.xmybucseq
LET g_errparam.popup = TRUE
CALL cl_err()
LET r_success = FALSE
END IF
LET l_xmybucseq = l_xmybuc.xmybucseq
END FOR
RETURN r_success
END FUNCTION
总结
此功能可以减少很多重复工作