I've got a select statement to get the orders of a reference, but now I need to restrict the results into a range od the last 30 days but i don't know how to do it.
SELECT
*
FROM AFKO
WHERE AFKO~PLNBEZ = @reference
AND DATEDIFF( DAY, AFKO~GLTRP, @sy-datum ) >= -30
ORDER BY AFKO~GLTRP DESCENDING
INTO TABLE @it_afko.
I've readed that DATEDIFF can make the operatio but SAP says that the function is unknown. I'm trying directly using the - operator:
SELECT
*
FROM AFKO
WHERE AFKO~PLNBEZ = @reference
AND AFKO~GLTRP - @sy-datum >= -30
ORDER BY AFKO~GLTRP DESCENDING
INTO TABLE @it_afko.
but SAP says Only elementary arithmetic types can be used in arithmetic expressions. The type of AFKO~GLTRP is invalid
How can I get the difference?