Quantcast
Channel: SCN: Message List - ABAP Connectivity
Viewing all articles
Browse latest Browse all 3125

ABAP Stored procedure call with table as input - secondary database

$
0
0

I have a requirement to modify table available in secondary database from ABAP using stored procedure exposed by database team.

 

Database Stored procedure expects a set of records, and it internally modifies table using the records.

 

I'm unable to pass internal table as input while calling stored procedure.

 

 

  DATAsql     TYPE REF TO cl_sql_statement.

  TYPES:BEGIN OF gty_stoproc,
               id     TYPE i,
               status TYPE I,
               END   OF gty_stoproc.

DATA:   stageid    TYPE STANDARD TABLE OF gty_stoproc,
               gw_stoproc TYPE gty_stoproc,
             dref       TYPE REF TO data.

gw_stoproc-id      = 285867.
gw_stoproc-status = 1.
APPEND gw_stoproc TO stageid.



CREATE OBJECT sql.

**//Connecting to DB
go_con_ref = cl_sql_connection=>get_connection( p_dbcon ).

sql = go_con_ref->create_statement( ).


GET REFERENCE OF stageid INTO dref.


sql->set_param_table( table_ref = dref  ).



TRY.
   sql->execute_procedure( proc_name = 'DUMMYSET' ).

  CATCH cx_sql_exception INTO DATA(lx_01).
  DATA(lv_exception) = | An exception occurred with SQL_MESSAGE = { lx_01->sql_message }|.
  MESSAGE lv_exception TYPE 'E'.
ENDTRY.



But the above code is giving an exception "Too many parameters found in procedure of function "


 

********************************************************************************************************************************

Structure of Database procedure in secondary DB


CREATE TYPE [dbo].[StageID] AS TABLE(
[ID] [bigint] NOT NULL,
[Status] [char](2) NULL
)

 

CREATE PROC DUMMYSET  (@StageID StageID READONLY)
AS
BEGIN
       UPDATE A
       SET a.STATUS = b.status
       FROM RLOERStagedata A
       INNER JOIN @STAGEiD B ON A.ID= B.ID
      
      
END 


**************************************




Thank you for the support



Viewing all articles
Browse latest Browse all 3125

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>