If you’ve developed anything in the supply chain area, you’ve most probably come across InventDimJoin. InvenDimJoin is a macro and it’s mostly used to narrow down search results for inventory transactions (inventTrans) or inventory postings (inventTransPost), but can be used on any table having a inventDimId field.
The macro accepts four to five parameters
· InventDimId
· InventDim
· InventDimCriteria
· InventDimParm
· Index hint (optional)
You must use it as a join with a select-statement (hence the name) and it returns no contents from inventDim. It is not an exist join, but doesn’t return any useful fields, so it probably should be an exist-join. Anyway, let’s take the parameters one by one:
InventDimId
This is the unique key to the inventory dimension table. This is where you supply the inventDimId field from the table you are joining.
InventDim
Any InventDim table buffer. This is the table buffer used in the joined select. The contents of the buffer has no influence on the select result set and resulting records will only have the tableId field filled (but that’s a constant anyway and already filled by just defining the buffer, so really you get nothing).
InventDimCriteria
This is also a inventDim buffer, but the contents of this one matters. Using this buffer, you define which dimensions you are looking for exactly (warehouse ‘Main’, location ‘IN-1’, batch ‘241105’ etc.).
InventDimParm
InventDimParm is a temporary table. A record basically consists of nothing but a number of flags to indicate which inventory dimensions are important and which ones can be disregarded. There is a *Flag field for every inventory dimension field. InventDimParm has a variety of methods to initialize these flags. An example would be initPhysicalInvent(). It clears all flags (=No) and sets only those flags to yes whose corresponding inventory dimension is a physical dimension (for the dimension group id you pass along as a parameter).
Consequently you provide InventDimJoin with a InventDimParm buffer. For all flags with value ‘No’ the contents of the corresponding inventDimParm field does not matter.
Index hint
This is an optional parameter to help you optimize performance.
Here’s an example:
static void InventDimJoinTest(Args _args)
{
SalesLine salesLine;
InventDim inventDim;
InventDim inventDimCriteria;
InventDimParm inventDimParm;
;
InventDimCriteria.InventLocationId = ‘Main';
InventDimCriteria.wMSLocationId = ‘IN-1′;
InventDimCriteria.configId = ‘Red';
inventDimParm.clear();
inventDimParm.InventLocationIdFlag = NoYes::Yes;
inventDimParm.wmsLocationIdFlag = NoYes::No;
inventDimParm.ConfigIdFlag = NoYes::Yes;
while select salesLine
#InventDimJoin(salesLine.inventDimId, InventDim, inventDimCriteria, InventDimParm, dimIdx)
{
print strfmt(“%1 %2 %3 %4 %5″,salesLine.InventDimId, salesLine.SalesId, salesLine.ItemId,
inventDim.InventLocationId, salesLine.inventDim().InventLocationId);
}
pause;
}
The job finds all salesLines for the ‘Main’ warehouse and configuration ‘Red’. The location doesn’t matter, since it’s inventDimParm flag is turned off (additional dimensions like batch, serial etc.wouldn’t make a difference either, clear() takes care of that).
Note that %4 prints the inventDim.inventLocationId. I just put that in there to make the point that it will always be blank.
dimIdx is the optional parameter. It’s an index defined on the InventDim table. You will notice in the output the result is sorted by inventDimId.