Skip to Content
0

Syntax issue in advacne SQL

Aug 03, 2017 at 08:42 AM

56

avatar image
Former Member

Hello,

I am writing a simple expression as below,

DATA lv_dis TYPE netwr.
START-OF-SELECTION.
lv_dis = '0.10'.
SELECT vbeln AS order,
             audat AS date,
             netwr AS price,
             kunnr AS customer,
             netwr - ( netwr  *  @lv_dis )  
FROM vbak
INTO TABLE @DATA(lt_result).

         cl_demo_output=>display_data(
             value = lt_result
         ).

I am getting syntax error as "DescriptionResourcePathLocationType The maximum possible number of places in the expression starting with NETWR is 32 places with 4 decimal places. There can be, however, no more than 31 places and 14 decimal places. any subexpressions. ABAP Syntax Check Problem".

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
avatar image
Former Member Aug 03, 2017 at 09:37 AM
0

Hi,

Try like the below query: <removed by moderator>

DATA lv_dis TYPE netwr.
START-OF-SELECTION.
lv_dis = '0.10'.
SELECT vbeln AS order,
             audat AS date,
             netwr AS price,
             kunnr AS customer,
             cast( netwr -  ( netwr  *  @lv_dis ) as curr( 15, 2 ) ) as net_value
FROM vbak
INTO TABLE @DATA(lt_result).
         cl_demo_output=>display_data(
             value = lt_result
         ).
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hmm, I'd rather say, it might be a bug that CAST prevents the syntax error.

The documentation says:

If a decimal expression is specified statically, the syntax check checks that the result of each operation is in the value range of the type DEC with length 31 and a maximum of 14 decimal places. If any operands are specified that could produce other values, a syntax error occurs. If the expression is specified dynamically, an exception of the class CX_SY_DYNAMIC_OSQL_SEMANTICS is raised in this case.

Therefore:

DATA pack TYPE p LENGTH 16 DECIMALS 2.
SELECT FROM demo_expressions
       FIELDS @pack * @pack  AS test "<-- Syntax error
       INTO TABLE @DATA(tab).
SELECT FROM demo_expressions
       FIELDS CAST( @pack * @pack AS DEC( 15, 2 ) ) AS test "<-- No syntax error ???
       INTO TABLE @DATA(tab).

Why should the CAST influence the above rule?

Forwarded to development ...

1