如何找到AX2009中最后一个labelId?
我想将 labelModuleId 中的所有标签插入 AX2009 表中。
我有这份工作,它几乎可以完成我需要的一切。但我必须输入最大 Id (toLabel = 1000):
static void OcShowAllLabel(Args _args)
{
xInfo xinfo;
LanguageId currentLanguageId;
LabelModuleId labelModuleId = 'OCM'; // hier evt eine Eingabe durch Benutzer zur Auswahl
LabelIdNum frLabel;
LabelIdNum toLabel = 1000;
LabelId labelId;
OcShowAllLabels_RS tab;
Label blub = new Label();
str label;
;
xInfo = new xInfo();
currentLanguageId = xInfo.language();
delete_from tab
where tab.LanguageId == currentLanguageId
&& tab.LabelModuleId == labelModuleId;
for (frLabel = 1; frLabel <= toLabel; frLabel++)
{
labelId = strfmt('@%1%2', labelModuleId, frLabel);
label = SysLabel::labelId2String(labelId, currentLanguageId);
if (labelId != label)
{
tab.initValue();
tab.LabelId = labelId;
tab.Label = label;
tab.LanguageId = currentLanguageId;
tab.LabelModuleId = labelModuleId;
tab.insert();
}
}
Info('done');
}
I'd like to insert all Labels from a labelModuleId in an AX2009 table.
I have this job, that does nearly everything I need. But I have to enter the max Id (toLabel = 1000):
static void OcShowAllLabel(Args _args)
{
xInfo xinfo;
LanguageId currentLanguageId;
LabelModuleId labelModuleId = 'OCM'; // hier evt eine Eingabe durch Benutzer zur Auswahl
LabelIdNum frLabel;
LabelIdNum toLabel = 1000;
LabelId labelId;
OcShowAllLabels_RS tab;
Label blub = new Label();
str label;
;
xInfo = new xInfo();
currentLanguageId = xInfo.language();
delete_from tab
where tab.LanguageId == currentLanguageId
&& tab.LabelModuleId == labelModuleId;
for (frLabel = 1; frLabel <= toLabel; frLabel++)
{
labelId = strfmt('@%1%2', labelModuleId, frLabel);
label = SysLabel::labelId2String(labelId, currentLanguageId);
if (labelId != label)
{
tab.initValue();
tab.LabelId = labelId;
tab.Label = label;
tab.LanguageId = currentLanguageId;
tab.LabelModuleId = labelModuleId;
tab.insert();
}
}
Info('done');
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果这是一项一次性工作,您只需停止 AOS 并在记事本中打开标签文件即可。它位于名为 axXXXen-us.ald 的应用程序文件夹中,其中 XXX 是您的标签文件名,en-us 是您的语言。
查看classes\Tutorial_ThreadWork\doTheWork,看看他们在哪里使用 while(sLabel) 而不是像您那样使用 for 循环。
由于标签文件是一个文本文件,因此您不能只选择最后一个文件,而是必须迭代该文件。然而,AX 会缓存标签,但据我所知,我不相信您可以轻松访问标签缓存。
最后,希望您不会尝试此操作,但不要尝试仅读取标签文本文件,因为 AX 有时具有尚未从缓存刷新到该文件的标签。我认为 Label::Flush(...) 会刷新它们,但我不确定。
If this is a one-time job, you can just stop the AOS and open the label file in notepad. It's in your application folder called axXXXen-us.ald, where XXX is your label file name and en-us is your language.
Look at classes\Tutorial_ThreadWork\doTheWork to see where they use a while(sLabel) instead of a for loop like you have.
Since the label file is a text file, it would make sense that you can't just select the last one, but you have to iterate through the file. AX caches the labels however, but I don't believe you can just readily access the label cache as far as I know.
Lastly, hopefully you won't try this, but don't try to just read in the label text file, because AX sometimes has labels that it hasn't flushed to that file from the cache. I think Label::Flush(...) will flush them, but I'm not sure.
这是我想的另一种选择。您可以插入标签来获取下一个标签编号,然后立即删除它:
不过,它似乎确实消耗了编号序列中的数字。您可以只执行 Label::Flush(...),然后通过代码检查文本文件。查看 Classes\SysLabel* 以了解系统如何处理标签的一些信息。无论如何,它看起来都不是很简单。
Here is another option I suppose. You can insert a label to get the next label number and then just immediately delete it:
It does seem to consume the number from the number sequence though. You could just do a Label::Flush(...) and then check the text file via code. Look at Classes\SysLabel* to see some of how the system deals with labels. It doesn't look very simple by any means.
这是另一个可能适合您的选项。这也将识别丢失的标签。将“en-us”更改为您的语言。我认为这是一个“肮脏”的选择。您可能需要添加一些内容来表示“如果我们在一行中找到 5 个类似‘@OCM’的标签”。
Here is another option that might work for you. This will identify missing labels too. Change 'en-us' to your language. This is a "dirty" alternative I suppose. You might need to add something to say "if we find 5 labels in a row where they're like '@OCM'".