I don't think you can do this easily.
Conditional compilation is out because it will take the status when you compile (probably not on batch mode).
The only solution I can think of would be to have 2 versions of the object code (.r) and make sure that the correct one appears first in your PROPATH depending on whether you are in batch mode or not.
To prevent having 2 versions of the source code (.p), you would need to have 2 versions of the include file (.i) and compile with different PROPATHs.
/* progs/abc.i */
DEF VAR iBanana AS INT NO-UNDO INIT 1.
/* progs/batch/abc.i */
DEF VAR iBanana AS INT NO-UNDO INIT 2.
/* progs/banana.p */
DEF VAR iLoop AS INT NO-UNDO.
{abc.i}
DO iLoop = 1 TO iBanana:
......
END.
To compile the normal version your PROPATH should be "progs" and you want to COMPILE banana.p SAVE
To compile the batch version your PROPATH should be "progs/batch,progs" and you want to COMPILE banana.p SAVE INTO progs/batch
Thereafter, when running in normal mode, your PROPATH should be "progs" and when running in batch mode your PROPATH should be "progs/batch,progs" to ensure you pick up the correct version.