<?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 Inserting data to a database table from a dynamic internal table? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-data-to-a-database-table-from-a-dynamic-internal-table/m-p/2051721#M423046</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;       I have a dynamic internal table called &amp;lt;dyn_table&amp;gt; in which I have data. I want to move all the values from this internal table to a custom database table ZREAL. How do I go about it. Please help ASAP. Points would be awarded for it. &lt;/P&gt;&lt;P&gt;          Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 17 Mar 2007 12:24:34 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-03-17T12:24:34Z</dc:date>
    <item>
      <title>Inserting data to a database table from a dynamic internal table?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-data-to-a-database-table-from-a-dynamic-internal-table/m-p/2051721#M423046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;       I have a dynamic internal table called &amp;lt;dyn_table&amp;gt; in which I have data. I want to move all the values from this internal table to a custom database table ZREAL. How do I go about it. Please help ASAP. Points would be awarded for it. &lt;/P&gt;&lt;P&gt;          Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Mar 2007 12:24:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-data-to-a-database-table-from-a-dynamic-internal-table/m-p/2051721#M423046</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-17T12:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting data to a database table from a dynamic internal table?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-data-to-a-database-table-from-a-dynamic-internal-table/m-p/2051722#M423047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this custom FM...You can found it on &amp;lt;a href="/people/alvaro.tejadagalindo/blog/2006/03/03/tasting-the-mix-of-php-and-sap--volume-2 the mix of PHP and SAP - Volume 2&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FUNCTION ZRFC_TABLE_OPERATIONS_LINE.
*"----------------------------------------------------------------------
*"*"Interfase local
*"  IMPORTING
*"     VALUE(QUERY_TABLE) LIKE  DD02L-TABNAME
*"     VALUE(OPERATION) LIKE  BDLDATCOL-TYPE
*"     VALUE(FIELDS) LIKE  ZTABLE_OPERATION-FIELDS
*"     VALUE(DATA) LIKE  ZTABLE_OPERATION-DATA
*"  EXCEPTIONS
*"      RECORD_NOT_INSERTED
*"      RECORD_NOT_UPDATED
*"      RECORD_NOT_DELETED
*"      NOT_AUTHORIZED
*"      TABLE_NOT_AVAILABLE
*"----------------------------------------------------------------------

  CALL FUNCTION 'VIEW_AUTHORITY_CHECK'
    EXPORTING
      VIEW_ACTION                    = 'S'
      VIEW_NAME                      = QUERY_TABLE
    EXCEPTIONS
      NO_AUTHORITY                   = 2
      NO_CLIENTINDEPENDENT_AUTHORITY = 2
      NO_LINEDEPENDENT_AUTHORITY     = 2
      OTHERS                         = 1.

  IF SY-SUBRC = 2.
    RAISE NOT_AUTHORIZED.
  ELSEIF SY-SUBRC = 1.
    RAISE TABLE_NOT_AVAILABLE.
  ENDIF.

*=======================================================================
* Types.
*=======================================================================
  TYPES: X_LINES TYPE STRING.

*=======================================================================
* Internal Tables.
*=======================================================================
  DATA: DESCR_STRUCT_REF TYPE REF TO CL_ABAP_STRUCTDESCR,
        DATAREF TYPE REF TO DATA,
        WA_FCAT TYPE LVC_S_FCAT,
        IT_FIELDCATALOG TYPE LVC_T_FCAT,
        T_LINES TYPE STANDARD TABLE OF X_LINES,
        T_FIELDS TYPE STANDARD TABLE OF X_LINES WITH HEADER LINE,
        NEW_LINE  TYPE REF TO DATA.

  DATA: W_LINES TYPE STRING.

*=======================================================================
* Variables.
*=======================================================================
  DATA: W_TABIX LIKE SY-TABIX.

*=======================================================================
* Field-Symbols.
*=======================================================================
  FIELD-SYMBOLS:
                &amp;lt;TABLE&amp;gt;,
                &amp;lt;COMPONENT&amp;gt; TYPE ABAP_COMPDESCR,
                &amp;lt;FS&amp;gt;  TYPE ANY,
                &amp;lt;FIELD&amp;gt; TYPE ANY,
                &amp;lt;LINE&amp;gt; TYPE ANY,
                &amp;lt;DYN_TABLE&amp;gt; TYPE STANDARD TABLE,
                &amp;lt;DYN_WA&amp;gt;.

