Created
July 11, 2023 13:09
-
-
Save bayramcetin/8ba3699abaec39bb1e1a609cece7ec69 to your computer and use it in GitHub Desktop.
Dialog Multiselect Lookup in Batch Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ETGVehicleExpenseCalculatorBatch extends RunBaseBatch | |
{ | |
TransDate fromDate, toDate; | |
DialogField dlgFromDate, dlgToDate; | |
container businessUnits; | |
SysLookupMultiSelectCtrl businessUnitMultiSelect; | |
FormBuildStringControl businessUnitCtrl; | |
DialogField businessUnitsField; | |
#define.CurrentVersion(1) | |
#define.Version1(1) | |
#localmacro.CurrentList | |
fromDate, | |
toDate, | |
businessUnits | |
#endmacro | |
public Object dialog() | |
{ | |
DialogRunbase dialog; | |
DialogGroup dialogGroup; | |
FormBuildControl formBuildControl; | |
dialog = super(); | |
dialog.allowUpdateOnSelectCtrl(true); | |
dialogGroup = dialog.addGroup(); | |
dlgFromDate = dialog.addFieldValue(extendedTypeStr(FromDate),fromDate); | |
dlgToDate = dialog.addFieldValue(extendedTypeStr(ToDate),toDate); | |
formBuildControl = dialog.formBuildDesign().control(dialogGroup.formBuildGroup().id()); | |
businessUnitCtrl = formBuildControl.addControl(FormControlType::String, identifierstr(OMOperatingUnitNumber)); | |
businessUnitCtrl.label("@SYS313109"); | |
return dialog; | |
} | |
public void dialogPostRun(DialogRunbase dialog) | |
{ | |
FormRun formRun; | |
FormStringControl fsCtrlBusinessUnit; | |
Query q; | |
QueryBuildDataSource qbds; | |
q = new Query(); | |
qbds = q.addDataSource(tablenum(OMOperatingUnit)); | |
QueryBuildRange qbrBusinessUnit = qbds.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)); | |
qbrBusinessUnit.value(queryValue(OMOperatingUnitType::OMBusinessUnit)); | |
qbrBusinessUnit.status(RangeStatus::Locked); | |
qbds.addSelectionField(fieldNum(OMOperatingUnit, OMOperatingUnitNumber)); | |
qbds.addSelectionField(fieldNum(OMOperatingUnit, Name)); | |
super(dialog); | |
formRun = dialog.dialogForm().formRun(); | |
if (formRun) | |
{ | |
fsCtrlBusinessUnit = formRun.design().control(businessUnitCtrl.id()); | |
businessUnitMultiSelect = SysLookupMultiSelectCtrl::constructWithQuery(formRun, fsCtrlBusinessUnit, q); | |
businessUnitMultiSelect.set([this.businessUnitIdsToRecIds(businessUnits), businessUnits]); | |
} | |
} | |
public boolean getFromDialog() | |
{ | |
boolean ret; | |
ret = super(); | |
fromDate = dlgFromDate.value(); | |
toDate = dlgToDate.value(); | |
businessUnits = this.businessUnitRecIdsToIDs(businessUnitMultiSelect.get()); | |
return ret; | |
} | |
public container businessUnitIdsToRecIds(container _businessUnitIds) | |
{ | |
OMOperatingUnit omOperatingUnit; | |
OMOperatingUnitNumber omOperatingUnitNumber; | |
container omOperatingUnitRecIds; | |
int i; | |
omOperatingUnitRecIds = conNull(); | |
for (i = 1; i <= conLen(_businessUnitIds); i++) | |
{ | |
omOperatingUnitNumber = conPeek(_businessUnitIds, i); | |
select firstOnly RecId from omOperatingUnit | |
where omOperatingUnit.OMOperatingUnitNumber == omOperatingUnitNumber; | |
omOperatingUnitRecIds += [omOperatingUnit.RecId]; | |
} | |
return omOperatingUnitRecIds; | |
} | |
public container businessUnitRecIdsToIDs(container _businessUnitRecIds) | |
{ | |
OMOperatingUnit omOperatingUnit; | |
RecId omOperatingUnitRecId; | |
container omOperatingUnitNumbers; | |
int i; | |
omOperatingUnitNumbers = conNull(); | |
for (i = 1; i <= conLen(_businessUnitRecIds); i++) | |
{ | |
omOperatingUnitRecId = conPeek(_businessUnitRecIds, i); | |
select firstOnly OMOperatingUnitNumber from omOperatingUnit | |
where omOperatingUnit.RecId == omOperatingUnitRecId; | |
omOperatingUnitNumbers += [omOperatingUnit.OMOperatingUnitNumber]; | |
} | |
return omOperatingUnitNumbers; | |
} | |
protected void new() | |
{ | |
super(); | |
} | |
public container pack() | |
{ | |
return [#CurrentVersion,#CurrentList]; | |
} | |
public void run() | |
{ | |
#OCCRetryCount | |
RetailStoreTable retailStoreTable; | |
DataAreaId dataAreaId; | |
try | |
{ | |
ttsbegin; | |
Query query = new Query(); | |
QueryBuildDataSource qbds = query.addDataSource(tableNum(RetailStoreTable)); | |
qbds.addGroupByField(fieldNum(RetailStoreTable, inventLocationDataAreaId)); | |
qbds.addRange(fieldNum(RetailStoreTable, ETGBussinessUnit)).value(SysQueryRangeUtil::queryListRange(con2List(businessUnits))); | |
QueryRun qr = new QueryRun(query); | |
while(qr.next()) | |
{ | |
retailStoreTable = qr.get(tableNum(RetailStoreTable)); | |
dataAreaId = retailStoreTable.inventLocationDataAreaId; | |
changeCompany(dataAreaId) | |
{ | |
//... | |
} | |
} | |
ttscommit; | |
} | |
catch (Exception::Deadlock) | |
{ | |
retry; | |
} | |
catch (Exception::UpdateConflict) | |
{ | |
if (appl.ttsLevel() == 0) | |
{ | |
if (xSession::currentRetryCount() >= #RetryNum) | |
{ | |
throw Exception::UpdateConflictNotRecovered; | |
} | |
else | |
{ | |
retry; | |
} | |
} | |
else | |
{ | |
throw Exception::UpdateConflict; | |
} | |
} | |
} | |
public boolean runsImpersonated() | |
{ | |
return true; | |
} | |
public boolean unpack(container packedClass) | |
{ | |
Version version = RunBase::getVersion(packedClass); | |
; | |
switch (version) | |
{ | |
case #CurrentVersion: | |
[version,#CurrentList] = packedClass; | |
break; | |
default: | |
return false; | |
} | |
return true; | |
} | |
public static ETGVehicleExpenseCalculatorBatch construct() | |
{ | |
return new ETGVehicleExpenseCalculatorBatch(); | |
} | |
public static ClassDescription description() | |
{ | |
return "Araç giderleri yapılandırma toplu iş"; | |
} | |
public static void main(Args args) | |
{ | |
ETGVehicleExpenseCalculatorBatch calculatorBatch = ETGVehicleExpenseCalculatorBatch::construct(); | |
if (calculatorBatch.prompt()) | |
calculatorBatch.run(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment