BQL与一个自定义表联接,在运行时在“ [keyword]”附近给出错误的语法

时间:2019-07-11 15:46:26

标签: acumatica

我正在尝试创建一个自定义屏幕,以计划在Acumatica中发货的交货时间。为此,我创建了一个名为DeliverySchedule的自定义表和DAC。然后,我创建一个数据视图,该数据视图将SOShipLine表与此新的自定义表连接在一起。但是,当我加载屏幕时,出现运行时错误,提示“ =”附近的语法不正确。

当我仅连接两个Acumatica表(SOShipment和SOShipLine)时,不会发生错误。当我将自定义表加入组合时,就会发生这种情况。我尝试使用Acumatica中的Request Profiler屏幕进行调试,但是我从中没有太多信息(或者可能我不知道如何使用它并读取它提供的数据)

public PXSelectJoin<SOShipLine, InnerJoin<SOShipment, On<SOShipment.shipmentNbr, Equal<SOShipLine.shipmentNbr>>, LeftJoin<DeliverySchedule, On<DeliverySchedule.shipmentNbr, Equal<SOShipLine.shipmentNbr>, And<DeliverySchedule.lineNbr, Equal<SOShipLine.lineNbr>>>>>, Where<SOShipment.status, Equal<SOShipmentStatus.open>>> Shipments;

DAC


    [Serializable]
    public class DeliverySchedule : IBqlTable
    {
        #region ShipmentNbr
        [PXString(15, IsKey = true)]
        [PXDBDefault(typeof(SOShipLine.shipmentNbr))]
        [PXParent(typeof(Select<SOShipLine, Where<SOShipLine.shipmentNbr, Equal<Current<DeliverySchedule.shipmentNbr>>, And<SOShipLine.lineNbr, Equal<Current<DeliverySchedule.lineNbr>>>>>))]
        [PXUIField(DisplayName = "Shipment No.")]
        public string ShipmentNbr { get; set; }
        public class shipmentNbr : IBqlField { }
        #endregion

        #region LineNbr
        [PXDBInt(IsKey = true)]   
        [PXDBDefault(typeof(SOShipLine.lineNbr))]
        [PXParent(typeof(Select<SOShipLine, Where<SOShipLine.shipmentNbr, Equal<Current<DeliverySchedule.shipmentNbr>>, And<SOShipLine.lineNbr, Equal<Current<DeliverySchedule.lineNbr>>>>>))]
        [PXUIField(DisplayName = "Line Nbr.", Visible = false)]
        public Int32? LineNbr { get; set; }
        public class lineNbr : IBqlField { }
        #endregion

        #region InventoryID
        [PXDBInt]
        [PXUIField(DisplayName = "Inventory ID")]
        public Int32? InventoryID { get; set; }
        public class inventoryID : IBqlField { }
        #endregion

        #region TransportID
        [PXDBInt]
        [PXUIField(DisplayName = "Transport")]
        public Int32? TransportID { get; set; }
        public class transportID : IBqlField { }
        #endregion

        #region DriverID
        [PXDBInt]
        [PXUIField(DisplayName = "Driver/ Captain")]
        public Int32? DriverID { get; set; }
        public class driverID : IBqlField { }
        #endregion

        #region TripNbr
        [PXDBString(15)]
        [PXUIField(DisplayName = "Trip No.")]
        public string TripNbr { get; set; }
        public class tripNbr : IBqlField { }
        #endregion

        #region ScheduledDelivery
        [PXDBDateAndTime(DisplayNameDate = "Scheduled Delivery Date", DisplayNameTime = "Scheduled Delivery Time")]
        public DateTime? ScheduledDelivery { get; set; }
        public class scheduledDelivery : IBqlField { }
        #endregion

        #region CustInvLvlBeforeDel
        [PXDBDecimal]
        [PXUIField(DisplayName = "Cust. Inv. Lvl. (Before Delivery)")]
        public decimal? CustInvLvlBeforeDel { get; set; }

        public class custInvLvlBeforeDel : IBqlField { }
        #endregion

        #region CustInvLvlAfterDel
        [PXDBDecimal]
        [PXUIField(DisplayName = "Cust. Inv. Lvl. (After Delivery)")]
        public decimal? CustInvLvlAfterDel { get; set; }

        public class custInvLvlAfterDel : IBqlField { }
        #endregion
    }