*=======================================================================
* Create a dynamic internal table.
*=======================================================================
  CREATE DATA DATAREF TYPE (QUERY_TABLE).

  ASSIGN DATAREF-&amp;gt;* TO &amp;lt;FS&amp;gt;.

  DESCR_STRUCT_REF ?= CL_ABAP_TYPEDESCR=&amp;gt;DESCRIBE_BY_DATA( &amp;lt;FS&amp;gt; ).

  LOOP AT DESCR_STRUCT_REF-&amp;gt;COMPONENTS ASSIGNING &amp;lt;COMPONENT&amp;gt;.
    WA_FCAT-FIELDNAME     = &amp;lt;COMPONENT&amp;gt;-NAME.
    WA_FCAT-REF_TABLE     = QUERY_TABLE.
    WA_FCAT-REF_FIELD     = &amp;lt;COMPONENT&amp;gt;-NAME.
    APPEND WA_FCAT TO IT_FIELDCATALOG.
  ENDLOOP.

  CALL METHOD CL_ALV_TABLE_CREATE=&amp;gt;CREATE_DYNAMIC_TABLE
    EXPORTING
      IT_FIELDCATALOG           = IT_FIELDCATALOG
    IMPORTING
      EP_TABLE                  = DATAREF.
*    EXCEPTIONS
*      GENERATE_SUBPOOL_DIR_FULL = 1
*      OTHERS                    = 2.

  ASSIGN DATAREF-&amp;gt;* TO &amp;lt;DYN_TABLE&amp;gt;.

  CREATE DATA NEW_LINE LIKE LINE OF &amp;lt;DYN_TABLE&amp;gt;.
  ASSIGN NEW_LINE-&amp;gt;* TO &amp;lt;DYN_WA&amp;gt;.

*=======================================================================
* Fill the dynamic internal table.
*=======================================================================
    SPLIT DATA AT '/' INTO TABLE T_LINES.
    SPLIT FIELDS AT '/' INTO TABLE T_FIELDS.
    LOOP AT T_LINES ASSIGNING &amp;lt;LINE&amp;gt;.
      W_TABIX = SY-TABIX.
      W_LINES = &amp;lt;LINE&amp;gt;.
      READ TABLE T_FIELDS INDEX W_TABIX.
      ASSIGN T_FIELDS TO &amp;lt;FIELD&amp;gt;.
      ASSIGN COMPONENT &amp;lt;FIELD&amp;gt; OF STRUCTURE &amp;lt;DYN_WA&amp;gt; TO &amp;lt;TABLE&amp;gt;.
      &amp;lt;TABLE&amp;gt; =  W_LINES.
    ENDLOOP.

    APPEND &amp;lt;DYN_WA&amp;gt; TO &amp;lt;DYN_TABLE&amp;gt;.

*============================== ========================================
* Perform task depending of the choose operation.
*=======================================================================
    CASE OPERATION.
      WHEN 'I'.
        MODIFY (QUERY_TABLE) FROM TABLE &amp;lt;DYN_TABLE&amp;gt;.
        IF SY-SUBRC NE 0.
          RAISE RECORD_NOT_INSERTED.
        ENDIF.
      WHEN 'U'.
        UPDATE (QUERY_TABLE) FROM TABLE &amp;lt;DYN_TABLE&amp;gt;.
        IF SY-SUBRC NE 0.
          RAISE RECORD_NOT_UPDATED.
        ENDIF.
      WHEN 'D'.
        DELETE (QUERY_TABLE) FROM TABLE &amp;lt;DYN_TABLE&amp;gt;.
        IF SY-SUBRC NE 0.
          RAISE RECORD_NOT_DELETED.
        ENDIF.
    ENDCASE.

ENDFUNCTION.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Blag.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Mar 2007 12:33:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-data-to-a-database-table-from-a-dynamic-internal-table/m-p/2051722#M423047</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-17T12:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting data to a database table from a dynamic internal table?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-data-to-a-database-table-from-a-dynamic-internal-table/m-p/2051723#M423048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Narendra,&lt;/P&gt;&lt;P&gt; After completion of alll validations and populate the data into the final internal table then move each record into one work area and from work area just insert each reocord.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB INTO WA.&lt;/P&gt;&lt;P&gt; INSERT ZREAL FROM WA.&lt;/P&gt;&lt;P&gt;CLEAR ITAB.&lt;/P&gt;&lt;P&gt;CLEAR WA.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kumar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2007 04:54:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-data-to-a-database-table-from-a-dynamic-internal-table/m-p/2051723#M423048</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-19T04:54:49Z</dc:date>
    </item>
  </channel>
</rss>

