我需要每天更新这张表(如下)

我会每天更新新的产品 ID & recipe_A 和 recipe_B。
然后我需要排序recipe_A & recipe_B 到另外两个列 (sort_A & sort_B) 。
所以我复制recipe_A & recipe_B 到 sort_A & sort_B ,并运行这个脚本(如下)
这样,我可以重新编码sort_A & sort_B。
Current Data Table() << Begin Data Update;
For Each Row( :sort_A = Match( :sort_A, "ZXC", "worse", "QWE", "better", "ASD", "good", :sort_A ) );
Current Data Table() << End Data Update;
Current Data Table() << Begin Data Update;
For Each Row( :sort_B = Match( :sort_B, "R123", "rrr", "H123", "hhh", "G123", "ggg", :sort_B ) );
Current Data Table() << End Data Update;
我的问题是:
如何创建一个脚本来自动复制 recipe_A 和 recipe_B 到 sort_A 和 sort_B?
(如果 sort_A 和 sort_B 数据丢失,则自动复制)?
下面是代码的返工,用于检查 sort_A 或 sort_B 列是否存在,如果不存在,则创建它并填充它。 如果确实存在,则重新填充它。 由于sort_A 和sort_B 的结果基于recipe_A 和recipe_B 的值,因此无需将值复制到sort_A 和sort_B,然后更改每个值。 仅使用 recipe_A 和 recipe_B 中的值来设置 sort_A 和 sort_B 中的值要容易得多。
Names Default To Here( 1 );
dt = Current Data Table();
// Get a list of the current columns in the data table
ColList = dt << get column names( string );
// See if a column named "sort_A" does not exist
If( N Rows( Loc( ColList, "sort_A" ) ) == 0,
// If it does not exist, create the new column and use a formula to populate the values based upon the recipe_A values
dt << New Column( "sort_A", character, formula( Match( :recipe_A, "ZXC", "worse", "QWE", "better", "ASD", "good", :recipe_A ) ) );
// Remove the formula which will leave the results
dt:sort_A << delete formula;
,
// If the column already exists, then loop through the data table creating new values for sort_A based upon the recipe_A values
For Each Row( :sort_A = Match( :recipe_A, "ZXC", "worse", "QWE", "better", "ASD", "good", :recipe_A ) )
);
// See if a column named "sort_B" does not exist
If( N Rows( Loc( ColList, "sort_B" ) ) == 0,
// If it does not exist, create the new column and use a formula to populate the values based upon the recipe_B values
dt << New Column( "sort_B", character, formula( Match( :recipe_B, "R123", "rrr", "H123", "hhh", "G123", "ggg", :recipe_B ) ) );
dt:sort_B << delete formula;
,
// If the column already exists, then loop through the data table creating new values for sort_B based upon the recipe_B values
For Each Row( :sort_B = Match( :recipe_B, "R123", "rrr", "H123", "hhh", "G123", "ggg", :recipe_B ) )
);