Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Call Scalar or Table Function in AMDP method

RachamallaKiran
Participant
0 Kudos
375

hi all,

I am trying to call Scalar or Tabular function in AMDP Method. but when i try to use it is giving syntax error.

may i know what is the way to call in AMDP method.

Here is the sample code which i tried.

CLASS z10102_cl_scalar_test DEFINITION

PUBLIC

FINAL

CREATE PUBLIC .

PUBLIC SECTION.

INTERFACES if_amdp_marker_hdb.

CLASS-METHODS: scalar_function_test

FOR SCALAR FUNCTION z10102_scalar_fun.

CLASS-METHODS amdp_test

AMDP OPTIONS CLIENT INDEPENDENT

EXPORTING

VALUE(res) TYPE s_smax_b.

PROTECTED SECTION.

PRIVATE SECTION.

ENDCLASS.

CLASS z10102_cl_scalar_test IMPLEMENTATION.

METHOD scalar_function_test BY DATABASE FUNCTION FOR HDB LANGUAGE SQLSCRIPT

OPTIONS READ-ONLY.

result = seatsmax_b + seatsocc_b + seatsmax_f + seatsocc_f ;

ENDMETHOD.

METHOD amdp_test BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT

OPTIONS READ-ONLY.

DECLARE s char(2);

SELECT Z10102_SCALAR_FUN( res=>res ) as abc from dummy;

s = 'A';

ENDMETHOD.

ENDCLASS.

Getting following error

The syntax check detected a use of the database object "Z10102_SCALAR_FUN".

If a database object managed by ABAP or DDIC is to be used here, its use must be declared in the USING clause of the METHOD statement.

If instead a parameter or variable is addressed in this position, it must be prefixed with the character ":".

I tried these ways but getting different errors

another try

METHOD amdp_test1 BY DATABASE PROCEDURE FOR HDB LANGUAGE SQLSCRIPT

OPTIONS READ-ONLY.

DECLARE s char(2);

SELECT "Z10102_SCALAR_FUN"( res=>res ) as abc from dummy;

s = 'A';

ENDMETHOD.

another try

DECLARE s char(2);

SELECT "Z10102_SCALAR_FUN"( res=>res ) as abc from dummy;

s = 'A';

Regards,

kiran rachamalla.

1 REPLY 1

Sandra_Rossi
Active Contributor
0 Kudos
330

Be careful with your ABAP formatting, it's incorrectly done.