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. Ubuntu 14.04 MySQL同步

    主服务器:192.168.2.212 从服务器:192.168.2.211   主服务器(192.168.2.212): 先到/etc/mysql/my.cnf下 将 bind-address 127 ...

  2. Metronic_下拉列表Select2插件的使用

    这个插件是基于Select的扩展插件,能够提供更加丰富的功能和用户体验,它的github官网地址为:https://select2.github.io/,具体的使用案例,可以参考地址:https:// ...

  3. The Storage Situation: Removable Storage

    http://commonsware.com/blog/2014/04/09/storage-situation-removable-storage.html There is a lot of co ...

  4. 创建 maven 本地仓库; (五)

    在 pom.xml 添加依赖包的时候,有时候会提示无法从 http://repo1.maven.org/maven2/ 获取的情况,这时可配置个本地仓库: 从网上下载 maven 仓库网站源码包 Ne ...

  5. 【C语言】07-基本语句和运算

    一.基本语句 C语言的基本语句跟Java中的差不多,所以,这里只是简单地提一下 循环语句(do while.while.for) 条件语句(if .if-else.switch) goto语句 二.基 ...

  6. DataGridView控件添加数据时空白的可 错误情况

    写一个小程序,将数据库中的两张表相关信息显示在DataGridView中.代码如下: //获取项目数据,添加到表中 SqlConnection con = new SqlConnection(Main ...

  7. Objective-C中属性及其特质@property、attribute

    属性: 属性@property和属性attribute不同,@property在OC里有自己的一套专对实例变量的处理机制.attribute我们可以特指属性所具有或遵循的特质. 使用属性,编译器就会自 ...

  8. linux查看时间和修改时间

    查看当前时间,date -R 设置时间 date -s 例如当前时间2014年11月3日17:22:48 date -s 11/3/2014 date -s 17:22:48 先设置日期后设置具体时间 ...

  9. http304状态码缓存设置问题

    当浏览器第一次加载资源的时候,返回一般为200,意思是成功获取资源,并会在浏览器的缓存中记录下max-age,第二次访问的时候:如果只是用浏览器打开,那么浏览器会去判断这个资源在缓存里有没有,如果有的 ...

  10. nginx日志配置[转]

     * * * sh /home/zyf/sh/cut_nginx_log.sh 这样就每天的0点1分把nginx日志重命名为日期格式,并重新生成今天的新日志文件。 日志对于统计排错来说非常有利的。本文 ...