Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Yes look at subroutines.
Basically wrap each part of your script in a sub function, then build your if around the calls
What would that look like with the query above?
Hi there,
First things first:
In order to use the content of a cell within a column within a table (matrix of values) in an if statement, you have to take it from the table into a variable (single value recipient).
let vSAP1 = peek('SAP1',-1,'TableNameHavingSAP1');
... and so on ...
Notes:
1.In order to avoid confusion, it is a good practice to use a small v at the beginning of the names of the variables.)
2. I made an assumption that TableNameHavingSAP1 has only one row. I used -1 to get the LAST row . You can use 0 to get the FIRST row (if you have only one row in the table, they are equivalent, but do not use 1, because it will look for the 2nd row, which might not exist , if you have only one row in the table)
3. peek function requires single quotes for the names of Field and Table
4. peek can be used in other cool ways (even within inter record ops in load instructions)
And after that, you can can really use the if statement...
if vSAP1 >= vSAP2 and vBASE1 >= vBASE2 then
load whatever;
else if vSAP1 <= vSAP2 and vBASE1 >= vBASE2 then
load other;
else
load 3rd option;
end if
Notes:
1. mandatory to have on a single ROW the whole if .... then
2. else if can be used multiple times, of course. Or not at all.
else only once at the end, or never.
3. you could also make the if statement directly:
if peek('SAP1',-1,'TableNameHavingSAP1')>=peek('SAP2',-1,'TableNameHavingSAP2') then
...
but it's harder to debug, in case you do not "peek" the right thing:
Good luck !
Can't see a direct connection between your answer and the issue raised, but I would like to get more details, to understand.