CREATE VIEW "SBODEMODE"."B1_ElectronicDocumentLogViewBR" ( "AbsEntry", "ActType", "ActStatus", "DocNum", "Serial", "DocDate", "SeqCode", "NfeSeries", "NfeModel", "TaxId0", "CardCode", "CardName", "CountryS", "CityS", "AssignedID", "Submits", "MdCreateDate", "UserSign", "ActMessage", "EnvType", "ObjType", "DocEntry", "SrcObjType", "SrcObjAbs", "NFeNoFrom", "NFeNoTo", "Year", "Reason", "CreateTS", "CreateDate", "CreateTime", "Code", "ObjectID", "ReportID", "BPLId", "DocBtch", "DocBtchLn", "SendDate", "RecvDate", "Carrier", "SendData", "RecvData", "IsRemoved", "CANCELED", "EDocGenTyp", "Cancel", "UpdateDate", "SendTime" ) AS SELECT T1."AbsEntry", T1."ActType", T1."ActStatus", T2."DocNum", T2."Serial", T2."DocDate", COALESCE(T2."SeqCode", T5."SeqCode") AS "SeqCode", COALESCE(T2."SeriesStr", T6."SeriesStr") AS "NfeSeries", COALESCE(T2."Model", T6."Model") AS "NfeModel", T4."TaxId0", COALESCE(T2."CardCode", T7."CardCode") AS "CardCode", COALESCE(T2."CardName", T7."CardName") AS "CardName", T3."CountryS", T3."CityS", T1."AssignedID", T1."Submits", T2."CreateDate" AS "MdCreateDate", T1."UserSign", T1."ActMessage", COALESCE(T6."EnvTypeNFe", T1."ActEnv") AS "EnvType", T2."ObjType", T2."DocEntry", T1."SrcObjType", T1."SrcObjAbs", T5."NFeNoFrom", T5."NFeNoTo", T5."Year", T5."Reason", COALESCE(T2."CreateTS", T5."CreateTime") AS "CreateTS", T1."CreateDate", T1."CreateTS" AS "CreateTime", T1."Code", T1."ObjectID", T1."ReportID", COALESCE(T2."BPLId", T6."BPLId") AS "BPLId", T1."DocBtch", T1."DocBtchLn", T8."LogOpDate" AS "SendDate", T9."LogOpDate" AS "RecvDate", T3."Carrier", T8."LogData" AS "SendData", T9."LogData" AS "RecvData", T1."IsRemoved", T2."CANCELED", T2."EDocGenTyp", T1."Cancel", T1."UpdateDate", T8."LogOpTS" AS "SendTime" FROM  "SBODEMODE"."OECM" T0  INNER  JOIN "SBODEMODE"."ECM2" T1  ON  T1."Code" = T0."Code"    LEFT OUTER  JOIN "SBODEMODE"."B1_AllDocumentsView_EDF" T2  ON  T2."ObjType" = T1."SrcObjType"  AND  T2."DocEntry" = T1."SrcObjAbs"  AND  ((T2."IsDraft" = 'Y'  AND  T1."ActType" = 5 ) OR  (T2."IsDraft" = 'N'  AND  T1."ActType" IN(3 ,4 ,11 ,12 ,13 ,14 ,15 )  ))   LEFT OUTER  JOIN "SBODEMODE"."B1_Doc12AddressView" T3  ON  T3."ObjectType" = T1."SrcObjType"  AND  T3."DocEntry" = T1."SrcObjAbs"    LEFT OUTER  JOIN "SBODEMODE"."CRD7" T4  ON  T4."CardCode" = T2."CardCode"  AND  T4."Address" = ''    LEFT OUTER  JOIN "SBODEMODE"."NFN5" T5  ON  TO_CHAR(T5."SeqCode") = T1."SrcObjType"  AND  T5."VisOrder" = T1."SrcObjAbs"    LEFT OUTER  JOIN "SBODEMODE"."NFN1" T6  ON  T6."SeqCode" = T5."SeqCode"    LEFT OUTER  JOIN "SBODEMODE"."OCRD" T7  ON  T7."DocEntry" = T1."SrcObjAbs"  AND  T1."ActType" = 10    LEFT OUTER  JOIN "SBODEMODE"."B1_EDFLatestLogsView" T8  ON  T8."AbsEntry" = T1."AbsEntry"  AND  T8."LogType" = 'S'    LEFT OUTER  JOIN "SBODEMODE"."B1_EDFLatestLogsView" T9  ON  T9."AbsEntry" = T1."AbsEntry"  AND  T9."LogType" = 'R' WITH READ ONLY