// ------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version: 17.0.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// ------------------------------------------------------------------------------
namespace TestApp.Templates
{
using System.Linq;
using System.Text;
using System.Collections.Generic;
using WorkerService.Models.Reporting;
using WorkerService.Helpers;
using System;
///
/// Class to produce the template output
///
#line 1 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class QueryTemplate2 : QueryTemplate2Base
{
#line hidden
///
/// Create the template output
///
public virtual string TransformText()
{
#line 8 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(AddData){
#line default
#line hidden
this.Write(@"DELETE FROM WORKORDER_FILTER;
DELETE FROM COMPONENT_LOT_FILTER;
DELETE FROM PROFIT_CENTER_FILTER;
DELETE FROM WORK_CENTER_FILTER;
DELETE FROM ITEM_NUMBER_FILTER;
DELETE FROM OPERATOR_FILTER;
DELETE FROM PART_OPERATIONS_FILTER;
DELETE FROM TEMP_WO;
DELETE FROM TEMP_MIS;
/* Add filter criteria to temp tables */
");
#line 20 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 21 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.WorkOrderFilterEnabled) {
#line default
#line hidden
#line 22 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(AddData){
#line default
#line hidden
this.Write("INSERT ALL\r\n");
#line 24 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
foreach(var woNumber in Model.WorkOrderFilter.Select(wo=>wo.WorkOrderNumber)) {
#line default
#line hidden
this.Write(" INTO WORKORDER_FILTER(WORKORDERNUMBER) VALUES(");
#line 25 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(woNumber));
#line default
#line hidden
this.Write(")\r\n");
#line 26 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write("SELECT 1 FROM DUAL;\r\n");
#line 28 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write(@"
/* Add manually specified work orders to flagged work orders */
MERGE INTO TEMP_WO TARGET
USING
(
SELECT DISTINCT WADOCO, COALESCE(WALOTN, CAST(WADOCO AS CHAR(8))) WALOTN, WAMMCU, WAITM
FROM F4801_WO wo INNER JOIN
WORKORDER_FILTER p_wo ON (wo.WADOCO = p_wo.WORKORDERNUMBER)
) SOURCE ON (TARGET.WORKORDERNUMBER = SOURCE.WADOCO)
WHEN NOT MATCHED THEN
INSERT (WORKORDERNUMBER, LOTNUMBER, BRANCHCODE, SHORTITEMNUMBER, MANUALLYSPECIFIED)
VALUES (SOURCE.WADOCO, SOURCE.WALOTN, SOURCE.WAMMCU, SOURCE.WAITM, 'T');
");
#line 41 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 42 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.ItemNumberFilterEnabled) {
#line default
#line hidden
this.Write("\r\n");
#line 44 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(AddData){
#line default
#line hidden
this.Write("INSERT ALL\r\n");
#line 46 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
foreach(var item in Model.ItemNumberFilter) {
#line default
#line hidden
this.Write(" INTO ITEM_NUMBER_FILTER(ITEMNUMBER) VALUES(\'");
#line 47 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(item.ItemNumber));
#line default
#line hidden
this.Write("\')\r\n");
#line 48 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write("SELECT 1 FROM DUAL;\r\n");
#line 50 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 51 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 52 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.ProfitCenterFilterEnabled) {
#line default
#line hidden
this.Write("\r\n");
#line 54 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(AddData){
#line default
#line hidden
this.Write("INSERT ALL\r\n");
#line 56 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
foreach(var profitCenter in Model.ProfitCenterFilter) {
#line default
#line hidden
this.Write(" INTO PROFIT_CENTER_FILTER(CODE) VALUES(\'");
#line 57 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(profitCenter.Code));
#line default
#line hidden
this.Write("\')\r\n");
#line 58 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write(@"SELECT 1 FROM DUAL;
/* Add work centers in specified profit centers to work center filter */
INSERT INTO WORK_CENTER_FILTER(CODE)
SELECT DISTINCT TRIM(IWMCU)
FROM F30006_GIW91 oh INNER JOIN
PROFIT_CENTER_FILTER p_pc ON (TRIM(oh.IWMCUW) = TRIM(p_pc.CODE));
");
#line 66 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 67 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 68 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.WorkCenterFilterEnabled) {
#line default
#line hidden
this.Write("\r\n");
#line 70 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(AddData){
#line default
#line hidden
this.Write("INSERT ALL\r\n");
#line 72 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
foreach(var workCenter in Model.WorkCenterFilter) {
#line default
#line hidden
this.Write(" INTO WORK_CENTER_FILTER(CODE) VALUES(\'");
#line 73 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(workCenter.Code));
#line default
#line hidden
this.Write("\')\r\n");
#line 74 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write("SELECT 1 FROM DUAL;\r\n");
#line 76 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 77 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 78 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.ComponentLotFilterEnabled) {
#line default
#line hidden
this.Write("\r\n");
#line 80 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(AddData){
#line default
#line hidden
this.Write("INSERT ALL\r\n");
#line 82 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
foreach(var componentLot in Model.ComponentLotFilter) {
#line default
#line hidden
this.Write(" INTO COMPONENT_LOT_FILTER(LOTNUMBER, ITEMNUMBER) VALUES(\'");
#line 83 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(componentLot.LotNumber));
#line default
#line hidden
this.Write("\', \'");
#line 83 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(componentLot.ItemNumber));
#line default
#line hidden
this.Write("\')\r\n");
#line 84 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write("SELECT 1 FROM DUAL;\r\n");
#line 86 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write(@"
/* Add downstream product for manually specified component lots */
MERGE INTO TEMP_WO TARGET
USING
(
SELECT DISTINCT WADOCO, COALESCE(WALOTN, CAST(WADOCO AS CHAR(8))) WALOTN, WAMMCU, WAITM
FROM COMPONENT_LOT_FILTER p_clf INNER JOIN
F4108_LOT lot ON (p_clf.LOTNUMBER = lot.IOLOTN and p_clf.ITEMNUMBER = lot.IOLITM) INNER JOIN
F3111_WOC woc ON (lot.IOLOTN = woc.WMLOTN AND lot.IOITM = woc.WMCPIT ) INNER JOIN
F4801_WO wo ON (woc.WMDOCO = wo.WADOCO)
) SOURCE ON (TARGET.WORKORDERNUMBER = SOURCE.WADOCO)
WHEN MATCHED THEN
UPDATE SET PARTSLIST = 'T'
WHEN NOT MATCHED THEN
INSERT (WORKORDERNUMBER, LOTNUMBER, BRANCHCODE, SHORTITEMNUMBER, PARTSLIST)
VALUES (SOURCE.WADOCO, SOURCE.WALOTN, SOURCE.WAMMCU, SOURCE.WAITM, 'T');
MERGE INTO TEMP_WO TARGET
USING
(
SELECT DISTINCT WADOCO, COALESCE(WALOTN, CAST(WADOCO AS CHAR(8))) WALOTN, WAMMCU, WAITM
FROM COMPONENT_LOT_FILTER p_clf INNER JOIN
F4108_LOT lot ON (p_clf.LOTNUMBER = lot.IOLOTN and p_clf.ITEMNUMBER = lot.IOLITM) INNER JOIN
F4111_CARDEX lu ON (lot.IOLOTN = lu.ILLOTN AND lot.IOITM = lu.ILITM ) INNER JOIN
F4801_WO wo ON (lu.ILDOCO = wo.WADOCO)
) SOURCE ON (TARGET.WORKORDERNUMBER = SOURCE.WADOCO)
WHEN MATCHED THEN
UPDATE SET CARDEX = 'T'
WHEN NOT MATCHED THEN
INSERT (WORKORDERNUMBER, LOTNUMBER, BRANCHCODE, SHORTITEMNUMBER, CARDEX)
VALUES (SOURCE.WADOCO, SOURCE.WALOTN, SOURCE.WAMMCU, SOURCE.WAITM, 'T');
");
#line 118 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 119 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.OperatorFilterEnabled) {
#line default
#line hidden
this.Write("\r\n");
#line 121 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(AddData){
#line default
#line hidden
this.Write("INSERT ALL\r\n");
#line 123 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
foreach(var oper in Model.OperatorFilter) {
#line default
#line hidden
this.Write(" INTO OPERATOR_FILTER(ADDRESSNUMBER) VALUES(\'");
#line 124 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(oper.AddressNumber));
#line default
#line hidden
this.Write("\')\r\n");
#line 125 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write("SELECT 1 FROM DUAL;\r\n");
#line 127 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 128 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 129 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.ItemOperationMisFilterEnabled) {
#line default
#line hidden
this.Write("\r\n");
#line 131 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(AddData){
#line default
#line hidden
this.Write("INSERT ALL\r\n");
#line 133 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
foreach(var itemOp in Model.ItemOperationMisFilter) {
#line default
#line hidden
this.Write(" INTO PART_OPERATIONS_FILTER(ITEMNUMBER, OPERATIONNUMBER, MISNUMBER, MISREVISI" +
"ON) VALUES(\'");
#line 134 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(itemOp.ItemNumber));
#line default
#line hidden
this.Write("\', \'");
#line 134 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(itemOp.OperationNumber));
#line default
#line hidden
this.Write("\', \'");
#line 134 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(itemOp.MisNumber));
#line default
#line hidden
this.Write("\', \'");
#line 134 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(itemOp.MisRevision));
#line default
#line hidden
this.Write("\')\r\n");
#line 135 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write("SELECT 1 FROM DUAL;\r\n");
#line 137 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 138 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 139 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.ShouldSearchSteps()) {
#line default
#line hidden
this.Write(@"
/* Find work orders matching filter criteria and add to flagged work orders */
MERGE INTO TEMP_WO TARGET
USING (
SELECT DISTINCT WADOCO, WALOTN, WAMMCU, WAITM FROM (
SELECT wo.WADOCO, COALESCE(wo.WALOTN, to_char(wo.WADOCO)) AS WALOTN, wo.WAMMCU, wo.WAITM
FROM F4801_WO wo ");
#line 146 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.ItemNumberFilterEnabled) {
#line default
#line hidden
this.Write(" INNER JOIN\r\n ITEM_NUMBER_FILTER p_in ON (wo.WALITM = p_in.ITEMNUMB" +
"ER)");
#line 147 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write(" INNER JOIN \r\n F3112_WOS wos ON (wo.WADOCO = wos.WLDOCO) ");
#line 148 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.ProfitCenterFilterEnabled || Model.WorkCenterFilterEnabled) {
#line default
#line hidden
this.Write("INNER JOIN\r\n WORK_CENTER_FILTER p_wc ON (wos.WLMCU = p_wc.CODE)");
#line 149 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write(" LEFT OUTER JOIN\r\n F31122_WOT wot ON (wos.WLDOCO = wot.WTDOCO and w" +
"os.WLOPSQ = wot.WTOPSQ) ");
#line 150 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.OperatorFilterEnabled) {
#line default
#line hidden
this.Write("INNER JOIN \r\n OPERATOR_FILTER p_o ON (wot.WTAN8 = p_o.ADDRESSNUMBER" +
")");
#line 151 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 151 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.ItemOperationMisFilterEnabled) {
#line default
#line hidden
this.Write(@" INNER JOIN
MIS m ON (wos.WLDOCO = m.WORKORDERNUMBER and wos.WLOPSQ/10 = m.SEQUENCENUMBER and wos.WLMMCU = m.BRANCHCODE ) INNER JOIN
PART_OPERATIONS_FILTER p_po ON (m.ITEMNUMBER = p_po.ITEMNUMBER and m.SEQUENCENUMBER = p_po.OPERATIONNUMBER and m.MISNUMBER = p_po.MISNUMBER and m.REVID = p_po.MISREVISION)
");
#line 154 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write(" \r\n WHERE ");
#line 156 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture($"(wos.WLSTRX between 1{Model.MinimumDT:yy}{Model.MinimumDT.Value.DayOfYear:000} and 1{Model.MaximumDT:yy}{Model.MaximumDT.Value.DayOfYear:000})"));
#line default
#line hidden
this.Write(" OR\r\n ");
#line 157 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture($"(wot.WTDGL between 1{Model.MinimumDT:yy}{Model.MinimumDT.Value.DayOfYear:000} and 1{Model.MaximumDT:yy}{Model.MaximumDT.Value.DayOfYear:000})"));
#line default
#line hidden
this.Write("\r\n ");
#line 158 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(!Model.ItemOperationMisFilterEnabled) {
#line default
#line hidden
this.Write("UNION\r\n SELECT wo.WADOCO, COALESCE(wo.WALOTN, to_char(wo.WADOCO)) AS WALOT" +
"N, wo.WAMMCU, wo.WAITM\r\n FROM F4801_WO wo");
#line 160 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.ItemNumberFilterEnabled) {
#line default
#line hidden
this.Write(" INNER JOIN\r\n ITEM_NUMBER_FILTER p_in ON (wo.WALITM = p_in.ITEMNUMB" +
"ER)");
#line 161 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write(" INNER JOIN \r\n F31122_WOT wot ON (wo.WADOCO = wot.WTDOCO)");
#line 162 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.ProfitCenterFilterEnabled || Model.WorkCenterFilterEnabled) {
#line default
#line hidden
this.Write(" INNER JOIN\r\n WORK_CENTER_FILTER p_wc ON (wot.WTMCU = p_wc.CODE)");
#line 163 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
#line 163 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.OperatorFilterEnabled) {
#line default
#line hidden
this.Write("INNER JOIN \r\n OPERATOR_FILTER p_o ON (wot.WTAN8 = p_o.ADDRESSNUMBER" +
")");
#line 164 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write(" \r\n WHERE ");
#line 165 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture($"(wot.WTDGL between 1{Model.MinimumDT:yy}{Model.MinimumDT.Value.DayOfYear:000} and 1{Model.MaximumDT:yy}{Model.MaximumDT.Value.DayOfYear:000})"));
#line default
#line hidden
this.Write("\r\n ");
#line 166 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write(")\r\n) SOURCE ON (TARGET.WORKORDERNUMBER = SOURCE.WADOCO)\r\nWHEN NOT MATCHED THEN\r\n " +
" INSERT(WORKORDERNUMBER, LOTNUMBER, BRANCHCODE, SHORTITEMNUMBER, FLAGGED)\r\n VAL" +
"UES(SOURCE.WADOCO, SOURCE.WALOTN, SOURCE.WAMMCU, SOURCE.WAITM, \'T\');\r\n");
#line 171 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write("\r\n/* Add downstream product */\r\nDECLARE\r\n v_NumWO NUMBER := -1;\r\n v_NewNumWO NU" +
"MBER := 0;\r\n v_NumRuns NUMBER := 0;\r\nBEGIN\r\n WHILE (1 = 1) LOOP\r\n\r\n /* Sea" +
"rch parts list */\r\n MERGE INTO TEMP_WO TARGET\r\n USING\r\n (\r\n SELECT" +
" DISTINCT WADOCO, COALESCE(WALOTN, CAST(WADOCO AS CHAR(8))) WALOTN, WAMMCU, WAIT" +
"M\r\n FROM TEMP_WO t_wo INNER JOIN\r\n F4108_LOT lot ON (t_wo.LOT" +
"NUMBER = lot.IOLOTN and t_wo.SHORTITEMNUMBER = lot.IOITM) INNER JOIN\r\n " +
" F3111_WOC woc ON (lot.IOLOTN = woc.WMLOTN AND lot.IOITM = woc.WMCPIT ) INNER" +
" JOIN\r\n F4801_WO wo ON (woc.WMDOCO = wo.WADOCO)\r\n ) SOURCE ON (TA" +
"RGET.WORKORDERNUMBER = SOURCE.WADOCO)\r\n WHEN MATCHED THEN\r\n UPDATE SET P" +
"ARTSLIST = \'T\'\r\n WHEN NOT MATCHED THEN\r\n INSERT (WORKORDERNUMBER, LOTNUM" +
"BER, BRANCHCODE, SHORTITEMNUMBER, PARTSLIST)\r\n VALUES (SOURCE.WADOCO, SOURC" +
"E.WALOTN, SOURCE.WAMMCU, SOURCE.WAITM, \'T\');\r\n\r\n /* Search CARDEX */\r\n MER" +
"GE INTO TEMP_WO TARGET\r\n USING\r\n (\r\n SELECT DISTINCT WADOCO, COALESCE" +
"(WALOTN, CAST(WADOCO AS CHAR(8))) WALOTN, WAMMCU, WAITM\r\n FROM TEMP_WO t_" +
"wo INNER JOIN\r\n F4108_LOT lot ON (t_wo.LOTNUMBER = lot.IOLOTN and t" +
"_wo.SHORTITEMNUMBER = lot.IOITM) INNER JOIN\r\n F4111_CARDEX lu ON (lo" +
"t.IOLOTN = lu.ILLOTN AND lot.IOITM = lu.ILITM ) INNER JOIN\r\n F4801_W" +
"O wo ON (lu.ILDOCO = wo.WADOCO)\r\n ) SOURCE ON (TARGET.WORKORDERNUMBER = SOURC" +
"E.WADOCO)\r\n WHEN MATCHED THEN\r\n UPDATE SET CARDEX = \'T\'\r\n WHEN NOT MA" +
"TCHED THEN\r\n INSERT (WORKORDERNUMBER, LOTNUMBER, BRANCHCODE, SHORTITEMNUMBE" +
"R, CARDEX)\r\n VALUES (SOURCE.WADOCO, SOURCE.WALOTN, SOURCE.WAMMCU, SOURCE.WA" +
"ITM, \'T\');\r\n\r\n /* Add any work orders split from flagged work orders */\r\n " +
" MERGE INTO TEMP_WO TARGET\r\n USING\r\n (\r\n SELECT DISTINCT WADOCO, COAL" +
"ESCE(WALOTN, CAST(WADOCO AS CHAR(8))) WALOTN, WAMMCU, WAITM\r\n FROM F4801_" +
"WO wo INNER JOIN\r\n TEMP_WO t_wo ON wo.WAPARS = CAST(t_wo.WORKORDERNU" +
"MBER AS char(8))\r\n ) SOURCE ON (TARGET.WORKORDERNUMBER = SOURCE.WADOCO)\r\n " +
"WHEN MATCHED THEN\r\n UPDATE SET SPLITORDER = \'T\'\r\n WHEN NOT MATCHED THEN\r" +
"\n INSERT (WORKORDERNUMBER, LOTNUMBER, BRANCHCODE, SHORTITEMNUMBER, SPLITORD" +
"ER)\r\n VALUES (SOURCE.WADOCO, SOURCE.WALOTN, SOURCE.WAMMCU, SOURCE.WAITM, \'T" +
"\');\r\n\r\n /* Increment run counter and check updated number of flagged work ord" +
"ers */\r\n v_NumRuns := v_NumRuns + 1;\r\n SELECT COUNT(*) INTO v_NewNumWO FRO" +
"M TEMP_WO;\r\n\r\n /* Stop when no new flagged work orders were found OR when max" +
" recursion counter reached */\r\n IF v_NumWO = v_NewNumWO OR v_NumRuns >= 20 TH" +
"EN\r\n EXIT;\r\n END IF;\r\n END LOOP;\r\nEND;\r\n\r\n/* Lookup flagged work o" +
"rder details */\r\nSELECT t_wo.WORKORDERNUMBER,\r\n t_wo.BRANCHCODE,\r\n t" +
"_wo.LOTNUMBER,\r\n COALESCE(item.IMLITM, wo.WALITM) ItemNumber,\r\n item" +
".IMPRP4 PlanningFamily,\r\n\t item.IMSTKT StockingType,\r\n wo.WAUORG / 100 O" +
"rderQuantity,\r\n wo.WASOBK / 100 HeldQuantity,\r\n (SELECT COALESCE(sum" +
"(WLSOCN), 0) / 100\r\n FROM F3112_SCRAP scrap\r\n WHERE scrap.WLDOC" +
"O = t_wo.WORKORDERNUMBER AND \r\n MOD(scrap.WLOPSQ, 1) = 0) Scrapped" +
"Quantity,\r\n wo.WASOQS / 100 ShippedQuantity,\r\n last_step.WLMMCU Oper" +
"ationStepBranchCode,\r\n last_step.WLOPSQ / 10 OperationStep,\r\n last_s" +
"tep.WLDSC1 OperationStepDescription,\r\n last_step.CFDS80 FunctionOperationD" +
"escription,\r\n last_step.LASTUPDATEDT OperationStepUpdateTimestamp,\r\n " +
" wo.WASRST StatusCode,\r\n sc.DRDL01 StatusDescription,\r\n TO_DATE(wo.W" +
"ADCG + 1900000, \'YYYYDDD\') StatusUpdateTimestamp,\r\n CASE\r\n WHEN t_" +
"wo.MANUALLYSPECIFIED = \'T\' THEN \'ManuallySpecified\'\r\n WHEN t_wo.FLAGGED " +
"= \'T\' THEN \'Flagged\'\r\n WHEN t_wo.SPLITORDER = \'T\' THEN \'Split\'\r\n " +
" WHEN t_wo.CARDEX = \'T\' AND t_wo.PARTSLIST = \'F\' THEN \'ComponentUsage (CARDEX)\'\r" +
"\n WHEN (t_wo.CARDEX = \'F\' AND t_wo.PARTSLIST = \'T\') THEN \'ComponentUsage" +
" (Parts List)\'\r\n WHEN (t_wo.CARDEX = \'T\' AND t_wo.PARTSLIST = \'T\') THEN " +
"\'ComponentUsage (CARDEX + Parts List)\'\r\n ELSE \'\'\r\n END InclusionRe" +
"ason\r\nFROM TEMP_WO t_wo INNER JOIN\r\n F4801_WO wo ON (t_wo.WORKORDERNUMBE" +
"R = wo.WADOCO) LEFT OUTER JOIN\r\n F4101_ITEM item ON (t_wo.SHORTITEMNUMBER " +
"= item.IMITM) LEFT OUTER JOIN\r\n (SELECT wos.WLDOCO, wos.WLMMCU, wos.WLOPSQ" +
", wos.WLDSC1, wos.CFDS80, wos.LASTUPDATEDT,\r\n ROW_NUMBER() OVER (P" +
"ARTITION BY wos.WLDOCO ORDER BY WLSTRX DESC, WLOPSQ DESC) RN\r\n FROM F31" +
"12_WOS wos) last_step ON (t_wo.WORKORDERNUMBER = last_step.WLDOCO and last_step." +
"RN = 1) LEFT OUTER JOIN\r\n F0005_SC sc ON (sc.DRKY = wo.WASRST);\r\n");
#line 276 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.ExtractMisData) {
#line default
#line hidden
this.Write(@"
/* Extract MIS data */
INSERT INTO TEMP_MIS
(
WorkOrderNumber,
ItemNumber,
ItemDescription,
BranchCode,
WorkCenterCode,
StepTimestamp,
SequenceNumber,
FunctionCode,
FunctionOperationDescription,
MatchedSequenceNumber,
RoutingMatch,
MasterMatch,
MisNumber,
RevID,
CharNumber,
MisSequenceNumber,
TestDescription,
SamplingType,
SamplingValue,
ToolsGauges,
WorkInstructions,
Status,
ReleaseDate
)
SELECT m.*
FROM F4801_WO wo");
#line 306 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.ItemNumberFilterEnabled) {
#line default
#line hidden
this.Write(" INNER JOIN\r\n ITEM_NUMBER_FILTER p_in ON (wo.WALITM = p_in.ITEMNUMBER)");
#line 307 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write(" INNER JOIN\r\n F3112_WOS wos ON (wo.WADOCO = wos.WLDOCO)");
#line 308 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.ProfitCenterFilterEnabled || Model.WorkCenterFilterEnabled) {
#line default
#line hidden
this.Write(" INNER JOIN\r\n WORK_CENTER_FILTER p_wc ON (wos.WLMCU = p_wc.CODE)");
#line 309 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write(" LEFT OUTER JOIN\r\n F31122_WOT wot ON (wos.WLDOCO = wot.WTDOCO and wos.WLOPS" +
"Q = wot.WTOPSQ)");
#line 310 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
if(Model.OperatorFilterEnabled) {
#line default
#line hidden
this.Write(" INNER JOIN\r\n OPERATOR_FILTER p_o ON (wot.WTAN8 = p_o.ADDRESSNUMBER)");
#line 311 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write(" INNER JOIN\r\n MIS m ON (wos.WLDOCO = m.WORKORDERNUMBER AND wos.WLOPSQ/10 = " +
"m.SEQUENCENUMBER)\r\nWHERE ");
#line 313 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture($"(wos.WLSTRX between 1{Model.MinimumDT:yy}{Model.MinimumDT.Value.DayOfYear:000} and 1{Model.MaximumDT:yy}{Model.MaximumDT.Value.DayOfYear:000})"));
#line default
#line hidden
this.Write(" OR\r\n ");
#line 314 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
this.Write(this.ToStringHelper.ToStringWithCulture($"(wot.WTDGL between 1{Model.MinimumDT:yy}{Model.MinimumDT.Value.DayOfYear:000} and 1{Model.MaximumDT:yy}{Model.MaximumDT.Value.DayOfYear:000})"));
#line default
#line hidden
this.Write("\r\n\r\n/* Get MIS search results */\r\nSELECT DISTINCT tmd.ItemNumber,\r\n tmd.I" +
"temDescription,\r\n tmd.BranchCode,\r\n tmd.MisSequenceNumber Sequen" +
"ceNumber,\r\n tmd.FunctionCode,\r\n tmd.FunctionOperationDescription" +
",\r\n tmd.SequenceNumber JobStepSequenceNumber,\r\n tmd.MatchedSeque" +
"nceNumber,\r\n tmd.RoutingMatch,\r\n tmd.MasterMatch,\r\n tmd." +
"MisNumber,\r\n tmd.RevID,\r\n tmd.CharNumber,\r\n tmd.TestDesc" +
"ription,\r\n tmd.SamplingType,\r\n tmd.SamplingValue,\r\n tmd." +
"ToolsGauges,\r\n tmd.WorkInstructions,\r\n tmd.Status,\r\n tmd" +
".ReleaseDate\r\nFROM TEMP_MIS tmd\r\nORDER BY tmd.ItemNumber,\r\n tmd.Bran" +
"chCode,\r\n tmd.SequenceNumber,\r\n tmd.MatchedSequenceNumber;\r\n\r\n/*" +
" Get no-match MIS search results */\r\nSELECT DISTINCT tmd.WorkCenterCode,\r\n " +
" tmd.WorkOrderNumber,\r\n TO_DATE(wo.WATRDJ + 1900000, \'YYYYDDD\') Work" +
"OrderStartDate,\r\n tmd.SequenceNumber JobStepNumber,\r\n tmd.Functi" +
"onOperationDescription JobStepDescription,\r\n tmd.StepTimestamp JobStepEn" +
"dDate,\r\n\t\t CASE \r\n\t\t\tWHEN wo.WATRT=\'NMR\' OR \r\n\t\t\t\t NOT EXISTS(SELECT * \r\n\t\t\t\t\t\t\t" +
"FROM F3112Z1_WOR wor \r\n\t\t\t\t\t\t\tWHERE tmd.WorkOrderNumber = wor.SZDOCO AND \r\n\t\t\t\t\t" +
"\t\t\t tmd.SequenceNumber = wor.SZOPSQ\r\n\t\t\t\t\t\t ) THEN 1 \r\n\t\t\tELSE 0 \r\n\t\t END AS" +
" WasJobStepAdded,\r\n\t\t CASE \r\n\t\t\tWHEN wo.WATRT=\'NMR\' THEN NULL \r\n\t\t\tELSE (SELECT " +
"TOP 1 wor.SZOPSQ \r\n\t\t\t\t FROM F3112Z1_WOR wor \r\n\t\t\t\t WHERE (tmd.WorkOrderNum" +
"ber = wor.SZDOCO AND \r\n\t\t\t\t\t\t tmd.WorkCenterCode = wor.SZMCU AND \r\n\t\t\t\t\t\t tmd.Fu" +
"nctionCode = wor.SZURRF) AND \r\n\t\t\t\t\t\t tmd.SequenceNumber <> wor.SZOPSQ\r\n\t\t\t\t ) " +
"\r\n\t\t END AS MatchedJobStepNumber,\r\n tmd.FunctionCode,\r\n tmd.Item" +
"Number,\r\n tmd.ItemDescription,\r\n wo.WATRT AS RoutingType\r\nFROM " +
" TEMP_MIS tmd INNER JOIN \r\n F4801_WO wo ON (tmd.WorkOrderNumber = wo.W" +
"ADOCO) INNER JOIN \r\n F4101_ITEM item ON (wo.WAITM = item.IMITM)\r\nWHERE " +
" (tmd.RoutingMatch = \'F\' AND tmd.MasterMatch = \'F\') OR \r\n tmd.MisNumber" +
" IS NULL\r\nORDER BY tmd.WorkOrderNumber,\r\n tmd.SequenceNumber;\r\n");
#line 380 "D:\SHARE\Visual Studio 2019\LotFinderJDE\TestApp\Templates\QueryTemplate2.tt"
}
#line default
#line hidden
this.Write("/");
return this.GenerationEnvironment.ToString();
}
}
#line default
#line hidden
#region Base class
///
/// Base class for this transformation
///
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public class QueryTemplate2Base
{
#region Fields
private global::System.Text.StringBuilder generationEnvironmentField;
private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField;
private global::System.Collections.Generic.List indentLengthsField;
private string currentIndentField = "";
private bool endsWithNewline;
private global::System.Collections.Generic.IDictionary sessionField;
#endregion
#region Properties
///
/// The string builder that generation-time code is using to assemble generated output
///
protected System.Text.StringBuilder GenerationEnvironment
{
get
{
if ((this.generationEnvironmentField == null))
{
this.generationEnvironmentField = new global::System.Text.StringBuilder();
}
return this.generationEnvironmentField;
}
set
{
this.generationEnvironmentField = value;
}
}
///
/// The error collection for the generation process
///
public System.CodeDom.Compiler.CompilerErrorCollection Errors
{
get
{
if ((this.errorsField == null))
{
this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection();
}
return this.errorsField;
}
}
///
/// A list of the lengths of each indent that was added with PushIndent
///
private System.Collections.Generic.List indentLengths
{
get
{
if ((this.indentLengthsField == null))
{
this.indentLengthsField = new global::System.Collections.Generic.List();
}
return this.indentLengthsField;
}
}
///
/// Gets the current indent we use when adding lines to the output
///
public string CurrentIndent
{
get
{
return this.currentIndentField;
}
}
///
/// Current transformation session
///
public virtual global::System.Collections.Generic.IDictionary Session
{
get
{
return this.sessionField;
}
set
{
this.sessionField = value;
}
}
#endregion
#region Transform-time helpers
///
/// Write text directly into the generated output
///
public void Write(string textToAppend)
{
if (string.IsNullOrEmpty(textToAppend))
{
return;
}
// If we're starting off, or if the previous text ended with a newline,
// we have to append the current indent first.
if (((this.GenerationEnvironment.Length == 0)
|| this.endsWithNewline))
{
this.GenerationEnvironment.Append(this.currentIndentField);
this.endsWithNewline = false;
}
// Check if the current text ends with a newline
if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture))
{
this.endsWithNewline = true;
}
// This is an optimization. If the current indent is "", then we don't have to do any
// of the more complex stuff further down.
if ((this.currentIndentField.Length == 0))
{
this.GenerationEnvironment.Append(textToAppend);
return;
}
// Everywhere there is a newline in the text, add an indent after it
textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField));
// If the text ends with a newline, then we should strip off the indent added at the very end
// because the appropriate indent will be added when the next time Write() is called
if (this.endsWithNewline)
{
this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length));
}
else
{
this.GenerationEnvironment.Append(textToAppend);
}
}
///
/// Write text directly into the generated output
///
public void WriteLine(string textToAppend)
{
this.Write(textToAppend);
this.GenerationEnvironment.AppendLine();
this.endsWithNewline = true;
}
///
/// Write formatted text directly into the generated output
///
public void Write(string format, params object[] args)
{
this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
}
///
/// Write formatted text directly into the generated output
///
public void WriteLine(string format, params object[] args)
{
this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
}
///
/// Raise an error
///
public void Error(string message)
{
System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
error.ErrorText = message;
this.Errors.Add(error);
}
///
/// Raise a warning
///
public void Warning(string message)
{
System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
error.ErrorText = message;
error.IsWarning = true;
this.Errors.Add(error);
}
///
/// Increase the indent
///
public void PushIndent(string indent)
{
if ((indent == null))
{
throw new global::System.ArgumentNullException("indent");
}
this.currentIndentField = (this.currentIndentField + indent);
this.indentLengths.Add(indent.Length);
}
///
/// Remove the last indent that was added with PushIndent
///
public string PopIndent()
{
string returnValue = "";
if ((this.indentLengths.Count > 0))
{
int indentLength = this.indentLengths[(this.indentLengths.Count - 1)];
this.indentLengths.RemoveAt((this.indentLengths.Count - 1));
if ((indentLength > 0))
{
returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength));
this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength));
}
}
return returnValue;
}
///
/// Remove any indentation
///
public void ClearIndent()
{
this.indentLengths.Clear();
this.currentIndentField = "";
}
#endregion
#region ToString Helpers
///
/// Utility class to produce culture-oriented representation of an object as a string.
///
public class ToStringInstanceHelper
{
private System.IFormatProvider formatProviderField = global::System.Globalization.CultureInfo.InvariantCulture;
///
/// Gets or sets format provider to be used by ToStringWithCulture method.
///
public System.IFormatProvider FormatProvider
{
get
{
return this.formatProviderField ;
}
set
{
if ((value != null))
{
this.formatProviderField = value;
}
}
}
///
/// This is called from the compile/run appdomain to convert objects within an expression block to a string
///
public string ToStringWithCulture(object objectToConvert)
{
if ((objectToConvert == null))
{
throw new global::System.ArgumentNullException("objectToConvert");
}
System.Type t = objectToConvert.GetType();
System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] {
typeof(System.IFormatProvider)});
if ((method == null))
{
return objectToConvert.ToString();
}
else
{
return ((string)(method.Invoke(objectToConvert, new object[] {
this.formatProviderField })));
}
}
}
private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper();
///
/// Helper to produce culture-oriented representation of an object as a string
///
public ToStringInstanceHelper ToStringHelper
{
get
{
return this.toStringHelperField;
}
}
#endregion
}
#endregion
}