0

谁能帮我理解这段 VBScript 在做什么。我迷失在 WhereClause 位

 If CVs = "," or CVs = ",," Then
    ExistingSupplierCVs = 0
Else
    Set CVRecords = Ext.CreateAppRecordList( ActivityTableId )
    WhereClause = Left(CVs, Len(CVs)-1)
    WhereClause = Right(WhereClause, Len(WhereClause)-1)
    WhereClause = "TS_ID in (" & WhereClause & ") and TS_SUPPLIER = " &      Supplier

    If Not CVRecords.ReadWithWhere( WhereClause ) then
        Call Ext.LogErrorMsg( "TeamScript Error : Cannot find " & QUOTE & WhereClause & QUOTE & " in table " & QUOTE & "USR_ACTIVITY" & QUOTE )
        Exit Sub
    End If

    ExistingSupplierCVs = CVRecords.Length()
End If
4

4 回答 4

1

就像@Dave 所说:他们正在从字符串中删除第一个和最后一个字符CVs

一种更简单的方法是使用Mid

WhereClause = Mid(CVs, 2, Len(CVs) - 2)

您可以像这样组合所有三行:

WhereClause = "TS_ID in (" & Mid(CVs, 2, Len(CVs) - 2) & ") and TS_SUPPLIER = " & Supplier
于 2016-07-20T21:03:57.717 回答
0

这是非常典型的 Serena Business Manager Composer 语言 - AppScript。

您共享的代码是计算多关系字段中的记录数,然后在字段中输入值。一个典型的空多​​关系字段看起来像这样“,”,它的值看起来像这样“,1,34”,数字显示了这个 MR 字段指向的字段的 Id。

正在构建的 where 子句只是简单地从 MR 字段中删除第一个和最后一个逗号,然后查询 Id。

如果您仍然有任何疑问,请告诉我。

于 2016-09-08T07:32:30.703 回答
0

最好的猜测如下...

If CVs = "," or CVs = ",," Then
    ExistingSupplierCVs = 0 ' if the string is empty advise that the number of CVs is zero
Else
    Set CVRecords = Ext.CreateAppRecordList( ActivityTableId ) ' extract a list of CVRecords
    WhereClause = Left(CVs, Len(CVs)-1) ' strip the last char from this string
    WhereClause = Right(WhereClause, Len(WhereClause)-1) ' strip the first char from this string
    WhereClause = "TS_ID in (" & WhereClause & ") and TS_SUPPLIER = " &      Supplier ' insert the values into (presumably) a SQL query

    If Not CVRecords.ReadWithWhere( WhereClause ) then ' if executing the query returns false
        Call Ext.LogErrorMsg( "TeamScript Error : Cannot find " & QUOTE & WhereClause & QUOTE & " in table " & QUOTE & "USR_ACTIVITY" & QUOTE ) 'report an error and exit the subroutine.
        Exit Sub
    End If

    ExistingSupplierCVs = CVRecords.Length() ' return the number of records from the query
End If
于 2016-07-20T14:46:55.707 回答
0

因为这是 AppScript(SBM 的 VBScript 变体),所以将其发布到Serena(现在是 MicroFocus 的一部分)社区站点会得到更好的答案。

于 2017-10-25T16:16:45.233 回答