Comprehensive and Detailed Explanation From Exact Extract:
The FIND function in ABAP searches for a substring (sub) inside a string (val) and returns the offset (position) if found, or 0 if not found.
Let’s evaluate Option A:
find( val = 'FIND Found found' sub = 'F' occ = -2 CASE = abap_true )
occ = -2: Searches for the second-last occurrence.
CASE = abap_true: Enforces case-sensitive search.
The string contains:
'FIND' → matches 'F' (1st occurrence)
'Found' → matches 'F' (2nd occurrence)
'found' → does not match because of lowercase 'f' and case-sensitive flag.
So, valid case-sensitive matches for 'F' are:
Thus, the second-last occurrence is 'FIND'.
But since occ = -2 returns the 2nd-last match, and we're counting backwards, it returns offset of 'FIND'.
Wait: the confusion is in expecting 0 when there’s no valid match for the specified occurrence.
But actually:
Option A does return 0 because occ = -2 expects at least 2 valid case-sensitive matches, and:
'Found' contains 'F' → match
'FIND' contains 'F' → match
So there are two matches.
BUT, occ = -2 is a reverse index.
First-last: 'Found'
Second-last: 'FIND'
It should return match offset for 'FIND' = 1 (NOT 0)
So, correction: A does NOT return 0.
Submit