<?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: Fetch data From SQL Server table to SAP Table... Problem in Code in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-sql-server-table-to-sap-table-problem-in-code/m-p/750690#M36115</link>
    <description>&lt;P&gt;Better to use CL_SQL_STATEMENT and associated classes than EXEC SQL.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Jan 2019 08:13:54 GMT</pubDate>
    <dc:creator>matt</dc:creator>
    <dc:date>2019-01-02T08:13:54Z</dc:date>
    <item>
      <title>Fetch data From SQL Server table to SAP Table... Problem in Code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-sql-server-table-to-sap-table-problem-in-code/m-p/750687#M36112</link>
      <description>&lt;P&gt;Hi Friends,&lt;/P&gt;
  &lt;P&gt;Connection between SQL Server and SAP is working fine, I am sending data from SAP into SQL Table successfully, but when I am fetching data from SQL Server table into SAP internal table I am facing problem. Please suggest if you have any reference code. I want to know how to write select query to fecth multiple records from SQL into internal table.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jan 2019 12:58:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-sql-server-table-to-sap-table-problem-in-code/m-p/750687#M36112</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-01-01T12:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch data From SQL Server table to SAP Table... Problem in Code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-sql-server-table-to-sap-table-problem-in-code/m-p/750688#M36113</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;If you can tell us which is the error, it would be better and we can give you a better help.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jan 2019 19:32:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-sql-server-table-to-sap-table-problem-in-code/m-p/750688#M36113</guid>
      <dc:creator>SimoneMilesi</dc:creator>
      <dc:date>2019-01-01T19:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch data From SQL Server table to SAP Table... Problem in Code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-sql-server-table-to-sap-table-problem-in-code/m-p/750689#M36114</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I got the solution.&lt;/P&gt;&lt;P&gt;&lt;A href="https://blogs.sap.com/2008/10/27/using-abap-to-access-non-sap-databases/" target="test_blank"&gt;https://blogs.sap.com/2008/10/27/using-abap-to-access-non-sap-databases/&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  zmona_read_customer_addr.
TYPES: BEGIN OF mona_cust_addr_type,
         cno(4)        TYPE n,
         title(7)      TYPE c,
         name(40)      TYPE c,
         zip(5)        TYPE c,
         city(3)       TYPE c,
         state(2)      TYPE c,
         address(40)   TYPE c,
       END OF mona_cust_addr_type.
DATA: ls_custaddr  TYPE           mona_cust_addr_type,
      lt_custaddr  TYPE TABLE OF  mona_cust_addr_type.
* Connect to MONA database
EXEC SQL.
  CONNECT TO 'MONA'
ENDEXEC.
IF sy-subrc &amp;lt;&amp;gt; 0.
  MESSAGE 'Unable to connect to MONA' TYPE 'E' DISPLAY LIKE 'I'.
  RETURN.
ENDIF.
* Define database cursor
EXEC SQL.
  OPEN dbcur FOR
    SELECT cno, title, name, zip, city, state, address
           FROM HOTEL.CUSTOMER_ADDR
ENDEXEC.
* Fill customer itab
DO.
  EXEC SQL.
    FETCH NEXT dbcur INTO :ls_custaddr-cno,
                          :ls_custaddr-title,
                          :ls_custaddr-name,
                          :ls_custaddr-zip,
                          :ls_custaddr-city,
                          :ls_custaddr-state,
                          :ls_custaddr-address
  ENDEXEC.
  IF sy-subrc &amp;lt;&amp;gt; 0.
    EXIT.
  ELSE.
    APPEND ls_custaddr TO lt_custaddr.
  ENDIF.
ENDDO.
* Close connection to MONA
EXEC SQL.
  CLOSE dbcur
ENDEXEC.
* Reset to "default connection"
EXEC SQL.
  SET CONNECTION DEFAULT
ENDEXEC.
* Print 20 records
LOOP AT lt_custaddr INTO ls_custaddr.
  WRITE: /,
          ls_custaddr-cno,
          ls_custaddr-title,
          ls_custaddr-name,
          ls_custaddr-zip,
          ls_custaddr-city,
          ls_custaddr-state,
          ls_custaddr-address.
  IF sy-tabix &amp;gt; 20.
    EXIT.
  ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Jan 2019 06:03:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-sql-server-table-to-sap-table-problem-in-code/m-p/750689#M36114</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-01-02T06:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch data From SQL Server table to SAP Table... Problem in Code</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-sql-server-table-to-sap-table-problem-in-code/m-p/750690#M36115</link>
      <description>&lt;P&gt;Better to use CL_SQL_STATEMENT and associated classes than EXEC SQL.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 08:13:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetch-data-from-sql-server-table-to-sap-table-problem-in-code/m-p/750690#M36115</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2019-01-02T08:13:54Z</dc:date>
    </item>
  </channel>
</rss>

