<?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 insert rows into database table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-rows-into-database-table/m-p/2424841#M541589</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Pavan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I assumed is that your database table has three columns as custno, custname &amp;amp; custadd, with custno as Key field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You want to update these fields from an internal table to your database table. Again only few rows of internal table you want to update in the database table depending on some condition or so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For this, create one more internal table having type same as database table. Pass the values from the t_tab into this internal table depending on condition and finally update the database table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TABLES: ZSAMPTAB1.

DATA: T_TAB2 TYPE TABLE OF ZSAMPTAB1,
      WA_TAB2 TYPE ZSAMPTAB1.

LOOP AT T_ITAB INTO WA_TAB1.
* On some condition, fill the second internal table
  IF WA_TAB1-CUSTNO EQ 'CONDITION'.
     MOVE WA_TAB1-CUSTNO TO WA_TAB2-CUSTNO.
     MOVE WA_TAB1-CUSTNAME TO WA_TAB2-CUSTNAME.
     MOVE WA_TAB1-CUSTADD TO WA_TAB2-CUSTADD.
     APPEND WA_TAB2 TO T_TAB2.
     CLEAR WA_TAB2.
  ENDIF.
  CLEAR WA_TAB1.
ENDLOOP.

* If the data is available in the second internal table, 
* insert it into database table
IF NOT T_TAB2 IS INITIAL.
  INSERT ZSAMPTAB1 FROM TABLE T_TAB2.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS If the answer solves the query, plz close the thread by rewarding each reply and marking it Solved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Sapna Modi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Jun 2007 06:03:37 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-20T06:03:37Z</dc:date>
    <item>
      <title>how to insert rows into database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-rows-into-database-table/m-p/2424837#M541585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I hv created a table name "zsamptab1" &lt;/P&gt;&lt;P&gt;I hav created an internaltable named "t_itab" &lt;/P&gt;&lt;P&gt;I would like to insert few rows using internal table into table ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table name : "zsamptab1"&lt;/P&gt;&lt;P&gt;Fields I would like to insert :  custno, custname, custadd&lt;/P&gt;&lt;P&gt;Internal table name = t_itab&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know the statement to insert the above fields to database table...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2007 05:09:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-rows-into-database-table/m-p/2424837#M541585</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-20T05:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert rows into database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-rows-into-database-table/m-p/2424838#M541586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi pavan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which all fields are there in Z table and internal table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Atish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2007 05:11:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-rows-into-database-table/m-p/2424838#M541586</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-20T05:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert rows into database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-rows-into-database-table/m-p/2424839#M541587</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;Try this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

DATA: WA_ZSAMPTAB1 TYPE ZSAMPTAB1.
DATA: T_DATA TYPE STANDARD TABLE OF ZSAMPTAB1.

WA_ZSAMPTAB1-CUSTNO = 'TEST'.
WA_ZSAMPTAB1-CUSTNAME = 'TEST CUSTOMER'.
WA_ZSAMPTAB1-CUSTADD    = '44 TEST'.
APPEND WA_ZSAMPTAB1 TO T_DATA.

WA_ZSAMPTAB1-CUSTNO = 'TEST2'.
WA_ZSAMPTAB1-CUSTNAME = 'TEST CUSTOMER 2'.
WA_ZSAMPTAB1-CUSTADD    = '44 TEST 2'.
APPEND WA_ZSAMPTAB1 TO T_DATA.


* INsert the records.
INSERT ZSAMPTAB1 FROM TABLE T_DATA.

* Commit.
COMMIT WORK.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Naren&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2007 05:13:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-rows-into-database-table/m-p/2424839#M541587</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-20T05:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert rows into database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-rows-into-database-table/m-p/2424840#M541588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;    Check these demo programs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RSDEMO_TABLE_CONTROL&lt;/P&gt;&lt;P&gt;DEMO_DYNPRO_TABLE_CONTROL_1&lt;/P&gt;&lt;P&gt;DEMO_DYNPRO_TABLE_CONTROL_2&lt;/P&gt;&lt;P&gt;RSDEMO_TABLE_CONTROL&lt;/P&gt;&lt;P&gt;RSDEMO02&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Reward points&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2007 05:15:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-rows-into-database-table/m-p/2424840#M541588</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-20T05:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to insert rows into database table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-rows-into-database-table/m-p/2424841#M541589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Pavan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I assumed is that your database table has three columns as custno, custname &amp;amp; custadd, with custno as Key field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You want to update these fields from an internal table to your database table. Again only few rows of internal table you want to update in the database table depending on some condition or so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For this, create one more internal table having type same as database table. Pass the values from the t_tab into this internal table depending on condition and finally update the database table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TABLES: ZSAMPTAB1.

DATA: T_TAB2 TYPE TABLE OF ZSAMPTAB1,
      WA_TAB2 TYPE ZSAMPTAB1.

LOOP AT T_ITAB INTO WA_TAB1.
* On some condition, fill the second internal table
  IF WA_TAB1-CUSTNO EQ 'CONDITION'.
     MOVE WA_TAB1-CUSTNO TO WA_TAB2-CUSTNO.
     MOVE WA_TAB1-CUSTNAME TO WA_TAB2-CUSTNAME.
     MOVE WA_TAB1-CUSTADD TO WA_TAB2-CUSTADD.
     APPEND WA_TAB2 TO T_TAB2.
     CLEAR WA_TAB2.
  ENDIF.
  CLEAR WA_TAB1.
ENDLOOP.

* If the data is available in the second internal table, 
* insert it into database table
IF NOT T_TAB2 IS INITIAL.
  INSERT ZSAMPTAB1 FROM TABLE T_TAB2.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS If the answer solves the query, plz close the thread by rewarding each reply and marking it Solved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Sapna Modi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2007 06:03:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-insert-rows-into-database-table/m-p/2424841#M541589</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-20T06:03:37Z</dc:date>
    </item>
  </channel>
</rss>

