void
callerRefresh()
{
Object
formObject;
if(element.args().caller() &&
element.args().caller().name() == formstr(SalesTable))
{
formObject = element.args().caller();
formObject.doRefresh();
}
}
public void
init()
{
super();
//get record from caller
if(element.args() &&
element.args().record() &&element.args().record().TableId == tableNum(WMSOrderTrans))
{
wmsot
= element.args().record();
}
}
============================= sample ==============================
void clicked()
{
InventJournalTable
_getRecordInventJournalTable;
Args _args;
FormRun _FormRun;
Journalid
_Journalid;
;
_getRecordInventJournalTable = element.args().record();
_Journalid = InventJournalTable.JournalId;
_args = new Args();
_args.name(formstr(BIT_FM_TempFFB));
_args.caller(this);
_args.parm(_Journalid);
_args.record(InventJournalTable);
_FormRun
= classFactory.formRunClass(_args);
_FormRun.init();
_FormRun.run();
_FormRun.wait();
}
public void
init()
{
super();
//get record from caller
if(element.args() &&
element.args().record() && element.args().record().TableId == tableNum(InventJournalTable))
{
_InventJournalTable = element.args().record();
}
}
public void
Generate()
{
int
rowCount = 0;
int i = 1;
boolean isCheckHG,
isCheckPL, isCheckPR = false;
InventTransId inventTransID;
Object
callerForm = element.args().caller();
//kl _tmpPurchLine_ds gak bisa otomatis diakses, declarasi
dulu
InventJournalTrans _InventJournalTrans;
InventDim _Inventdim;
InventDimId
_InventdimidHG, _InventdimidPC, _InventdimidPL;
str
inventDimArray[3];
Qty
qtyArray[3];
MainAccountNum inventAccountNum;
DimensionAttributeValueCombination dimensionAttributeValueCombination;
str 10
ffbConfig[3];
if(_InventJournalTable &&
BIT_Tb_TemporaryFFB.InUse != NoYes::Yes
&& (BIT_Tb_TemporaryFFB.QtyHG +
BIT_Tb_TemporaryFFB.QtyPC + BIT_Tb_TemporaryFFB.QtyPL ==
BIT_Tb_TemporaryFFB.Qty))
{
if(BIT_Tb_TemporaryFFB.HG)
{
_InventdimidHG = 'BSP-000731';
rowCount++;
inventDimArray[rowCount] = _InventdimidHG;
qtyArray[rowCount] = BIT_Tb_TemporaryFFB.QtyHG;
ffbConfig[rowCount] = "FFB_HG";
}
if(BIT_Tb_TemporaryFFB.PC)
{
_InventdimidPC = 'BSP-000732';
rowCount++;
inventDimArray[rowCount] = _InventdimidPC;
qtyArray[rowCount] =
BIT_Tb_TemporaryFFB.QtyPC;
ffbConfig[rowCount] = "FFB_PC";
}
if(BIT_Tb_TemporaryFFB.Plasma)
{
_InventdimidPL = 'BSP-000774';
rowCount++;
inventDimArray[rowCount] = _InventdimidPL;
qtyArray[rowCount]
= BIT_Tb_TemporaryFFB.QtyPL;
ffbConfig[rowCount]
= "FFB_PL";
}
ttsBegin;
for(i=1;
i<= rowCount; i++)
{
_InventJournalTrans.clear();
_InventJournalTrans.initFromInventJournalTable(_InventJournalTable);
_InventJournalTrans.initFromInventTable(InventTable::find(BIT_Tb_TemporaryFFB.ItemNumber));
_InventJournalTrans.TransDate = BIT_Tb_TemporaryFFB.DateProcess;
_InventJournalTrans.ItemId =
BIT_Tb_TemporaryFFB.ItemNumber;
inventTransID =
NumberSeq::newGetNum(InventParameters::numRefInventTransId()).num();
_InventJournalTrans.InventTransId = inventTransID;
_InventJournalTrans.Voucher =
NumberSeq::newGetNumFromId(_InventJournalTable.VoucherNumberSequenceTable).num();
_InventJournalTrans.Qty = qtyArray[i];
_InventJournalTrans.InventDimId = inventDimArray[i];
_InventJournalTrans.LineNum = i;
// Get Main Account
inventAccountNum =
BIT_Tb_ParmFFb::GetInventMainAccount(BIT_Tb_TemporaryFFB.ItemNumber,
ffbConfig[i] );
select firstOnly1 dimensionAttributeValueCombination
where
dimensionAttributeValueCombination.DisplayValue == inventAccountNum;
_InventJournalTrans.LedgerDimension =
dimensionAttributeValueCombination.RecId;
_InventJournalTrans.insert();
}
ttsCommit;
if(InventJournalCheckPost::newPostJournal(_InventJournalTable).validate())
{
InventJournalCheckPost::newPostJournal(_InventJournalTable).run();
}
ttsBegin;
BIT_Tb_TemporaryFFB.InUse = NoYes::Yes;
BIT_Tb_TemporaryFFB.update();
ttsCommit;
info("Qty has been splited and Posted");
element.close();
}
else
{
error(strFmt("Item %1 has been used at %2 Or Qty Homeground Or
Qty Purchase Or Qty Plasma cannot not same Qty", BIT_Tb_TemporaryFFB.ItemNumber,
BIT_Tb_TemporaryFFB.DateProcess));
}
}
===================
Cara hide object with menuitem ===========================
void init()
{
#ISOCountryRegionCodes
AccessRight accessRight;
boolean financialsDimensionsEnabled = false;
container lastValue;
// Container combines all country codes attached to all
fields/their EDT's in the table. Cache before super() so usable by
FormDataSource.init()
enableLedgerJournalTable_W =
SysCountryRegionCode::isLegalEntityInCountryRegion([#isoCN, #isoLT, #isoLV,
#isoEE, #isoRU, #isoCZ, #isoHU, #isoPL]);
if (!enableLedgerJournalTable_W)
{
enableLedgerJournalTable_W = BrazilParameters::isEnabled();
}
journalFormTable = new
LedgerJournalFormTable(element);
SysListPageHelper::handleInitPreSuper(element);
super();
FormSecurity::setFormDataSourceMaxAccessRight(this);
dimOffsetAccountController =
DimensionDynamicAccountController::construct(ledgerJournalTable_DS, fieldStr(LedgerJournalTable,
OffsetLedgerDimension), fieldStr(LedgerJournalTable,
OffsetAccountType));
dimOffsetAccountController.parmIsDefaultAccount(true);
dimOffsetAccountController.parmValidateBlockedForManualEntry(true);
custPaymEntryButton.visible(journalFormTable.journalTypeId()
== LedgerJournalType::CustPayment);
correction_RU.visible(journalFormTable.journalTypeId() ==
LedgerJournalType::Daily || journalFormTable.journalTypeId() ==
LedgerJournalType::RTax25);
journalFormTable.parmCtrlAllOpenPosted(allOpenPostedField);
journalFormTable.parmCtrlShowUserCreatedOnly(showUserCreatedOnly);
journalFormTable.parmCtrlJournalIdTab(journalNum);
journalFormTable.parmCtrlJournalIdGrid(ledgerJournalTable_JournalNum);
journalFormTable.parmCtrlJournalTypeGrid(journalTypeGrid);
journalFormTable.parmCtrlOverview(gridOverview);
journalFormTable.parmCtrlCustPaymEntryButton(custPaymEntryButton);
journalFormTable.parmCtrlLines(journalLines);
journalFormTable.parmCtrlCheckJournal(checkJournal);
journalFormTable.parmCtrlPostJournalMenu(postJournal);
journalFormTable.parmCtrlMarkUserBlock(isUserPrivate);
journalFormTable.parmCtrlMarkInUseBlock(markInUseBlock);
journalFormTable.parmCtrlSystemBlocked(systemBlocked);
journalFormTable.parmCtrlBlockImage(blockImage);
journalFormTable.parmCtrlApprovalMenu(course);
journalFormTable.parmCtrlJournalLinesGeneratePayment(journalLines_GeneratePayments);
journalFormTable.parmCtrlJournalLinesEdit(journalLines_Edit);
journalFormTable.parmCtrlJournalLinesReview(journalLines_Review);
journalFormTable.parmCtrlJournalLines_WorkFlowApproved(journalLines_WorkflowApproved);
/* lift GEEW
journalFormTable.parmCtrlAssetPackingSlip_LT(assetPackingSlipPrint_LT);
*/
journalFormTable.formInitPost();
bankAccount_IT =
SysCountryRegionCode::isLegalEntityInCountryRegion([#isoIT]);
// Added to the inquiries button of the posted statement
form to show only posted payment journals for the statement.
if (isConfigurationkeyEnabled(configurationKeyNum(Retail))
&& element.args().caller() is
FormRun)
{
if (element.args().caller().name() == formStr(RetailStatementJour))
{
allOpenPostedField.selection(AllOpenPosted::Posted);
allOpenPostedField.enabled(false);
newButton.enabled(false);
deleteButton.enabled(false);
}
}
//Only execute code if called from ForEdit menu item
if
(SysListPageHelper::isFormOpenedWithOpenModeForEditParm(element))
{
SysListPageHelper::handleInitPostSuper(element);
journalFormTable.queryAddRange();
//If opened from payment journal list page, set to All
types
if ((element.args().caller().name() == formStr(LedgerJournalTableCustPaymentListPage))
||
(element.args().caller().name() == formStr(LedgerJournalTableVendPaymentListPage)))
{
allOpenPostedField.selection(AllOpenPosted::All);
}
}
accessRight = FormSecurity::getMenuItemAccessRight(this);
if (accessRight >= AccessRight::Edit)
{
financialsDimensionsEnabled = true;
if (element.args() &&
element.args().menuItemName())
{
if (element.args().menuItemType() ==
MenuItemType::Display
&& (element.args().menuItemName() == menuitemDisplayStr(LedgerJournalTable_BankChequeReversal)
|| element.args().menuItemName() == menuitemDisplayStr(LedgerJournalTable_BankDepositPaymCancel)))
{
financialsDimensionsEnabled = false;
}
}
}
dimensionDefaultingController = DimensionDefaultingController::constructInTabWithValues(false, true,
financialsDimensionsEnabled, 0, this,
tabFinancialDimensions, "@SYS138491");
dimensionDefaultingController.parmAttributeValueSetDataSource(ledgerJournalTable_ds,
fieldStr(LedgerJournalTable,
DefaultDimension));
dimensionDefaultingController.parmValidateBlockedForManualEntry(true);
tabFinancialDimensions.enabled(financialsDimensionsEnabled);
if (LedgerParameters::isChineseVoucher_CN()
&& journalFormTable.journalTypeId() == LedgerJournalType::Daily)
{
lastValue = classfactory.lastValueGet(curext(),
curUserId(), UtilElementType::Form, formStr(LedgerJournalTable));
if (lastValue)
{
this.unpack(lastValue);
}
}
if (RetailSMB::IsRetailSMBEnabled())
{
RetailSMB::SetVisible(element);
}
// add by adit -
hide payment voucher from invoice journal)
if
(element.args().menuItemType() == MenuItemType::Display &&
(element.args().menuItemName() == menuitemDisplayStr(LedgerJournalTable5)))
{
BIT_PaymentVoucher.visible(true);
}
else
{
BIT_PaymentVoucher.visible(false);
}
// end by adit
}
void clicked()
{
MenuFunction mf;
args args = new
Args();
;
args.record(LedgerJournalTrans);
mf = new
menufunction(identifierstr(BIT_GetMainAccountLedger),
MenuItemType::Action);
mf.run(args);
}
Contoh class :
//
------------------------------------------------(c) 2016 LAST
// System: Microsoft
Dynamics AX for BSP)
// Purpose:
// Description:
// Extern:
// Creator: BIT_SH Dynamics AX (Admin)
// Others:
// Creation date: 12.10.16
//
-----------------------------------------------------------------
//
-----------------------------------------------------------------
private static
void GetLedger(LedgerJournalTrans
ledgerJournalTrans)
{
container conDimValue;
RefRecId
ledgerDimension;
DimensionAttributeValueCombination
_DimensionAttributeValueCombination;
int recordsCount;
str _mainAccount,
CashFlow, Location , Division, YOPID, Fields, Vehicle, Category, Station;
container con;
container accountCon;
MainAccount
mainAcc;
DimensionStorage
dimensionStorage;
DimensionAttributeValueCombination
dimCombination;
int
hierarchyCount, hierarchyIndex, segmentCount, segmentIndex;
RefRecId
recordvalue;
int dimCount;
DimensionStorageSegment
segment;
DimensionHierarchyLevel
hierarchyLevel;
DimensionAttribute
dimAttribute;
DimensionServiceProvider
DimensionServiceProvider = new
DimensionServiceProvider();
LedgerAccountContract
LedgerAccountContract = new
LedgerAccountContract();
DimensionAttributeValueContract
ValueContract;
List
ListValueContract = new
List(Types::Class);
dimensionAttributeValueCombination
dimensionAttributeValueCombination;
DimensionStorage
dimStorage;
// Get Exchange Rate
ExchangeRateHelper
exchangeRateHelper;
Transdate
Transactiondate, FirstOfMth;
CurrencyCode
transactionCurrency;
CurrencyExchangeRate
exchangeRate1;
CurrencyExchangeRate
exchangeRate2;
Real r=1;
str ExchRate;
int i,z;
_mainAccount =
ledgerJournalTrans.BIT_LedgerDimension;
CashFlow =
ledgerJournalTrans.BIT_CashFlow; // #1
Location = ledgerJournalTrans.BIT_Location; // #2
Division =
ledgerJournalTrans.BIT_Division; // #3
YOPID =
ledgerJournalTrans.BIT_YOPid; // #4
Vehicle = ledgerJournalTrans.BIT_Vehicle; // #5
Fields =
ledgerJournalTrans.BIT_Fields; // #6
Station =
ledgerJournalTrans.BIT_Station; // #7
Category =
ledgerJournalTrans.BIT_Category; // #8
//Resetting container
accountCon = conNull();
accountCon = [_mainAccount,
_mainAccount];
mainAcc = MainAccount::findByMainAccountId(_mainAccount);
recordvalue = DimensionHierarchy::getAccountStructure(mainAcc.RecId);
// Get Exchange Rate
transactionCurrency =
ledgerJournalTrans.CurrencyCode;
FirstOfMth = mkdate(1,mthofyr(ledgerJournalTrans.TransDate),year(ledgerJournalTrans.TransDate));
exchangeRateHelper =
ExchangeRateHelper::newExchangeDate(Ledger::current(), transactionCurrency,
transactiondate);
exchangeRate1 = exchangeRateHelper.getExchangeRate1();
exchangeRate2 =
exchangeRateHelper.getExchangeRate2();
ExchRate = num2str(r,0,17,1,3);
//If the ledgerDimension already created
then we can find it in below table
select firstonly recid from
dimCombination where dimCombination.MainAccount == mainAcc.RecId
&& dimCombination.AccountStructure == recordvalue &&
dimCombination.dataAreaId == curext();
if (!dimCombination)
{
accountCon = [_mainAccount, _mainAccount,''];
// #1
if (CashFlow)
{
accountCon += ["CashFlow", CashFlow];
dimCount++;
}
// #2
if (Location)
{
accountCon += ["Location", Location];
dimCount++;
}
// #3
if (Division)
{
accountCon += ["Division", Division];
dimCount++;
}
// #4
if (YOPID)
{
accountCon += ["YOPID", YOPID];
dimCount++;
}
// #5
if (Vehicle)
{
accountCon += ["Vehicle", Vehicle];
dimCount++;
}
// #6
if (Fields)
{
accountCon += ["Fields", Fields];
dimCount++;
}
// #7
if (Station)
{
accountCon += ["Station", Station];
dimCount++;
}
// #8
if (Category)
{
accountCon += ["Category", Category];
dimCount++;
}
}
accountCon = conPoke(accountCon,
3 , dimCount);
//below code lines create ledgerdimension
as per chart of account setup
dimensionStorage = DimensionStorage::findById(dimCombination.RecId);
if (dimensionStorage == null)
{
ttsBegin;
//#1
if (CashFlow)
{
ValueContract = new
DimensionAttributeValueContract();
ValueContract.parmName('CashFlow') ;
ValueContract.parmValue(CashFlow);
ListValueContract.addEnd(ValueContract);
}
//#2
if (Location)
{
ValueContract = new
DimensionAttributeValueContract();
ValueContract.parmName('Location') ;
ValueContract.parmValue(Location);
ListValueContract.addEnd(ValueContract);
}
//#3
if (Division)
{
ValueContract = new
DimensionAttributeValueContract();
ValueContract.parmName('Division') ;
ValueContract.parmValue(Division);
ListValueContract.addEnd(ValueContract);
}
//#4
if (YOPID)
{
ValueContract = new
DimensionAttributeValueContract();
ValueContract.parmName('YOPID') ;
ValueContract.parmValue(YOPID);
ListValueContract.addEnd(ValueContract);
}
//#5
if (Vehicle)
{
ValueContract = new
DimensionAttributeValueContract();
ValueContract.parmName('Vehicle') ;
ValueContract.parmValue(Vehicle);
ListValueContract.addEnd(ValueContract);
}
//#6
if (Fields)
{
ValueContract = new
DimensionAttributeValueContract();
ValueContract.parmName('Fields') ;
ValueContract.parmValue(Fields);
ListValueContract.addEnd(ValueContract);
}
// #7
if (Station)
{
ValueContract = new
DimensionAttributeValueContract();
ValueContract.parmName('Station') ;
ValueContract.parmValue(Station);
ListValueContract.addEnd(ValueContract);
}
// #8
if (Category)
{
ValueContract = new
DimensionAttributeValueContract();
ValueContract.parmName('Category') ;
ValueContract.parmValue(Category);
ListValueContract.addEnd(ValueContract);
}
LedgerAccountContract.parmMainAccount(_mainAccount);
LedgerAccountContract.parmValues(ListValueContract);
dimStorage =
DimensionServiceProvider::buildDimensionStorageForLedgerAccount(LedgerAccountContract);
dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(dimStorage.save());
ledgerJournalTrans.LedgerDimension =
dimensionAttributeValueCombination.RecId;
ledgerJournalTrans.editExchRate(false,
1);
ledgerJournalTrans.update();
z++;
ttsCommit;
//Loop Close #1 ^
// info(strFmt("Account %1 has been
inserted - Journalnum %2", dimensionAttributeValueCombination.DisplayValue
, ledgerJournalTrans.JournalNum));
// info(strFmt("Records Updated
%1",ledgerJournalTrans.RowCount()));
}
else
{
ttsBegin;
hierarchyCount = dimensionStorage.hierarchyCount();
for(hierarchyIndex = 1; hierarchyIndex <= hierarchyCount;
hierarchyIndex++)
{
segmentCount =
dimensionStorage.segmentCountForHierarchy(hierarchyIndex);
// accountCon +=
[0];
//Loop through segments and display required values
for (segmentIndex = 1; segmentIndex <= segmentCount;
segmentIndex++)
{
segment =
dimensionStorage.getSegmentForHierarchy(hierarchyIndex, segmentIndex);
hierarchyLevel
= DimensionHierarchyLevel::findByDimensionHierarchyAndLevel(recordvalue,
segmentIndex);
dimAttribute =
DimensionAttribute::find(hierarchyLevel.DimensionAttribute);
switch
(dimAttribute.Name)
{
// #1
case "CashFlow"
:
if(CashFlow)
{
accountCon += ["CashFlow",
CashFlow];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
// #2
case "Location":
if(Location)
{
accountCon += ["Location", Location];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
// #3
case "Division":
if(Division)
{
accountCon += ["Division",
Division];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
// #4
case "YOPID":
if(YOPID)
{
accountCon += ["YOPID",
YOPID];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
// #5
case "Vehicle":
if(Vehicle)
{
accountCon += ["Vehicle",
Vehicle];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
// #6
case "Fields":
if(Fields)
{
accountCon += ["Fields",
Fields];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
// #7
case "Station":
if(Station)
{
accountCon
+= ["Station", Station];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
// #8
case "Category":
if(Category)
{
accountCon += ["Category", Category];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
}
}
}
try
{ ledgerDimension =
AxdDimensionUtil::getLedgerAccountId(accountCon);
}
catch
{
warning(strFmt('Error getting ledger Dimension for main account for %1 -
%2', mainAcc, ledgerJournalTrans.accountName()));
}
select firstOnly
RecId from
_DimensionAttributeValueCombination
where _DimensionAttributeValueCombination.RecId
== ledgerDimension
&&
_DimensionAttributeValueCombination.dataAreaId == curext();
ledgerJournalTrans.LedgerDimension =
_DimensionAttributeValueCombination.RecId;
ledgerJournalTrans.editExchRate(false, 1);
ledgerJournalTrans.update();
z++;
ttsCommit;
// info(strFmt("Account %1 has been inserted -
Journalnum %2 Voucher Num %3 %4", ledgerJournalTrans.LedgerDimension,
ledgerJournalTrans.JournalNum,ledgerJournalTrans.Voucher,
ledgerJournalTrans.accountName()));
//
info(strFmt("Records Updated
%1",ledgerJournalTrans.RowCount()));
// info(strfmt(ledgerJournalTrans.JournalNum)); // next record
}
}
void
init()
{
str
callername;
salesFormLetter = element.args().caller();
// add by void
callerRefresh()
{
Object formObject;
if(element.args().caller()
&& element.args().caller().name() == formstr(SalesTable))
{
formObject =
element.args().caller();
formObject.doRefresh();
}
}
public
void init()
{
super();
//get record from caller
if(element.args()
&& element.args().record() &&element.args().record().TableId ==
tableNum(WMSOrderTrans))
{
wmsot = element.args().record();
}
}
=============================
sample ==============================
void
clicked()
{
InventJournalTable _getRecordInventJournalTable;
Args _args;
FormRun _FormRun;
Journalid _Journalid;
;
_getRecordInventJournalTable =
element.args().record();
_Journalid = InventJournalTable.JournalId;
_args = new
Args();
_args.name(formstr(BIT_FM_TempFFB));
_args.caller(this);
_args.parm(_Journalid);
_args.record(InventJournalTable);
_FormRun = classFactory.formRunClass(_args);
_FormRun.init();
_FormRun.run();
_FormRun.wait();
}
public
void init()
{
super();
//get record from caller
if(element.args()
&& element.args().record() && element.args().record().TableId
== tableNum(InventJournalTable))
{
_InventJournalTable =
element.args().record();
}
}
public
void Generate()
{
int
rowCount = 0;
int i = 1;
boolean isCheckHG,
isCheckPL, isCheckPR = false;
InventTransId inventTransID;
Object callerForm = element.args().caller();
//kl _tmpPurchLine_ds gak bisa otomatis
diakses, declarasi dulu
InventJournalTrans _InventJournalTrans;
InventDim _Inventdim;
InventDimId
_InventdimidHG, _InventdimidPC, _InventdimidPL;
str
inventDimArray[3];
Qty
qtyArray[3];
MainAccountNum inventAccountNum;
DimensionAttributeValueCombination dimensionAttributeValueCombination;
str 10
ffbConfig[3];
if(_InventJournalTable
&& BIT_Tb_TemporaryFFB.InUse != NoYes::Yes
&& (BIT_Tb_TemporaryFFB.QtyHG +
BIT_Tb_TemporaryFFB.QtyPC + BIT_Tb_TemporaryFFB.QtyPL ==
BIT_Tb_TemporaryFFB.Qty))
{
if(BIT_Tb_TemporaryFFB.HG)
{
_InventdimidHG = 'BSP-000731';
rowCount++;
inventDimArray[rowCount] =
_InventdimidHG;
qtyArray[rowCount] =
BIT_Tb_TemporaryFFB.QtyHG;
ffbConfig[rowCount] = "FFB_HG";
}
if(BIT_Tb_TemporaryFFB.PC)
{
_InventdimidPC = 'BSP-000732';
rowCount++;
inventDimArray[rowCount] = _InventdimidPC;
qtyArray[rowCount] =
BIT_Tb_TemporaryFFB.QtyPC;
ffbConfig[rowCount] = "FFB_PC";
}
if(BIT_Tb_TemporaryFFB.Plasma)
{
_InventdimidPL = 'BSP-000774';
rowCount++;
inventDimArray[rowCount] = _InventdimidPL;
qtyArray[rowCount]
= BIT_Tb_TemporaryFFB.QtyPL;
ffbConfig[rowCount]
= "FFB_PL";
}
ttsBegin;
for(i=1; i<= rowCount; i++)
{
_InventJournalTrans.clear();
_InventJournalTrans.initFromInventJournalTable(_InventJournalTable);
_InventJournalTrans.initFromInventTable(InventTable::find(BIT_Tb_TemporaryFFB.ItemNumber));
_InventJournalTrans.TransDate =
BIT_Tb_TemporaryFFB.DateProcess;
_InventJournalTrans.ItemId = BIT_Tb_TemporaryFFB.ItemNumber;
inventTransID =
NumberSeq::newGetNum(InventParameters::numRefInventTransId()).num();
_InventJournalTrans.InventTransId = inventTransID;
_InventJournalTrans.Voucher =
NumberSeq::newGetNumFromId(_InventJournalTable.VoucherNumberSequenceTable).num();
_InventJournalTrans.Qty =
qtyArray[i];
_InventJournalTrans.InventDimId
= inventDimArray[i];
_InventJournalTrans.LineNum =
i;
//
Get Main Account
inventAccountNum =
BIT_Tb_ParmFFb::GetInventMainAccount(BIT_Tb_TemporaryFFB.ItemNumber,
ffbConfig[i] );
select
firstOnly1
dimensionAttributeValueCombination
where
dimensionAttributeValueCombination.DisplayValue == inventAccountNum;
_InventJournalTrans.LedgerDimension =
dimensionAttributeValueCombination.RecId;
_InventJournalTrans.insert();
}
ttsCommit;
if(InventJournalCheckPost::newPostJournal(_InventJournalTable).validate())
{
InventJournalCheckPost::newPostJournal(_InventJournalTable).run();
}
ttsBegin;
BIT_Tb_TemporaryFFB.InUse =
NoYes::Yes;
BIT_Tb_TemporaryFFB.update();
ttsCommit;
info("Qty
has been splited and Posted");
element.close();
}
else
{
error(strFmt("Item %1 has been used at %2 Or Qty Homeground Or
Qty Purchase Or Qty Plasma cannot not same Qty", BIT_Tb_TemporaryFFB.ItemNumber,
BIT_Tb_TemporaryFFB.DateProcess));
}
}
===================
Cara hide object with menuitem ===========================
void
init()
{
#ISOCountryRegionCodes
AccessRight accessRight;
boolean
financialsDimensionsEnabled = false;
container lastValue;
// Container combines all country codes
attached to all fields/their EDT's in the table. Cache before super() so usable
by FormDataSource.init()
enableLedgerJournalTable_W =
SysCountryRegionCode::isLegalEntityInCountryRegion([#isoCN, #isoLT, #isoLV,
#isoEE, #isoRU, #isoCZ, #isoHU, #isoPL]);
if
(!enableLedgerJournalTable_W)
{
enableLedgerJournalTable_W =
BrazilParameters::isEnabled();
}
journalFormTable = new
LedgerJournalFormTable(element);
SysListPageHelper::handleInitPreSuper(element);
super();
FormSecurity::setFormDataSourceMaxAccessRight(this);
dimOffsetAccountController =
DimensionDynamicAccountController::construct(ledgerJournalTable_DS, fieldStr(LedgerJournalTable,
OffsetLedgerDimension), fieldStr(LedgerJournalTable,
OffsetAccountType));
dimOffsetAccountController.parmIsDefaultAccount(true);
dimOffsetAccountController.parmValidateBlockedForManualEntry(true);
custPaymEntryButton.visible(journalFormTable.journalTypeId() ==
LedgerJournalType::CustPayment);
correction_RU.visible(journalFormTable.journalTypeId() ==
LedgerJournalType::Daily || journalFormTable.journalTypeId() ==
LedgerJournalType::RTax25);
journalFormTable.parmCtrlAllOpenPosted(allOpenPostedField);
journalFormTable.parmCtrlShowUserCreatedOnly(showUserCreatedOnly);
journalFormTable.parmCtrlJournalIdTab(journalNum);
journalFormTable.parmCtrlJournalIdGrid(ledgerJournalTable_JournalNum);
journalFormTable.parmCtrlJournalTypeGrid(journalTypeGrid);
journalFormTable.parmCtrlOverview(gridOverview);
journalFormTable.parmCtrlCustPaymEntryButton(custPaymEntryButton);
journalFormTable.parmCtrlLines(journalLines);
journalFormTable.parmCtrlCheckJournal(checkJournal);
journalFormTable.parmCtrlPostJournalMenu(postJournal);
journalFormTable.parmCtrlMarkUserBlock(isUserPrivate);
journalFormTable.parmCtrlMarkInUseBlock(markInUseBlock);
journalFormTable.parmCtrlSystemBlocked(systemBlocked);
journalFormTable.parmCtrlBlockImage(blockImage);
journalFormTable.parmCtrlApprovalMenu(course);
journalFormTable.parmCtrlJournalLinesGeneratePayment(journalLines_GeneratePayments);
journalFormTable.parmCtrlJournalLinesEdit(journalLines_Edit);
journalFormTable.parmCtrlJournalLinesReview(journalLines_Review);
journalFormTable.parmCtrlJournalLines_WorkFlowApproved(journalLines_WorkflowApproved);
/* lift GEEW
journalFormTable.parmCtrlAssetPackingSlip_LT(assetPackingSlipPrint_LT);
*/
journalFormTable.formInitPost();
bankAccount_IT =
SysCountryRegionCode::isLegalEntityInCountryRegion([#isoIT]);
// Added to the inquiries button of the
posted statement form to show only posted payment journals for the statement.
if
(isConfigurationkeyEnabled(configurationKeyNum(Retail))
&& element.args().caller() is FormRun)
{
if
(element.args().caller().name() == formStr(RetailStatementJour))
{
allOpenPostedField.selection(AllOpenPosted::Posted);
allOpenPostedField.enabled(false);
newButton.enabled(false);
deleteButton.enabled(false);
}
}
//Only execute code if called from ForEdit
menu item
if
(SysListPageHelper::isFormOpenedWithOpenModeForEditParm(element))
{
SysListPageHelper::handleInitPostSuper(element);
journalFormTable.queryAddRange();
//If
opened from payment journal list page, set to All types
if
((element.args().caller().name() == formStr(LedgerJournalTableCustPaymentListPage))
|| (element.args().caller().name() == formStr(LedgerJournalTableVendPaymentListPage)))
{
allOpenPostedField.selection(AllOpenPosted::All);
}
}
accessRight = FormSecurity::getMenuItemAccessRight(this);
if (accessRight >=
AccessRight::Edit)
{
financialsDimensionsEnabled = true;
if
(element.args() && element.args().menuItemName())
{
if
(element.args().menuItemType() == MenuItemType::Display
&&
(element.args().menuItemName() == menuitemDisplayStr(LedgerJournalTable_BankChequeReversal)
|| element.args().menuItemName()
== menuitemDisplayStr(LedgerJournalTable_BankDepositPaymCancel)))
{
financialsDimensionsEnabled = false;
}
}
}
dimensionDefaultingController = DimensionDefaultingController::constructInTabWithValues(false, true,
financialsDimensionsEnabled, 0, this,
tabFinancialDimensions, "@SYS138491");
dimensionDefaultingController.parmAttributeValueSetDataSource(ledgerJournalTable_ds,
fieldStr(LedgerJournalTable,
DefaultDimension));
dimensionDefaultingController.parmValidateBlockedForManualEntry(true);
tabFinancialDimensions.enabled(financialsDimensionsEnabled);
if
(LedgerParameters::isChineseVoucher_CN()
&&
journalFormTable.journalTypeId() == LedgerJournalType::Daily)
{
lastValue = classfactory.lastValueGet(curext(), curUserId(),
UtilElementType::Form, formStr(LedgerJournalTable));
if
(lastValue)
{
this.unpack(lastValue);
}
}
if
(RetailSMB::IsRetailSMBEnabled())
{
RetailSMB::SetVisible(element);
}
// add by adit -
hide payment voucher from invoice journal)
if (element.args().menuItemType() ==
MenuItemType::Display && (element.args().menuItemName() == menuitemDisplayStr(LedgerJournalTable5)))
{
BIT_PaymentVoucher.visible(true);
}
else
{
BIT_PaymentVoucher.visible(false);
}
// end by adit
}
void
clicked()
{
MenuFunction mf;
args args = new Args();
;
args.record(LedgerJournalTrans);
mf = new
menufunction(identifierstr(BIT_GetMainAccountLedger),
MenuItemType::Action);
mf.run(args);
}
Contoh class :
//
------------------------------------------------(c) 2016 LAST
// System: Microsoft
Dynamics AX for BSP)
// Purpose:
// Description:
// Extern:
// Creator: BIT_SH Dynamics AX (Admin)
// Others:
// Creation date: 12.10.16
//
-----------------------------------------------------------------
//
-----------------------------------------------------------------
private
static void
GetLedger(LedgerJournalTrans ledgerJournalTrans)
{
container conDimValue;
RefRecId
ledgerDimension;
DimensionAttributeValueCombination
_DimensionAttributeValueCombination;
int recordsCount;
str _mainAccount,
CashFlow, Location , Division, YOPID, Fields, Vehicle, Category, Station;
container con;
container accountCon;
MainAccount
mainAcc;
DimensionStorage
dimensionStorage;
DimensionAttributeValueCombination
dimCombination;
int
hierarchyCount, hierarchyIndex, segmentCount, segmentIndex;
RefRecId
recordvalue;
int dimCount;
DimensionStorageSegment
segment;
DimensionHierarchyLevel
hierarchyLevel;
DimensionAttribute
dimAttribute;
DimensionServiceProvider
DimensionServiceProvider = new
DimensionServiceProvider();
LedgerAccountContract
LedgerAccountContract = new
LedgerAccountContract();
DimensionAttributeValueContract
ValueContract;
List
ListValueContract = new
List(Types::Class);
dimensionAttributeValueCombination
dimensionAttributeValueCombination;
DimensionStorage
dimStorage;
// Get Exchange Rate
ExchangeRateHelper
exchangeRateHelper;
Transdate
Transactiondate, FirstOfMth;
CurrencyCode
transactionCurrency;
CurrencyExchangeRate
exchangeRate1;
CurrencyExchangeRate
exchangeRate2;
Real r=1;
str ExchRate;
int i,z;
_mainAccount = ledgerJournalTrans.BIT_LedgerDimension;
CashFlow = ledgerJournalTrans.BIT_CashFlow; // #1
Location = ledgerJournalTrans.BIT_Location; // #2
Division = ledgerJournalTrans.BIT_Division; // #3
YOPID = ledgerJournalTrans.BIT_YOPid; // #4
Vehicle = ledgerJournalTrans.BIT_Vehicle; // #5
Fields = ledgerJournalTrans.BIT_Fields; // #6
Station = ledgerJournalTrans.BIT_Station; // #7
Category = ledgerJournalTrans.BIT_Category; // #8
//Resetting
container
accountCon = conNull();
accountCon = [_mainAccount, _mainAccount];
mainAcc =
MainAccount::findByMainAccountId(_mainAccount);
recordvalue =
DimensionHierarchy::getAccountStructure(mainAcc.RecId);
//
Get Exchange Rate
transactionCurrency = ledgerJournalTrans.CurrencyCode;
FirstOfMth = mkdate(1,mthofyr(ledgerJournalTrans.TransDate),year(ledgerJournalTrans.TransDate));
exchangeRateHelper =
ExchangeRateHelper::newExchangeDate(Ledger::current(), transactionCurrency,
transactiondate);
exchangeRate1 = exchangeRateHelper.getExchangeRate1();
exchangeRate2 =
exchangeRateHelper.getExchangeRate2();
ExchRate = num2str(r,0,17,1,3);
//If
the ledgerDimension already created then we can find it in below table
select
firstonly recid from dimCombination where
dimCombination.MainAccount == mainAcc.RecId
&&
dimCombination.AccountStructure == recordvalue &&
dimCombination.dataAreaId == curext();
if
(!dimCombination)
{
accountCon = [_mainAccount,
_mainAccount,''];
//
#1
if
(CashFlow)
{
accountCon += ["CashFlow", CashFlow];
dimCount++;
}
//
#2
if
(Location)
{
accountCon += ["Location", Location];
dimCount++;
}
//
#3
if
(Division)
{
accountCon += ["Division", Division];
dimCount++;
}
//
#4
if
(YOPID)
{
accountCon += ["YOPID", YOPID];
dimCount++;
}
//
#5
if
(Vehicle)
{
accountCon += ["Vehicle", Vehicle];
dimCount++;
}
//
#6
if
(Fields)
{
accountCon += ["Fields", Fields];
dimCount++;
}
//
#7
if
(Station)
{
accountCon += ["Station", Station];
dimCount++;
}
//
#8
if
(Category)
{
accountCon += ["Category", Category];
dimCount++;
}
}
accountCon = conPoke(accountCon, 3 , dimCount);
//below
code lines create ledgerdimension as per chart of account setup
dimensionStorage =
DimensionStorage::findById(dimCombination.RecId);
if
(dimensionStorage == null)
{
ttsBegin;
//#1
if
(CashFlow)
{
ValueContract = new DimensionAttributeValueContract();
ValueContract.parmName('CashFlow') ;
ValueContract.parmValue(CashFlow);
ListValueContract.addEnd(ValueContract);
}
//#2
if
(Location)
{
ValueContract = new DimensionAttributeValueContract();
ValueContract.parmName('Location') ;
ValueContract.parmValue(Location);
ListValueContract.addEnd(ValueContract);
}
//#3
if
(Division)
{
ValueContract = new DimensionAttributeValueContract();
ValueContract.parmName('Division') ;
ValueContract.parmValue(Division);
ListValueContract.addEnd(ValueContract);
}
//#4
if
(YOPID)
{
ValueContract = new DimensionAttributeValueContract();
ValueContract.parmName('YOPID') ;
ValueContract.parmValue(YOPID);
ListValueContract.addEnd(ValueContract);
}
//#5
if
(Vehicle)
{
ValueContract = new DimensionAttributeValueContract();
ValueContract.parmName('Vehicle') ;
ValueContract.parmValue(Vehicle);
ListValueContract.addEnd(ValueContract);
}
//#6
if
(Fields)
{
ValueContract = new DimensionAttributeValueContract();
ValueContract.parmName('Fields') ;
ValueContract.parmValue(Fields);
ListValueContract.addEnd(ValueContract);
}
//
#7
if
(Station)
{
ValueContract = new DimensionAttributeValueContract();
ValueContract.parmName('Station') ;
ValueContract.parmValue(Station);
ListValueContract.addEnd(ValueContract);
}
//
#8
if
(Category)
{
ValueContract = new DimensionAttributeValueContract();
ValueContract.parmName('Category') ;
ValueContract.parmValue(Category);
ListValueContract.addEnd(ValueContract);
}
LedgerAccountContract.parmMainAccount(_mainAccount);
LedgerAccountContract.parmValues(ListValueContract);
dimStorage =
DimensionServiceProvider::buildDimensionStorageForLedgerAccount(LedgerAccountContract);
dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(dimStorage.save());
ledgerJournalTrans.LedgerDimension =
dimensionAttributeValueCombination.RecId;
ledgerJournalTrans.editExchRate(false,
1);
ledgerJournalTrans.update();
z++;
ttsCommit;
//Loop Close #1 ^
//
info(strFmt("Account %1 has been inserted - Journalnum %2",
dimensionAttributeValueCombination.DisplayValue ,
ledgerJournalTrans.JournalNum));
//
info(strFmt("Records Updated %1",ledgerJournalTrans.RowCount()));
}
else
{
ttsBegin;
hierarchyCount =
dimensionStorage.hierarchyCount();
for(hierarchyIndex
= 1; hierarchyIndex <= hierarchyCount;
hierarchyIndex++)
{
segmentCount =
dimensionStorage.segmentCountForHierarchy(hierarchyIndex);
// accountCon +=
[0];
//Loop through segments and display required values
for (segmentIndex = 1; segmentIndex <= segmentCount;
segmentIndex++)
{
segment =
dimensionStorage.getSegmentForHierarchy(hierarchyIndex, segmentIndex);
hierarchyLevel
= DimensionHierarchyLevel::findByDimensionHierarchyAndLevel(recordvalue,
segmentIndex);
dimAttribute =
DimensionAttribute::find(hierarchyLevel.DimensionAttribute);
switch
(dimAttribute.Name)
{
// #1
case "CashFlow"
:
if(CashFlow)
{
accountCon += ["CashFlow",
CashFlow];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
// #2
case "Location":
if(Location)
{
accountCon += ["Location", Location];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
// #3
case "Division":
if(Division)
{
accountCon += ["Division",
Division];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
// #4
case "YOPID":
if(YOPID)
{
accountCon += ["YOPID",
YOPID];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
// #5
case "Vehicle":
if(Vehicle)
{
accountCon += ["Vehicle",
Vehicle];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
// #6
case "Fields":
if(Fields)
{
accountCon += ["Fields",
Fields];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
// #7
case "Station":
if(Station)
{
accountCon += ["Station", Station];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
// #8
case "Category":
if(Category)
{
accountCon += ["Category", Category];
accountCon = conPoke(accountCon,
3, conPeek(accountCon,
3) + 1);
}
break;
}
}
}
try
{ ledgerDimension =
AxdDimensionUtil::getLedgerAccountId(accountCon);
}
catch
{
warning(strFmt('Error
getting ledger Dimension for main account for %1 - %2', mainAcc,
ledgerJournalTrans.accountName()));
}
select firstOnly
RecId from
_DimensionAttributeValueCombination
where _DimensionAttributeValueCombination.RecId
== ledgerDimension
&&
_DimensionAttributeValueCombination.dataAreaId == curext();
ledgerJournalTrans.LedgerDimension =
_DimensionAttributeValueCombination.RecId;
ledgerJournalTrans.editExchRate(false, 1);
ledgerJournalTrans.update();
z++;
ttsCommit;
// info(strFmt("Account %1 has been inserted -
Journalnum %2 Voucher Num %3 %4", ledgerJournalTrans.LedgerDimension,
ledgerJournalTrans.JournalNum,ledgerJournalTrans.Voucher,
ledgerJournalTrans.accountName()));
//
info(strFmt("Records Updated
%1",ledgerJournalTrans.RowCount()));
//
info(strfmt(ledgerJournalTrans.JournalNum)); // next record
}
}
void init()
{
str callername;
salesFormLetter = element.args().caller();
// add by adit - pada saat confirm field
Use WB tidak perlu ditampilkan
callername = salesFormLetter.name();
if (callername == 'SalesFormLetter_Confirm')
{
BIT_UseWB.visible(false);
}
}
adit - pada saat confirm field Use WB tidak perlu
ditampilkan
callername = salesFormLetter.name();
if (callername == 'SalesFormLetter_Confirm')
{
BIT_UseWB.visible(false);
}
}
0 comments:
Post a Comment