/**Begin D:\PDM_UPGRADE\PDM1\MRP_constraint.sql **/
 EXEC P_ALTERPK 'PK_MRP_XPLANORDER', 'T_MRP_XPLANORDER', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MRP_XPLANORDER_FNUM') CREATE INDEX IDX_MRP_XPLANORDER_FNUM ON T_MRP_XPLANORDER ( FBILLNO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MRP_XPLANORDER_ORG') CREATE INDEX IDX_MRP_XPLANORDER_ORG ON T_MRP_XPLANORDER ( FPROORPURORG );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MRP_XPLANORDER_MA') CREATE INDEX IDX_MRP_XPLANORDER_MA ON T_MRP_XPLANORDER ( FMATERIAL );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MRP_XPLANORDER_PL') CREATE INDEX IDX_MRP_XPLANORDER_PL ON T_MRP_XPLANORDER ( FPLANOPERATENUM );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MRP_XPLANORDER_SRC') CREATE INDEX IDX_MRP_XPLANORDER_SRC ON T_MRP_XPLANORDER ( FSOURCEID );


 EXEC P_ALTERPK 'PK_MRP_XPLANORDERENTRY', 'T_MRP_XPLANORDERENTRY', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MRP_XPLANORDERENTRY') CREATE INDEX IDX_MRP_XPLANORDERENTRY ON T_MRP_XPLANORDERENTRY ( FID ,FSEQ );


 EXEC P_ALTERPK 'PK_T_MRP_XPLANORDER_L', 'T_MRP_XPLANORDER_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MRP_XPLANORDER_L') CREATE INDEX IDX_MRP_XPLANORDER_L ON T_MRP_XPLANORDER_L ( FID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_MRP_XPLANORDERCOPENTRY', 'T_MRP_XPLANORDERCOPENTRY', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MRP_XPLANORDERCOPENTRY_FID') CREATE INDEX IDX_MRP_XPLANORDERCOPENTRY_FID ON T_MRP_XPLANORDERCOPENTRY ( FID );


 EXEC P_ALTERPK 'PK_MRP_XPLANORDERCOPENTRY_L', 'T_MRP_XPLANORDERCOPENTRY_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MRP_XPLANORDERCOPENTRY_L') CREATE INDEX IDX_MRP_XPLANORDERCOPENTRY_L ON T_MRP_XPLANORDERCOPENTRY_L ( FENTRYID ,FLOCALEID );


 EXEC P_ALTERPK 'PK_MRP_XPLANORDERLOG', 'T_MRP_XPLANORDERLOG', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MRP_XPLANORDERLOG_SRC') CREATE INDEX IDX_MRP_XPLANORDERLOG_SRC ON T_MRP_XPLANORDERLOG ( FSRCBILLID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MRP_XPLANORDERLOG_XBID') CREATE INDEX IDX_MRP_XPLANORDERLOG_XBID ON T_MRP_XPLANORDERLOG ( FXBILLID );


 EXEC P_ALTERPK 'PK_MRP_XPLANORDERLOGENTRY', 'T_MRP_XPLANORDERLOGENTRY', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_MRP_XPLANORDERLOGENTRY') CREATE INDEX IDX_MRP_XPLANORDERLOGENTRY ON T_MRP_XPLANORDERLOGENTRY ( FID ,FSEQ );



/**End D:\PDM_UPGRADE\PDM1\MRP_constraint.sql **/
