/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\AR_constraint.sql **/
 EXEC P_ALTERPK 'PK_T_AR_ACCRUALAGINGENTRY', 'T_AR_ACCRUALAGINGENTRY', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_AR_ACCRUALAGING', 'T_AR_ACCRUALAGING', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_AR_ACCRUALAGING_NUMBER') CREATE INDEX IDX_AR_ACCRUALAGING_NUMBER ON T_AR_ACCRUALAGING ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_AR_ACCRUALAGING_L', 'T_AR_ACCRUALAGING_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_AR_ACCRUALENTITYOBJ', 'T_AR_ACCRUALENTITYOBJ', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_AR_ACCENTITY_NUMBER') CREATE INDEX IDX_AR_ACCENTITY_NUMBER ON T_AR_ACCRUALENTITYOBJ ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_AR_ACCRUALENTITYOBJ_L', 'T_AR_ACCRUALENTITYOBJ_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_AR_ACCRUALPLANENTRY_L', 'T_AR_ACCRUALPLANENTRY_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_AR_BADDEBTACCRUALPLAN', 'T_AR_BADDEBTACCRUALPLAN', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_AR_ACCPLAN_FNUMBER') CREATE INDEX IDX_AR_ACCPLAN_FNUMBER ON T_AR_BADDEBTACCRUALPLAN ( FNUMBER );


 EXEC P_ALTERPK 'PK_T_AR_BADDEBTACCRUALPLAN_L', 'T_AR_BADDEBTACCRUALPLAN_L', 'FPKID', '1';

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


 EXEC P_ALTERPK 'PK_T_AR_ACCRUALCUSTOMER', 'T_AR_ACCRUALCUSTOMER', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_AR_ACCCUSTOMER_ENTRYID') CREATE INDEX IDX_AR_ACCCUSTOMER_ENTRYID ON T_AR_ACCRUALCUSTOMER ( FENTRYID );


 EXEC P_ALTERPK 'PK_T_AR_BADDEBTACCRUE', 'T_AR_BADDEBTACCRUE', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_AR_BADDEBT_PERIOD_ORG') CREATE INDEX IDX_AR_BADDEBT_PERIOD_ORG ON T_AR_BADDEBTACCRUE ( FPERIODID ,FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_AR_BADDEBT_ORG') CREATE INDEX IDX_AR_BADDEBT_ORG ON T_AR_BADDEBTACCRUE ( FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_AR_BADDEBT_SCHEME') CREATE INDEX IDX_AR_BADDEBT_SCHEME ON T_AR_BADDEBTACCRUE ( FACCRUALSCHEMEID );


 EXEC P_ALTERPK 'PK_T_AR_BADDEBTACCRUEENTRY', 'T_AR_BADDEBTACCRUEENTRY', 'FENTRYID', '1';

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


 EXEC P_ALTERPK 'PK_T_AR_BADDEBTPREPAREENTRY', 'T_AR_BADDEBTPREPAREENTRY', 'FENTRYID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_AR_BDPE_SRCIDENTRYID') CREATE INDEX IDX_AR_BDPE_SRCIDENTRYID ON T_AR_BADDEBTPREPAREENTRY ( FSRCBILLID ,FSRCENTRYID );


 EXEC P_ALTERPK 'PK_T_AR_BADDEBTPREPARE', 'T_AR_BADDEBTPREPARE', 'FID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_AR_BDP_PERIOD_ORG') CREATE INDEX IDX_AR_BDP_PERIOD_ORG ON T_AR_BADDEBTPREPARE ( FPERIODID ,FORGID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_AR_BDP_FACCRUALDATE') CREATE INDEX IDX_AR_BDP_FACCRUALDATE ON T_AR_BADDEBTPREPARE ( FACCRUALDATE );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_AR_BDP_ORG') CREATE INDEX IDX_AR_BDP_ORG ON T_AR_BADDEBTPREPARE ( FORGID );



 EXEC P_ALTERPK 'PK_T_AR_ACCRUALPLANENTRY', 'T_AR_ACCRUALPLANENTRY', 'FENTRYID', '1';

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

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_AR_ACCPLANENTRY_ENTITY') CREATE INDEX IDX_AR_ACCPLANENTRY_ENTITY ON T_AR_ACCRUALPLANENTRY ( FACCRUALENTITYOBJID );

 EXEC P_ALTERPK 'PK_T_AR_BUSVERIFYRECORD', 'T_AR_BUSVERIFYRECORD', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_AR_BUSVR_FNUMBER') CREATE INDEX IDX_AR_BUSVR_FNUMBER ON T_AR_BUSVERIFYRECORD ( FWFNUMBER );


 EXEC P_ALTERPK 'PK_T_AR_BUSVERIFYRECORDENTRY', 'T_AR_BUSVERIFYRECORDENTRY', 'FENTRYID', '1';

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

/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\AR_constraint.sql **/
