03-24-2021 9:16 AM
I wrote below code tocheck changes in zplp1.
SELECT COUNT(*) FROM mbew WHERE matnr = wmbew-matnr AND bwkey = wmbew-bwkey
AND zplp1 = wmbew-zplp1 AND zpld1 = wmbew-zpld1
AND zplp2 = wmbew-zplp2 AND zpld2 = wmbew-zpld2.
IF sy-subrc <> 0.
MESSAGE e006(zfico).
ENDIF.
And if the values of zplp1/p2/d1/d2 are initial it doesn't work. To solve this I think I can first query the orignial values from db and compare to new one like below.
SELECT single * FROM mbew WHERE matnr = wmbew-matnr AND bwkey = wmbew-bwkey
into @data(mbew_o) .
IF sy-subrc = 0.
if ((mbew_o-zplp1 = wmbew-zplp1 ) or (mbew_o-zplp1 is initial and wmbew-zplp1 is initial)).
else .
MESSAGE e006(zfico).
ENDIF.
ENDIF.
Is there a simpler way to do it? Thx.
03-24-2021 10:01 AM
loki_luo15,
Your Question does not have all the necessary details to get an answer:
1) What is WMBEW here?
2) What is your expectation here?
3) Your select statement has AND operator and Conditional Statement has OR operator.
Can you explain your question better?
Regards!
03-24-2021 3:14 PM
I guess you didn't check the option "not null" of the Z columns, so all existing rows have Z columns with value "null" and the comparison fails because ABAP "initial" <> database "null".
If you check the option "not null", there will be a table adjustment to set initial values where values were previously null.
03-25-2021 1:21 AM
@sandra.rossi.Thx. So if I want to check zplp1 changed or zplp1 is null I should write like below, is it?
where ( zplp1 = wmbew-zplp1 or zplp1 is initial )
03-25-2021 6:39 AM
What I recommend is that you set the option "not null", otherwise people will often make errors. I would consider not setting the option "not null" as being "error prone".
If not, your program will look like a mess. In case a line has ZPLP1 equal to null, not initial (I don't know its type so I can't say space or zero or all zeroes...), you would use this complex code:
IF wmbew-zplp1 IS NOT INITIAL.
SELECT ...
WHERE ( zplp1 = wmbew-zplp1 ) ...
ELSE.
SELECT ...
WHERE ( zplp1 = wmbew-zplp1 OR zplp1 IS NULL ) ...
ENDIF.