class NEC_ItemBlockedDialog extends RunBase
{
DialogRunbase dialog;
DialogGroup dialogGrp;
FormBuildStringControl fbsCtrlPromotion;
FormStringControl fsCtrlPromotion;
SysLookupMultiSelectCtrl msCtrlPromotion;
container msWhcon;
InventLocationId msWhStr,warehouse;
WHSWorkTable wHSWorkTable;
int i;
public Object dialog()
{
FormBuildControl setupGroupControl;
;
dialog = super();
dialog.alwaysOnTop(true);
dialog.windowType(FormWindowType::Workspace);
dialogGrp = dialog.addGroup('Item Block Dialog');
setupGroupControl = dialog.formBuildDesign().control(dialogGrp.formBuildGroup().id());
fbsCtrlPromotion = setupGroupControl.addControl(FormControlType::String, identifierstr(InventLocationId));
fbsCtrlPromotion.label('Ware House');
dialog.allowUpdateOnSelectCtrl(true);
this.dialogSelectCtrl();
return dialog;
}
public void dialogPostRun(DialogRunbase _dialog)
{
FormRun formRun;
super(dialog);
formRun = _dialog.dialogForm().formRun();
if (formRun)
{
fsCtrlPromotion = formRun.design().control(fbsCtrlPromotion.id());
msCtrlPromotion = SysLookupMultiSelectCtrl::constructWithQuery(formRun, fsCtrlPromotion, this.buildQuery());
}
}
public boolean getFromDialog()
{
boolean ret;
#Characters
ret = super();
if (msCtrlPromotion)
{
msWhcon = msCtrlPromotion.getSelectedFieldValues(); // get actual value of the selected rows
}
msWhStr = con2StrUnlimited(msWhcon,#comma);
this.itemblocking(msWhStr);
return ret;
}
public static void main(Args _args)
{
NEC_ItemBlockedDialog ItemBlock;
ItemBlock = new NEC_ItemBlockedDialog();
if(ItemBlock.prompt())
{
ItemBlock.run();
}
}
public query buildQuery()
{
Query q = new Query();
QueryBuildDataSource qbds;
;
qbds = q.addDataSource(tablenum(WHSWorkTable));
qbds.addSelectionField(fieldNum(WHSWorkTable, InventLocationId));
qbds.addSortField(fieldNum(WHSWorkTable,InventLocationId));
qbds.orderMode(OrderMode::GroupBy);
while select wHSWorkTable
{
qbds.addRange(fieldNum(WHSWorkTable,InventLocationId)).value(wHSWorkTable.InventLocationId);
}
return q;
}
public void itemblocking(InventLocationId _inventLocationId)
{
container con,c;
WHSWorkLine wHSWorkLine;
InventTable inventTable;
InventDim inventDim;
InventItemLocation inventItemLocation;
InventItemLocationCountingStatus inventItemLocationCountingStatus;
int value;
str locationid,itemnum,text;
boolean blocked;
boolean unBlocked;
boolean statusClose;
con = str2con(_inventLocationId);
for(i=1;i<=conLen(con);i++)
{
blocked = false;
unBlocked = false;
statusClose = false;
value = 0;
warehouse = conPeek(con,i);
while select wHSWorkTable
where wHSWorkTable.InventLocationId == warehouse
&& wHSWorkTable.WorkStatus == WHSWorkStatus::Open
&& wHSWorkTable.WorkTransType == WHSWorkTransType::CycleCount
join wHSWorkLine
where wHSWorkLine.WorkId == wHSWorkTable.WorkId
join inventDim
where inventDim.inventDimId == wHSWorkLine.InventDimId
{
if(inventDim.inventDimId)
{
value = 1;
select inventItemLocation
where inventItemLocation.inventDimId == inventDim.inventDimId
join inventItemLocationCountingStatus
where inventItemLocationCountingStatus.InventDimId == inventItemLocation.inventDimId
&& inventItemLocationCountingStatus.ItemId == inventItemLocation.ItemId;
if(!inventItemLocation.inventDimId)
{
inventItemLocation.CountGroupId = 'Default';
inventItemLocation.inventDimId = inventDim.inventDimId;
inventItemLocation.ItemId = wHSWorkLine.ItemId;
inventItemLocation.insert();
inventItemLocationCountingStatus.CountingStarted = NoYes::Yes;
inventItemLocationCountingStatus.InventDimId = inventDim.inventDimId;
inventItemLocationCountingStatus.ItemId = wHSWorkLine.ItemId;
inventItemLocationCountingStatus.insert();
blocked = true;
}
else
{
unBlocked = true;
}
}
}
if(!inventDim.inventDimId && value == 0)
{
statusClose = true;
}
if (blocked)
{
info(strFmt("Items are blocked for selected Warehouse: %1", warehouse));
}
if (unBlocked)
{
warning(strFmt(" Items are already blocked for selected Warehouse: %1", warehouse));
}
if (statusClose)
{
warning(strFmt("No items for selected Warehouse: %1 with status 'Open' and type 'Cycle counting'", warehouse));
}
}
}
}