Quantcast
Channel: Martin Dráb's Activities
Viewing all articles
Browse latest Browse all 17532

BOMCalcTrans: Need help to decipher X++ code

$
0
0

Hello everyone,

I am new at X++ and I am trying to decipher the code below.  If someone could explain what the code below is doing.  I would appreciate it.

/// <summary>
/// Builds the query to use to load the estimated cost.
/// </summary>
/// <returns>
/// The query to use for loading estimated cost.
/// </returns>
protected Query buildEstimateQuery()
{
Query query;
QueryBuildRange qbrLevel;
QueryBuildRange qbrOrCondition;

query = new Query(queryStr(BOMCalcSum));
SysQuery::findOrCreateRange(query.dataSourceTable(tableNum(BOMCalcTrans)), fieldNum(BOMCalcTrans, PriceCalcId)).value(queryValue(inventItemPrice.PriceCalcId));

// Loop through the records using the lineNum
query.dataSourceTable(tableNum(BOMCalcTrans)).addSortField(fieldNum(BOMCalcTrans, LineNum));
query.dataSourceTable(tableNum(BOMCalcTrans)).orderMode(OrderMode::OrderBy);

if (! isCostBreakdownActivated)
{
qbrLevel = SysQuery::findOrCreateRange(query.dataSourceTable(tableNum(BOMCalcTrans)), fieldNum(BOMCalcTrans, Level));
qbrLevel.value(queryValue(1));
}
else
{
qbrOrCondition = SysQuery::findOrCreateRange(query.dataSourceTable(tableNum(BOMCalcTrans)), fieldNum(BOMCalcTrans, Resource));

// Add an or Condition:
// Everything that is level single or not bom
qbrOrCondition.value(strFmt('((%1.%2 == %3) || (%1.%4 == %5))',
query.dataSourceTable(tableNum(BOMCalcTrans)).name(), // BOMCalcTrans %1
fieldStr(BOMCalcTrans, Level), // Level %2
any2int(InventCostLevel::Single), // 1 (= Level Single) %3
fieldStr(BOMCalcTrans, bom), // BOM %4
any2int(NoYes::No))); // No %5
qbrOrCondition.status(RangeStatus::Hidden);
}

return query;
}


Viewing all articles
Browse latest Browse all 17532

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>