在EBSForm查找界面点"Find"之后都发生了什么?
我一直对form 都感觉比较困惑, 特别是form 里面的trigger, 像PRE-QUERY, POST-QUERY 一直都弄不清情况. 这个trigger 是什么时候触发的呢? 看名字就是在QUERY 之前或之后触发的. 那么QUERY 什么呢? 搞不清楚. 今天就看下代码, 弄明白点了 find 之后做了什么事
我一直对form 都感觉比较困惑, 特别是form 里面的trigger, 像PRE-QUERY, POST-QUERY 一直都弄不清情况. 这个trigger 是什么时候触发的呢? 看名字就是在QUERY 之前或之后触发的. 那么QUERY 什么呢? 搞不清楚.
今天就看下代码, 弄明白点了 "find" 之后做了什么事情, 那些数据库里面的值怎么到form 界面上去的.
我们知道, 每一个form 上的数据块都是绑定一个table 或者 view 的. 通常会绑定view. 像下面那样:
vcu1REVNX09SREVSX1YsIMi7uvOw0XZpZXcgwO/D5rXE19a2ztK70ru21NOm09rK/b7dv+m1xNfWts4sINXi0fmx4NLr1MvQ0LXEyrG68iwg1Npmb3JtIL3nw+ayy7Wlyc8gdmlldyAtJmd0OyBxdWVyeSBieSAtJmd0OyBydW4sIL7Nv8nS1NaxvdPX9rLp0a+1xLav1/csINTaZm9ybSC958Pmyc++zbvhz9TKvrP2yv2+3b/itcS8x8K8LjwvcD4KPHA+ICAgICDV4sDvvs3X9sHL0ru0zlFVRVJZILXEtq/X9ywgsunRr8r9vt2/4iwgyLu687DRvMfCvLXEJiMyMDU0MDvM7rW9ttTTprXEZmllbGQgwO/D5silLjwvcD4KPHA+ICAgICC1q8rH1eLR+bXEwt+8rcrHvPK1pbXELCDDu9PQsOy3qNOmuLZFQlMguLTU07XE0rXO8cLfvK0uINLytMvU2sq1vMq1xNf2t6jW0CwgsqLDu9PQ08PV4tH5vPK1pdaxvdO1xLe9yr0uIM7Sw8fIpb+0RUJTIMDvw+a1xGZvcm0sIMr9vt2/4snPtcTX1rbOus12aWV3IMDvw+a1xNfWts68uLr1w7vT0LbU06a52M+1LiAmIzIwMjg0O7r1ysfBvbj2srvP4LnYway1xLarzvcsINa7ysfD+9fWutzP8S48L3A+CjxwPiAgICAg1eLR+df2tcS94bn7vs3Kx7y4uvXL+dPQtcTQ0M6qtrzSqtfUvLrQtLT6wuvKtc/WLiCyu8Tcz/HJz8PmxMfR+bXjz8Ky6dGvLCDIu7rzy/nT0LXEJiMyMDU0MDvX1Lavz9TKvtTavefD5snPwcsuINPJ09rIscnZyv2+3b/i0+u958Pm19a2zrXEudjBqiwgvLTKubLp0a/By8r9vt2/4iwg0rLSqsrWtq+w0SYjMjA1NDA7uLTWxrj4vefD5snPtcTX1rbOLjwvcD4KPHA+ICAgICDO0sPH0tRQTyBSZWNlaXB0cyC958PmzqrA/Swgv7S/tLXjz8ImcXVvdDtmaW5kJnF1b3Q7ILa81/bBy8TE0KnKwsfpLjwvcD4KPHA+MS4gytfPyM6qwcu88ruvzsrM4iwgztLDx9XiwO/Wu7+8wsdSQ1ZSQ0VSQy5mbWIg1eK49mZvcm0g1rvT0MG9uPbK/b7dv+kgYSkgRmluZCAgIGIpUkNWX1RSQU5TQUNUSU9OPC9wPgo8cD7U2kZpbmQgvefD5snPzO7QtLrDsunRr8z1vP668ywgtePSu8/CJnF1b3Q7ZmluZCZxdW90Oywg1eLKsbvhs/a3oldIRU4tQlVUVE9OLVBSRVNTRUQg1eK49nRyaWdnZXIuINTa1eK49nRyaWdnZXIgwO/D5s/ItffTw0FQUF9TVEFOREFSRC5BUFBfVkFMSURBVEUgKFJFQ09SRF9TQ09QRSkg1/bR6dakLCDIu7rztffTw8HLRklORF9CVVRUT05fQ09ERSDV4rj2t723qC4gPC9wPgo8cD7U2tXiuPa3vbeowO/D5iwgtffTw8HLUkNWX0ZJTkRfQy5GSU5EX0JVVFRPTig="WHEN-BUTTON-PRESSED','FIND','RCV_TRANSACTION') 这个过程.
这时在RCVCOFND.pld 里面定义的一个过程. 这个文件是一个比较底层的文件, Receipts form 从这个from 上继承了很多, 也调用里面的方法.
这个方法里面有3 个参数, 第一个是trigger 名. 第二个是find block name, 第三个是navigation block name. 那么调用这个过程会去到RCV_TRANSACTION 这个数据块, 然后做查询, 用下面的代码来实现:
go_block(navigation block name);
do_key('EXECUTE_QUERY');
2. 那么这时焦点就会跑到RCV_TRANSACTION 这个块上去, 然后做查询. 查询什么呢? 就是查询这个数据块所绑定的view.
在做查询之前, 我们要在RCV_TRANSACTION 这个数据块下面找到了PRE-QUERY 和 POST-QUERY 这两个trigger. 这两个是干嘛的呢? 就是在做QUERY 之前给查询做一些准备工作, 和查询结束之后进行一些后续工作. PRE-QUERY 只在查询之前执行一次, 但是POST-QUERY 要在查询之后触发多次. 查询到多少条记录就出发多少次.
3. 现在来看PRE-QUERY 里面做了什么.
先是调用了这个过程: analyze_search_criteria(l_rcv_view, l_dest_query_pos, l_src_type); 看名字能看出来是在做什么... 分析查询条件. 这3 个参数属性都是OUT. 在这个过程里面确定了查询使用的view: l_rcv_view 是那个. 比如说, 如果我们做的是一个组织间转移 inter org transfer, 那么使用的view 就是RCV_ENTER_RECEIPTS_INTERNAL_V; 如果是ASN 接收的话, 使用的view 是RCV_ENTER_RECEIPTS_ASN_V; 使用哪个view 做查询就是在这个过程里面决定的. 决定标准是根据"Find" form 界面上填入的查询条件. l_dest_query_pos 意思是使用的查询方式, 有"from" 和 "where" 两种取值可能. l_src_type 就是source type, 可能是INTERNAL, LCM, CUSTOMER, VENDOR, ALL 等等;
我们这里考虑l_dest_query_pos = where 的情况.
这里面会用下面这个过程APP_QUERY.append(block_name, clause) 把 clause 加到前面block_name 后面, 作为查询条件.
4. 就这样通过判断find form 里面填入的值, 给查询的数据块加入一个一个条件. 比如, 如果FIND.SOURCE_TYPE 的值是VENDOR, 加上的查询条件就是: (RCV_ENTER_RECEIPTS_V.SOURCE_TYPE_CODE = ''VENDOR'' OR RCV_ENTER_RECEIPTS_V.SOURCE_TYPE_CODE = ''ASN''). 诸如此类.
5. PRE-QUERY 还做了一件事, 就是把find 界面上的值copy 给RCV_TRANSACTION 对应的字段. 但是这些不是作为查询条件来的.
6. 就这样在PRE-QUERY 里面确定了查询使用哪个view, 并且确定了查询条件. 然后就是做查询的动作. 查询是从前面的RCV_ENTER_RECEIPTS_INTERNAL_V 和RCV_TRANSACTION 绑定的view RCV_ENTER_RECEIPTS_V 两个view 里面查出结果来. 当查询结束后, 就会执行POST-QUERY 这个trigger.
7. 之前我们说过, 由于RCV_TRANSACTION 这个数据块上的字段和view 里面的字段是没有绑定关系的, 因此查询出来的结果并不会自动赋值给界面上的字段. 需要在POST-QUERY 里面手动赋值. 所以这个trigger 主要就是做的赋值的工作. 这个里面有大量的代码, 格式很单一:
if (criteria ) then select a into b from table where .. copy (b , 'RCV_TRANSACTION.field');
也就是根据某个条件从数据库查出某个值, 赋值给数据库的字段. 所以这个里面出现了大量select 语句和copy 语句.
8. 在POST-QUERY 里面也调用了非常多的数据库过程, 这些过程写在 pls 文件中. 这里没有去深究这许多过程有哪些功能, 但能从调用的结果上看出来, 这里面是做了一些逻辑判断和计算的. 例如v_secondary_quantity := inv_convert.inv_um_convert
9. 另外在这个trigger 的最后会set 字段的属性, 例如set_item_property: item_is_valid, 就是让字段验证属性为真.
10. 到这里为止, query 的动作就做完了, 通过PRE-QUERY 设定查询条件, POST-QUERY 给界面字段赋值. 要注意的是, 如果查询出来有两条记录的话, 那么POST-QUERY 会执行两次. 为啥要执行两次呢? 因为界面上两条记录的字段是不一样的, 需要根据不同的条件赋值, 比如两条记录的id 不一样, 就要用这个id 分别查出某个字段的值在赋值.
11. 到这里为止, 上面的RCV_FIND_C.FIND_BUTTON('WHEN-BUTTON-PRESSED','FIND','RCV_TRANSACTION') 这个过程就执行完了. 在此之后又执行了一下过程, 但是已经更查询的关系不大了, 主要是跳到某个窗口, 设置属性等等. 至此, WHEN-BUTTON-PRESSED 这个trigger 就全部执行完毕了. 查询的结果就已经在界面上显示出来了.
12. 在焦点跳入RCV_TRANSACTION 数据块的时候, 又会出发WHEN-NEW-RECORD-INSTANCE 等等trigger, 但这是后事了, 这里就不讨论了;
总结: 这样的做法显得非常复杂而且需要写很多代码, 但是优点也是比较明显的, 这对于所有的字段都有比较精确的控制. 这对于实现复杂的业务逻辑是必须的.
代码中有许多built-in 的代码, 可以在form builder 里面找看看是怎么用的. 帮助很大.
注: 这是我看着代码写出来的, 如果里面有错误的地方, 希望大家能够指出来, 共同进步.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Use the Array.IndexOf function in C# to find the index of an element in an array. In a C# program, when we need to find the index of an element in an array, we can use the Array.IndexOf function. The Array.IndexOf function finds the specified element within the specified array range and returns the index of its first occurrence. If the element is not found, -1 is returned. The following is a sample code that demonstrates how to use the Array.IndexOf function to find an element in an array.

