<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to use 'Execute Procedure' to retrieve table data from an ext. MS SQL ? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813488#M1126562</link>
    <description>&lt;P&gt;Stored procedures can be executed using the following instance method of the class CL_SQL_STATEMENT&lt;/P&gt;&lt;P&gt;EXECUTE_PROCEDURE&lt;/P&gt;&lt;P&gt;The method has an mandatory input parameter PROC_NAME of type string, which must be passed the name of an existing stored procedure statement. In the same way as in DML statements, it is possible to bind ABAP data objects as actual parameters to the formal parameters of the stored procedure using the method SET_PARAM. The type of parameter must be specified using the additional parameter INOUT. Possible values are defined in the constants C_PARAM_IN, C_PARAM_OUT, and C_PARAM_INOUT of the class CL_SQL_STATEMENT. C_PARAM_IN is the default value. The order of the calls determines the assignment to the formal parameters from left to right.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jun 2021 17:00:04 GMT</pubDate>
    <dc:creator>Tenorio</dc:creator>
    <dc:date>2021-06-23T17:00:04Z</dc:date>
    <item>
      <title>How to use 'Execute Procedure' to retrieve table data from an ext. MS SQL ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813482#M1126556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;We have to call a stored procedure from an external MS SQL database . We are able to connect to the database and are able to successfully do a SQL (Select ) on the SQL tables. However to maintain data integrity and other security issues, we have to call a stored procedure on that database  from SAP. The stored rocedure will return a table which will contain multiple records . &lt;/P&gt;&lt;P&gt;We have tried using the EXECUTE PROCEDURE command. However it returns SQL errors?&lt;/P&gt;&lt;P&gt;Our SAP instance is on MS SQL.&lt;/P&gt;&lt;P&gt;Please note we have gone through all SAP notes and SDN already. The query is not about connecting to the database. It is solely to find out the correct way for calling the stored procedure. The example in the SAP help documentation is for single IN and OUT parameters. We are able to do that successfully. Our requirement is to get a table back from the stored procedure.&lt;/P&gt;&lt;P&gt;Please help with the correct syntax and code example if you have one.&lt;/P&gt;&lt;P&gt;I would be glad to provide any other information that may be helpful.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2008 01:11:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813482#M1126556</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-01T01:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to use 'Execute Procedure' to retrieve table data from an ext. MS SQL ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813483#M1126557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you go through this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Using ABAP to access non-SAP databases|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/11543] &lt;B&gt;[original link is broken]&lt;/B&gt; &lt;B&gt;[original link is broken]&lt;/B&gt; &lt;B&gt;[original link is broken]&lt;/B&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Installing DB Connect with MSSQL Server Database|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/4305] &lt;B&gt;[original link is broken]&lt;/B&gt; &lt;B&gt;[original link is broken]&lt;/B&gt; &lt;B&gt;[original link is broken]&lt;/B&gt;;?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2008 01:16:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813483#M1126557</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-01T01:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to use 'Execute Procedure' to retrieve table data from an ext. MS SQL ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813484#M1126558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Amit,&lt;/P&gt;&lt;P&gt;Thanks for the suggestions. However my question is specifically about using the stored procedure. As I have mentioned, I am able to retrieve data using the select from tables. I would like to use the EXECUTE PROCEDURE command. My code would look something like this&lt;/P&gt;&lt;P&gt;data:&lt;/P&gt;&lt;P&gt;  someInt type i value 5,&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; someotherInt type i,&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  begin of fs_table,&lt;/P&gt;&lt;P&gt;    a type int2,&lt;/P&gt;&lt;P&gt;    b type int2,&lt;/P&gt;&lt;P&gt;  end of fs_table,&lt;/P&gt;&lt;P&gt;  t_table like standard table of fs_table with header  line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: exc_ref    TYPE REF TO cx_sy_native_sql_error,&lt;/P&gt;&lt;P&gt;        error_text TYPE string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Test if connection 'FAST_DEV' has already been opened&lt;/P&gt;&lt;P&gt;  EXEC SQL.&lt;/P&gt;&lt;P&gt;    SET CONNECTION :'FAST_DEV'&lt;/P&gt;&lt;P&gt;  ENDEXEC.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    Write:/ 'Connection not yet opened.'.&lt;/P&gt;&lt;P&gt;    EXEC SQL .&lt;/P&gt;&lt;P&gt;      CONNECT TO :'FAST_DEV'&lt;/P&gt;&lt;P&gt;    ENDEXEC.&lt;/P&gt;&lt;P&gt;    IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;error handling&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    else.&lt;/P&gt;&lt;P&gt;      write:/ 'Connection to FAST_DEV opened.'.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;  EXEC SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;execute procedure testSAP_sayhi2 ( out :someInt, out :t_table )&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDEXEC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to get data into t_table from the procedure. However I get all sorts of SQL errors with no good description.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2008 13:32:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813484#M1126558</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-12-01T13:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use 'Execute Procedure' to retrieve table data from an ext. MS SQL ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813485#M1126559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nishikant. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just to let you know, that we are experiencing exactly the same problem reading MSSQL Stored Procedures from SAP as you. We are able to read from single tables, but it just doesn't seem to work if we use stored procedures. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have created the following and very simple stored procedure in MSSQL &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create procedure tt_NJT @Kundenr  VARCHAR(20)&lt;/P&gt;&lt;P&gt;as&lt;/P&gt;&lt;P&gt;SELECT Ordrenr FROM FSHeader where Kundenr = @Kundenr &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when calling it from SAP using the following code:&lt;/P&gt;&lt;P&gt;EXEC SQL.&lt;/P&gt;&lt;P&gt;  EXECUTE PROCEDURE tt_NJT ( IN '0000011050', OUT :ordrenr )&lt;/P&gt;&lt;P&gt;EXEC SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   it dumps with the errormessage: "Error 8144 occurred in the current database connection "FSDATA - Procedure tt_NJT has to many arguments specified" &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you can see there is only one single IN and one single OUT-parameter, so we don't really understand what is wrong.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However if I change the OUT-parameter to an INOUT-parameter like shown below &lt;/P&gt;&lt;P&gt;no dumps and no error-message are returned, but it still doesn¨'t return any values to my the :ordrenr variable.&lt;/P&gt;&lt;P&gt;EXEC SQL.&lt;/P&gt;&lt;P&gt;  EXECUTE PROCEDURE tt_NJT ( IN '0000011050', INOUT :ordrenr )&lt;/P&gt;&lt;P&gt;EXEC SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We would also be happy if anybody could help solving this problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards.&lt;/P&gt;&lt;P&gt;   Niels Trans.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Dec 2008 11:29:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813485#M1126559</guid>
      <dc:creator>nielsjorgen_trans</dc:creator>
      <dc:date>2008-12-08T11:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to use 'Execute Procedure' to retrieve table data from an ext. MS SQL ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813486#M1126560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I too have a similar issue, I have a stored procedure written in MS SQL and it executes but I need the result in an internal table; How do I get it into an internal table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following code is being used. Now the output of the query that is being executed, I need it in my internal table&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
