05-25-2022 7:21 AM
I want to query from table ztmm01 the value of column lp plus current month. So I wrote below code but it not work.
DATA:currmonth type i.
currmonth = sy-datum+4(2).
select matnr, ( lp + currmonth ) as p1 FROM ztmm01 where zorderdate = sy-datum INTO TABLE @DATA(t1) .
So can I use an object in SQL function or I have to first put query result to an itab then loop it and add month value? Thx.
05-25-2022 10:01 AM
A database object is an artefact such as a database table, an SQL view, or a stored procedure. As a rule, a database object is defined with the database’s DDL, e.g. with CREATE VIEW.
Read More - https://blogs.sap.com/2019/02/15/tadir-object-types-and-object-descriptions-via-sql/
05-25-2022 10:45 AM
Please don't say "it doesn't work", explain the symptom ("it does a syntax error, whose message is ...")
Also please provide correct code, it seems that you typed it manually directly in the forum with many typos.
If you use @ (i.e. strict syntax) then use it everywhere (currmonth, sy-datum).
currmonth or currentmonth?
05-26-2022 2:25 AM
@sandra.rossi. Ok. Looks like the reason is I didn't add @ to the currmonth. But normally when I miss an @, the error message is "all hosts must be escaped with @" but this one the error msg is "unknow column currmonth until runtime"
05-26-2022 10:09 AM
In fact, the syntax checker can't know what currmonth can be, here it's guessing that it's merely a typo in the column name. Approximate messages are very common since the Strict SQL Syntax and Constructor Expressions, so you need to guess a lot.