It is difficult to know where to start. So, lets start with something simple.
As you noted, you wanted to:
This is quite impossible using your code layout. As you yourself noted, there is no way to change &CAMPO and &VALOR except by changing the underlying global variables and recompiling (or re-Running, see below).
Depending on how many descriptor fields you might be using, one way to do what you want would be to have something like:
DECIDE various conditions or values
WHEN condition 1
PERFORM first combination of descriptor and value
WHEN condition 2
PERFORM second combination of descriptor and value
where each combination is a local (or stand alone) subroutine.
Actually, for the values (assuming all are alpha) you could use a local variable such as #VALOR. Then all the FINDs would be something like FIND … WITH CO-UNIDADE-08 = #VALUE.
The above is probably the easiest way to go and maintain.
If you want to use ampersand variables, you could “combine” test1 and test2 into a single source program called, just test.
Then you could have something like:
0080 FIND F168-VIEW WITH &CAMPO = &VALOR
0090 WRITE NOTITLE ‘=’ &CAMPO
0100 END-FIND
IF something true
MOVE ‘CO-UNIDADE-08’ TO +CAMPO
MOVE ‘’‘1010500’‘’ TO +VALOR
RUN ‘test’
else STOP
This is typically rather silly code, but it does work. NOT recommended.
The reason it is NOT recommended is that you would lose values of all the other local variables, since the program test would be recompiled. Yes, you could pass values between different executions of test, but this could be VERY messy depending on how may such variables there are.