cancel
Showing results for 
Search instead for 
Did you mean: 

Why CEIL and FLOOR inbuilt function is not working in OPEN SQL??

06-06-2020 7:36 AM
Pankaj-Kumar Participant
3878 views 9 comments
0 Likes
SAP Managed Tags
Subscribe

Hello Expert,

Why CIEL/Floor Function is not working . Other is working as expected but these two is creatinng the problem.

Could you please help me here.

Below is my Code -

SELECT  abs( num1 ) AS abs_value,  div(  500, 100 ) AS div_value,
        mod( 500 , 2 ) AS rem_value, round( num2, 2 ) AS round_value,
        ceil( 8.9 ) AS ceil_value
        FLOOR( 2.7 ) as floor_value 
FROM demo_expressions INTO TABLE @DATA(maths_tab).

Below is snap shot of the error -

0 Likes

Accepted Solutions (0)

Answers (3)

Answers (3)

Flavio
Active Contributor

what about:

SELECT  abs( num1 ) AS abs_value,  div(  500, 100 ) AS div_value,
        mod( 500 , 2 ) AS rem_value, round( num2, 2 ) AS round_value,
        ceil( "8.9" ) AS ceil_value
        FLOOR( "2.7" ) as floor_value 
FROM demo_expressions INTO TABLE @DATA(maths_tab).
MateuszAdamus
Active Contributor

Hello flavio.ciotola3

This does not work either. Syntax will see the "8.9" as a start of comment.

Kind regards,
Mateusz
Flavio
Active Contributor
0 Likes

Ops, sorry, my answer above is wrong...

Have had the time now to check in NPL:
as already said, hardcoded decimal values seem not allowed,
while built-in functions are both properly working with table fields:

Flavio

Sandra_Rossi
Active Contributor
0 Likes

There are so many ABAP rules. The only queries I can make work around numeric literals with decimal places (ABAP 7.52):

CONSTANTS decnum TYPE decfloat34 VALUE '7.4'.
CONSTANTS decnum2 TYPE p DECIMALS 1 VALUE '7.4'.


SELECT @decnum AS decnum
    FROM t000
    INTO TABLE @DATA(decnum_tab1).

SELECT @( CONV decfloat34( '7.4' ) ) AS decnum
    FROM t000
    INTO TABLE @DATA(decnum_tab).

SELECT price, ceil( price + division( 74, 10, 1 ) ) AS ceil_value
    FROM sflight
    INTO TABLE @DATA(ceil_tab).

SELECT price, ceil( price + @decnum2 ) AS ceil_value
    FROM sflight
    INTO TABLE @DATA(ceil_tab2).
matt
Active Contributor
0 Likes

. is seen as a statement end. If you want decimals, you have to put them in single quotes.

MateuszAdamus
Active Contributor

Single quotes don't work either.


Kind regards,
Mateusz
matt
Active Contributor
0 Likes

Still true though.

Should've been the first thing the OP tried. So - no hard coding of decimal values in OpenSQL. Which doesn't seem to awful a restriction! 🙂