What happens when you turn off Find My on iPhone? Find My iPhone helps you locate a lost or stolen device. When enabled, Find My iPhone lets you track your device's location on a map, plays sounds, and helps you find your device. Find My also includes an Activation Lock to prevent anyone from using your iPhone. When you turn off Find My iPhone, you lose all these features, which may make recovering a lost Apple device difficult. While Find My iPhone is very useful, you should disable it when you want to sell, donate, trade in your phone, or send it for battery replacement or any other service. Doing this will ensure that no one can access information about you

Hard drive serial numbers and MAC addresses are important identifiers in computer hardware and are very useful in managing and maintaining computer systems. This article will introduce how to find the hard disk serial number and MAC address. 1. Find the hard drive serial number. The hard drive serial number is a unique identifier used by the hard drive manufacturer to identify and track the hard drive. In different operating systems, the method of finding the hard drive serial number is slightly different. Windows: Open Command Prompt (search for "cmd" in the Start menu) and enter the following command and press Enter: wmicdisk

Apple's Find My app allows you to locate your iPhone or other device to prevent it from being lost or forgotten. While Find My is a useful tool for tracking devices, you may want to disable it if you're concerned about privacy issues, don't want to drain your battery, or for other reasons. Fortunately, there are several ways to turn off Find My on iPhone, all of which we will explain in this article. How to Turn off Find My on iPhone [4 Methods] You can turn off Find My on iPhone in four ways. If you used Method 1 to turn off Find, you can do this from the device you want to disable it on. To proceed with methods 2, 3, and 4, the iPhone that you want to turn off Find Finder should be powered off or

