-- 简单委外入库单
-- 字段1：业务协同号  bizcoopno  ，fbizcoopno  ，文本，长度50
--字段2：业务协同行ID  bizcoopentryid，fbizcoopentryid，Long
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_OMINBILLENTRY' AND KSQL_COL_NAME ='FBIZCOOPNO') 
 ALTER TABLE T_IM_MDC_OMINBILLENTRY ADD (FBIZCOOPNO NVARCHAR(50) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_OMINBILLENTRY' AND KSQL_COL_NAME ='FBIZCOOPENTRYID') 
 ALTER TABLE T_IM_MDC_OMINBILLENTRY ADD (FBIZCOOPENTRYID BIGINT DEFAULT 0 NOT NULL );
 
 --委外完工入库单
 -- 字段1：业务协同号  bizcoopno  ，fbizcoopno  ，文本，长度50
--字段2：业务协同行ID  bizcoopentryid，fbizcoopentryid，Long
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_OMCPBILLENTRY' AND KSQL_COL_NAME ='FBIZCOOPNO') 
 ALTER TABLE T_IM_MDC_OMCPBILLENTRY ADD (FBIZCOOPNO NVARCHAR(50) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_OMCPBILLENTRY' AND KSQL_COL_NAME ='FBIZCOOPENTRYID') 
 ALTER TABLE T_IM_MDC_OMCPBILLENTRY ADD (FBIZCOOPENTRYID BIGINT DEFAULT 0 NOT NULL );
 
--完工入库单(制造模板)
-- 字段1：业务协同号  bizcoopno  ，fbizcoopno  ，文本，长度50
--字段2：业务协同行ID  bizcoopentryid，fbizcoopentryid，Long 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_PRBLENTRY' AND KSQL_COL_NAME ='FBIZCOOPNO') 
 ALTER TABLE T_IM_MDC_PRBLENTRY ADD (FBIZCOOPNO NVARCHAR(50) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_PRBLENTRY' AND KSQL_COL_NAME ='FBIZCOOPENTRYID') 
 ALTER TABLE T_IM_MDC_PRBLENTRY ADD (FBIZCOOPENTRYID BIGINT DEFAULT 0 NOT NULL );
 
 
 -- 简单委外领料单
 -- 字段1：业务协同号  bizcoopno  ，fbizcoopno  ，文本，长度50
--字段2：业务协同行ID  bizcoopentryid，fbizcoopentryid，Long 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDCOM_MQBENTRY' AND KSQL_COL_NAME ='FBIZCOOPNO') 
 ALTER TABLE T_IM_MDCOM_MQBENTRY ADD (FBIZCOOPNO NVARCHAR(50) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDCOM_MQBENTRY' AND KSQL_COL_NAME ='FBIZCOOPENTRYID') 
 ALTER TABLE T_IM_MDCOM_MQBENTRY ADD (FBIZCOOPENTRYID BIGINT DEFAULT 0 NOT NULL );
 
  -- 委外领料单
 -- 字段1：业务协同号  bizcoopno  ，fbizcoopno  ，文本，长度50
--字段2：业务协同行ID  bizcoopentryid，fbizcoopentryid，Long 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_OMOUTBILLENTRY' AND KSQL_COL_NAME ='FBIZCOOPNO') 
 ALTER TABLE T_IM_MDC_OMOUTBILLENTRY ADD (FBIZCOOPNO NVARCHAR(50) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_OMOUTBILLENTRY' AND KSQL_COL_NAME ='FBIZCOOPENTRYID') 
 ALTER TABLE T_IM_MDC_OMOUTBILLENTRY ADD (FBIZCOOPENTRYID BIGINT DEFAULT 0 NOT NULL );

 --生产领料单
  -- 字段1：业务协同号  bizcoopno  ，fbizcoopno  ，文本，长度50
--字段2：业务协同行ID  bizcoopentryid，fbizcoopentryid，Long 
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_MQBENTRY' AND KSQL_COL_NAME ='FBIZCOOPNO') 
 ALTER TABLE T_IM_MDC_MQBENTRY ADD (FBIZCOOPNO NVARCHAR(50) DEFAULT ' ' NOT NULL );
 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_MDC_MQBENTRY' AND KSQL_COL_NAME ='FBIZCOOPENTRYID') 
 ALTER TABLE T_IM_MDC_MQBENTRY ADD (FBIZCOOPENTRYID BIGINT DEFAULT 0 NOT NULL );