Ich muss diese Tabelle täglich aktualisieren (siehe unten)

Ich werde täglich neue Produkt-ID & Rezept_A & Rezept_B aktualisieren.
Dann muss ich sortieren recipe_A & recipe_B zu zwei anderen Spalten (sort_A & sort_B).
also kopiere ich recipe_A & recipe_B nach sort_A & sort_B und führen Sie dieses Skript aus (wie unten)
Auf diese Weise kann ich umkodieren 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;
Meine Frage ist :
Wie erstelle ich ein Skript, um recipe_A & recipe_B automatisch nach sort_A & sort_B zu kopieren?
(automatisches Kopieren, wenn Daten von sort_A und sort_B fehlen)?
Nachfolgend finden Sie eine Überarbeitung Ihres Codes, um zu überprüfen, ob eine sort_A- oder sort_B-Spalte vorhanden ist. Wenn dies nicht der Fall ist, erstellen Sie sie und füllen Sie sie auf. Wenn es existiert, füllen Sie es erneut auf. Da die Ergebnisse von sort_A und sort_B auf den Werten von recipe_A und recipe_B basieren, besteht keine Notwendigkeit, die Werte nach sort_A und sort_B zu kopieren und dann die Werte in jedem zu ändern. Es ist viel einfacher, nur die Werte in Rezept_A und Rezept_B zu verwenden, um die Werte in Sort_A und Sort_B festzulegen.
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 ) )
);