-- B1 DEPENDS: AFTER:PT:PROCESS_END

create procedure TmSp_ZZZ_VIEW_B1_OinmWithBinTransfer
LANGUAGE SQLSCRIPT 
SQL SECURITY INVOKER
AS
cnt int;
sqlStr nvarchar(50000);
BEGIN
	select count (*) into cnt from "PUBLIC"."VIEWS" where "VIEW_NAME" = 'B1_OinmWithBinTransfer' AND "SCHEMA_NAME" = CURRENT_SCHEMA;
	if :cnt > 0 then
		sqlStr := ('drop view "B1_OinmWithBinTransfer"');
		exec (:sqlStr);
	end if;
	
	sqlStr := 'CREATE VIEW "B1_OinmWithBinTransfer" ( "TransNum",
	 "TransType",
	 "CreatedBy",
	 "BASE_REF",
	 "DocLineNum",
	 "DocDate",
	 "DocDueDate",
	 "CardCode",
	 "CardName",
	 "Ref1",
	 "Ref2",
	 "Comments",
	 "JrnlMemo",
	 "DocTime",
	 "ItemCode",
	 "Dscription",
	 "InQty",
	 "OutQty",
	 "Price",
	 "Currency",
	 "Rate",
	 "VendorNum",
	 "SerialNum",
	 "Warehouse",
	 "TreeType",
	 "SlpCode",
	 "TaxDate",
	 "DataSource",
	 "PrjCode",
	 "UserSign",
	 "BlockNum",
	 "ImportLog",
	 "UseDocPric",
	 "Location",
	 "CalcPrice",
	 "OpenQty",
	 "Instance",
	 "LastInst",
	 "RevalTotal",
	 "BaseCurr",
	 "ApplObj",
	 "AppObjAbs",
	 "AppObjType",
	 "StockAct",
	 "TrnsfrAct",
	 "PriceDifAc",
	 "VarianceAc",
	 "ReturnAct",
	 "ExcRateAct",
	 "ClearAct",
	 "CostAct",
	 "WipAct",
	 "Balance",
	 "CreateDate",
	 "BaseLine",
	 "TransValue",
	 "PriceDiff",
	 "TransSeq",
	 "InvntAct",
	 "RemMethod",
	 "OpenValue",
	 "SubLineNum",
	 "AppObjLine",
	 "Expenses",
	 "OpenExp",
	 "Allocation",
	 "OpenAlloc",
	 "ExpAlloc",
	 "OExpAlloc",
	 "OpenPDiff",
	 "ExchDiff",
	 "OpenEDiff",
	 "NegInvAdjs",
	 "OpenNegInv",
	 "NegStckAct",
	 "BTransVal",
	 "VarVal",
	 "BExpVal",
	 "CogsVal",
	 "BNegAVal",
	 "IOffIncAcc",
	 "IOffIncVal",
	 "DOffDecAcc",
	 "DOffDecVal",
	 "DecAcc",
	 "DecVal",
	 "WipVal",
	 "WipVarAcc",
	 "WipVarVal",
	 "IncAct",
	 "IncVal",
	 "ExpCAcc",
	 "CostMethod",
	 "OcrCode",
	 "BaseQty",
	 "PrevTrans",
	 "HTransSeq",
	 "OcrCode2",
	 "OcrCode3",
	 "OcrCode4",
	 "OcrCode5",
	 "StgSeqNum",
	 "StgEntry",
	 "StgDesc",
	 "InvPLInQty",
	 "InvPLOutQty",
	 "InvPLPrice",
	 "InvPLCurrency",
	 "InvPLRate",
	 "InvPLLayerID",
	 "InvPLMessageID",
	 "InvPLSubLineNum",
	 "SnBType" ) AS ((((((((SELECT
	 T3."TransNum" AS "TransNum",
	 T0."TransType" AS "TransType",
	 T0."CreatedBy" AS "CreatedBy",
	 T0."BASE_REF" AS "BASE_REF",
	 T0."DocLineNum" AS "DocLineNum",
	 T0."DocDate" AS "DocDate",
	 T4."DocDueDate" AS "DocDueDate",
	 T4."BPCardCode" AS "CardCode",
	 T4."CardName" AS "CardName",
	 T4."Ref1" AS "Ref1",
	 T4."Ref2" AS "Ref2",
	 T4."Comment" AS "Comments",
	 T4."JrnlMemo" AS "JrnlMemo",
	 T0."CreateTime" AS "DocTime",
	 T0."ItemCode" AS "ItemCode",
	 T4."Dscription" AS "Dscription",
	 T1."LayerInQty" AS "InQty",
	 T1."LayerOutQ" AS "OutQty",
	 T0."Price" AS "Price",
	 T0."Currency" AS "Currency",
	 T0."Rate" AS "Rate",
	 T4."VendorNum" AS "VendorNum",
	 T4."SerialNum" AS "SerialNum",
	 T0."LocCode" AS "Warehouse",
	 T4."TreeType" AS "TreeType",
	 T4."SlpCode" AS "SlpCode",
	 T4."TaxDate" AS "TaxDate",
	 T4."DataSource" AS "DataSource",
	 T4."PrjCode" AS "PrjCode",
	 T4."UserSign" AS "UserSign",
	 T4."BlockNum" AS "BlockNum",
	 T4."ImportLog" AS "ImportLog",
	 T4."UseDocPric" AS "UseDocPric",
	 T4."Location" AS "Location",
	 T1."CalcPrice" AS "CalcPrice",
	 COALESCE(T2."OpenQty",
	 0) AS "OpenQty",
	 T3."Instance" AS "Instance",
	 0 AS "LastInst",
	 0 AS "RevalTotal",
	 '''' AS "BaseCurr",
	 T4."ApplObj" AS "ApplObj",
	 T4."AppObjAbs" AS "AppObjAbs",
	 T4."AppObjType" AS "AppObjType",
	 '''' AS "StockAct",
	 T0."TrnsfrAct" AS "TrnsfrAct",
	 T0."PriceDifAc" AS "PriceDifAc",
	 T0."VarianceAc" AS "VarianceAc",
	 T0."ReturnAct" AS "ReturnAct",
	 T0."ExcRateAct" AS "ExcRateAct",
	 T0."ClearAct" AS "ClearAct",
	 T0."CostAct" AS "CostAct",
	 T0."WipAct" AS "WipAct",
	 T1."Balance" AS "Balance",
	 T4."CreateDate" AS "CreateDate",
	 T4."BaseLine" AS "BaseLine",
	 T1."TransValue" AS "TransValue",
	 T0."PriceDiff" AS "PriceDiff",
	 T3."INMTransSe" AS "TransSeq",
	 T0."InvntAct" AS "InvntAct",
	 COALESCE(T2."RemMethod",
	 ''U'') AS "RemMethod",
	 COALESCE(T2."OpenValue",
	 T0."OpenStock") AS "OpenValue",
	 -1 AS "SubLineNum",
	 T4."AppObjLine" AS "AppObjLine",
	 T0."Expenses" AS "Expenses",
	 T0."OpenExp" AS "OpenExp",
	 T0."Allocation" AS "Allocation",
	 T0."OpenAlloc" AS "OpenAlloc",
	 T0."ExpAlloc" AS "ExpAlloc",
	 T0."OExpAlloc" AS "OExpAlloc",
	 T0."OpenPDiff" AS "OpenPDiff",
	 T0."ExchDiff" AS "ExchDiff",
	 T0."OpenEDiff" AS "OpenEDiff",
	 T0."NegInvAdjs" AS "NegInvAdjs",
	 T0."OpenNegInv" AS "OpenNegInv",
	 T0."NegStckAct" AS "NegStckAct",
	 0 AS "BTransVal",
	 T0."VarVal" AS "VarVal",
	 T0."BExpVal" AS "BExpVal",
	 T0."CogsVal" AS "CogsVal",
	 T0."BNegAVal" AS "BNegAVal",
	 T0."IOffIncAcc" AS "IOffIncAcc",
	 T0."IOffIncVal" AS "IOffIncVal",
	 T0."DOffDecAcc" AS "DOffDecAcc",
	 T0."DOffDecVal" AS "DOffDecVal",
	 T0."DecAcc" AS "DecAcc",
	 T0."DecVal" AS "DecVal",
	 T0."WipVal" AS "WipVal",
	 T0."WipVarAcc" AS "WipVarAcc",
	 T0."WipVarVal" AS "WipVarVal",
	 T0."IncAct" AS "IncAct",
	 T0."IncVal" AS "IncVal",
	 T0."ExpCAcc" AS "ExpCAcc",
	 T0."CostMethod" AS "CostMethod",
	 T4."OcrCode" AS "OcrCode",
	 0 AS "BaseQty",
	 0 AS "PrevTrans",
	 0 AS "HTransSeq",
	 T4."OcrCode2" AS "OcrCode2",
	 T4."OcrCode3" AS "OcrCode3",
	 T4."OcrCode4" AS "OcrCode4",
	 T4."OcrCode5" AS "OcrCode5",
	 T4."StgSeqNum" AS "StgSeqNum",
	 T4."StgEntry" AS "StgEntry",
	 T4."StgDesc" AS "StgDesc",
	 T0."InQty" AS "InvPLInQty",
	 T0."OutQty" AS "InvPLOutQty",
	 T0."Price" AS "InvPLPrice",
	 T0."Currency" AS "InvPLCurrency",
	 T0."Rate" AS "InvPLRate",
	 T1."LayerID" AS "InvPLLayerID",
	 T4."MessageID" AS "InvPLMessageID",
	 T4."SubLineNum" AS "InvPLSubLineNum",
	 T4."SnBType" AS "SnBType" 
								FROM "' || CURRENT_SCHEMA || '"."OIVL" T0 
								INNER JOIN "' || CURRENT_SCHEMA || '"."IVL1" T1 ON T0."TransSeq" = T1."TransSeq" 
								LEFT OUTER JOIN "' || CURRENT_SCHEMA || '"."OIVQ" T2 ON T1."TransSeq" = T2."TransSeq" 
								AND T1."LayerID" = T2."LayerID" 
								INNER JOIN "' || CURRENT_SCHEMA || '"."OIVK" T3 ON T1."TransSeq" = T3."TransSeq" 
								AND T1."LayerID" = T3."LayerID" 
								INNER JOIN "' || CURRENT_SCHEMA || '"."OILM" T4 ON T0."MessageID" = T4."MessageID" 
								LEFT OUTER JOIN "' || CURRENT_SCHEMA || '"."OADM" T5 ON T5."Code" = T5."Code" 
								WHERE ((T0."TransType" <> (18 ) 
										AND T0."TransType" <> (19 ) ) 
									OR ((T0."TransType" = (18 ) 
											OR T0."TransType" = (19 ) ) 
										AND T4."EffectQty" <> (0 ) 
										AND (T0."TransType" = (18 ) 
											OR (T0."TransType" = (19 ) 
												AND T4."ActionType" <> (6 ) 
												AND T4."ActionType" <> (11 ) )) 
										AND T4."AccumType" <> (3 ) )) 
								AND T0."TransType" <> (162 ) 
								AND T0."TransType" <> (69 ) 
								AND T0."TransType" <> (163 ) 
								AND T0."TransType" <> (164 ) 
								AND (T0."TransType" <> (13 ) 
									OR T0."TransType" = (13 ) 
									AND T4."AccumType" <> (4 ) )) 
							UNION ALL (SELECT
	 T3."TransNum" AS "TransNum",
	 T0."TransType" AS "TransType",
	 T0."CreatedBy" AS "CreatedBy",
	 T0."BASE_REF" AS "BASE_REF",
	 T0."DocLineNum" AS "DocLineNum",
	 T0."DocDate" AS "DocDate",
	 T4."DocDueDate" AS "DocDueDate",
	 T4."BPCardCode" AS "CardCode",
	 T4."CardName" AS "CardName",
	 T4."Ref1" AS "Ref1",
	 T4."Ref2" AS "Ref2",
	 T4."Comment" AS "Comments",
	 T4."JrnlMemo" AS "JrnlMemo",
	 T0."CreateTime" AS "DocTime",
	 T0."ItemCode" AS "ItemCode",
	 T4."Dscription" AS "Dscription",
	 T1."LayerInQty" AS "InQty",
	 T1."LayerOutQ" AS "OutQty",
	 T1."RevalTotal" AS "Price",
	 T5."MainCurncy" AS "Currency",
	 0 AS "Rate",
	 T4."VendorNum" AS "VendorNum",
	 T4."SerialNum" AS "SerialNum",
	 T0."LocCode" AS "Warehouse",
	 T4."TreeType" AS "TreeType",
	 T4."SlpCode" AS "SlpCode",
	 T4."TaxDate" AS "TaxDate",
	 T4."DataSource" AS "DataSource",
	 T4."PrjCode" AS "PrjCode",
	 T4."UserSign" AS "UserSign",
	 T4."BlockNum" AS "BlockNum",
	 T4."ImportLog" AS "ImportLog",
	 T4."UseDocPric" AS "UseDocPric",
	 T4."Location" AS "Location",
	 T1."CalcPrice" AS "CalcPrice",
	 COALESCE(T2."OpenQty",
	 0) AS "OpenQty",
	 T3."Instance" AS "Instance",
	 0 AS "LastInst",
	 0 AS "RevalTotal",
	 '''' AS "BaseCurr",
	 T4."ApplObj" AS "ApplObj",
	 T4."AppObjAbs" AS "AppObjAbs",
	 T4."AppObjType" AS "AppObjType",
	 '''' AS "StockAct",
	 T0."TrnsfrAct" AS "TrnsfrAct",
	 T0."PriceDifAc" AS "PriceDifAc",
	 T0."VarianceAc" AS "VarianceAc",
	 T0."ReturnAct" AS "ReturnAct",
	 T0."ExcRateAct" AS "ExcRateAct",
	 T0."ClearAct" AS "ClearAct",
	 T0."CostAct" AS "CostAct",
	 T0."WipAct" AS "WipAct",
	 T1."Balance" AS "Balance",
	 T4."CreateDate" AS "CreateDate",
	 T4."BaseLine" AS "BaseLine",
	 T1."TransValue" AS "TransValue",
	 T0."PriceDiff" AS "PriceDiff",
	 T3."INMTransSe" AS "TransSeq",
	 T0."InvntAct" AS "InvntAct",
	 COALESCE(T2."RemMethod",
	 ''U'') AS "RemMethod",
	 COALESCE(T2."OpenValue",
	 T0."OpenStock") AS "OpenValue",
	 -1 AS "SubLineNum",
	 T4."AppObjLine" AS "AppObjLine",
	 T0."Expenses" AS "Expenses",
	 T0."OpenExp" AS "OpenExp",
	 T0."Allocation" AS "Allocation",
	 T0."OpenAlloc" AS "OpenAlloc",
	 T0."ExpAlloc" AS "ExpAlloc",
	 T0."OExpAlloc" AS "OExpAlloc",
	 T0."OpenPDiff" AS "OpenPDiff",
	 T0."ExchDiff" AS "ExchDiff",
	 T0."OpenEDiff" AS "OpenEDiff",
	 T0."NegInvAdjs" AS "NegInvAdjs",
	 T0."OpenNegInv" AS "OpenNegInv",
	 T0."NegStckAct" AS "NegStckAct",
	 0 AS "BTransVal",
	 T0."VarVal" AS "VarVal",
	 T0."BExpVal" AS "BExpVal",
	 T0."CogsVal" AS "CogsVal",
	 T0."BNegAVal" AS "BNegAVal",
	 T0."IOffIncAcc" AS "IOffIncAcc",
	 T0."IOffIncVal" AS "IOffIncVal",
	 T0."DOffDecAcc" AS "DOffDecAcc",
	 T0."DOffDecVal" AS "DOffDecVal",
	 T0."DecAcc" AS "DecAcc",
	 T0."DecVal" AS "DecVal",
	 T0."WipVal" AS "WipVal",
	 T0."WipVarAcc" AS "WipVarAcc",
	 T0."WipVarVal" AS "WipVarVal",
	 T0."IncAct" AS "IncAct",
	 T0."IncVal" AS "IncVal",
	 T0."ExpCAcc" AS "ExpCAcc",
	 T0."CostMethod" AS "CostMethod",
	 T4."OcrCode" AS "OcrCode",
	 0 AS "BaseQty",
	 0 AS "PrevTrans",
	 0 AS "HTransSeq",
	 T4."OcrCode2" AS "OcrCode2",
	 T4."OcrCode3" AS "OcrCode3",
	 T4."OcrCode4" AS "OcrCode4",
	 T4."OcrCode5" AS "OcrCode5",
	 T4."StgSeqNum" AS "StgSeqNum",
	 T4."StgEntry" AS "StgEntry",
	 T4."StgDesc" AS "StgDesc",
	 T0."InQty" AS "InvPLInQty",
	 T0."OutQty" AS "InvPLOutQty",
	 T0."Price" AS "InvPLPrice",
	 T0."Currency" AS "InvPLCurrency",
	 T0."Rate" AS "InvPLRate",
	 T1."LayerID" AS "InvPLLayerID",
	 T4."MessageID" AS "InvPLMessageID",
	 T4."SubLineNum" AS "InvPLSubLineNum",
	 T4."SnBType" AS "SnBType" 
								FROM "' || CURRENT_SCHEMA || '"."OIVL" T0 
								INNER JOIN "' || CURRENT_SCHEMA || '"."IVL1" T1 ON T0."TransSeq" = T1."TransSeq" 
								LEFT OUTER JOIN "' || CURRENT_SCHEMA || '"."OIVQ" T2 ON T1."TransSeq" = T2."TransSeq" 
								AND T1."LayerID" = T2."LayerID" 
								INNER JOIN "' || CURRENT_SCHEMA || '"."OIVK" T3 ON T1."TransSeq" = T3."TransSeq" 
								AND T1."LayerID" = T3."LayerID" 
								INNER JOIN "' || CURRENT_SCHEMA || '"."OILM" T4 ON T0."MessageID" = T4."MessageID" 
								LEFT OUTER JOIN "' || CURRENT_SCHEMA || '"."OADM" T5 ON T5."Code" = T5."Code" 
								WHERE (T0."TransType" = (18 ) 
									OR T0."TransType" = (19 ) ) 
								AND T4."EffectQty" = (0 ) 
								AND (T0."TransType" = (18 ) 
									OR (T0."TransType" = (19 ) 
										AND T4."ActionType" <> (6 ) 
										AND T4."ActionType" <> (11 ) )) 
								AND T4."AccumType" <> (3 ))) 
						UNION ALL (SELECT
	 T3."TransNum" AS "TransNum",
	 T0."TransType" AS "TransType",
	 T0."CreatedBy" AS "CreatedBy",
	 T0."BASE_REF" AS "BASE_REF",
	 T0."DocLineNum" AS "DocLineNum",
	 T0."DocDate" AS "DocDate",
	 T4."DocDueDate" AS "DocDueDate",
	 T4."BPCardCode" AS "CardCode",
	 T4."CardName" AS "CardName",
	 T4."Ref1" AS "Ref1",
	 T4."Ref2" AS "Ref2",
	 T4."Comment" AS "Comments",
	 T4."JrnlMemo" AS "JrnlMemo",
	 T0."CreateTime" AS "DocTime",
	 T0."ItemCode" AS "ItemCode",
	 T4."Dscription" AS "Dscription",
	 T1."LayerInQty" AS "InQty",
	 T1."LayerOutQ" AS "OutQty",
	 T0."Price" AS "Price",
	 T0."Currency" AS "Currency",
	 T0."Rate" AS "Rate",
	 T4."VendorNum" AS "VendorNum",
	 T4."SerialNum" AS "SerialNum",
	 T0."LocCode" AS "Warehouse",
	 T4."TreeType" AS "TreeType",
	 T4."SlpCode" AS "SlpCode",
	 T4."TaxDate" AS "TaxDate",
	 T4."DataSource" AS "DataSource",
	 T4."PrjCode" AS "PrjCode",
	 T4."UserSign" AS "UserSign",
	 T4."BlockNum" AS "BlockNum",
	 T4."ImportLog" AS "ImportLog",
	 T4."UseDocPric" AS "UseDocPric",
	 T4."Location" AS "Location",
	 T1."CalcPrice" AS "CalcPrice",
	 COALESCE(T2."OpenQty",
	 0) AS "OpenQty",
	 T3."Instance" AS "Instance",
	 0 AS "LastInst",
	 T1."RevalTotal" AS "RevalTotal",
	 '''' AS "BaseCurr",
	 T4."ApplObj" AS "ApplObj",
	 T4."AppObjAbs" AS "AppObjAbs",
	 T4."AppObjType" AS "AppObjType",
	 '''' AS "StockAct",
	 T0."TrnsfrAct" AS "TrnsfrAct",
	 T0."PriceDifAc" AS "PriceDifAc",
	 T0."VarianceAc" AS "VarianceAc",
	 T0."ReturnAct" AS "ReturnAct",
	 T0."ExcRateAct" AS "ExcRateAct",
	 T0."ClearAct" AS "ClearAct",
	 T0."CostAct" AS "CostAct",
	 T0."WipAct" AS "WipAct",
	 T1."Balance" AS "Balance",
	 T4."CreateDate" AS "CreateDate",
	 T4."BaseLine" AS "BaseLine",
	 T1."TransValue" AS "TransValue",
	 T0."PriceDiff" AS "PriceDiff",
	 T3."INMTransSe" AS "TransSeq",
	 T0."InvntAct" AS "InvntAct",
	 COALESCE(T2."RemMethod",
	 ''U'') AS "RemMethod",
	 COALESCE(T2."OpenValue",
	 T0."OpenStock") AS "OpenValue",
	 T4."SubLineNum" AS "SubLineNum",
	 T4."AppObjLine" AS "AppObjLine",
	 T0."Expenses" AS "Expenses",
	 T0."OpenExp" AS "OpenExp",
	 T0."Allocation" AS "Allocation",
	 T0."OpenAlloc" AS "OpenAlloc",
	 T0."ExpAlloc" AS "ExpAlloc",
	 T0."OExpAlloc" AS "OExpAlloc",
	 T0."OpenPDiff" AS "OpenPDiff",
	 T0."ExchDiff" AS "ExchDiff",
	 T0."OpenEDiff" AS "OpenEDiff",
	 T0."NegInvAdjs" AS "NegInvAdjs",
	 T0."OpenNegInv" AS "OpenNegInv",
	 T0."NegStckAct" AS "NegStckAct",
	 0 AS "BTransVal",
	 T0."VarVal" AS "VarVal",
	 T0."BExpVal" AS "BExpVal",
	 T0."CogsVal" AS "CogsVal",
	 T0."BNegAVal" AS "BNegAVal",
	 T0."IOffIncAcc" AS "IOffIncAcc",
	 T0."IOffIncVal" AS "IOffIncVal",
	 T0."DOffDecAcc" AS "DOffDecAcc",
	 T0."DOffDecVal" AS "DOffDecVal",
	 T0."DecAcc" AS "DecAcc",
	 T0."DecVal" AS "DecVal",
	 T0."WipVal" AS "WipVal",
	 T0."WipVarAcc" AS "WipVarAcc",
	 T0."WipVarVal" AS "WipVarVal",
	 T0."IncAct" AS "IncAct",
	 T0."IncVal" AS "IncVal",
	 T0."ExpCAcc" AS "ExpCAcc",
	 T0."CostMethod" AS "CostMethod",
	 T4."OcrCode" AS "OcrCode",
	 0 AS "BaseQty",
	 0 AS "PrevTrans",
	 0 AS "HTransSeq",
	 T4."OcrCode2" AS "OcrCode2",
	 T4."OcrCode3" AS "OcrCode3",
	 T4."OcrCode4" AS "OcrCode4",
	 T4."OcrCode5" AS "OcrCode5",
	 T4."StgSeqNum" AS "StgSeqNum",
	 T4."StgEntry" AS "StgEntry",
	 T4."StgDesc" AS "StgDesc",
	 T0."InQty" AS "InvPLInQty",
	 T0."OutQty" AS "InvPLOutQty",
	 T0."Price" AS "InvPLPrice",
	 T0."Currency" AS "InvPLCurrency",
	 T0."Rate" AS "InvPLRate",
	 T1."LayerID" AS "InvPLLayerID",
	 T4."MessageID" AS "InvPLMessageID",
	 T4."SubLineNum" AS "InvPLSubLineNum",
	 T4."SnBType" AS "SnBType" 
							FROM "' || CURRENT_SCHEMA || '"."OIVL" T0 
							INNER JOIN "' || CURRENT_SCHEMA || '"."IVL1" T1 ON T0."TransSeq" = T1."TransSeq" 
							LEFT OUTER JOIN "' || CURRENT_SCHEMA || '"."OIVQ" T2 ON T1."TransSeq" = T2."TransSeq" 
							AND T1."LayerID" = T2."LayerID" 
							INNER JOIN "' || CURRENT_SCHEMA || '"."OIVK" T3 ON T1."TransSeq" = T3."TransSeq" 
							AND T1."LayerID" = T3."LayerID" 
							INNER JOIN "' || CURRENT_SCHEMA || '"."OILM" T4 ON T0."MessageID" = T4."MessageID" 
							LEFT OUTER JOIN "' || CURRENT_SCHEMA || '"."OADM" T5 ON T5."Code" = T5."Code" 
							WHERE T0."TransType" = (162 ))) 
					UNION ALL (SELECT
	 T3."TransNum" AS "TransNum",
	 T0."TransType" AS "TransType",
	 T0."CreatedBy" AS "CreatedBy",
	 T0."BASE_REF" AS "BASE_REF",
	 T0."DocLineNum" AS "DocLineNum",
	 T0."DocDate" AS "DocDate",
	 T4."DocDueDate" AS "DocDueDate",
	 T4."BPCardCode" AS "CardCode",
	 T4."CardName" AS "CardName",
	 T4."Ref1" AS "Ref1",
	 T4."Ref2" AS "Ref2",
	 T4."Comment" AS "Comments",
	 T4."JrnlMemo" AS "JrnlMemo",
	 T0."CreateTime" AS "DocTime",
	 T0."ItemCode" AS "ItemCode",
	 T4."Dscription" AS "Dscription",
	 T1."LayerInQty" AS "InQty",
	 T1."LayerOutQ" AS "OutQty",
	 T1."RevalTotal" AS "Price",
	 T5."MainCurncy" AS "Currency",
	 0 AS "Rate",
	 T4."VendorNum" AS "VendorNum",
	 T4."SerialNum" AS "SerialNum",
	 T0."LocCode" AS "Warehouse",
	 T4."TreeType" AS "TreeType",
	 T4."SlpCode" AS "SlpCode",
	 T4."TaxDate" AS "TaxDate",
	 T4."DataSource" AS "DataSource",
	 T4."PrjCode" AS "PrjCode",
	 T4."UserSign" AS "UserSign",
	 T4."BlockNum" AS "BlockNum",
	 T4."ImportLog" AS "ImportLog",
	 T4."UseDocPric" AS "UseDocPric",
	 T4."Location" AS "Location",
	 T1."CalcPrice" AS "CalcPrice",
	 COALESCE(T2."OpenQty",
	 0) AS "OpenQty",
	 T3."Instance" AS "Instance",
	 0 AS "LastInst",
	 0 AS "RevalTotal",
	 '''' AS "BaseCurr",
	 T4."ApplObj" AS "ApplObj",
	 T4."AppObjAbs" AS "AppObjAbs",
	 T4."AppObjType" AS "AppObjType",
	 '''' AS "StockAct",
	 T0."TrnsfrAct" AS "TrnsfrAct",
	 T0."PriceDifAc" AS "PriceDifAc",
	 T0."VarianceAc" AS "VarianceAc",
	 T0."ReturnAct" AS "ReturnAct",
	 T0."ExcRateAct" AS "ExcRateAct",
	 T0."ClearAct" AS "ClearAct",
	 T0."CostAct" AS "CostAct",
	 T0."WipAct" AS "WipAct",
	 T1."Balance" AS "Balance",
	 T4."CreateDate" AS "CreateDate",
	 T4."BaseLine" AS "BaseLine",
	 T1."TransValue" AS "TransValue",
	 T0."PriceDiff" AS "PriceDiff",
	 T3."INMTransSe" AS "TransSeq",
	 T0."InvntAct" AS "InvntAct",
	 COALESCE(T2."RemMethod",
	 ''U'') AS "RemMethod",
	 COALESCE(T2."OpenValue",
	 T0."OpenStock") AS "OpenValue",
	 -1 AS "SubLineNum",
	 T4."AppObjLine" AS "AppObjLine",
	 T0."Expenses" AS "Expenses",
	 T0."OpenExp" AS "OpenExp",
	 T0."Allocation" AS "Allocation",
	 T0."OpenAlloc" AS "OpenAlloc",
	 T0."ExpAlloc" AS "ExpAlloc",
	 T0."OExpAlloc" AS "OExpAlloc",
	 T0."OpenPDiff" AS "OpenPDiff",
	 T0."ExchDiff" AS "ExchDiff",
	 T0."OpenEDiff" AS "OpenEDiff",
	 T0."NegInvAdjs" AS "NegInvAdjs",
	 T0."OpenNegInv" AS "OpenNegInv",
	 T0."NegStckAct" AS "NegStckAct",
	 0 AS "BTransVal",
	 T0."VarVal" AS "VarVal",
	 T0."BExpVal" AS "BExpVal",
	 T0."CogsVal" AS "CogsVal",
	 T0."BNegAVal" AS "BNegAVal",
	 T0."IOffIncAcc" AS "IOffIncAcc",
	 T0."IOffIncVal" AS "IOffIncVal",
	 T0."DOffDecAcc" AS "DOffDecAcc",
	 T0."DOffDecVal" AS "DOffDecVal",
	 T0."DecAcc" AS "DecAcc",
	 T0."DecVal" AS "DecVal",
	 T0."WipVal" AS "WipVal",
	 T0."WipVarAcc" AS "WipVarAcc",
	 T0."WipVarVal" AS "WipVarVal",
	 T0."IncAct" AS "IncAct",
	 T0."IncVal" AS "IncVal",
	 T0."ExpCAcc" AS "ExpCAcc",
	 T0."CostMethod" AS "CostMethod",
	 T4."OcrCode" AS "OcrCode",
	 0 AS "BaseQty",
	 0 AS "PrevTrans",
	 0 AS "HTransSeq",
	 T4."OcrCode2" AS "OcrCode2",
	 T4."OcrCode3" AS "OcrCode3",
	 T4."OcrCode4" AS "OcrCode4",
	 T4."OcrCode5" AS "OcrCode5",
	 T4."StgSeqNum" AS "StgSeqNum",
	 T4."StgEntry" AS "StgEntry",
	 T4."StgDesc" AS "StgDesc",
	 T0."InQty" AS "InvPLInQty",
	 T0."OutQty" AS "InvPLOutQty",
	 T0."Price" AS "InvPLPrice",
	 T0."Currency" AS "InvPLCurrency",
	 T0."Rate" AS "InvPLRate",
	 T1."LayerID" AS "InvPLLayerID",
	 T4."MessageID" AS "InvPLMessageID",
	 T4."SubLineNum" AS "InvPLSubLineNum",
	 T4."SnBType" AS "SnBType" 
						FROM "' || CURRENT_SCHEMA || '"."OIVL" T0 
						INNER JOIN "' || CURRENT_SCHEMA || '"."IVL1" T1 ON T0."TransSeq" = T1."TransSeq" 
						LEFT OUTER JOIN "' || CURRENT_SCHEMA || '"."OIVQ" T2 ON T1."TransSeq" = T2."TransSeq" 
						AND T1."LayerID" = T2."LayerID" 
						INNER JOIN "' || CURRENT_SCHEMA || '"."OIVK" T3 ON T1."TransSeq" = T3."TransSeq" 
						AND T1."LayerID" = T3."LayerID" 
						INNER JOIN "' || CURRENT_SCHEMA || '"."OILM" T4 ON T0."MessageID" = T4."MessageID" 
						LEFT OUTER JOIN "' || CURRENT_SCHEMA || '"."OADM" T5 ON T5."Code" = T5."Code" 
						WHERE T0."TransType" = (69 ))) 
				UNION ALL (SELECT
	 T3."TransNum" AS "TransNum",
	 T0."TransType" AS "TransType",
	 T0."CreatedBy" AS "CreatedBy",
	 T0."BASE_REF" AS "BASE_REF",
	 T0."DocLineNum" AS "DocLineNum",
	 T0."DocDate" AS "DocDate",
	 T4."DocDueDate" AS "DocDueDate",
	 T4."BPCardCode" AS "CardCode",
	 T4."CardName" AS "CardName",
	 T4."Ref1" AS "Ref1",
	 T4."Ref2" AS "Ref2",
	 T4."Comment" AS "Comments",
	 T4."JrnlMemo" AS "JrnlMemo",
	 T0."CreateTime" AS "DocTime",
	 T0."ItemCode" AS "ItemCode",
	 T4."Dscription" AS "Dscription",
	 T1."LayerInQty" AS "InQty",
	 T1."LayerOutQ" AS "OutQty",
	 T0."Price" AS "Price",
	 T0."Currency" AS "Currency",
	 T0."Rate" AS "Rate",
	 T4."VendorNum" AS "VendorNum",
	 T4."SerialNum" AS "SerialNum",
	 T0."LocCode" AS "Warehouse",
	 T4."TreeType" AS "TreeType",
	 T4."SlpCode" AS "SlpCode",
	 T4."TaxDate" AS "TaxDate",
	 T4."DataSource" AS "DataSource",
	 T4."PrjCode" AS "PrjCode",
	 T4."UserSign" AS "UserSign",
	 T4."BlockNum" AS "BlockNum",
	 T4."ImportLog" AS "ImportLog",
	 T4."UseDocPric" AS "UseDocPric",
	 T4."Location" AS "Location",
	 T1."CalcPrice" AS "CalcPrice",
	 COALESCE(T2."OpenQty",
	 0) AS "OpenQty",
	 T3."Instance" AS "Instance",
	 0 AS "LastInst",
	 T1."RevalTotal" AS "RevalTotal",
	 '''' AS "BaseCurr",
	 T4."ApplObj" AS "ApplObj",
	 T4."AppObjAbs" AS "AppObjAbs",
	 T4."AppObjType" AS "AppObjType",
	 '''' AS "StockAct",
	 T0."TrnsfrAct" AS "TrnsfrAct",
	 T0."PriceDifAc" AS "PriceDifAc",
	 T0."VarianceAc" AS "VarianceAc",
	 T0."ReturnAct" AS "ReturnAct",
	 T0."ExcRateAct" AS "ExcRateAct",
	 T0."ClearAct" AS "ClearAct",
	 T0."CostAct" AS "CostAct",
	 T0."WipAct" AS "WipAct",
	 T1."Balance" AS "Balance",
	 T4."CreateDate" AS "CreateDate",
	 T4."BaseLine" AS "BaseLine",
	 T1."TransValue" AS "TransValue",
	 T0."PriceDiff" AS "PriceDiff",
	 T3."INMTransSe" AS "TransSeq",
	 T0."InvntAct" AS "InvntAct",
	 COALESCE(T2."RemMethod",
	 ''U'') AS "RemMethod",
	 COALESCE(T2."OpenValue",
	 T0."OpenStock") AS "OpenValue",
	 -1 AS "SubLineNum",
	 T4."AppObjLine" AS "AppObjLine",
	 T0."Expenses" AS "Expenses",
	 T0."OpenExp" AS "OpenExp",
	 T0."Allocation" AS "Allocation",
	 T0."OpenAlloc" AS "OpenAlloc",
	 T0."ExpAlloc" AS "ExpAlloc",
	 T0."OExpAlloc" AS "OExpAlloc",
	 T0."OpenPDiff" AS "OpenPDiff",
	 T0."ExchDiff" AS "ExchDiff",
	 T0."OpenEDiff" AS "OpenEDiff",
	 T0."NegInvAdjs" AS "NegInvAdjs",
	 T0."OpenNegInv" AS "OpenNegInv",
	 T0."NegStckAct" AS "NegStckAct",
	 0 AS "BTransVal",
	 T0."VarVal" AS "VarVal",
	 T0."BExpVal" AS "BExpVal",
	 T0."CogsVal" AS "CogsVal",
	 T0."BNegAVal" AS "BNegAVal",
	 T0."IOffIncAcc" AS "IOffIncAcc",
	 T0."IOffIncVal" AS "IOffIncVal",
	 T0."DOffDecAcc" AS "DOffDecAcc",
	 T0."DOffDecVal" AS "DOffDecVal",
	 T0."DecAcc" AS "DecAcc",
	 T0."DecVal" AS "DecVal",
	 T0."WipVal" AS "WipVal",
	 T0."WipVarAcc" AS "WipVarAcc",
	 T0."WipVarVal" AS "WipVarVal",
	 T0."IncAct" AS "IncAct",
	 T0."IncVal" AS "IncVal",
	 T0."ExpCAcc" AS "ExpCAcc",
	 T0."CostMethod" AS "CostMethod",
	 T4."OcrCode" AS "OcrCode",
	 0 AS "BaseQty",
	 0 AS "PrevTrans",
	 0 AS "HTransSeq",
	 T4."OcrCode2" AS "OcrCode2",
	 T4."OcrCode3" AS "OcrCode3",
	 T4."OcrCode4" AS "OcrCode4",
	 T4."OcrCode5" AS "OcrCode5",
	 T4."StgSeqNum" AS "StgSeqNum",
	 T4."StgEntry" AS "StgEntry",
	 T4."StgDesc" AS "StgDesc",
	 T0."InQty" AS "InvPLInQty",
	 T0."OutQty" AS "InvPLOutQty",
	 T0."Price" AS "InvPLPrice",
	 T0."Currency" AS "InvPLCurrency",
	 T0."Rate" AS "InvPLRate",
	 T1."LayerID" AS "InvPLLayerID",
	 T4."MessageID" AS "InvPLMessageID",
	 T4."SubLineNum" AS "InvPLSubLineNum",
	 T4."SnBType" AS "SnBType" 
					FROM "' || CURRENT_SCHEMA || '"."OIVL" T0 
					INNER JOIN "' || CURRENT_SCHEMA || '"."IVL1" T1 ON T0."TransSeq" = T1."TransSeq" 
					LEFT OUTER JOIN "' || CURRENT_SCHEMA || '"."OIVQ" T2 ON T1."TransSeq" = T2."TransSeq" 
					AND T1."LayerID" = T2."LayerID" 
					INNER JOIN "' || CURRENT_SCHEMA || '"."OIVK" T3 ON T1."TransSeq" = T3."TransSeq" 
					AND T1."LayerID" = T3."LayerID" 
					INNER JOIN "' || CURRENT_SCHEMA || '"."OILM" T4 ON T0."MessageID" = T4."MessageID" 
					LEFT OUTER JOIN "' || CURRENT_SCHEMA || '"."OADM" T5 ON T5."Code" = T5."Code" 
					WHERE (T0."TransType" = (163 ) 
						OR T0."TransType" = (164 ) ) 
					AND T4."EffectQty" <> (0 ))) 
			UNION ALL (SELECT
	 T3."TransNum" AS "TransNum",
	 T0."TransType" AS "TransType",
	 T0."CreatedBy" AS "CreatedBy",
	 T0."BASE_REF" AS "BASE_REF",
	 T0."DocLineNum" AS "DocLineNum",
	 T0."DocDate" AS "DocDate",
	 T4."DocDueDate" AS "DocDueDate",
	 T4."BPCardCode" AS "CardCode",
	 T4."CardName" AS "CardName",
	 T4."Ref1" AS "Ref1",
	 T4."Ref2" AS "Ref2",
	 T4."Comment" AS "Comments",
	 T4."JrnlMemo" AS "JrnlMemo",
	 T0."CreateTime" AS "DocTime",
	 T0."ItemCode" AS "ItemCode",
	 T4."Dscription" AS "Dscription",
	 T1."LayerInQty" AS "InQty",
	 T1."LayerOutQ" AS "OutQty",
	 T1."RevalTotal" AS "Price",
	 T5."MainCurncy" AS "Currency",
	 0 AS "Rate",
	 T4."VendorNum" AS "VendorNum",
	 T4."SerialNum" AS "SerialNum",
	 T0."LocCode" AS "Warehouse",
	 T4."TreeType" AS "TreeType",
	 T4."SlpCode" AS "SlpCode",
	 T4."TaxDate" AS "TaxDate",
	 T4."DataSource" AS "DataSource",
	 T4."PrjCode" AS "PrjCode",
	 T4."UserSign" AS "UserSign",
	 T4."BlockNum" AS "BlockNum",
	 T4."ImportLog" AS "ImportLog",
	 T4."UseDocPric" AS "UseDocPric",
	 T4."Location" AS "Location",
	 T1."CalcPrice" AS "CalcPrice",
	 COALESCE(T2."OpenQty",
	 0) AS "OpenQty",
	 T3."Instance" AS "Instance",
	 0 AS "LastInst",
	 T1."RevalTotal" AS "RevalTotal",
	 '''' AS "BaseCurr",
	 T4."ApplObj" AS "ApplObj",
	 T4."AppObjAbs" AS "AppObjAbs",
	 T4."AppObjType" AS "AppObjType",
	 '''' AS "StockAct",
	 T0."TrnsfrAct" AS "TrnsfrAct",
	 T0."PriceDifAc" AS "PriceDifAc",
	 T0."VarianceAc" AS "VarianceAc",
	 T0."ReturnAct" AS "ReturnAct",
	 T0."ExcRateAct" AS "ExcRateAct",
	 T0."ClearAct" AS "ClearAct",
	 T0."CostAct" AS "CostAct",
	 T0."WipAct" AS "WipAct",
	 T1."Balance" AS "Balance",
	 T4."CreateDate" AS "CreateDate",
	 T4."BaseLine" AS "BaseLine",
	 T1."TransValue" AS "TransValue",
	 T0."PriceDiff" AS "PriceDiff",
	 T3."INMTransSe" AS "TransSeq",
	 T0."InvntAct" AS "InvntAct",
	 COALESCE(T2."RemMethod",
	 ''U'') AS "RemMethod",
	 COALESCE(T2."OpenValue",
	 T0."OpenStock") AS "OpenValue",
	 -1 AS "SubLineNum",
	 T4."AppObjLine" AS "AppObjLine",
	 T0."Expenses" AS "Expenses",
	 T0."OpenExp" AS "OpenExp",
	 T0."Allocation" AS "Allocation",
	 T0."OpenAlloc" AS "OpenAlloc",
	 T0."ExpAlloc" AS "ExpAlloc",
	 T0."OExpAlloc" AS "OExpAlloc",
	 T0."OpenPDiff" AS "OpenPDiff",
	 T0."ExchDiff" AS "ExchDiff",
	 T0."OpenEDiff" AS "OpenEDiff",
	 T0."NegInvAdjs" AS "NegInvAdjs",
	 T0."OpenNegInv" AS "OpenNegInv",
	 T0."NegStckAct" AS "NegStckAct",
	 0 AS "BTransVal",
	 T0."VarVal" AS "VarVal",
	 T0."BExpVal" AS "BExpVal",
	 T0."CogsVal" AS "CogsVal",
	 T0."BNegAVal" AS "BNegAVal",
	 T0."IOffIncAcc" AS "IOffIncAcc",
	 T0."IOffIncVal" AS "IOffIncVal",
	 T0."DOffDecAcc" AS "DOffDecAcc",
	 T0."DOffDecVal" AS "DOffDecVal",
	 T0."DecAcc" AS "DecAcc",
	 T0."DecVal" AS "DecVal",
	 T0."WipVal" AS "WipVal",
	 T0."WipVarAcc" AS "WipVarAcc",
	 T0."WipVarVal" AS "WipVarVal",
	 T0."IncAct" AS "IncAct",
	 T0."IncVal" AS "IncVal",
	 T0."ExpCAcc" AS "ExpCAcc",
	 T0."CostMethod" AS "CostMethod",
	 T4."OcrCode" AS "OcrCode",
	 0 AS "BaseQty",
	 0 AS "PrevTrans",
	 0 AS "HTransSeq",
	 T4."OcrCode2" AS "OcrCode2",
	 T4."OcrCode3" AS "OcrCode3",
	 T4."OcrCode4" AS "OcrCode4",
	 T4."OcrCode5" AS "OcrCode5",
	 T4."StgSeqNum" AS "StgSeqNum",
	 T4."StgEntry" AS "StgEntry",
	 T4."StgDesc" AS "StgDesc",
	 T0."InQty" AS "InvPLInQty",
	 T0."OutQty" AS "InvPLOutQty",
	 T0."Price" AS "InvPLPrice",
	 T0."Currency" AS "InvPLCurrency",
	 T0."Rate" AS "InvPLRate",
	 T1."LayerID" AS "InvPLLayerID",
	 T4."MessageID" AS "InvPLMessageID",
	 T4."SubLineNum" AS "InvPLSubLineNum",
	 T4."SnBType" AS "SnBType" 
				FROM "' || CURRENT_SCHEMA || '"."OIVL" T0 
				INNER JOIN "' || CURRENT_SCHEMA || '"."IVL1" T1 ON T0."TransSeq" = T1."TransSeq" 
				LEFT OUTER JOIN "' || CURRENT_SCHEMA || '"."OIVQ" T2 ON T1."TransSeq" = T2."TransSeq" 
				AND T1."LayerID" = T2."LayerID" 
				INNER JOIN "' || CURRENT_SCHEMA || '"."OIVK" T3 ON T1."TransSeq" = T3."TransSeq" 
				AND T1."LayerID" = T3."LayerID" 
				INNER JOIN "' || CURRENT_SCHEMA || '"."OILM" T4 ON T0."MessageID" = T4."MessageID" 
				LEFT OUTER JOIN "' || CURRENT_SCHEMA || '"."OADM" T5 ON T5."Code" = T5."Code" 
				WHERE (T0."TransType" = (163 ) 
					OR T0."TransType" = (164 ) ) 
				AND T4."EffectQty" = (0 ))) 
		UNION ALL (SELECT
	 -1 AS "TransNum",
	 T0."TransType" AS "TransType",
	 T0."DocEntry" AS "CreatedBy",
	 T0."BASE_REF" AS "BASE_REF",
	 T0."DocLineNum" AS "DocLineNum",
	 T0."DocDate" AS "DocDate",
	 T0."DocDueDate" AS "DocDueDate",
	 T0."BPCardCode" AS "CardCode",
	 T0."CardName" AS "CardName",
	 T0."Ref1" AS "Ref1",
	 T0."Ref2" AS "Ref2",
	 T0."Comment" AS "Comments",
	 T0."JrnlMemo" AS "JrnlMemo",
	 T0."CreateTime" AS "DocTime",
	 T0."ItemCode" AS "ItemCode",
	 T0."Dscription" AS "Dscription",
	 T0."Quantity" AS "InQty",
	 0 AS "OutQty",
	 T0."DocPrice" AS "Price",
	 T0."Currency" AS "Currency",
	 T0."DocRate" AS "Rate",
	 T0."VendorNum" AS "VendorNum",
	 T0."SerialNum" AS "SerialNum",
	 T0."LocCode" AS "Warehouse",
	 T0."TreeType" AS "TreeType",
	 T0."SlpCode" AS "SlpCode",
	 T0."TaxDate" AS "TaxDate",
	 T0."DataSource" AS "DataSource",
	 T0."PrjCode" AS "PrjCode",
	 T0."UserSign" AS "UserSign",
	 T0."BlockNum" AS "BlockNum",
	 T0."ImportLog" AS "ImportLog",
	 T0."UseDocPric" AS "UseDocPric",
	 T0."Location" AS "Location",
	 T0."DocPrice" AS "CalcPrice",
	 0 AS "OpenQty",
	 -1 AS "Instance",
	 0 AS "LastInst",
	 T0."DocPrice" AS "RevalTotal",
	 '''' AS "BaseCurr",
	 T0."ApplObj" AS "ApplObj",
	 T0."AppObjAbs" AS "AppObjAbs",
	 T0."AppObjType" AS "AppObjType",
	 '''' AS "StockAct",
	 '''' AS "TrnsfrAct",
	 '''' AS "PriceDifAc",
	 '''' AS "VarianceAc",
	 '''' AS "ReturnAct",
	 '''' AS "ExcRateAct",
	 '''' AS "ClearAct",
	 '''' AS "CostAct",
	 '''' AS "WipAct",
	 0 AS "Balance",
	 T0."CreateDate" AS "CreateDate",
	 T0."BaseLine" AS "BaseLine",
	 0 AS "TransValue",
	 0 AS "PriceDiff",
	 -1 AS "TransSeq",
	 '''' AS "InvntAct",
	 '''' AS "RemMethod",
	 0 AS "OpenValue",
	 T0."SubLineNum" AS "SubLineNum",
	 T0."AppObjLine" AS "AppObjLine",
	 0 AS "Expenses",
	 0 AS "OpenExp",
	 0 AS "Allocation",
	 0 AS "OpenAlloc",
	 0 AS "ExpAlloc",
	 0 AS "OExpAlloc",
	 0 AS "OpenPDiff",
	 0 AS "ExchDiff",
	 0 AS "OpenEDiff",
	 0 AS "NegInvAdjs",
	 0 AS "OpenNegInv",
	 '''' AS "NegStckAct",
	 0 AS "BTransVal",
	 0 AS "VarVal",
	 0 AS "BExpVal",
	 0 AS "CogsVal",
	 0 AS "BNegAVal",
	 '''' AS "IOffIncAcc",
	 0 AS "IOffIncVal",
	 '''' AS "DOffDecAcc",
	 0 AS "DOffDecVal",
	 '''' AS "DecAcc",
	 0 AS "DecVal",
	 0 AS "WipVal",
	 '''' AS "WipVarAcc",
	 0 AS "WipVarVal",
	 '''' AS "IncAct",
	 0 AS "IncVal",
	 '''' AS "ExpCAcc",
	 '''' AS "CostMethod",
	 T0."OcrCode" AS "OcrCode",
	 0 AS "BaseQty",
	 0 AS "PrevTrans",
	 0 AS "HTransSeq",
	 T0."OcrCode2" AS "OcrCode2",
	 T0."OcrCode3" AS "OcrCode3",
	 T0."OcrCode4" AS "OcrCode4",
	 T0."OcrCode5" AS "OcrCode5",
	 T0."StgSeqNum" AS "StgSeqNum",
	 T0."StgEntry" AS "StgEntry",
	 T0."StgDesc" AS "StgDesc",
	 T0."Quantity" AS "InvPLInQty",
	 0 AS "InvPLOutQty",
	 T0."Price" AS "InvPLPrice",
	 T0."Currency" AS "InvPLCurrency",
	 T0."DocRate" AS "InvPLRate",
	 0 AS "InvPLLayerID",
	 T0."MessageID" AS "InvPLMessageID",
	 T0."SubLineNum" AS "InvPLSubLineNum",
	 T0."SnBType" AS "SnBType" 
			FROM "' || CURRENT_SCHEMA || '"."OILM" T0 
			WHERE T0."TransType" = (67 ) 
			AND T0."AccumType" = (1 ) 
			AND T0."ActionType" = (19 ))) 
	UNION ALL (SELECT
	 -1 AS "TransNum",
	 T0."TransType" AS "TransType",
	 T0."DocEntry" AS "CreatedBy",
	 T0."BASE_REF" AS "BASE_REF",
	 T0."DocLineNum" AS "DocLineNum",
	 T0."DocDate" AS "DocDate",
	 T0."DocDueDate" AS "DocDueDate",
	 T0."BPCardCode" AS "CardCode",
	 T0."CardName" AS "CardName",
	 T0."Ref1" AS "Ref1",
	 T0."Ref2" AS "Ref2",
	 T0."Comment" AS "Comments",
	 T0."JrnlMemo" AS "JrnlMemo",
	 T0."CreateTime" AS "DocTime",
	 T0."ItemCode" AS "ItemCode",
	 T0."Dscription" AS "Dscription",
	 0 AS "InQty",
	 T0."Quantity" AS "OutQty",
	 T0."DocPrice" AS "Price",
	 T0."Currency" AS "Currency",
	 T0."DocRate" AS "Rate",
	 T0."VendorNum" AS "VendorNum",
	 T0."SerialNum" AS "SerialNum",
	 T0."LocCode" AS "Warehouse",
	 T0."TreeType" AS "TreeType",
	 T0."SlpCode" AS "SlpCode",
	 T0."TaxDate" AS "TaxDate",
	 T0."DataSource" AS "DataSource",
	 T0."PrjCode" AS "PrjCode",
	 T0."UserSign" AS "UserSign",
	 T0."BlockNum" AS "BlockNum",
	 T0."ImportLog" AS "ImportLog",
	 T0."UseDocPric" AS "UseDocPric",
	 T0."Location" AS "Location",
	 T0."DocPrice" AS "CalcPrice",
	 0 AS "OpenQty",
	 -1 AS "Instance",
	 0 AS "LastInst",
	 T0."DocPrice" AS "RevalTotal",
	 '''' AS "BaseCurr",
	 T0."ApplObj" AS "ApplObj",
	 T0."AppObjAbs" AS "AppObjAbs",
	 T0."AppObjType" AS "AppObjType",
	 '''' AS "StockAct",
	 '''' AS "TrnsfrAct",
	 '''' AS "PriceDifAc",
	 '''' AS "VarianceAc",
	 '''' AS "ReturnAct",
	 '''' AS "ExcRateAct",
	 '''' AS "ClearAct",
	 '''' AS "CostAct",
	 '''' AS "WipAct",
	 0 AS "Balance",
	 T0."CreateDate" AS "CreateDate",
	 T0."BaseLine" AS "BaseLine",
	 0 AS "TransValue",
	 0 AS "PriceDiff",
	 -1 AS "TransSeq",
	 '''' AS "InvntAct",
	 '''' AS "RemMethod",
	 0 AS "OpenValue",
	 T0."SubLineNum" AS "SubLineNum",
	 T0."AppObjLine" AS "AppObjLine",
	 0 AS "Expenses",
	 0 AS "OpenExp",
	 0 AS "Allocation",
	 0 AS "OpenAlloc",
	 0 AS "ExpAlloc",
	 0 AS "OExpAlloc",
	 0 AS "OpenPDiff",
	 0 AS "ExchDiff",
	 0 AS "OpenEDiff",
	 0 AS "NegInvAdjs",
	 0 AS "OpenNegInv",
	 '''' AS "NegStckAct",
	 0 AS "BTransVal",
	 0 AS "VarVal",
	 0 AS "BExpVal",
	 0 AS "CogsVal",
	 0 AS "BNegAVal",
	 '''' AS "IOffIncAcc",
	 0 AS "IOffIncVal",
	 '''' AS "DOffDecAcc",
	 0 AS "DOffDecVal",
	 '''' AS "DecAcc",
	 0 AS "DecVal",
	 0 AS "WipVal",
	 '''' AS "WipVarAcc",
	 0 AS "WipVarVal",
	 '''' AS "IncAct",
	 0 AS "IncVal",
	 '''' AS "ExpCAcc",
	 '''' AS "CostMethod",
	 T0."OcrCode" AS "OcrCode",
	 0 AS "BaseQty",
	 0 AS "PrevTrans",
	 0 AS "HTransSeq",
	 T0."OcrCode2" AS "OcrCode2",
	 T0."OcrCode3" AS "OcrCode3",
	 T0."OcrCode4" AS "OcrCode4",
	 T0."OcrCode5" AS "OcrCode5",
	 T0."StgSeqNum" AS "StgSeqNum",
	 T0."StgEntry" AS "StgEntry",
	 T0."StgDesc" AS "StgDesc",
	 0 AS "InvPLInQty",
	 T0."Quantity" AS "InvPLOutQty",
	 T0."Price" AS "InvPLPrice",
	 T0."Currency" AS "InvPLCurrency",
	 T0."DocRate" AS "InvPLRate",
	 0 AS "InvPLLayerID",
	 T0."MessageID" AS "InvPLMessageID",
	 T0."SubLineNum" AS "InvPLSubLineNum",
	 T0."SnBType" AS "SnBType" 
		FROM "' || CURRENT_SCHEMA || '"."OILM" T0 
		WHERE T0."TransType" = (67 ) 
		AND T0."AccumType" = (1 ) 
		AND T0."ActionType" = (20 ))) WITH READ ONLY';

  exec (:sqlStr);
	--ins_msg_proc(:sqlStr);
END;