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.

Macro and SQL的更多相关文章

  1. dbt macro 说明

    macro是SQL的片段,可以像模型中的函数一样调用.macro可以在模型之间重复使用SQL,以符合DRY(不要重复自己)的工程原理. 此外,共享包可以公开您可以在自己的dbt项目中使用的macro. ...

  2. Cobar介绍及配置

    from:http://code.alibabatech.com/wiki/display/cobar/Home Skip to end of metadata   Page restrictions ...

  3. sqler sql 转rest api 源码解析(四)macro 的执行

    macro 说明 macro 是sqler 的核心,当前的处理流程为授权处理,数据校验,依赖执行(include),聚合处理,数据转换 处理,sql 执行以及sql 参数绑定 授权处理 这个是通过go ...

  4. sqlmap和burpsuite绕过csrf token进行SQL注入检测

    利用sqlmap和burpsuite绕过csrf token进行SQL注入 转载请注明来源:http://www.cnblogs.com/phoenix--/archive/2013/04/12/30 ...

  5. Teradata SQL programming

    Teradata的SQL设计和Oracle真不是一个水平, 一点美感的没有.  上个世纪它靠着MPP一招鲜吃变天, 居然做了十多年数据仓库的老大,  时过境迁, 现在有不少SQL On Hadoop ...

  6. [Hive - LanguageManual ] ]SQL Standard Based Hive Authorization

    Status of Hive Authorization before Hive 0.13 SQL Standards Based Hive Authorization (New in Hive 0. ...

  7. SQL Standard Based Hive Authorization(基于SQL标准的Hive授权)

    说明:该文档翻译/整理于Hive官方文档https://cwiki.apache.org/confluence/display/Hive/SQL+Standard+Based+Hive+Authori ...

  8. Using Notepad++ to Execute Oracle SQL

    原文链接:http://www.toadworld.com/products/toad-for-oracle/b/weblog/archive/2013/08/21/using-notepad-to- ...

  9. SQL*Loader FAQ

    SQL*Loader FAQ: Contents [hide]  1 What is SQL*Loader and what is it used for? 2 How does one use th ...

随机推荐

  1. unity 播放过场动画

    public var url="file:///c:/sample.ogg"; //文件路径 function Start () { //拼凑一个url url="fil ...

  2. [BZOJ 3759]Hungergame

    Nim游戏获胜的条件是所有石子的异或和为0 如果先手要获胜,那么一定是打开了一个异或和为0的极大子集 什么是极大子集呢? 就是无论后手打开任何子集的箱子,都不能再使此时打开的箱子异或和为0. 容易证明 ...

  3. CentOS 下安装python 之MySQLdb

    yum -y install mysql-devwget http://downloads.sourceforge.net/project/mysql-python/mysql-python-test ...

  4. 李洪强-C语言5-函数

    C语言函数 一.函数 C语言程序是由函数构成的,每个函数负责完成一部分的功能,函数将工恩呢该封装起来,以供程序调用. 二.函数定义 目的:将一些常用的功能封装起来,以供日后调用. 步骤:确定函数名,确 ...

  5. select @@identity的用法

    用select @@identity得到上一次插入记录时自动产生的ID 如果你使用存储过程的话,将非常简单,代码如下:SET @NewID=@@IDENTITY 说明: 在 一条 INSERT.SEL ...

  6. 初识python面向对象

    一.初识python面向对象: class Person: #使用class关键字定义一个类 age=0 #类变量(静态变量) def eat(self,food): #定义一个方法 self.age ...

  7. git实用攻略

    Git是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目. 下面是实用教程,免基础. 一.安装git https://git-scm.com/downloads 二.git创建 ...

  8. 当一回Android Studio 2.0的小白鼠

    上个星期就放出了Android studio出2.0的消息,看了一下what's new 简直抓到了那个蛋疼的编译速度痛点.在网上稍微搜索了一下后发现基本都是介绍视频.一番挣扎后(因为被这IDE坑过几 ...

  9. GridVeiw 使用

    1. 因使用的是 Mongodb,因此要在 ActiveDataProvider 中指定 key 属性 2. 自定义表格中的按钮 'class' => 'yii\grid\ActionColum ...

  10. 运行eclipse弹出“Failed to load the JNI shared”解决方法

    听周围的人说,看网上的人说eclipse有多么神奇.我不禁好奇万分,于是自己就去eclipse官网下载一个软件.咱也来用用,满怀兴奋的心情,一运行eclipse结果 出现下图的错误提示:“Failed ...