Macro and SQL
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的更多相关文章
- dbt macro 说明
macro是SQL的片段,可以像模型中的函数一样调用.macro可以在模型之间重复使用SQL,以符合DRY(不要重复自己)的工程原理. 此外,共享包可以公开您可以在自己的dbt项目中使用的macro. ...
- Cobar介绍及配置
from:http://code.alibabatech.com/wiki/display/cobar/Home Skip to end of metadata Page restrictions ...
- sqler sql 转rest api 源码解析(四)macro 的执行
macro 说明 macro 是sqler 的核心,当前的处理流程为授权处理,数据校验,依赖执行(include),聚合处理,数据转换 处理,sql 执行以及sql 参数绑定 授权处理 这个是通过go ...
- sqlmap和burpsuite绕过csrf token进行SQL注入检测
利用sqlmap和burpsuite绕过csrf token进行SQL注入 转载请注明来源:http://www.cnblogs.com/phoenix--/archive/2013/04/12/30 ...
- Teradata SQL programming
Teradata的SQL设计和Oracle真不是一个水平, 一点美感的没有. 上个世纪它靠着MPP一招鲜吃变天, 居然做了十多年数据仓库的老大, 时过境迁, 现在有不少SQL On Hadoop ...
- [Hive - LanguageManual ] ]SQL Standard Based Hive Authorization
Status of Hive Authorization before Hive 0.13 SQL Standards Based Hive Authorization (New in Hive 0. ...
- SQL Standard Based Hive Authorization(基于SQL标准的Hive授权)
说明:该文档翻译/整理于Hive官方文档https://cwiki.apache.org/confluence/display/Hive/SQL+Standard+Based+Hive+Authori ...
- Using Notepad++ to Execute Oracle SQL
原文链接:http://www.toadworld.com/products/toad-for-oracle/b/weblog/archive/2013/08/21/using-notepad-to- ...
- 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 ...
随机推荐
- BZOJ2530 : [Poi2011]Party
注意到随机一组贪心解得到的团的大小不小于$\frac{N}{3}$的概率是很大的,所以一直随机下去,直到找到一组解即可,随机次数是常数级别的,所以复杂度为$O(n^2)$. #include<c ...
- BZOJ1397 : Ural 1486 Equal squares
二分答案mid,然后检验是否存在两个相同的mid*mid的正方形 检验方法: 首先对于每个位置,求出它开始长度为mid的横行的hash值 然后对于hash值再求一次竖列的hash值 将第二次求出的ha ...
- Vijos 1100 (区间DP)
题目链接: https://vijos.org/p/1100 题目大意:NOIP著名的加分二叉树.给出一棵树的中序遍历,加分规则左子树*右子树+根.空子树分数为1.问最大加分的树结构,输出树结构的先序 ...
- POJ 2486 Apple Tree(树形DP)
题目链接 树形DP很弱啊,开始看题,觉得貌似挺简单的,然后发现貌似还可以往回走...然后就不知道怎么做了... 看看了题解http://www.cnblogs.com/wuyiqi/archive/2 ...
- [转]单例模式——C++实现自动释放单例类的实例
[转]单例模式——C++实现自动释放单例类的实例 http://www.cnblogs.com/wxxweb/archive/2011/04/15/2017088.html http://blog.s ...
- npm 国内淘宝镜像cnpm
某些插件很奇怪,需要用国内的镜像下载才可以 #安装淘宝镜像npm install cnpm -g --registry=https://registry.npm.taobao.org #使用淘宝镜像下 ...
- 相关css 细节处理 neat.css
人性化的细节处理 例如: textarea 默认只能垂直拖动,防止宽度改变破坏布局. textarea { resize: vertical; } 汉字字号小于 12px 不易阅读,为 <sma ...
- 程序设计第二次作业<1>
面向对象程序设计第二次作业<1> Github 链接:https://github.com/Wasdns/object-oriented 题目: <1>第一次尝试 我立马认识到 ...
- HTTP 笔记与总结(2 )HTTP 协议的(请求行的)请求方法 及 (响应行的)状态码
(请求行的)请求方法 包括: GET,POST,HEAD,PUT,TRACE,DELETE,OPTIONS 注意:这些请求方法虽然是 HTTP 协议规定的,但是 Web Server 未必允许或支持这 ...
- swfit-pod使用
一.查询第三方版本号 pod search SDWebImage 二.项目添加pod 1.在终端打开项目路径 2.输入 pod init 生成Podfile 三.在Podfile输入需要的第三方 ...