跟踪日志

enter image description here

信息。屏幕快照中显示的“表”列中,将其粘贴为文本。

Tables
@@DBTS, IDENT_CURRENT('WatchDog') OPTION(OPTIMIZE FOR UNKNOWN) /* PA.20.81.00 */
@@DBTS, IDENT_CURRENT('WatchDog') OPTION(OPTIMIZE FOR UNKNOWN) /* PA.20.81.00 */
Favorite
@@DBTS, IDENT_CURRENT('WatchDog') OPTION(OPTIMIZE FOR UNKNOWN) /* PA.20.81.00 */
@@DBTS, IDENT_CURRENT('WatchDog') OPTION(OPTIMIZE FOR UNKNOWN) /* PA.20.81.00 */
"[WikiPage].[PageID], [WikiPage].[WikiID], [WikiPage].[ArticleType], [WikiPage].[ParentUID], [WikiPage].[Number], [WikiPage].[Name], [WikiPage].[Versioned], [WikiPage].[Folder], [WikiPage].[NoteID], NULL, NULL, NULL, [WikiPage].[CreatedByID], [WikiPage].[CreatedDateTime], [WikiPage].[LastModifiedByID], [WikiPage].[LastModifiedDateTime], [WikiPage].[tstamp], [WikiPage].[StatusID], [WikiPage].[ApprovalGroupID], [WikiPage].[ApprovalUserID], [WikiPage].[Width], [WikiPage].[Height], [WikiPage].[IsHtml]
FROM [WikiPage] [WikiPage]
WHERE [WikiPage].CompanyID IN (1, 2) AND 8 = SUBSTRING([WikiPage].CompanyMask, 1, 1) & 8 AND [WikiPage].[Name] = @P0
ORDER BY [WikiPage].[PageID] OPTION(OPTIMIZE FOR UNKNOWN) /* PA.20.81.00 */"
@@DBTS, IDENT_CURRENT('WatchDog') OPTION(OPTIMIZE FOR UNKNOWN) /* PA.20.81.00 */
@@DBTS, IDENT_CURRENT('WatchDog') OPTION(OPTIMIZE FOR UNKNOWN) /* PA.20.81.00 */
WatchDog
SMPerformanceSettings
@@DBTS, IDENT_CURRENT('WatchDog') OPTION(OPTIMIZE FOR UNKNOWN) /* PA.20.81.00 */
"TOP (201) [SOShipLine].[ShipmentNbr], [SOShipLine].[ShipmentType], [SOShipLine].[LineNbr], [SOShipLine].[SortOrder], [SOShipLine].[CustomerID], [SOShipLine].[ShipDate], [SOShipLine].[Confirmed], [SOShipLine].[Released], [SOShipLine].[LineType], [SOShipLine].[OrigOrderType], [SOShipLine].[OrigOrderNbr], [SOShipLine].[OrigLineNbr], [SOShipLine].[OrigSplitLineNbr], [SOShipLine].[Operation], [SOShipLine].[OrigPlanType], [SOShipLine].[InvtMult], [SOShipLine].[InventoryID], [SOShipLine].[PlanType], [SOShipLine].[SubItemID], [SOShipLine].[SiteID], [SOShipLine].[LocationID], [SOShipLine].[LotSerialNbr], [SOShipLine].[ExpireDate], [SOShipLine].[OrderUOM], [SOShipLine].[UOM], [SOShipLine].[ShippedQty], [SOShipLine].[BaseShippedQty], [SOShipLine].[BaseOriginalShippedQty], [SOShipLine].[UnassignedQty], [SOShipLine].[CompleteQtyMin], [SOShipLine].[BaseOrigOrderQty], [SOShipLine].[OrigOrderQty], [SOShipLine].[UnitCost], [SOShipLine].[ExtCost], [SOShipLine].[UnitPrice], [SOShipLine].[DiscPct], [SOShipLine].[AlternateID], [SOShipLine].[TranDesc], [SOShipLine].[UnitWeigth], [SOShipLine].[UnitVolume], [SOShipLine].[ExtWeight], [SOShipLine].[ExtVolume], [SOShipLine].[ProjectID], [SOShipLine].[TaskID], [SOShipLine].[ReasonCode], [SOShipLine].[IsFree], [SOShipLine].[ManualPrice], [SOShipLine].[ManualDisc], [SOShipLine].[IsUnassigned], [SOShipLine].[DiscountID], [SOShipLine].[DiscountSequenceID], [SOShipLine].[DetDiscIDC1], [SOShipLine].[DetDiscSeqIDC1], [SOShipLine].[DetDiscIDC2], [SOShipLine].[DetDiscSeqIDC2], [SOShipLine].[DetDiscApp], [SOShipLine].[DocDiscIDC1], [SOShipLine].[DocDiscSeqIDC1], [SOShipLine].[DocDiscIDC2], [SOShipLine].[DocDiscSeqIDC2], [SOShipLine].[ShipComplete], [SOShipLine].[RequireINUpdate], [SOShipLine].[NoteID], (SELECT TOP (1) [Note_s65].[NoteText] FROM [dbo].[Note] [Note_s65] WHERE [Note_s65].CompanyID IN (1, 2) AND 8 = SUBSTRING([Note_s65].CompanyMask, 1, 1) & 8 AND [Note_s65].[NoteId] = [SOShipLine].[NoteID]), (SELECT TOP (1) COUNT(*) FROM [dbo].[NoteDoc] [NoteDoc_s67] WHERE [NoteDoc_s67].CompanyID IN (1, 2) AND 8 = SUBSTRING([NoteDoc_s67].CompanyMask, 1, 1) & 8 AND [NoteDoc_s67].[NoteId] = [SOShipLine].[NoteID]), NULL, [SOShipLine].[CreatedByID], [SOShipLine].[CreatedByScreenID], [SOShipLine].[CreatedDateTime], [SOShipLine].[LastModifiedByID], [SOShipLine].[LastModifiedByScreenID], [SOShipLine].[LastModifiedDateTime], [SOShipLine].[tstamp], [SOShipLine].[UsrAPIGravity], [SOShipLine].[UsrMeterID], [SOShipLine].[UsrGrossQty], [SOShipLine].[UsrTemperature], [SOShipLine].[UsrToLocationID], [SOShipLine].[UsrBOLQty], [SOShipLine].[UsrBeginningTotalizer], [SOShipLine].[UsrEndingTotalizer], [SOShipment].[ShipmentNbr], [SOShipment].[ShipDate], [SOShipment].[Operation], [SOShipment].[ShipmentType], [SOShipment].[CustomerID], [SOShipment].[CustomerLocationID], [SOShipment].[SiteID], [SOShipment].[DestinationSiteID], [SOShipment].[ShipAddressID], [SOShipment].[ShipContactID], [SOShipment].[FOBPoint], [SOShipment].[ShipVia], [SOShipment].[UseCustomerAccount], [SOShipment].[Resedential], [SOShipment].[SaturdayDelivery], [SOShipment].[Insurance], [SOShipment].[GroundCollect], [SOShipment].[LabelsPrinted], [SOShipment].[PickListPrinted], [SOShipment].[ShippedViaCarrier], [SOShipment].[ShipTermsID], [SOShipment].[ShipZoneID], [SOShipment].[LineTotal], [SOShipment].[CuryID], [SOShipment].[CuryInfoID], [SOShipment].[CuryFreightCost], [SOShipment].[FreightCost], [SOShipment].[CuryFreightAmt], [SOShipment].[FreightAmt], [SOShipment].[CuryPremiumFreightAmt], [SOShipment].[PremiumFreightAmt], [SOShipment].[CuryTotalFreightAmt], [SOShipment].[TotalFreightAmt], [SOShipment].[TaxCategoryID], [SOShipment].[NoteID], NULL, NULL, NULL, [SOShipment].[Hold], [SOShipment].[Confirmed], [SOShipment].[Released], [SOShipment].[Status], [SOShipment].[LineCntr], [SOShipment].[BilledOrderCntr], [SOShipment].[UnbilledOrderCntr], [SOShipment].[ReleasedOrderCntr], [SOShipment].[ControlQty], [SOShipment].[ShipmentQty], [SOShipment].[ShipmentWeight], [SOShipment].[ShipmentVolume], [SOShipment].[PackageLineCntr], [SOShipment].[PackageWeight], [SOShipment].[IsPackageValid], [SOShipment].[CreatedByID], [SOShipment].[CreatedByScreenID], [SOShipment].[CreatedDateTime], [SOShipment].[LastModifiedByID], [SOShipment].[LastModifiedByScreenID], [SOShipment].[LastModifiedDateTime], [SOShipment].[tstamp], [SOShipment].[WorkgroupID], [SOShipment].[OwnerID], [SOShipment].[FreeItemQtyTot], CASE WHEN  ( [SOShipment].[Status] IS NULL) THEN  'A' ELSE  [SOShipment].[Status] END, [SOShipment].[UsrBOLNbr], [DeliverySchedule].[LineNbr], [DeliverySchedule].[InventoryID], [DeliverySchedule].[TransportID], [DeliverySchedule].[DriverID], [DeliverySchedule].[TripNbr], [DeliverySchedule].[CustInvLvlBeforeDel], [DeliverySchedule].[CustInvLvlAfterDel]
FROM [SOShipLine] [SOShipLine]
INNER JOIN [SOShipment] [SOShipment] ON [SOShipment].CompanyID = 2 AND [SOShipment].[ShipmentNbr] = [SOShipLine].[ShipmentNbr]
LEFT JOIN [DeliverySchedule] [DeliverySchedule] ON [DeliverySchedule].CompanyID = 2 AND = [SOShipLine].[ShipmentNbr] AND [DeliverySchedule].[LineNbr] = [SOShipLine].[LineNbr]
WHERE [SOShipLine].CompanyID = 2 AND [SOShipment].[Status] = 'N'
ORDER BY [SOShipLine].[ShipmentNbr], [SOShipLine].[ShipmentType], [SOShipLine].[LineNbr] OPTION(OPTIMIZE FOR UNKNOWN) /* PA.20.81.00 */"

