Tips & Tricks - Conditions on Method Execution¶
There are a various options available to specify conditions for whether a method should be executed or not:
Condition On First Row¶
This may be used to call a procedure only once during an execution. The OUT-parameters from this procedure may be parsed to methods on the list. Look here>> for info about parsing variables.
Condition on New Master¶
You may also preset procedures to be executed only when key-values on the selected data change. For all SELECT-lists, Data Migration adds a virtual column named NEW_MASTER. This column holds the value TRUE or FALSE depending on the values of the KEY-columns. This is useful if your dataset is a Master/Detail selection, f.ex. Customer Order and Customer Order Line, or as shown here, when we use a procedure to lookup multiple data-items.
Set up the job as follows:
- Make sure to SORT your dataset by key values.
- When executing the select, the first Key-columns on top of your column list will be concatenated to a Master-value. The virtual column NEW_MASTER will have value TRUE for each new occurrence of the master-value. As long as same value is listed, the column have value FALSE. You may change the flags on columns if you need a special master-value, only make sure your keys start with lowest value in Pos.
- If you tick off column On New Master, this method will be executed only when key values change (NEW_MASTER=TRUE), in this example the concatenated values of Company and Identity.
- Customer defaults may now be parsed to following methods in the list. Look here >> for info about parsing variables.
Condition on Source Column¶
From the method list, you may also define conditions based on values of mapped columns under Source Mapping.
- Use LOV behind Column Name to find mapped columns
- The method will be executed according to table below
|Specific value (as below)||mapped column = Column Value|
|Wildcard combinations (A%, B%100)||mapped column LIKE Column Value|
|Wildcard %||mapped column IS NOT NULL|
|No Column Value||mapped column IS NULL|
Condition on Virtual Column¶
Under Source Mapping, you may also add your own columns, giving them values from a SQL expression. In the example below we want the method to be executed when Prime Commodity has certain values.
Condition either New or Modify¶
Sometimes, we want to insert new rows only, and not modify existing rows, or visa versa; only perform updates but no inserts.
To check whether a record exists or not, we may include a GET-function on a mandatory column in the selection. The result will be NULL if the record does not exist.
Below you see the mapping + the 2 alternatives we can have in Method List
Condition on OUT-value on previous method¶
As we save return-values for each method (attr-strings, OUT-parameters or function-results), we can also use these values to decide if a method should be executed or not. We use same notation as when mapping Fixed Values in Method List Attributes:
The result from the function executed in Seq 20 is stored in memory. We can use the @-notation to address this variable and check its value.
Tailor-made Error Message¶
In this case, we have a situation were we try to release a Customer Order by using standard functionality from the Order Flow Process. Method 10 does not raise an error even if the release action fails. We have to check the status of the order in method 20, and call Error_SYS in method 30 to make our own error-message.
- Call Error_SYS.Record_General to provoke a RAISE, i.e. create an error situation. The parameters of this method is displayed by RMB Method List Attribute...
- Normally, the method take the name of the calling LU as input. We may enter any text here, but choose to use 'MigrationError' to indicate that this is not a standard error message.
- Here we enter the error message we want to display. The message must start with an uppercase identifier followed by colon + the error message itself. Inside the message, we may use up to 3 variables that may contain values from selected data f.ex.
In this case we use input parameter P1_ to send a value to variable:P1 within the text.
(Below) The parameter P1_ is mapped to item ORDER_NO under Source_Mapping