My SAP System had to call a stored procedure on a 3rd party MS-SQL database. As suggested by many blogs, I used DBCO to maintain the parameters of the database... (kind of a BASIS job, but anyway...)
Then found I could use the DBCursor mechanism to retrieve to a table... but my 3rd Party guy didn't want to use SELECT statements, he wanted to use a stored procedure.
Turns out you can use DBCursor to select from an Stored Procedure too...
We had to "qualify" the database name, pre-empting the stored procedure (see highlight)
data: ls_output type tty_output, "This bit will differ in each Stored Procedure,
lt_output type TABLE of tty_output. " so I have not put it in!!
EXEC SQL.
CONNECT TO 'CO11' AS 'V'
ENDEXEC.
EXEC SQL.
SET CONNECTION 'V'
ENDEXEC.
EXEC SQL.
open dbcursor for
EXEC [DatabaseName].[dbo].[StoredProcedureName] 700, '2041', 'S1233124'
endexec.
DO.
EXEC SQL.
FETCH NEXT dbcursor INTO :ls_output-SerialNumber,
:ls_output-MACID
ENDEXEC.
IF sy-subrc = 0.
APPEND ls_output to lt_output.
clear ls_output.
CONTINUE.
else.
exit.
endif.
enddo.
No comments:
Post a Comment