CREATE VIEW "SBODEMODE"."B1_ElectronicDocumentView" ( "AbsEntry", "Code", "ActType", "ActStatus", "ActDesc", "ActMessage", "ActEnv", "Branch", "SrcObjType", "SrcObjAbs", "Submits", "SendDate", "RecvDate", "UserSign", "CreateDate", "CreateTS", "UserSign2", "UpdateDate", "IsRemoved", "Cancelation", "SendData", "RecvData", "ReportID", "DocNum", "Series", "DocCanceled", "CardCode", "CardName", "LicTradNum", "DocCreateDate", "DocCreateTime", "IsDraft", "DocBranch", "DocDate", "TaxDate", "VatDate", "FolNumFrom", "FolNumTo", "AssignedID" ) AS SELECT T0."AbsEntry", T0."Code", T0."ActType", T0."ActStatus", T0."ActDesc", T0."ActMessage", T0."ActEnv", T0."BPLId" AS "Branch", T0."SrcObjType", T0."SrcObjAbs", T0."Submits", T2."LogOpDate" AS "SendDate", T3."LogOpDate" AS "RecvDate", T0."UserSign", T0."CreateDate", T0."CreateTS", T0."UserSign2", T0."UpdateDate", T0."IsRemoved", T0."Cancel" AS "Cancelation", T2."LogData" AS "SendData", T3."LogData" AS "RecvData", T0."ReportID", T1."DocNum", T1."Series", T1."CANCELED" AS "DocCanceled", T1."CardCode", T1."CardName", T1."LicTradNum", T1."CreateDate" AS "DocCreateDate", T1."CreateTS" AS "DocCreateTime", T1."IsDraft", T1."BPLId" AS "DocBranch", T1."DocDate", T1."TaxDate", T1."VatDate", T1."FolNumFrom", T1."FolNumTo", T0."AssignedID" FROM  "SBODEMODE"."ECM2" T0   LEFT OUTER  JOIN "SBODEMODE"."B1_AllDocumentsView_EDF" T1  ON  T1."ObjType" = T0."SrcObjType"  AND  T1."DocEntry" = T0."SrcObjAbs"  AND  ((T1."IsDraft" = 'Y'  AND  T0."ActType" = 5 ) OR  (T1."IsDraft" = 'N'  AND  T0."ActType" IN(3 ,4 ,11 ,12 ,13 ,14 ,15 )  ))   LEFT OUTER  JOIN "SBODEMODE"."B1_EDFLatestLogsView" T2  ON  T2."AbsEntry" = T0."AbsEntry"  AND  T2."LogType" = 'S'    LEFT OUTER  JOIN "SBODEMODE"."B1_EDFLatestLogsView" T3  ON  T3."AbsEntry" = T0."AbsEntry"  AND  T3."LogType" = 'R' WITH READ ONLY