An easy way to bypass this issue is to use the following definition instead:
@AbapCatalog.sqlViewName: 'z_test_jg3'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'test 2'
define view Z_Test3 as select from vbak { //Key key vbak.vbeln as SalesDocument, instr(replace(vbak.vbeln, '0', 'a'), '5a') as test
}
Via this chained function usage at first zeros are replaced by some single, non-numeric character (you could also replace another number value). Secondly, function instr() could be used as initially intended. Note: Function replace() will need additional runtime. However, as I just needed to get this working and my code is neither performance ciritial nor there are other backdraws for my use-case, this is a fine solution for me.