4 Sales Line
4 Sales Line
4 Sales Line
Call BeginTabLog(vTab);
ClosedSalesOrder_Tmp:
$(vFirst)
LOAD *
FROM [$(vRawDataDir)$(vTPJI)F42119_*.qvd] (qvd)
WHERE
//SDDGL >= '$(vDateStart)'
// AND not match(SDLNTY, $(vMatchLineType))
// AND not match(SDDCTO, $(vMatchOrderType))
SDCPNT = 0
;
SalesOrderClosed:
LOAD *,
//%OrderKey as %DateKey,
applymap('ClosedOrderCRMQuoteId', [Order Company] & '|' & [Order Number] & '|' &
[Sales Order Type Code], ' ') as [JDE CRMQuoteId],
applymap('ClosedOrderCRMOpportunityId', [Order Company] & '|' & [Order Number] &
'|' & [Sales Order Type Code], ' ') as [JDE CRMOpportunityId],
LOAD
SDKCOO as [Order Company],
SDDOCO as [Order Number],
SDVR01 as [PO #], //Ali added this
// SDIR04 ,//Ali added this
SDIR01 as [SideMark], // ali added
SDFRTH as [Freight Handling Code],// Ali added this
SDCARS as [Carrier Number], // Ali added this
SDDCTO as [Sales Order Type Code],
Round(( SDLNID / 1000),.0001) as [Order Line Number],
SDLNTY as [Sales Order Line Type],//madhavi added this
SDMCU as [Business Unit ID],
SDAN8 as [Address Number],
SDURAB as [User Number],
SDSHAN as [Ship To Number],
// SDPA8 as [Parent Number],
SDITM as [Short Item No],
SDCPNT as [Line No.],
trim(SDLOB) as [Market Subsegment Code],
$(RJZFill(SDGLC, $(vLen4109))) as [GL Code],
SDUOM4 as [Pirmary UOM],
// if(match(SDUOM4, 'EA', 'CA'), 1 / applymap('ConvFactor_Map', SDITM & '|SY|
EA', 1), 1) as [UM Conv Factor],
// SDSO06 as [Order Status 06],
// SDSO10 as [Order Status 10],
// SDSO12 as [Order Status 12],
// SDSO14 as [Order Status 14],
// SDSO15 as [Order Status 15],
// SDSO16 as [Order Status 16],
// SDSO17 as [Order Status 17],
// SDSO18 as [Order Status 18],
// SDSO19 as [Order Status 19],
// SDSO20 as [Order Status 20],
$(JDEDate(SDDRQJ)) as [Request Date],
$(JDEDate(SDDRQJ)) as [Sales Request Date],
$(JDEDate(SDTRDJ)) as [Order Date],
$(JDEDate(SDTRDJ)) as [Sales Order Date],
$(JDEDate(SDPDDJ)) as [Schedule Pick Date],
$(JDEDate(SDADDJ)) as [Actual Ship Date],
$(JDEDate(SDADDJ)) as [Sales Actual Ship Date],
$(JDEDate(SDIVD)) as [Invoice Date],
$(JDEDate(SDCNDJ)) as [Cancel Date],
$(JDEDate(SDDGL)) as [G/L Date],
$(JDEDate(SDDGL)) as [Sales G/L Date],
$(JDEDate(SDRSDJ)) as [Promised Delivery Date],
// $(JDEDate(SDPEFJ)) as [Price Effective Date],
$(JDEDate(SDPPDJ)) as [Promised Ship Date],
$(JDEDate(SDPPDJ)) as [Sales Promised Ship Date],
$(JDEDate(SDURDT)) as [Plan Promised Date],//ali added 1.10
// $(RJZFill(SDNXTR, $(vLen41SS))) as [Next Status Code],
// $(RJZFill(SDLTTR, $(vLen41SS))) as [Last Status Code],
SDSHPN as [Shipment Number],
SDNXTR as [Next Status Code],
SDLTTR as [Last Status Code],
RTRIM(SDROUT) as [Route Code],
$(RJZFill(SDEMCU, $(vLen56BD))) as [Business Unit Code],
SDUORG / 10000 as [Quantity Ordered],
SDSOQS / 10000 as [Quantity Shipped],
SDSOBK / 10000 as [Quantity Backordered],
SDSOCN / 10000 as [Quantity Canceled],
SDSONE / 10000 as [Future Qty Committed],
SDUOPN / 10000 as [Quantity Open],
SDQTYT / 10000 as [Qty Ship To Date],
SDQRLV / 10000 as [Quantity Relieved],
SDUPRC / 10000 as [Unit Price] ,
// SDAEXP / 10000 as [Extended Price],
// SDAOPN / 10000 as [Amount Open],
SDLPRC as [Unit List Price],
// SDAITM as [3rd Item Number],
SDDSC1 as [Description2],
SDUNCS / 10000 as [Unit Cost],
SDECST / 100 as [Extended Cost],
SDPQOR / 10000 as [Primary Quantity Ordered],
SDSQOR / 10000 as [Secondary Qty Ordered],
SDURAT/100 as [User Amount],
//
Price/ApplyMap('Map_CurrMonth_ExchRate',Upper(Currency)&Date(Document_Date,'YYYYMM'
)) as Price_EUR
// num(ApplyMap('Map_ExchangeRateYear', SDCRCD&'USD'&YEAR($(JDEDate(SDDGL)))),
'#0.00') as [USD Currency_Rate],
// num(ApplyMap('Map_ExchangeRateYear', SDCRCD&'CAD'&YEAR($(JDEDate(SDDGL)))),
'#0.00') as [CAD Currency_Rate]
RESIDENT ClosedSalesOrder_Tmp;
///Open Sales
SalesOrderOpen_Tmp:
$(vFirst)
LOAD *
FROM [$(vRawDataDir)$(vTPJI)F4211_*.qvd] (qvd)
;
SalesOrderOpen:
Load *,
applymap('OpenOrderCRMQuoteId', [Order Company] & '|' & [Order Number] & '|' &
[Sales Order Type Code], ' ') as [JDE CRMQuoteId],
applymap('OpenOrderCRMOpportunityId', [Order Company] & '|' & [Order Number] &
'|' & [Sales Order Type Code], ' ') as [JDE CRMOpportunityId],
LOAD
SDKCOO as [Order Company],
SDDOCO as [Order Number],
SDDCTO as [Sales Order Type Code],
Round(( SDLNID / 1000),.0001) as [Order Line Number],
SDLNTY as [Sales Order Line Type],//madhavi added this
SDMCU as [Business Unit ID],
SDAN8 as [Address Number],
SDURAB as [User Number],
SDIR01 as [SideMark], //ali added
SDSHAN as [Ship To Number],
// SDPA8 as [Parent Number],
SDITM as [Short Item No],
SDCPNT as [Line No.],
// SDLOB as [Market Subsegment Code],
$(RJZFill(SDGLC, $(vLen4109))) as [GL Code],
SDUOM4 as [Pirmary UOM],
SDRORN as [Related PO/SO#],
SDRCTO as [Related Order Type],
SDRKCO as [Related Order Company],
// if(match(SDUOM4, 'EA', 'CA'), 1 / applymap('ConvFactor_Map', SDITM & '|SY|
EA', 1), 1) as [UM Conv Factor],
// SDSO06 as [Order Status 06],
// SDSO10 as [Order Status 10],
// SDSO12 as [Order Status 12],
// SDSO14 as [Order Status 14],
// SDSO15 as [Order Status 15],
// SDSO16 as [Order Status 16],
// SDSO17 as [Order Status 17],
// SDSO18 as [Order Status 18],
// SDSO19 as [Order Status 19],
// SDSO20 as [Order Status 20],
$(JDEDate(SDDRQJ)) as [Request Date],
$(JDEDate(SDDRQJ)) as [Sales Request Date],
$(JDEDate(SDTRDJ)) as [Order Date],
$(JDEDate(SDTRDJ)) as [Sales Order Date],
$(JDEDate(SDPDDJ)) as [Schedule Pick Date],
$(JDEDate(SDADDJ)) as [Actual Ship Date],
$(JDEDate(SDADDJ)) as [Sales Actual Ship Date],
$(JDEDate(SDIVD)) as [Invoice Date],
$(JDEDate(SDCNDJ)) as [Cancel Date],
$(JDEDate(SDDGL)) as [G/L Date],
$(JDEDate(SDDGL)) as [Sales G/L Date],
$(JDEDate(SDRSDJ)) as [Promised Delivery Date],
// $(JDEDate(SDPEFJ)) as [Price Effective Date],
$(JDEDate(SDPPDJ)) as [Promised Ship Date],
$(JDEDate(SDPPDJ)) as [Sales Promised Ship Date],
$(JDEDate(SDURDT)) as [Plan Promised Date],//ali added 1.10
// $(RJZFill(SDNXTR, $(vLen41SS))) as [Next Status Code],
// $(RJZFill(SDLTTR, $(vLen41SS))) as [Last Status Code],
SDNXTR as [Next Status Code],
SDLTTR as [Last Status Code],
RTRIM(SDROUT) as [Route Code],
$(RJZFill(SDEMCU, $(vLen56BD))) as [Business Unit Code],
SDUORG / 10000 as [Quantity Ordered],
SDVR01 as [PO #], //Ali added this
// SDIR04 ,//ali added this
SDFRTH as [Freight Handling Code],// Ali added this
SDCARS as [Carrier Number], // Ali added this
SDSOQS / 10000 as [Quantity Shipped],
SDSOBK / 10000 as [Quantity Backordered],
SDSOCN / 10000 as [Quantity Canceled],
SDSONE / 10000 as [Future Qty Committed],
SDUOPN / 10000 as [Quantity Open],
SDQTYT / 10000 as [Qty Ship To Date],
SDQRLV / 10000 as [Quantity Relieved],
SDUPRC / 10000 as [Unit Price],
// SDAEXP / 10000 as [Extended Price],
// SDAOPN / 10000 as [Amount Open],
// SDLPRC as [Unit List Price],
SDUNCS / 10000 as [Unit Cost],
SDECST / 100 as [Extended Cost],
SDPQOR / 10000 as [Primary Quantity Ordered],
SDSQOR / 10000 as [Secondary Qty Ordered],
SDURAT/100 as [User Amount],
if(SDKCOO='00305','Canada',
If(SDKCOO='00350','USA & Latin America',
If(SDKCOO='00340','USA',
If(SDKCOO='00365','Services',
If(SDKCOO='00370','USA'))))) as [Sales Center],
//
Upper(pick(match(SDKCOO,'00305','00350','00340','00365','00370'),'Canada','USA &
Latin America','USA','Services','USA')) as [Sales Center],
//
Price/ApplyMap('Map_CurrMonth_ExchRate',Upper(Currency)&Date(Document_Date,'YYYYMM'
)) as Price_EUR
num((SDURAT/100)*ApplyMap('ExchangeRate_Current_Map', SDCRCD& '|'
&'USD'),'#,##0.00') as [User Amount USD],
num((SDURAT/100)*ApplyMap('ExchangeRate_Map', SDCRCD& '|' &'USD'&'|'
&ApplyMap('Date_Map',$(JDEDate(SDTRDJ)))
,ApplyMap('ExchangeRate_Current_Map', SDCRCD& '|' &'USD')),'#,##0.00') as [User
Amount Received USD],
num((SDUPRC / 10000)*ApplyMap('ExchangeRate_Current_Map',
SDCRCD&'|'&'USD'),'#,##0.00') as [Unit Price USD],
// num((SDURAT/100)*ApplyMap('ExchangeRateOO_Map',
SDCRCD&'|'&'AUD'),'#,##0.00') as [User Amount AUD],
// num((SDUPRC / 10000)*ApplyMap('ExchangeRateOO_Map',
SDCRCD&'|'&'AUD'),'#,##0.00') as [Unit Price AUD],
// num((SDURAT/100)*ApplyMap('ExchangeRateOO_Map',
SDCRCD&'|'&'EUR'),'#,##0.00') as [User Amount EUR],
// num((SDUPRC / 10000)*ApplyMap('ExchangeRateOO_Map',
SDCRCD&'|'&'EUR'),'#,##0.00') as [Unit Price EUR],
// num((SDURAT/100)*ApplyMap('ExchangeRateOO_Map',
SDCRCD&'|'&'GBP'),'#,##0.00') as [User Amount GBP],
// num((SDUPRC / 10000)*ApplyMap('ExchangeRateOO_Map',
SDCRCD&'|'&'GBP'),'#,##0.00') as [Unit Price GBP],
num((SDURAT/100)*ApplyMap('ExchangeRate_Current_Map', SDCRCD& '|'
&'CAD'),'#,##0.00') as [User Amount CAD],
Num((SDUPRC / 10000)*ApplyMap('ExchangeRate_Current_Map',
SDCRCD&'|'&'CAD'),'#,##0.00') as [Unit Price CAD],
// num((SDUNCS / 10000)*ApplyMap('ExchangeRateOO_Map',
SDCRCD&'|'&'AUD'),'#,##0.00') as [Unit Cost AUD],
// num((SDUNCS / 10000)*ApplyMap('ExchangeRateOO_Map',
SDCRCD&'|'&'EUR'),'#,##0.00') as [Unit Cost EUR],
// num((SDUNCS / 10000)*ApplyMap('ExchangeRateOO_Map',
SDCRCD&'|'&'GBP'),'#,##0.00') as [Unit Cost GBP],
Num((SDUNCS / 10000)*ApplyMap('ExchangeRate_Current_Map',
SDCRCD&'|'&'CAD'),'#,##0.00') as [Unit Cost CAD]
//-------Lokesh 6/22/2018 - Exchange Rate field transformation--------
//num(ApplyMap('Map_ExchangeRateYear', SDCRCD&'USD'&YEAR($(JDEDate(SDTRDJ)))),
'#0.00') as [USD Currency_Rate],
//num(ApplyMap('Map_ExchangeRateYear', SDCRCD&'CAD'&YEAR($(JDEDate(SDTRDJ)))),
'#0.00') as [CAD Currency_Rate]
// applymap('ExchangeRate_Map',[Trans Currency Code]&'|'&'USD'&'|'
&[Fiscal Year] & num(Period, '00'), 1)
// -------Lokesh 4/19/2018 - Exchange Rate field transformation--------
RESIDENT SalesOrderOpen_Tmp;
// SalesCommission1:
// Load *,
// 'Closed' as [SalesLine Type],
// 'Closed' as [Comm Type],
// %OrderKey & '|' & %SalespersonKey as [OKey+SPK],
// %SalespersonKey & '|' & [Sales G/L Date] as [SPK+GLDate]
// //[%OrderKey] as %DateKey
// RESIDENT CommissionClosed
// where YEAR([Sales G/L Date])<='2017';
Call EndTabLog;