• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Maximo脚本没办法加载第二个MboSet

用户头像
it1352
帮助1

问题说明

我在INVOICELINE上有一个带有对象启动点的脚本. 对于MBO,我想获取所有具有与当前MBO相同的PONUM的INVOICELINES(因为它们可以位于当前MBO的发票之外的其他发票中)

I've a script with an object launchpoint on INVOICELINE. For the mbo I want to get all INVOICELINES with the same PONUM as the current MBO (since they could be in other then the current mbo's invoice)

在脚本中,我发现采购订单是这样的:(以测试状态)

In the script I find the PO like so: (to test for status)

from psdi.server import MXServer
from psdi.mbo import Mbo
from psdi.mbo import MboConstants
from psdi.security import UserInfo
from psdi.server import MXServer

myMXServer = MXServer.getMXServer()
userInfo = mbo.getThisMboSet().getUserInfo()

# find the PO
poSet = myMXServer.getMboSet("PO", userInfo)
poSetWhere = "ponum='"   mbo.getString("PONUM")   "' and siteid='"   mbo.getString("POSITEID")   "' and status not in "   poNoUpdate
poSet.setWhere(poSetWhere)

poMbo = poSet.getMbo(0)

效果很好.

然后,我对一组发票行执行相同的操作:

then later I do the very same for the set of invoicelines:

ilSet = myMXServer.getMboSet("INVOICELINE", userInfo)
ilSetWhere = "ponum='"   mbo.getString("PONUM")   "' and positeid='"   mbo.getString("POSITEID")   "'"
ilSet.setWhere(ilSetWhere)
ilMbo = ilSet.moveFirst()

while ilMbo is not None:
    ...

这将导致setWhere行上的错误.奇怪的是,日志记录(出于可读性考虑已删除)表明ilSet包含getMboSet之后的所有发票行记录(如预期的那样),ilSetWhere具有有效的查询,您可以在SQL Developer中将其复制粘贴.

which results in a error on the setWhere line. Curiously, logging (which I removed for readability) indicates that ilSet contains all invoicelines records after the getMboSet (as expected), the ilSetWhere has a valid query that you can copy-paste in SQL Developer.

Maximo在执行此setWhere之前需要一些索引吗?

Does Maximo need some index or so before it can execute this setWhere?

这是两个setWhere字符串的日志记录结果:

Here is the logging result for the two setWhere strings:

ponum='4140006682' and siteid='mysite' and status not in ('CLOSED','CAN','GESLTN','ANN')

ponum='4140006682' and positeid='mysite'

我得到的错误是脚本中的通用BMXAA7837E java.lang.NullPointerException在第...行(该行引用带有ilSet.setWhere(ilSetWhere)表达式的行.我不知道如何解决此问题而且不知道如何解决它.

The error I get is a generic BMXAA7837E java.lang.NullPointerException in script at line... (the line refers to the line with the ilSet.setWhere(ilSetWhere) expression. I'm out of ideas how to fix this and have no clue how to work around it.

正确答案

#1

现在我们遇到了一个错误!

Now we have an error to work with!

Maximo有效地坚持认为INVOICELINE集具有一个所有者",而您在代码示例中尚未设置该所有者.将所有者视为父集.具体来说,它是用于获取当前设置的MBOSet.实际上,它实际上不必与当前集合相关,但是在大多数情况下,它将与当前集合相关(并且以这种方式获取集合最有意义).可以在获取集合后将所有者注入到集合中(以对其进行更改或欺骗Maximo),但这很少是好的代码.

Maximo effectively insists that an INVOICELINE set has an "owner", which you have not set up in your code example. Think of an owner as a parent set. Specifically, it is the MBOSet used to fetch the current set off of. It doesn't actually have to be related to the current set, but most of the time it will be (and it makes the most sense to fetch sets that way). An owner can be injected into the set after it's fetched (to change it or trick Maximo), but this is rarely good code.

与其在自己的事务中从服务器获取一个新的集合(无其他联系或可能的数据缓存),不如从当前的MBO中获得发票行设置,这可能是最好的选择.我不知道您的确切用例,但是通常您想要做这样的事情,而不是像您那样获得新的集合.至少,它将为您的新集提供一个所有者".您甚至可能希望使SQL成为关系",而不是对其进行硬编码.

Instead of getting a fresh set (no other ties or possible data caching) from the server in its own transaction, you might be best off getting the invoiceline set off of your current MBO. I don't know your exact use case, but generally you want to do something like this instead of getting a new set like you did. At the least, it will give your new set an "owner". You may even want to make the SQL a "relationship" instead of hard-coding it.

ilSetWhere = "ponum='"   mbo.getString("PONUM")   "' and positeid='"   mbo.getString("POSITEID")   "'"
ilSet = mbo.getMboSet("$TempInvoiceLineRelationship", "INVOICELINE", ilSetWhere)
ilMbo = ilSet.moveFirst()

我正从内存中获取此代码,所以我不知道它是否完全正确. "getMboSet"的形式采用三个参数.第一个是关系名称.如果Maximo从该起始对象中找到了已经注册"的关系名称,它将忽略接下来的两个参数,并使用该关系来进行设置.如果找不到该关系已注册",则会在此代码的范围内对其进行注册(因此,如果需要,您可以稍后在此代码中重新使用它).第二个参数定义要创建临时关系的目标对象.第三个参数定义此临时关系的"where子句".

I'm going from memory for this code, so I don't know if it is exactly correct. That form of "getMboSet" takes three parameters. The first is a relationship name. If Maximo finds that relationship name already "registered" from this starting object, it will ignore the next two parameters and use that relationship to get you that set. If it doesn't find that relationship "registered" it registers it for the scope of this code (so you can re-use it later in this code if you wanted). The second parameter defines what destination object to create the temporary relationship to. The third parameter defines the "where clause" of this temporary relationship.

原始答案:

您遇到什么错误?

还说您在"myMXServer.getMboSet ..."行之后登录"ilSet"吗?这将导致Maximo运行查询,然后将对象加载到集合中(它会等待运行查询,直到必须这样做为止).结果,直到重置()"集合后,您才能看到where子句的更改.

Also, you say you log "ilSet" after the "myMXServer.getMboSet..." line? That is going to cause Maximo to run the query and load the objects into the set at that point (it waits to run the query until it has to). As a result of that, you won't see the effects of your where clause change until you "reset()" the set.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcgabkc
系列文章
更多 icon
同类精品
更多 icon
继续加载