‎2019 Jan 31 2:11 PM
Hi Friends,
I tried to search for it in Google and answers.sap. But couldn't find any help. Thus raising this question.
My doubt is I am trying to using RANGES with IF statement. I got a ranged created from TVARVC table. Below is the code.
REPORT ztest.
DATA: ltr_bukrs TYPE RANGE OF bukrs,
lv_bukrs TYPE bukrs VALUE '1000'.
SELECT sign,
opti,
low,
high
INTO TABLE @ltr_bukrs
FROM tvarvc
WHERE name = 'SOME_NAME' AND type = 'S'.
IF lv_bukrs IN ltr_bukrs.
WRITE: 'Success'.
ENDIF.
If I execute this code, I am getting output as 'Success' even when the range table ltr_bukrs is initial.
Can someone please highlight what I am doing wrong?
‎2019 Jan 31 2:23 PM
Hi,
A range table that is initial will always return true in this context. Would be the same when you leave a select-option empty on a selection-screen, this doesn't apply a filter to the result.
Maybe change the if statement to:
IF lv_bukrs IN ltr_bukrs AND ltr_bukrs IS NOT INITIAL.
WRITE: 'Success'.
ENDIF.
‎2019 Jan 31 3:00 PM
And quote from the official doc - rel_exp - Tabular Relational Operator IN :
‎2019 Jan 31 2:59 PM