Create ssrs report (ProductionTraveller) with the print button
Today we have a requirement that create ssrs report with the setting of the print mangement in the production report.
1) Create a helper class that will create a print setup.
2) Create a controller class.
3) Create a DP class.
1) Create a helper class that will create a print setup. :-
class AVAProdTravelerReportHelper
{
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataSourceEventHandler(formDataSourceStr(ProdParmRelease, ProdParmRelease), FormDataSourceEventType::Created),
FormDataSourceEventHandler(formDataSourceStr(ProdParmRelease, ProdParmRelease), FormDataSourceEventType::Activated)]
public static void ProdParmRelease_OnCreated(FormDataSource sender, FormDataSourceEventArgs e)
{
ProdParmRelease prodparmRelease = sender.cursor() as ProdParmRelease;
sender.formRun().design().controlName('SetupButtonProdTraveler').enabled(prodparmRelease.AVAPrintProdTraveler);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormDataFieldEventHandler(formDataFieldStr(ProdParmRelease, ProdParmRelease, AVAPrintProdTraveler), FormDataFieldEventType::Modified)]
public static void AVAPrintProdOrder_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
{
ProdParmRelease prodParmRelease = sender.datasource().cursor() as ProdParmRelease;
sender.datasource().formRun().design().controlName('SetupButtonProdTraveler').enabled(prodparmRelease.AVAPrintProdTraveler);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(ProdParmRelease, SetupButtonProdTraveler), FormControlEventType::Clicked)]
public static void SetupButtonProdOrder_OnClicked(FormControl sender, FormControlEventArgs e)
{
SRSPrintDestinationSettings printJobSettings;
ProdParmRelease prodParmRelease = sender.formRun().dataSource(1).cursor();
printJobSettings = new SRSPrintDestinationSettings(prodParmRelease.AVASetupPrintProdTraveler);
SrsReportRunUtil::showSettingsDialog(printJobSettings);
prodParmRelease.AVASetupPrintProdTraveler = printJobSettings.pack();
}
[FormDataSourceEventHandler(formDataSourceStr(ProdSetupRelease, ProdParmRelease), FormDataSourceEventType::Created),
FormDataSourceEventHandler(formDataSourceStr(ProdSetupRelease, ProdParmRelease), FormDataSourceEventType::Activated)]
public static void ProdSetupRelease_OnCreated(FormDataSource sender, FormDataSourceEventArgs e)
{
ProdParmRelease prodparmRelease = sender.cursor() as ProdParmRelease;
sender.formRun().design().controlName('SetupButtonProdTraveler').enabled(prodparmRelease.AVAPrintProdTraveler);
}
/// <summary>
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(ProdSetupRelease, ProdParmRelease_AVAPrintProdTraveler), FormControlEventType::Clicked)]
public static void ProdParmRelease_AVAPrintProdOrder_OnClicked(FormControl sender, FormControlEventArgs e)
{
ProdParmRelease prodParmRelease = sender.formRun().dataSource(1).cursor() as ProdParmRelease;
sender.formRun().design().controlName('SetupButtonProdTraveler').enabled(prodparmRelease.AVAPrintProdTraveler);
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(ProdSetupRelease, SetupButtonProdTraveler), FormControlEventType::Clicked)]
public static void AVASetupPrintProdorder_OnClicked(FormControl sender, FormControlEventArgs e)
{
SRSPrintDestinationSettings printJobSettings;
ProdParmRelease prodParmRelease = sender.formRun().dataSource(1).cursor();
printJobSettings = new SRSPrintDestinationSettings(prodParmRelease.AVASetupPrintProdTraveler);
SrsReportRunUtil::showSettingsDialog(printJobSettings);
prodParmRelease.AVASetupPrintProdTraveler = printJobSettings.pack();
}
/// <summary>
///
/// </summary>
/// <param name="args"></param>
[PostHandlerFor(classStr(ProdUpdRelease), methodStr(ProdUpdRelease, printout))]
public static void ProdUpdRelease_Post_printout(XppPrePostArgs args)
{
ProdUpdRelease object = args.getThis();
ProdParmRelease prodParmRelease;
prodParmRelease = object.parmParmBuffer();
if (prodParmRelease.AVAPrintProdTraveler == NoYes::Yes)
{
ProdUpd::printoutReportFromMenuItem(menuItemOutputStr(AVAProdTravellerReport), object, object.parmParmBuffer());
}
}
}
=====================================================================
2) Create a controller class. :-
/// <summary>
/// The <c>AVAProdTravellerReportController</c> class is the controller class for the <c>ProdRouteCard</c> report.
/// </summary>
class AVAProdTravellerReportController extends SrsReportRunController
{
/// <summary>
/// Sets the values in the <c>SRSReportParameters</c> table to the report contract.
/// </summary>
protected void prePromptModifyContract()
{
if (args)
{
this.parmShowDialog(!args.parmEnum());
}
this.setRange(this.getFirstQuery());
this.setPrintSettings();
}
/// <summary>
/// Sets the print settings.
/// </summary>
public void setPrintSettings()
{
if (args && (args.caller() is ProdUpdRelease))
{
ProdUpdRelease prodUpdRelease = args.caller();
ProdParmRelease prodParmRelease = prodUpdRelease.parmParmBuffer();
SrsReportDataContract dataContract = this.parmReportContract();
dataContract.parmPrintSettings(new SRSPrintDestinationSettings(prodParmRelease.AVASetupPrintProdTraveler));
}
}
/// <summary>
/// Sets the Microsoft SQL Server Reporting Services Report query range based on the caller.
/// </summary>
/// <param name="_query">
/// The <c>Query</c> report query object.
/// </param>
public void setRange(Query _query)
{
ProdParmRelease prodParmRelease;
ProdId prodId;
QueryBuildDataSource queryBuildDataSource = _query.dataSourceTable(tablenum(ProdTable));
if (!queryBuildDataSource)
{
queryBuildDataSource = _query.addDataSource(tablenum(ProdTable));
}
if (this.parmArgs() && this.parmArgs().dataset())
{
switch (this.parmArgs().dataset())
{
case tablenum(ProdTable):
ProdTable prodTable = this.parmArgs().record();
prodId = prodTable.ProdId;
break;
case tablenum(ProdJournalBOM):
ProdJournalBOM prodJournalBOM = this.parmArgs().record();
prodId = prodJournalBOM.ProdId;
break;
case tableNum(ProdParmRelease):
prodParmRelease = this.parmArgs().record();
prodId = prodParmRelease.ProdId;
break;
default:
throw error(strfmt("@SYS23396",funcname()));
}
}
if (this.parmArgs() && (this.parmArgs().caller() is ProdUpdRelease))
{
ProdUpdRelease prodUpdRelease = this.parmArgs().caller();
prodParmRelease = prodUpdRelease.parmParmBuffer();
prodId = prodParmRelease.ProdId;
}
SysQuery::findOrCreateRange(queryBuildDataSource, fieldnum(ProdTable, ProdId)).value(prodId);
}
public static void main(Args _args)
{
AVAProdTravellerReportController controller = new AVAProdTravellerReportController();
controller.parmArgs(_args);
controller.parmReportName(ssrsReportStr(AVAProdTravellerReport, Report));//Report
controller.parmShowDialog(false);
controller.startOperation();
}
}
=========================================================================
3) Create a DP class. :-
/// <summary>
/// The <c>AVAProdTravellerReportDP</c> class is the RDP class for the <c>AVAProdTravellerReport</c>Microsoft SQL Server
/// Reporting Services report.
/// </summary>
[
SRSReportQueryAttribute(queryStr(AVAProdTravellerReport))
]
class AVAProdTravellerReportDP extends SRSReportDataProviderPreProcessTempDB
{
DocuRef docuRef;
ProdTable prodTable,updateProdTable;
ProdRoute prodRoute;
InventDim inventDimProdTable,inventDimLocProd,inventDimBuffer;
// InventDim ;
InventDimCombination inventDimCombiantion;
EcoResDistinctProductVariant ecoResDistinctProductVariant;
InventDistinctProductExpanded InventDistinctProduct;
WHSProductVariantFixedLocation whsProductVariantFixedLocationProd;
WHSInventFixedLocation whsInventFixedLocationProd,whsInventFixedLocationBom;
InventTransOrigin inventTransOrigin;
InventQty primaryQty;
Integer totalCardNo;
Integer thisCardNo;
Integer docuVisibility;
BarcodeSetupId barcodeSetupId;
BarcodeSetup barcodeSetup;
Barcode jobBarCode;
DocuRefSearch docuRefSearch;
AVAProdTravellersReportTmp prodTravellerTmp, prodTravellerTmpBuffer;
JmgProdParametersDim jmgProdParametersDim;
RecordInsertList recordInsertList;
int line, lineSec;
int retryCount, retryCountSec;
//AVA_34510_PaintForTransfersToEXT_19052021_SN
boolean checkFromLocationTO;
Qty transferQuantity;
//AVA_34510_PaintForTransfersToEXT_19052021_EN
#OCCRetryCount
#define.DeadLockRetryCount(10)
#define.DeadLockRetryWait(500)
/// <summary>
/// Sets the Visibility for the barcode string.
/// </summary>
private void init()
{
// Shop Floor Control begin
barcodeSetupId = JmgParameters::find().getBarcodeSetupId();
barcodeSetup = BarcodeSetup::find(barcodeSetupId);
jobBarCode = barcodeSetup.barcode();
// Shop Floor Control end
}
/// <summary>
/// Calculates the barcode string.
/// </summary>
/// <param name="_text">
/// The text of the fields.
/// </param>
/// <returns>
/// The barcode string value for the specified fields.
/// </returns>
public BarCodeString getBarcodeString(str _text)
{
BarCodeString ret;
if(_text)
{
if(barcodeSetup.validateBarcode(strupr(_text)))
{
jobBarCode.string(true,strupr(_text));
jobBarCode.encode();
ret=jobBarCode.barcodeStr();
}
else
{
throw(error(strfmt("@RET5019",strupr(_text))));
}
}
else
{
ret = '';
}
return ret;
}
/// <summary>
/// Queries the temporary table and retrieves the data table to the calling method.
/// </summary>
/// <returns>
/// The required report data from temporary table.
/// </returns>
[
SRSReportDataSetAttribute(tableStr(AVAProdTravellersReportTmp))
]
public AVAProdTravellersReportTmp getprodTravellerTmp()
{
select prodTravellerTmp;
return prodTravellerTmp;
}
/// <summary>
/// Get the resource from the routes detail of production order
/// </summary>
private WrkCtrId getResource()
{
WrkCtrCapRes wrkCtrCapRes;
select firstonly WrkCtrId from wrkCtrCapRes
where wrkCtrCapRes.OprPriority == prodRoute.OprPriority &&
wrkCtrCapRes.OprNum == prodRoute.OprNum &&
wrkCtrCapRes.RefId == prodRoute.ProdId &&
wrkCtrCapRes.RecordState == WrkCtrCapResRecordState::Committed &&
wrkCtrCapRes.RefType == WrkCtrCapRefType::Production;
return wrkCtrCapRes.WrkCtrId;
}
/// <summary>
/// This is used to get the resource group which is tag on the resource
/// </summary>
private WrkCtrGroupId getResourceGroup()
{
WrkCtrCapRes wrkCtrCapRes;
WrkCtrResourceGroupResource wrkCtrResourceGroupResource;
WrkCtrResourceGroup wrkCtrResourceGroup;
select firstonly WrkCtrId from wrkCtrCapRes
where wrkCtrCapRes.OprPriority == prodRoute.OprPriority &&
wrkCtrCapRes.OprNum == prodRoute.OprNum &&
wrkCtrCapRes.RefId == prodRoute.ProdId &&
wrkCtrCapRes.RecordState == WrkCtrCapResRecordState::Committed &&
wrkCtrCapRes.RefType == WrkCtrCapRefType::Production
exists join wrkCtrResourceGroupResource
where wrkCtrResourceGroupResource.WrkCtrId == wrkCtrCapRes.WrkCtrId
join wrkCtrResourceGroup
where wrkCtrResourceGroup.RecId == wrkCtrResourceGroupResource.ResourceGroup;
return wrkCtrResourceGroup.WrkCtrId;
}
/// <summary>
/// This is used to get the Next resource detail for the next opr num
/// </summary>
private WrkCtrId getNextResourceDetail()
{
WrkCtrCapRes wrkCtrCapRes;
select firstonly WrkCtrId from wrkCtrCapRes
where wrkCtrCapRes.OprNum == prodRoute.OprNumNext
&& wrkCtrCapRes.OprPriority == prodRoute.OprPriority
&& wrkCtrCapRes.RefId == prodRoute.ProdId
&& wrkCtrCapRes.RefType == WrkCtrCapRefType::Production;
return wrkCtrCapRes.WrkCtrId;
}
/// <summary>
/// Retrieves the required data and inserts it into the temporary table.
/// </summary>
public void insertValues(recordInsertList _recordInsertListTmpBuffer)
{
//Prodtable details section
prodTravellerTmpBuffer.InventRefId = prodTable.InventRefId;
prodTravellerTmpBuffer.InventRefType = prodTable.InventRefType;
//AVA_34510_PaintForTransfersToEXT_19052021_SN
if(!transferQuantity && !checkFromLocationTO)
{
this.sumOfTOQuantities(prodTable);
this.checkToWarehouse(prodTable);
}
if(transferQuantity < prodTable.QtySched || checkFromLocationTO)
{
prodTravellerTmpBuffer.ProdId = prodTable.ProdId + "*";
}
else
{
prodTravellerTmpBuffer.ProdId = prodTable.ProdId;
}
//AVA_34510_PaintForTransfersToEXT_19052021_EN
prodTravellerTmpBuffer.ProdIdBarcode = this.getBarcodeString(prodTable.ProdId);
prodTravellerTmpBuffer.ItemId = prodTable.ItemId;
prodTravellerTmpBuffer.ProdUnitID = InventTableModule::find(prodTable.ItemId,ModuleInventPurchSales::Invent).UnitId;
prodTravellerTmpBuffer.ProdItemIdBarcode = this.getBarcodeString(prodTable.ItemId);
prodTravellerTmpBuffer.ItemName = prodTable.itemName();
prodTravellerTmpBuffer.Name = prodTable.Name;
prodTravellerTmpBuffer.ProdQty = prodTable.QtySched;
prodTravellerTmpBuffer.ProdSchedDate = prodTable.SchedStart;
prodTravellerTmpBuffer.ProdDlvDate = prodTable.DlvDate;
// Prod item product dimension detail with barcode
prodTravellerTmpBuffer.InventColorId = inventDimProdTable.InventColorId;
prodTravellerTmpBuffer.ProdItemIdColorBarcode = this.getBarcodeString(inventDimProdTable.InventColorId);
prodTravellerTmpBuffer.RevisionId = inventDimProdTable.InventDimension1;
prodTravellerTmpBuffer.ProdItemIdRevisionBarcode = this.getBarcodeString(inventDimProdTable.InventDimension1);
prodTravellerTmpBuffer.InventStyleId = inventDimProdTable.InventStyleId;
prodTravellerTmpBuffer.ProdItemIdStyleBarcode = this.getBarcodeString(inventDimProdTable.InventStyleId);
prodTravellerTmpBuffer.configId = inventDimProdTable.configId;
prodTravellerTmpBuffer.ProdItemIdConfigBarcode = this.getBarcodeString(inventDimProdTable.configId);
prodTravellerTmpBuffer.InventSizeId = inventDimProdTable.InventSizeId;
prodTravellerTmpBuffer.ProdItemIdSizeBarcode = this.getBarcodeString(inventDimProdTable.InventSizeId);
prodTravellerTmpBuffer.CardNo = strfmt("@SYS25607", thisCardNo, totalCardNo);
prodTravellerTmpBuffer.ReferenceName = prodTable.referenceName();
//ProdRoute table Details
prodTravellerTmpBuffer.OperationName = RouteOprTable::find(prodRoute.OprId).Name;
prodTravellerTmpBuffer.OprId = prodRoute.OprId;
prodTravellerTmpBuffer.OperationIdBarcode = this.getBarcodeString(int2Str(prodRoute.OprNum));
prodTravellerTmpBuffer.OprNum = prodRoute.OprNum;
//prodTravellerTmpBuffer.OprPriority = prodRoute.OprPriority;
prodTravellerTmpBuffer.OprId = prodRoute.OprId;
prodTravellerTmpBuffer.AVAOprDescription = RouteOpr::findRecId(ProdRoute.RouteOprRefRecId).AVAOprDescription;
prodTravellerTmpBuffer.CalcProc = prodRoute.CalcProc;
prodTravellerTmpBuffer.CalcSetUp = prodRoute.CalcSetUp;
prodTravellerTmpBuffer.Resource = this.getResource();
// If resource is not there then get the resource group
if (!prodTravellerTmpBuffer.Resource)
{
prodTravellerTmpBuffer.Resource = this.getResourceGroup();
}
prodTravellerTmpBuffer.RouteNextOperationInfo = 'Next Operation' + ' ' + int2Str(prodRoute.OprNumNext) + ' ' + 'Resource' + ' ' + this.getNextResourceDetail();
prodTravellerTmpBuffer.FromDate = prodRoute.FromDate;
prodTravellerTmpBuffer.FromTime = prodRoute.FromTime;
prodTravellerTmpBuffer.ToDate = prodRoute.ToDate;
prodTravellerTmpBuffer.ToTime = prodRoute.ToTime;
/* To fill the routes note
prodTravellerTmpBuffer.DocuName = docuRef.Name;
prodTravellerTmpBuffer.DocTypeId = docuRef.TypeId;
prodTravellerTmpBuffer.Notes = docuref.Notes;
prodTravellerTmpBuffer.TypeVisibility = docuVisibility;
*/
prodTravellerTmpBuffer.FontName = barcodeSetup.FontName;
prodTravellerTmpBuffer.FontSize = barcodeSetup.fontSize;
// To get the MFLegacyPartNo.
select firstonly AVAMFLegacyPartNumber, DisplayProductNumber from ecoResDistinctProductVariant
exists join inventDimCombiantion
where ecoResDistinctProductVariant.RecId == inventDimCombiantion.DistinctProductVariant
exists join inventDimBuffer
where inventDimCombiantion.InventDimId == inventDimBuffer.inventDimId
&& inventDimCombiantion.ItemId == prodTable.ItemId
&& inventDimBuffer.InventColorId == inventDimProdTable.InventColorId
&& inventDimBuffer.InventSizeId == inventDimProdTable.InventSizeId
&& inventDimBuffer.InventStyleId == inventDimProdTable.InventStyleId
&& inventDimBuffer.InventDimension1 == inventDimProdTable.InventDimension1
&& inventDimBuffer.InventLocationId == ''
&& inventDimBuffer.InventSiteId == '';
prodTravellerTmpBuffer.MFLegacyPartNo = ecoResDistinctProductVariant.AVAMFLegacyPartNumber;
prodTravellerTmpBuffer.MFLegacyPartNoBarcode = this.getBarcodeString(ecoResDistinctProductVariant.AVAMFLegacyPartNumber);
prodTravellerTmpBuffer.ProductVariantNumber = ecoResDistinctProductVariant.DisplayProductNumber;
prodTravellerTmpBuffer.ProdVarinatNumberBarcode = this.getBarcodeString(ecoResDistinctProductVariant.DisplayProductNumber);
// This is to create a barcode of item + Varient.
//select InventDistinctProduct
// join inventDimProdTable
// where InventDistinctProduct.configId == inventDimProdTable.configId
// && InventDistinctProduct.InventColorId == inventDimProdTable.InventColorId
// && InventDistinctProduct.InventSizeId == inventDimProdTable.InventSiteId
// && InventDistinctProduct.InventStyleId == inventDimProdTable.InventStyleId
// && InventDistinctProduct.InventVersionId == inventDimProdTable.InventVersionId
// && InventDistinctProduct.AVAEcoResProductRevName == inventDimProdTable.InventDimension1
// && InventDistinctProduct.ItemId == prodTable.ItemId
//prodTravellerTmpBuffer.ProdItemIdBarcode = this.getBarcodeString(InventDistinctProduct.DisplayProductNumber);
// To get the item product varient or productvarient location
select firstonly whsInventFixedLocationProd
where whsInventFixedLocationProd.ItemId == prodTable.ItemId
join inventDimProdTable
where inventDimProdTable.inventDimId == prodTable.InventDimId
&& inventDimProdTable.InventLocationId == whsInventFixedLocationProd.InventLocationId
&& inventDimProdTable.InventSiteId == whsInventFixedLocationProd.InventSiteId;
prodTravellerTmpBuffer.ProdItemLocationId = whsInventFixedLocationProd.WMSLocationId;
if(!prodTravellerTmpBuffer.ProdItemLocationId)
{
select firstonly whsProductVariantFixedLocationProd
where whsProductVariantFixedLocationProd.ItemId == prodTable.ItemId
exists join inventTransOrigin
where inventTransOrigin.ItemId == prodTable.ItemId
&& inventTransOrigin.ItemInventDimId == whsProductVariantFixedLocationProd.ProductVariantInventDimId
&& inventTransOrigin.ReferenceId == prodTable.ProdId
&& inventTransOrigin.ReferenceCategory == InventTransType::Production;
prodTravellerTmpBuffer.ProdItemLocationId = whsProductVariantFixedLocationProd.WMSLocationId;
}
// prodTravellerTmpBuffer.insert();
if(prodTable.AVAIsPrintedProdTraveler)
{
prodTravellerTmpBuffer.PrintType = "@SYS12898";
}
//AVA_33996_ProductionTravelerReport_19052021_Case34510_SN
if(prodTravellerTmpBuffer.TransferId)
{
InventTransferLine transferLine;
InventTransferTable transferTable = InventTransferTable::find(prodTravellerTmpBuffer.TransferId);
select sum(QtyTransfer) from transferLine
where transferLine.TransferId == prodTravellerTmpBuffer.TransferId;
prodTravellerTmpBuffer.InventLocationIdTo = transferTable.InventLocationIdTo;
prodTravellerTmpBuffer.QtyTransfer = transferLine.QtyTransfer;
}
//AVA_33996_ProductionTravelerReport_19052021_Case34510_EN
_recordInsertListTmpBuffer.add(prodTravellerTmpBuffer);
prodTravellerTmpBuffer.clear();
}
/// <summary>öi
/// Processes the report business logic.
/// </summary>
/// <remarks>
/// This method calls sub methods, depending on the parameters that are passed to it.
/// </remarks>
Public void processReport()
{
ProdBOM prodBom;
AVAReqLinkedTransferOrder linkedTransferOrder;
RecordInsertList recordInsertListTmpBuffer = new RecordInsertList(tableNum(AVAProdTravellersReportTmp), true, true, true, false, true, prodTravellerTmpBuffer);
this.init();
// Shop Floor Control end
QueryRun qr = new QueryRun(this.parmQuery());
while (qr.next())
{
prodTable = qr.get(tablenum(ProdTable));
ProdRouteIterator iter = new ProdRouteIterator(prodTable.ProdId);
thisCardNo = 1;
totalCardNo = iter.qty();
// AVA_34354_ProductionOrdersInNests_11052021_N
boolean iscatchFound = False;
//AVA_34510_PaintForTransfersToEXT_19052021_SN
checkFromLocationTO = False;
transferQuantity = 0.00;
//AVA_34510_PaintForTransfersToEXT_19052021_EN
while (iter.qty())
{
boolean isRecordAdded = false;
prodRoute = iter.next();
try
{
ProdRouteOprIterator oprIter = new ProdRouteOprIterator(prodRoute.ProdId, prodRoute.OprNum);
while (oprIter.qty())
{
prodRoute = oprIter.next();
isRecordAdded = false;
inventDimProdTable = InventDim::find(prodTable.inventDimID);
// Get the related BOM detail related to production order
while select prodBom
where prodBom.ProdId == prodTable.ProdId
{
InventDim inventDimProdBom, inventDimLocB;
WHSProductVariantFixedLocation whsProductVariantFixedLocation;
inventTransOrigin inventTransOriginBom;
InventLocationId locationID;
inventDimProdBom = InventDim::find(prodBom.inventDimID);
prodTravellerTmpBuffer.BomItemId = prodBom.ItemId;
prodTravellerTmpBuffer.BomDescription = prodBom.itemNameGrid();
prodTravellerTmpBuffer.BomQty = prodBom.RemainBOMPhysical;
prodTravellerTmpBuffer.BomUnitId = prodBom.UnitId;
prodTravellerTmpBuffer.BomItemColorId = inventDimProdBom.InventColorId;
prodTravellerTmpBuffer.BomItemRevisionId = inventDimProdBom.InventDimension1;
prodTravellerTmpBuffer.BomItemSizeId = inventDimProdBom.InventSizeId;
prodTravellerTmpBuffer.BomItemStyleId = inventDimProdBom.InventStyleId;
prodTravellerTmpBuffer.BomConfigId = inventDimProdBom.configId;
// Store the location Id of the prodbom material
locationID = inventDimProdBom.InventLocationId;
select firstonly inventTransOriginBom
where inventTransOriginBom.ItemId == prodBom.ItemId
&& inventTransOriginBom.InventTransId == prodBom.InventTransId
&& inventTransOriginBom.ReferenceCategory ==InventTransType::ProdLine
join whsProductVariantFixedLocation
where whsProductVariantFixedLocation.ItemId == inventTransOriginBom.ItemId
&& whsProductVariantFixedLocation.ProductVariantInventDimId == inventTransOriginBom.ItemInventDimId
&& whsProductVariantFixedLocation.InventLocationId == locationID;
prodTravellerTmpBuffer.BomItemLocationId = whsProductVariantFixedLocation.WMSLocationId;
// If there is no fixed loction varient it will check the fixed location of product
if(!whsProductVariantFixedLocation.WMSLocationId)
{
select firstonly whsInventFixedLocationBom
where whsInventFixedLocationBom.ItemId == prodBom.ItemId
exists join inventDimProdBom
where inventDimProdBom.inventDimId == prodBom.InventDimId
&& inventDimProdBom.InventLocationId == whsInventFixedLocationBom.InventLocationId
&& inventDimProdBom.InventSiteId == whsInventFixedLocationBom.InventSiteId;
prodTravellerTmpBuffer.BomItemLocationId = whsInventFixedLocationBom.WMSLocationId;
}
this.insertValues(recordInsertListTmpBuffer);
isRecordAdded = true;
}
if(isRecordAdded)
{
recordInsertListTmpBuffer.insertDatabase();
}
// Get the related transfer order of production order
while select linkedTransferOrder
where linkedTransferOrder.ProdId == prodTable.ProdId
{
prodTravellerTmpBuffer.TransferId = linkedTransferOrder.RefId;
this.insertValues(recordInsertListTmpBuffer);
isRecordAdded = true;
}
if(isRecordAdded)
{
recordInsertListTmpBuffer.insertDatabase();
}
}
}
catch(Exception::Deadlock)
{
// AVA_34354_ProductionOrdersInNests_11052021_N
iscatchFound = true;
error("@SYS25609");
}
}
// AVA_34354_ProductionOrdersInNests_11052021_SN
// To update the prodtable isprinted field when report run when no catch error found
if(!iscatchFound)
{
select firstonly forupdate updateProdTable
where updateProdTable.ProdId == prodTable.ProdId
&& updateProdTable.AVAIsPrintedProdTraveler == NoYes::No;
if(updateProdTable)
{
ttsbegin;
updateProdTable.AVAIsPrintedProdTraveler = NoYes::Yes;
updateProdTable.doUpdate();
ttscommit;
}
}
// AVA_34354_ProductionOrdersInNests_11052021_EN
}
//Shorting again on the state,oprnum,resource and proid in accending order
recordInsertList = new RecordInsertList(tableNum(AVAProdTravellersReportTmp),false,false,false,false,false,prodTravellerTmp);
while select prodTravellerTmpBuffer order by ProdSchedDate,oprnum, resource, ProdId asc
{
prodTravellerTmp.data(prodTravellerTmpBuffer);
recordInsertList.add(prodTravellerTmp);
}
recordInsertList.insertDatabase();
}
//AVA_34510_PaintForTransfersToEXT_19052021_SN
// Get the sum of the all linked transfer order qty from transfer order..
private Qty sumOfTOQuantities(ProdTable _prodTable)
{
AVAReqLinkedTransferOrder linkedTransferOrder;
InventTransferLine transferLine;
while select linkedTransferOrder
where linkedTransferOrder.ProdId == _prodTable.ProdId
if(linkedTransferOrder.RefId)
{
select sum(QtyTransfer) from transferLine
where transferLine.TransferId == linkedTransferOrder.RefId;
transferQuantity += transferLine.QtyTransfer;
}
return transferQuantity;
}
//AVA_34510_PaintForTransfersToEXT_19052021_EN
//AVA_34510_PaintForTransfersToEXT_19052021_SN
// Check the linked Transfer order To warehouse If found EXT display "*" in prodid..
private boolean checkToWarehouse(ProdTable _prodTable)
{
AVAReqLinkedTransferOrder linkedTransferOrder;
InventTransferTable transferTable;
while select linkedTransferOrder
where linkedTransferOrder.ProdId == _prodTable.ProdId
join transferTable
where transferTable.TransferId == linkedTransferOrder.RefId
&& transferTable.InventLocationIdTo == "EXT"
if(transferTable.RecId)
{
checkFromLocationTO = true;
break;
}
return checkFromLocationTO;
}
//AVA_34510_PaintForTransfersToEXT_19052021_EN
}
==============================================
Comments
Post a Comment