如何在 Dynamics AX 2009 的视图中加入字段值

发布于 2024-11-17 20:41:27 字数 477 浏览 2 评论 0原文

我需要创建一个视图来导出一些产品数据。理想情况下,我需要合并两个字段值(如果可能的话,可能是其他字段值)。

我知道 AX 中的 SQL 并不是真正正确的 SQL,正如我尝试过的那样:

Select field1 + field2 from table

哪个应该有效,但没有

我感觉我可以使用视图中的方法来实现此目的,但我以前从未这样做过,而且我可以'在任何地方都找不到任何合适的例子。

我想做的事情是否可能,如果可以的话我会怎么做?

编辑

我这样做的原因是因为我已经开始使用 Magento。它没有与 AX 正确集成,因此我将创建一个包含有关产品的所有数据的视图,然后手动导入到 Magento 中。

我想将产品的 SKU 与颜色 id 或尺码 id 结合起来。

因此 PP1234 和 BLU 将成为 PP1234-BLU

I need to create a View for exporting some Product Data. Ideally I need to merge two fields values (maybe others if possible).

I know SQL in AX is not really proper SQL as I've tried:

Select field1 + field2 from table

Which should work and it doesn't

I have a feeling I could this with a method in the View, but I've never done this before and I can't find any decent examples anywhere.

Is what I want to do even possible, and if so how would I do it?

Edit

The reason I'm doing this is because I've started using Magento. Its not properly integrated with AX so I was going to create a view with all the data about a product and then do a manual import into Magento.

I want to combine the the SKU of the product with the color id or size id.

So PP1234 and BLU would become PP1234-BLU

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

固执像三岁 2024-11-24 20:41:27

尝试一下

 select CAST(field1 AS varchar(number_characters)) 
 + CAST(field2 AS varchar(number_characters))
 from table

try that

 select CAST(field1 AS varchar(number_characters)) 
 + CAST(field2 AS varchar(number_characters))
 from table
骷髅 2024-11-24 20:41:27

您也许可以创建一个临时表,如果它适合您的目的,您可以将其用于导出......

static void Test(Args _args)
{
    InventTable inventTable;
    StagingTable stagingTable;
    ;

    ttsbegin;

    insert_recordset stagingTable (ItemId, Field1, Field2)
        select ItemId, SourceField1, SourceField2 from inventTable;

    update_recordset stagingTable
        setting Field1 = stagingTable.Field1 + inventTable.SourceField2,
                Field2 = -stagingTable.Field2 + inventTable.SourceField1
    join inventTable
        where inventTable.ItemId == stagingTable.ItemId;

    ttscommit;
}

You can probably create a staging table, which you would be able to use for export, if it suits your purpose...

static void Test(Args _args)
{
    InventTable inventTable;
    StagingTable stagingTable;
    ;

    ttsbegin;

    insert_recordset stagingTable (ItemId, Field1, Field2)
        select ItemId, SourceField1, SourceField2 from inventTable;

    update_recordset stagingTable
        setting Field1 = stagingTable.Field1 + inventTable.SourceField2,
                Field2 = -stagingTable.Field2 + inventTable.SourceField1
    join inventTable
        where inventTable.ItemId == stagingTable.ItemId;

    ttscommit;
}
怕倦 2024-11-24 20:41:27

通过查看有关 Dynamics AX 的少量文档,我认为这是不可能做到的。

您可以执行的 SQL 量很少,这似乎很奇怪。

From looking around through the little amount of Documentation there is about Dynamics AX I don't think this can be done.

Seems strange the little amount of SQL you can do.

一城柳絮吹成雪 2024-11-24 20:41:27

您没有提到为什么要将这两个字段添加在一起,但如果只是为了演示,那么可以通过在表实例上使用显示方法轻松解决这个问题。

public Amount myCustomMethod()
{
    return this.fieldA + thisfieldB;
}

由于您使用的是 X++,并且正在进行导出,所以我不明白为什么您不能将计算作为导出的一部分进行。

希望这有帮助。

You don't mention why you want to add those two fields together, but if it is merely for presentation, then this can easily be solved by using a display method on the table instance.

public Amount myCustomMethod()
{
    return this.fieldA + thisfieldB;
}

Since you're using X++, and you're doing exporting, I don't understand why you can't do the calculation as a part of the export.

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文