1 个答案:

答案 0 :(得分:2)

看起来您的ShipmentNbr字段应使用DB类型,例如PXDBString与PXString。在关键字段上更改属性,以查看是否有帮助(至[PXDBString(15, IsKey = true)])。如果您尝试将其连接到其他表,则很有可能在join语句中失败,因为您在问题中张贴的字段是未绑定的字段。在为SQL生成的查询中,如果在Join或Where子句中使用未绑定字段,则=语句的另一端可能为空。

示例:

#region ShipmentNbr
[PXDBString(15, IsKey = true)]
[PXDBDefault(typeof(SOShipLine.shipmentNbr))]
[PXParent(typeof(Select<SOShipLine, Where<SOShipLine.shipmentNbr, Equal<Current<DeliverySchedule.shipmentNbr>>, And<SOShipLine.lineNbr, Equal<Current<DeliverySchedule.lineNbr>>>>>))]
[PXUIField(DisplayName = "Shipment No.")]
public string ShipmentNbr { get; set; }
public class shipmentNbr : IBqlField { }
#endregion

此外,您只需要一个PXParent到一个表(您可以有多个PXParent-但不同的表)。您可以使用任何字段来放置PXParent属性,但对于给定的表只需要使用一次即可。 (您在ShipmentNbr和LineNbr上拥有SOShipLine的PXParent)