<?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>Question Re: Create ABAP program to send SQL command to another HANA DB in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14022653#M4904340</link>
    <description>&lt;P&gt;Why not use the SQL Console for SAP HANA to execute queries against SAP HANA databases?&lt;/P&gt;&lt;P&gt;Have you talked to your security officer about &lt;A href="https://me.sap.com/knowledge/search/%7B%22q%22%3A%22sql%20iectionnj%22%2C%22tab%22%3A%22All%22%2C%22f%22%3A%7B%22mh_note_type%22%3A%5B%22SAP%20Security%20Note%22%5D%7D%7D" target="_self"&gt;SQL injection&lt;/A&gt;?&lt;/P&gt;</description>
    <pubDate>Thu, 20 Feb 2025 14:10:54 GMT</pubDate>
    <dc:creator>RaymondGiuseppi</dc:creator>
    <dc:date>2025-02-20T14:10:54Z</dc:date>
    <item>
      <title>Create ABAP program to send SQL command to another HANA DB</title>
      <link>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaq-p/14022632</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Is there any possibility to create an ABAP program for instance with a select screen where we can write a SQL command then execute this SQL command into x hana DB ?&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 13:47:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaq-p/14022632</guid>
      <dc:creator>saumel</dc:creator>
      <dc:date>2025-02-20T13:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create ABAP program to send SQL command to another HANA DB</title>
      <link>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14022653#M4904340</link>
      <description>&lt;P&gt;Why not use the SQL Console for SAP HANA to execute queries against SAP HANA databases?&lt;/P&gt;&lt;P&gt;Have you talked to your security officer about &lt;A href="https://me.sap.com/knowledge/search/%7B%22q%22%3A%22sql%20iectionnj%22%2C%22tab%22%3A%22All%22%2C%22f%22%3A%7B%22mh_note_type%22%3A%5B%22SAP%20Security%20Note%22%5D%7D%7D" target="_self"&gt;SQL injection&lt;/A&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2025 14:10:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14022653#M4904340</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2025-02-20T14:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create ABAP program to send SQL command to another HANA DB</title>
      <link>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14022661#M4904343</link>
      <description>Hi Raymond ! It's a request from basis team in order to do this action in few hana DB with only 1 sql command. They already checked if we can do this with SQL console but is not possible. I mean, imagine you need to create one user in x hana DB you need to do this x times. This is the reason of my request.</description>
      <pubDate>Thu, 20 Feb 2025 14:16:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14022661#M4904343</guid>
      <dc:creator>saumel</dc:creator>
      <dc:date>2025-02-20T14:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: Create ABAP program to send SQL command to another HA...</title>
      <link>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14024536#M4904585</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/136776"&gt;@Samuel&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;The easier option is to use&amp;nbsp;HANA SQL Console/HANA Studio, what is the need to write a ABAP report when there are tools to query. There is option to query huge volume of data too&lt;BR /&gt;Data lake often resort to Standard SAP tools for a query&lt;BR /&gt;Answering the question :&lt;BR /&gt;Check list&lt;BR /&gt;1) If your user has S_DBCON and S_TABU_DIS authorizations, then that means you have&amp;nbsp;execution within SAP's Open SQL or native SQL framework.&lt;BR /&gt;2) DML operations like (INSERT, UPDATE, DELETE) should be blocked / handled inside your custom report&lt;BR /&gt;&lt;SPAN&gt;&lt;BR /&gt;Here is the sample code for your question :&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;REPORT zsql_exe.&lt;BR /&gt;&lt;/SPAN&gt;TABLES: dd02l.&lt;/P&gt;&lt;P&gt;DATA: gv_sql TYPE string, " -------&amp;gt;&amp;gt;&amp;gt;&amp;gt;replace with your SQL statement&lt;BR /&gt;gt_results TYPE STANDARD TABLE OF dd02l, " Table to store results&lt;BR /&gt;gv_message TYPE string.&lt;/P&gt;&lt;P&gt;SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.&lt;BR /&gt;PARAMETERS: p_sql TYPE string LOWER CASE OBLIGATORY.&amp;nbsp; ----&amp;gt;important&lt;BR /&gt;SELECTION-SCREEN: END OF BLOCK b1.&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;"-------------- avoid&amp;nbsp; harmful commands---- throw error otherwise&lt;BR /&gt;IF p_sql CS 'DELETE' OR&amp;nbsp;p_sql CS 'UPDATE' OR&amp;nbsp;p_sql CS 'INSERT'&lt;BR /&gt;&amp;nbsp; &amp;nbsp;OR&amp;nbsp;p_sql CS 'DROP' OR p_sql CS 'ALTER'.&lt;BR /&gt;gv_message = 'Only SELECT statements are allowed!'.&lt;BR /&gt;MESSAGE gv_message TYPE 'E'.&lt;BR /&gt;EXIT.&lt;BR /&gt;ENDIF.&lt;/P&gt;&lt;P&gt;" Store SQL Command&lt;BR /&gt;gv_sql = p_sql.&lt;/P&gt;&lt;P&gt;TRY.&lt;BR /&gt;EXEC SQL.&lt;BR /&gt;EXECUTE IMMEDIATE :gv_sql INTO TABLE :gt_results&lt;BR /&gt;ENDEXEC.&lt;/P&gt;&lt;P&gt;IF gt_results IS NOT INITIAL.&lt;BR /&gt;cl_demo_output=&amp;gt;display_data( gt_results ). " Display output&lt;BR /&gt;ELSE.&lt;BR /&gt;gv_message = 'No data found for the query'.&lt;BR /&gt;MESSAGE gv_message TYPE 'I'.&lt;BR /&gt;ENDIF.&lt;/P&gt;&lt;P&gt;"handle error&lt;BR /&gt;CATCH cx_sy_dynamic_osql_error INTO DATA(lo_error).&lt;BR /&gt;gv_message = lo_error-&amp;gt;get_text( ).&lt;BR /&gt;MESSAGE gv_message TYPE 'E'.&lt;BR /&gt;ENDTRY.&lt;BR /&gt;&lt;BR /&gt;If an exception is thrown that means you may not have access&lt;BR /&gt;1) check su53 results after running the above sample code&lt;BR /&gt;2) or else execute excecute function module: DB_CONNECTION_TEST.&lt;BR /&gt;with parameter DB connection = DEFAULT.&lt;BR /&gt;If it fails, direct SQL access may be blocked.&lt;BR /&gt;&lt;BR /&gt;Hope this helps! &lt;EM&gt;Cheers&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Feb 2025 22:58:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14024536#M4904585</guid>
      <dc:creator>RemiKaimal</dc:creator>
      <dc:date>2025-02-22T22:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create ABAP program to send SQL command to another HA...</title>
      <link>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14025238#M4904637</link>
      <description>&lt;P&gt;Hi Remi ! thank you so much for your reply I really appreciate this !&lt;/P&gt;&lt;P&gt;The request was to create a program to execute SQL commands to create or delete hana users not to execute sql commands in tables. Did you already do something similar ? The idea was to excute DBCO connection to a specific system when executing the abap program, then execute sql commande to insert or delete hana user then close DBCO connection.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I never did something like this, this is why I posted this request.&lt;/P&gt;&lt;P&gt;I received the information that we cannot do this kind of action in mass so execute this kind of sql action in many systems one after one. If we want to do something like this with a console, we need to connect into each system then execute sql command and could be a waist of time.&lt;/P&gt;&lt;P&gt;Thank you so much for your help !&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2025 07:02:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14025238#M4904637</guid>
      <dc:creator>saumel</dc:creator>
      <dc:date>2025-02-24T07:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create ABAP program to send SQL command to another HA...</title>
      <link>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14025562#M4904667</link>
      <description>I would add a OR p_sql NS 'SELECT'. to your checklist &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;</description>
      <pubDate>Mon, 24 Feb 2025 10:48:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14025562#M4904667</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2025-02-24T10:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create ABAP program to send SQL command to another HANA DB</title>
      <link>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14025744#M4904686</link>
      <description>&lt;P&gt;Basically, you want to create a wizard for &lt;A href="https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-administration-guide/manage-database-user" target="_self"&gt;Managing Database Users&lt;/A&gt; ?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2025 15:11:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14025744#M4904686</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2025-02-24T15:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create ABAP program to send SQL command to another HA...</title>
      <link>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14025755#M4904687</link>
      <description>&lt;P&gt;Basically, you want to create a cockpit/wizard for &lt;A href="https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-administration-guide/manage-database-user" target="_self"&gt;Managing Database Users&lt;/A&gt; ?&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Look at attachment of notes such as&amp;nbsp;&lt;A href="https://me.sap.com/notes/1986645/E" target="_self"&gt;1986645 - Allow only administration users to work on HANA database&lt;/A&gt;&amp;nbsp;to get an idea of the SQL statements to be executed.&lt;/LI&gt;&lt;LI&gt;Insure that &lt;A href="https://help.sap.com/docs/hana-cloud/sap-hana-cloud-database-administration-with-sap-hana-cockpit/database-users" target="_self"&gt;SAP HANA Database Administration with SAP HANA Cockpit&lt;/A&gt;&amp;nbsp;isn't the solution&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Mon, 24 Feb 2025 12:11:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-abap-program-to-send-sql-command-to-another-hana-db/qaa-p/14025755#M4904687</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2025-02-24T12:11:14Z</dc:date>
    </item>
  </channel>
</rss>

