IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PLANORDERCOPENTRY') 
 CREATE TABLE T_MRP_PLANORDERCOPENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FCOPENTRYTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCOPENTRYMATERIAL BIGINT DEFAULT 0 NOT NULL,
FCOPENTRYVERSION BIGINT DEFAULT 0 NOT NULL,
FCOPENTRYUNIT BIGINT DEFAULT 0 NOT NULL,
FCOPENTRYQTY DECIMAL(23,10)	DEFAULT 0 NOT NULL,
FCOPENTRYALLQTY DECIMAL(23,10)	DEFAULT 0 NOT NULL,
FCOPENTRYOPERATION BIGINT 		DEFAULT 0 NOT NULL,
FCOPENTRYVALIDDATE DATETIME,
FCOPENTRYINVALIDDATE DATETIME,
FCOPENTRYAUXPROPERTY BIGINT 		DEFAULT 0 NOT NULL

);


EXEC P_ALTERPK 'PK_MRP_PLANORDERCOPENTRY', 'T_MRP_PLANORDERCOPENTRY', 'FENTRYID', '1';   

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_MRP_PLANORDERCOPENTRY_L') 
CREATE TABLE T_MRP_PLANORDERCOPENTRY_L
(
  FPKID     NVARCHAR(18) DEFAULT ' ' NOT NULL,
  FENTRYID  BIGINT 		DEFAULT 0 NOT NULL,
  FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
  FCOPENTRYREMARK   NVARCHAR(255) DEFAULT ' ' NOT NULL
);
EXEC P_ALTERPK 'PK_MRP_PLANORDERCOPENTRY_L', 'T_MRP_PLANORDERCOPENTRY_L', 'FPKID', '1';  
