2

有谁知道如何将 CREATE VIEW SQL 语句推送到 Acumatica 定制项目中?

我知道如何在 SQL Management Studio 中执行此操作,但通过自定义项目执行此操作对 Acumatica SaaS 客户很有用。

4

1 回答 1

2

您应该执行以下步骤:

  1. 在 Management Studio 中创建您的 SQL 视图(出于演示目的,让我坚持一个简单的 PositivePay 视图):

    CREATE VIEW [dbo].[PositivePay] AS
    SELECT
        APPayment.RefNbr,
        APPayment.ExtRefNbr,
        APRegister.DocDate,
        APRegister.OrigDocAmt,
        CashAccount.ExtRefNbr BankAccountID
    FROM APPayment 
    JOIN APRegister 
        ON APRegister.CompanyID = APPayment.CompanyID 
            AND APRegister.RefNbr = APPayment.RefNbr 
    JOIN CashAccount 
        ON APPayment.CashAccountID = CashAccount.AccountID 
            AND APPayment.CompanyID = CashAccount.CompanyID 
    WHERE APPayment.CompanyID = 2 AND APPayment.DocType= 'CHK'
    GO
    
  2. 打开您的自定义项目并单击Code,然后根据您的 SQL 视图生成新的 DAC,如下面的屏幕截图所示: 在此处输入图像描述

  3. 为您的新 DAC 定义关键字段并保存更改。对于 PositivePay,我们将RefNbr字段顶部的 PXDBString 属性的 IsKey设置为true :

    [PXDBString(15, IsUnicode = true, InputMask = "", IsKey = true)]
    [PXUIField(DisplayName = "Ref Nbr")]
    public string RefNbr { get; set; }
    
  4. 单击DB Scripts ,在DBObject Name中选择您的 SQL 视图名称,然后按照以下模式将 SQL 脚本放入Custom Script控件中:

    IF EXISTS
    (
        SELECT * FROM sys.views
        WHERE name = 'PositivePay' AND schema_id = SCHEMA_ID('dbo')
    )
    DROP VIEW [dbo].[PositivePay]
    GO
    
    CREATE VIEW [dbo].[PositivePay] AS
    SELECT
        APPayment.RefNbr,
        APPayment.ExtRefNbr,
        APRegister.DocDate,
        APRegister.OrigDocAmt,
        CashAccount.ExtRefNbr BankAccountID
    FROM APPayment 
        JOIN APRegister 
            ON APRegister.CompanyID = APPayment.CompanyID 
                AND APRegister.RefNbr = APPayment.RefNbr 
        JOIN CashAccount 
            ON APPayment.CashAccountID = CashAccount.AccountID 
                AND APPayment.CompanyID = CashAccount.CompanyID 
    WHERE APPayment.CompanyID = 2 AND APPayment.DocType= 'CHK'
    GO
    

    在此处输入图像描述

于 2017-10-13T03:10:32.747 回答