The code "STOCK2" could be stored internally in the software. It might be defined in: Customize, Install Settings|Transactions, then press Transaction Sequences & Forms.
It's defined next to "Stock Label".
If this field is left blank in the configuration, then it can be uniquely defined per user.
If that is the case then it's going to be stored in CAPWIN.INI inside the user's profile folder (as per Windows registry settings for INI locations). The section heading will be Forms, as per:
Where XXX is the company folder.
The entry in this case is StockLabel=
If you want to do something by department, then as you've indicated your best option is to replace the standard print functionality with your own print functionality and react to event 5. Return FALSE to indicate your script will be dealing with printing.