The glob() function in PHP is used to find files or directories and is a powerful file operation function. It can return the path of a file or directory based on a specified pattern match. The syntax of the glob() function is as follows: glob(pattern, flags) where pattern represents the pattern string to be matched, which can be a wildcard expression, such as *.txt (matching files ending with .txt), or a specific file path. flags is an optional parameter used to control the function

How to Check the Serial Number of a Computer Hard Drive With the development of computer technology, computer hard drives have become an indispensable part of our lives. Whether it is storing important files or installing operating systems and software, you need to rely on the hard disk to complete it. Understanding some basic information about the computer hard drive, such as the hard drive's serial number, can help us better manage and maintain the computer system. So, how to check the serial number of a computer hard drive? This article will introduce several common methods. Method 1: Use the command line tool that comes with Windows system Windows system

In this fast-paced era, OPPO Find X7 can use its imaging power to let us savor every beautiful moment in life. Whether it's magnificent mountains, rivers, lakes, or seas, warm family gatherings, or encounters and surprises on the street, it can help you record them with "unparalleled" picture quality. From the outside, the camera Deco design of Find It looks very recognizable and has a high-end feel. The inside is also unique, starting with the basic hardware configuration. FindX7 maintains the previous

How to write a hash lookup algorithm in Python? Hash search algorithm, also known as hash search algorithm, is a data search method based on hash table. Compared with traditional search algorithms such as linear search and binary search, the hash search algorithm has higher search efficiency. In Python, we can use a dictionary to implement a hash table and then implement a hash lookup. The basic idea of the hash search algorithm is to convert the keyword to be searched into an index value through a hash function, and then search it in the hash table based on the index value.
