-- 委外采购领料单增加成组字段
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OSMREQOUTBILLENTRY' AND KSQL_COL_NAME ='FGROUPNUMBER')
 ALTER TABLE T_IM_OSMREQOUTBILLENTRY ADD (FGROUPNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL );

 IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IM_OSMREQOUTBILLENTRY' AND KSQL_COL_NAME ='FGROUPSEQ')
 ALTER TABLE T_IM_OSMREQOUTBILLENTRY ADD (FGROUPSEQ 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 ='FGROUPNUMBER')
 ALTER TABLE T_IM_MDC_MQBENTRY ADD (FGROUPNUMBER 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 ='FGROUPSEQ')
 ALTER TABLE T_IM_MDC_MQBENTRY ADD (FGROUPSEQ 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 ='FGROUPNUMBER')
 ALTER TABLE T_IM_MDC_OMOUTBILLENTRY ADD (FGROUPNUMBER 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 ='FGROUPSEQ')
 ALTER TABLE T_IM_MDC_OMOUTBILLENTRY ADD (FGROUPSEQ 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 ='FGROUPNUMBER')
 ALTER TABLE T_IM_MDCOM_MQBENTRY ADD (FGROUPNUMBER 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 ='FGROUPSEQ')
 ALTER TABLE T_IM_MDCOM_MQBENTRY ADD (FGROUPSEQ 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 ='FGROUPNUMBER')
 ALTER TABLE T_IM_MDC_PRBLENTRY ADD (FGROUPNUMBER 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 ='FGROUPSEQ')
 ALTER TABLE T_IM_MDC_PRBLENTRY ADD (FGROUPSEQ NVARCHAR(50) DEFAULT ' ' NOT NULL );