create table SAP_PSP_AAE (
    "UUID" raw(16),
    "AAE" varchar2(36 char),
    "SAP_PSP_UUID" raw(16),
    "PR_ID" varchar2(18 char),
    "EFFORT_PLAN" number,
    "EFFORT_ACT" number,
    "EFFORT_REM" number,
    "EFFORT_PLAN_PLANTA" number,
    "EFFORT_ACT_PLANTA" number,
    "EFFORT_REM_PLANTA" number,
    "COSTS_PLAN" number,
    "COSTS_ACT" number,
    "COSTS_REM" number,
    "COSTS_PLAN_PLANTA" number,
    "COSTS_ACT_PLANTA" number,
    "COSTS_REM_PLANTA" number,
    "BUDGET" number,
    "CREATED_ON" date,
    "MODIFIED_ON" date,
    "RWDU" number(5,0),
    "CREATED_BY" varchar2(20 char),
    "MODIFIED_BY" varchar2(20 char),
    "OWN_LIC" varchar2(4 char),
    "OPC" varchar2(8 char),
    "OWNER" number(5,0),
    "GROUP" number(5,0),
    "ANY" number(5,0)
);


alter table SAP_PSP_AAE add constraint PID975DT975 primary key ("UUID");

alter table SAP_PSP_AAE
    add constraint FKSAP_PSP_AAEID963
    foreign key ("SAP_PSP_UUID")
    references DT963
    on delete cascade
    deferrable
    novalidate;
alter table SAP_PSP_AAE enable validate constraint FKSAP_PSP_AAEID963;


create index IDX_SAP_PSP_AAEID963 on SAP_PSP_AAE ("SAP_PSP_UUID");

alter table SAP_PSP_AAE MODIFY ("UUID" DEFAULT SYS_GUID());

alter table SAP_PSP_AAE
    add constraint DT975UUID_NOT_NULL check("UUID" is not null);

alter table SAP_PSP_AAE modify ("AAE" not null);
alter table SAP_PSP_AAE MODIFY ("EFFORT_PLAN" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("EFFORT_ACT" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("EFFORT_REM" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("EFFORT_PLAN_PLANTA" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("EFFORT_ACT_PLANTA" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("EFFORT_REM_PLANTA" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("COSTS_PLAN" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("COSTS_ACT" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("COSTS_REM" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("COSTS_PLAN_PLANTA" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("COSTS_ACT_PLANTA" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("COSTS_REM_PLANTA" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("BUDGET" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("CREATED_ON" DEFAULT TO_DATE('01.01.1970','DD.MM.YYYY'));
alter table SAP_PSP_AAE MODIFY ("MODIFIED_ON" DEFAULT TO_DATE('01.01.1970','DD.MM.YYYY'));
alter table SAP_PSP_AAE MODIFY ("RWDU" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("OWNER" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("GROUP" DEFAULT 0);
alter table SAP_PSP_AAE MODIFY ("ANY" DEFAULT 0);


create table SAP_PSP_AAE_REPORT (
    "UUID" raw(16),
    "AAE" varchar2(36 char),
    "SAP_PSP_REP_UUID" raw(16),
    "PR_ID" varchar2(18 char),
    "REPORT_ID" varchar2(10 char),
    "EFFORT_PLAN" number,
    "EFFORT_ACT" number,
    "EFFORT_REM" number,
    "EFFORT_PLAN_PLANTA" number,
    "EFFORT_ACT_PLANTA" number,
    "EFFORT_REM_PLANTA" number,
    "COSTS_PLAN" number,
    "COSTS_ACT" number,
    "COSTS_REM" number,
    "COSTS_PLAN_PLANTA" number,
    "COSTS_ACT_PLANTA" number,
    "COSTS_REM_PLANTA" number,
    "BUDGET" number,
    "CREATED_ON" date,
    "MODIFIED_ON" date,
    "RWDU" number(5,0),
    "CREATED_BY" varchar2(20 char),
    "MODIFIED_BY" varchar2(20 char),
    "OWN_LIC" varchar2(4 char),
    "OPC" varchar2(8 char),
    "OWNER" number(5,0),
    "GROUP" number(5,0),
    "ANY" number(5,0)
);

alter table SAP_PSP_AAE_REPORT add constraint PID976DT976 primary key ("UUID", "AAE", "SAP_PSP_REP_UUID", "PR_ID", "REPORT_ID");

alter table SAP_PSP_AAE_REPORT
    add constraint FKSAP_PSP_AAE_REPORTID974
    foreign key ("SAP_PSP_REP_UUID", "PR_ID", "REPORT_ID")
    references DT974
    on delete cascade
    deferrable
    novalidate;
alter table SAP_PSP_AAE_REPORT enable validate constraint FKSAP_PSP_AAE_REPORTID974;

create index IDX_SAP_PSP_AAE_REPORTID974 on SAP_PSP_AAE_REPORT ("SAP_PSP_REP_UUID", "PR_ID", "REPORT_ID");

alter table SAP_PSP_AAE_REPORT MODIFY ("UUID" DEFAULT SYS_GUID());

alter table SAP_PSP_AAE_REPORT
    add constraint DT976UUID_NOT_NULL check("UUID" is not null);

alter table SAP_PSP_AAE_REPORT
    add constraint DT976AAE_NOT_NULL check("AAE" is not null);

alter table SAP_PSP_AAE_REPORT
    add constraint DT976SAP_PSP_REP_UUID_NOT_NULL check("SAP_PSP_REP_UUID" is not null);

alter table SAP_PSP_AAE_REPORT
    add constraint DT976PR_ID_NOT_NULL check("PR_ID" is not null);

alter table SAP_PSP_AAE_REPORT
    add constraint DT976REPORT_ID_NOT_NULL check("REPORT_ID" is not null);

alter table SAP_PSP_AAE_REPORT MODIFY ("EFFORT_PLAN" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("EFFORT_ACT" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("EFFORT_REM" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("EFFORT_PLAN_PLANTA" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("EFFORT_ACT_PLANTA" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("EFFORT_REM_PLANTA" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("COSTS_PLAN" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("COSTS_ACT" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("COSTS_REM" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("COSTS_PLAN_PLANTA" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("COSTS_ACT_PLANTA" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("COSTS_REM_PLANTA" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("BUDGET" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("CREATED_ON" DEFAULT TO_DATE('01.01.1970','DD.MM.YYYY'));
alter table SAP_PSP_AAE_REPORT MODIFY ("MODIFIED_ON" DEFAULT TO_DATE('01.01.1970','DD.MM.YYYY'));
alter table SAP_PSP_AAE_REPORT MODIFY ("RWDU" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("OWNER" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("GROUP" DEFAULT 0);
alter table SAP_PSP_AAE_REPORT MODIFY ("ANY" DEFAULT 0);