Skip to Content

call stored procedures from table functions

Dear Friends,

I am trying to call a stored procedure(Read only) inside a table function. I saw a SAP forum which says that it is possible to cal stored procedure inside table function and use its output inside table function.

https://answers.sap.com/questions/106249/use-of-stored-procedure-from-sps11-onwards.html

The Syntax which I am applying now:

BEGIN

/***************************** Write your function logic *****************************/

DECLARE TEMP TABLE;

RETURN TEMP = CALL "BIUSER"."GK1.Func_Proc::PR1" (?);

END;

I am getting error. Please suggest the right way to call.

Thanks,

Gaurav

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Sep 07, 2017 at 01:58 PM

    You can call a procedure within a table function as long as the procedure is read only. But your way of calling a procedure is not right. You are expecting the result as returning argument of the procedure, but a procedure has only IN, OUT, INOUT parameters. So I expect you are working with an OUT parameter to return your result.

    Just for demo purposes I assume that your OUT parameter is called ET_RESULT. You need to replace it of course by your real name. Also the local variable which points to the result needs to be typed to your type.

    ...
    DECLARE myResult TABLE (
      ID integer,
    VALUE nvarchar(255) ); CALL "BIUSER"."GK1.Func_Proc::PR1" (ET_RESULT => :myResult); ...

    Regards,
    Florian

    Add comment
    10|10000 characters needed characters exceeded

    • Regarding 1) Table functions were already part of the system and were not only introduced for the specific case you describe. But yes, table functions can be used as data sources in graphical calculation views and scripted calculation views should not be used anymore (they are deprecated).

      Regarding 2) Not really sure what you are meaning, but yes, you can call a read-only procedure in a table function which is then used in a graphical calc. view.