Axapta存储RecId为任意类型

Axapta存储RecId为任意类型,axapta,Axapta,当我在anytype对象中存储RecId时,该数字已损坏。在我的实现中,我将RecId存储在treeview项的数据值字段中。每当我检索数据值时,我保存的数字总是会发生很大的变化。有什么建议吗 以下是一个例子: void fillTree() { ABC_Menus _ABC_Menus; TreeItemIdx parentItemIdx; ; while select Prompt, RecId from _ABC_Menus { pa

当我在anytype对象中存储RecId时,该数字已损坏。在我的实现中,我将RecId存储在treeview项的数据值字段中。每当我检索数据值时,我保存的数字总是会发生很大的变化。有什么建议吗

以下是一个例子:

void fillTree()
{
    ABC_Menus _ABC_Menus;
    TreeItemIdx parentItemIdx;
    ;
    while select Prompt, RecId from _ABC_Menus
    {
        parentItemIdx = SysFormTreeControl::addTreeItem(formTreeControl, _ABC_Menus.Prompt, FormTreeAdd::Root, _ABC_Menus.RecId, 0, true);
    }
}

public void endLabelEdit(int _idx, str _text, anytype _data)
{
    FormTreeItem formTreeItem = this.getItem(_idx);
    ;
    formTreeItem.text(_text);
    this.setItem(formTreeItem);
    info(_data);     //this number comes out all wrong
    super(_idx, _text, _data);
}
我将RecId存储在树值字段中。但是,如果我稍后检索它,则会返回一个完全不同的数字。
-表中的RecId:5637144588
-endLabelEdit方法显示的RecId:202520592908288

在字段中存储RecId时,我还尝试使用num2str(ABC_Table.RecId,0,0,0)。以这种方式存储时,数字匹配,但会抛出“赋值/比较失去精度”警告。这样行吗,还是有更好的办法


谢谢

请为我们提供完整的示例:

RefRecId   recid = 5637144577;
anytype    tmp;
;
info(strfmt('%1', recid));
tmp = recid;
info(strfmt('%1', tmp));
recid = tmp;
info(strfmt('%1', recid));
结果是:

5637144577

5637144577


5637144577

请向我们提供完整示例:

RefRecId   recid = 5637144577;
anytype    tmp;
;
info(strfmt('%1', recid));
tmp = recid;
info(strfmt('%1', tmp));
recid = tmp;
info(strfmt('%1', recid));
结果是:

5637144577

5637144577


5637144577

在Axapta版本3之后,所有RECID都是64位整数。strFmt()函数可以将recId从int64转换为字符串,但也可以使用int642str()函数将recId显式转换为字符串

RecId recId = 5637144577;
anytype a;
int64 b;
;

a = recId;
b = a;

info(int642str(a));
info(int642str(b));
info(int642str(recId));

Axapta版本3之后,所有RECID都是64位整数。strFmt()函数可以将recId从int64转换为字符串,但也可以使用int642str()函数将recId显式转换为字符串

RecId recId = 5637144577;
anytype a;
int64 b;
;

a = recId;
b = a;

info(int642str(a));
info(int642str(b));
info(int642str(recId));

如果在将RecId发布到anytype字段之前使用strfmt(…),那么数据将保持不变。这解决了我的问题,但我将把这个问题留一点时间,以便有希望了解为什么RecId在发布到我的anytype字段时会出错。看起来你不应该把它转换成字符串来工作。谢谢尝试将recId打包到容器或类。不使用num2str,您可以使用strfmt来避免警告。如果我在将RecId发布到anytype字段之前使用strfmt(…),则数据保持不变。这解决了我的问题,但我将把这个问题留一点时间,以便有希望了解为什么RecId在发布到我的anytype字段时会出错。看起来你不应该把它转换成字符串来工作。谢谢尝试将recId打包到容器或类。除了num2str,您可以使用strfmt来避免警告。