创建一个作业以从 table 中获取具有特定列格式的记录并替换为所需格式
Create a job to fetch records from table with specific column format and replace with required format
我需要在 X++ 中创建一个作业以从 table X 中获取记录,其列的 ID 格式为 ER5000123440
并将 ax 中的 5 替换为 -0。 5 是 ER 之后的数字。
更换 id 后将是 ER-0000123440。
Select EXPENSEID
from ms_it_dms_staging
where EXPENSEID like 'ER4%'
and ms_it_dms_staging.FAILUREREASON=3
这是 sql 中的代码。
你能帮我用 x++
写这个吗
我面前没有AX,所以可能会有语法错误,但这基本上就是你要做的:
// Declare variable to hold your new ID temporarily
str myNewId;
// Declare the table buffer variable
ms_it_dms_staging ms_it_dms_staging;
ttsbegin; // Begin a transaction
while select forupdate ms_it_dms_staging
where ms_it_dms_staging.EXPENSEID like 'ER5*' &&
ms_it_dms_staging.FAILUREREASON == 3
{
// Do your logic here to change the ID. Make sure this works correctly, may need to adjust the start digit.
// This doesn't need to be in a variable but I'm making it simpler
myNewId = strfmt("ER-0%1", subStr(ms_it_dms_staging.EXPENSEID, 3, maxInt()));
ms_it_dms_staging.EXPENSEID = myNewId;
ms_it_dms_staging.update();
}
ttscommit; // Commit the transaction
我需要在 X++ 中创建一个作业以从 table X 中获取记录,其列的 ID 格式为 ER5000123440 并将 ax 中的 5 替换为 -0。 5 是 ER 之后的数字。
更换 id 后将是 ER-0000123440。
Select EXPENSEID
from ms_it_dms_staging
where EXPENSEID like 'ER4%'
and ms_it_dms_staging.FAILUREREASON=3
这是 sql 中的代码。 你能帮我用 x++
写这个吗我面前没有AX,所以可能会有语法错误,但这基本上就是你要做的:
// Declare variable to hold your new ID temporarily
str myNewId;
// Declare the table buffer variable
ms_it_dms_staging ms_it_dms_staging;
ttsbegin; // Begin a transaction
while select forupdate ms_it_dms_staging
where ms_it_dms_staging.EXPENSEID like 'ER5*' &&
ms_it_dms_staging.FAILUREREASON == 3
{
// Do your logic here to change the ID. Make sure this works correctly, may need to adjust the start digit.
// This doesn't need to be in a variable but I'm making it simpler
myNewId = strfmt("ER-0%1", subStr(ms_it_dms_staging.EXPENSEID, 3, maxInt()));
ms_it_dms_staging.EXPENSEID = myNewId;
ms_it_dms_staging.update();
}
ttscommit; // Commit the transaction