EXEC SQL.
  EXECUTE PROCEDURE d01.Z_PRICINGREPORT ( IN :i_mandt,
                                          IN :i_kschl,
                                          IN :i_vkorg,
                                          IN :i_vtweg,
                                          IN :i_matkll,
                                          IN :i_matklh,
                                          IN :i_matnrl,
                                          IN :i_matnrh,
                                          IN :i_inco1,
                                          IN :i_inco2,
                                          IN :i_zsalel,
                                          IN :i_zsaleh,
                                          IN :i_kunnrl,
                                          IN :i_kunnrh,
                                          IN :i_chargl,
                                          IN :i_chargh,
                                          IN :i_vkburl,
                                          IN :i_vkburh,
                                          IN :i_vkgrpl,
                                          IN :i_vkgrph,
                                          IN :i_wrkstl,
                                          IN :i_wrksth,
                                          IN :i_mtf,
                                          IN :i_mtt,
                                          IN :i_datbi,
                                          IN :i_werks,
                                          IN :i_stock
  )



ENDEXEC.
CATCH cx_sy_native_sql_error.
    MESSAGE `Error in procedure handling` TYPE 'I'.
endtry.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Warm Regards,&lt;/P&gt;&lt;P&gt;Abdullah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Jan 2009 13:54:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813486#M1126560</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-01-20T13:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to use 'Execute Procedure' to retrieve table data from an ext. MS SQL ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813487#M1126561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I too have a similar issue . I am reading MSSQL Stored Procedures from SAP. I have mentioned both Input and Output parameters in the SQL statement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Passing both input and&amp;nbsp; output parameters. When i execute below statement getting the short dump : SQL error 8144 occurred when executing Native SQL.Procedure or function&amp;nbsp; has too many arguments specified". &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; background: white;"&gt;&amp;nbsp; EXECUTE PROCEDURE &amp;lt; procedurename&amp;gt;&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; background: white;"&gt;&lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;( &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;IN &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;:&lt;/SPAN&gt;ls_in_ebeln&lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;,&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;IN &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;:ls_in_&lt;/SPAN&gt;ebelp&lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;,&lt;/SPAN&gt;&lt;BR /&gt; OUT &lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;:&lt;/SPAN&gt;ls_out&lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;-&lt;/SPAN&gt;ebeln&lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;,&lt;/SPAN&gt;&lt;BR /&gt; OUT &lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;:&lt;/SPAN&gt;ls_out&lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;-&lt;/SPAN&gt;ebelp&lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;,&lt;/SPAN&gt;&lt;BR /&gt; OUT &lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;:&lt;/SPAN&gt;ls_out&lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;-&lt;/SPAN&gt;qty&amp;nbsp; &lt;SPAN style="font-family: 'Arial','sans-serif';"&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2013 16:56:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813487#M1126561</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-08-23T16:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to use 'Execute Procedure' to retrieve table data from an ext. MS SQL ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813488#M1126562</link>
      <description>&lt;P&gt;Stored procedures can be executed using the following instance method of the class CL_SQL_STATEMENT&lt;/P&gt;&lt;P&gt;EXECUTE_PROCEDURE&lt;/P&gt;&lt;P&gt;The method has an mandatory input parameter PROC_NAME of type string, which must be passed the name of an existing stored procedure statement. In the same way as in DML statements, it is possible to bind ABAP data objects as actual parameters to the formal parameters of the stored procedure using the method SET_PARAM. The type of parameter must be specified using the additional parameter INOUT. Possible values are defined in the constants C_PARAM_IN, C_PARAM_OUT, and C_PARAM_INOUT of the class CL_SQL_STATEMENT. C_PARAM_IN is the default value. The order of the calls determines the assignment to the formal parameters from left to right.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 17:00:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-use-execute-procedure-to-retrieve-table-data-from-an-ext-ms-sql/m-p/4813488#M1126562</guid>
      <dc:creator>Tenorio</dc:creator>
      <dc:date>2021-06-23T17:00:04Z</dc:date>
    </item>
  </channel>
</rss>

