In a user exit following code is used:
DATA : h_rsnum LIKE afko-rsnum,
h_charg LIKE resb-charg,
h_matnr LIKE resb-matnr,
SELECT SINGLE rsnum INTO h_rsnum
WHERE aufnr = x_bncom-aufnr.
IF sy-subrc = 0 .
SELECT resbcharg resbmatnr
INTO (h_charg, h_matnr)
FROM mara INNER JOIN resb
ON maramatnr = resbmatnr
WHERE resb~rsnum = h_rsnum
AND resb~charg NE space
AND maramtart = 'HALB' OR maramtart = 'FERT'.
Goal of the source code is to detemine the reservation number of a process order. From table RESB with key h_rsnum, the material nb and the batch nb of the single material with material type HALB or FERT needs to be selected.
During debugging I found out that this code searches into a very long list of materials before ending up with the correct h_charg and h_matnr.
If the condition resb~rsnum = h_rsnum would be taken into account when creating the inner join, the list would only contain 20 materials maximum.
Can this behaviour be changed and how to do it?