--Order 20012430
alter table PURCHASEORDERLINE add EXT_PURCHASEORDERLINE_ID number;
comment on column PURCHASEORDERLINE.EXT_PURCHASEORDERLINE_ID
  is 'External Purchase Orderline ID';

alter table ERP_I_PURCHASEORDERHEADER add EXPORTDATE date;

--When it is already null allowed no problem
alter table ERP_O_WORKORDERLINEMEBLEM modify PURCHASEORDERLINE_ID null;


alter table WORKORDER
  drop constraint CHK_WORKORDER_ERP_EXP;
alter table WORKORDER
  add constraint CHK_WORKORDER_ERP_EXP
  check (ERP_EXPORTED in (0,10,20,30,40));


create table ERP_O_TRIGGER
(
  ERP_O_TABLENAME VARCHAR2(32) not null,
  ERP_O_ID        NUMBER not null,
  ERP_O_STATUS    VARCHAR2(2) not null
);
-- Create/Recreate indexes 
create index INDX_ERP_O_TRIGGER on ERP_O_TRIGGER (ERP_O_TABLENAME, ERP_O_ID, ERP_O_STATUS);