<?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: insert into sorted table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-into-sorted-table/m-p/6678093#M1449149</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could simplify your code, instead of inserting inside the select statement, just change the INTO CORRESPONDING FIELDS OF layout1 by INTO CORRESPONDING FIELDS OF TABLE layout1 and you won't need the insert statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Mar 2010 11:37:28 GMT</pubDate>
    <dc:creator>PedroGuarita</dc:creator>
    <dc:date>2010-03-05T11:37:28Z</dc:date>
    <item>
      <title>insert into sorted table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-into-sorted-table/m-p/6678092#M1449148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi experts&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TYPES: BEGIN OF ty_line_layout1,
        matnr LIKE mara-matnr,
        maktx LIKE makt-maktx,
        mfrpn LIKE mara-mfrpn,
        mfrnr LIKE mara-mfrnr,
        kunnr LIKE kna1-kunnr,
        name1 LIKE kna1-name1,
        vwerk LIKE knvv-vwerk,
        name1_plant LIKE t001w-name1,
        menge LIKE bapiwmdve-com_qty,
        werks LIKE vbap-werks,
        name2 LIKE t001w-name1,
        count TYPE i,
        percent LIKE ztable-cbetr,
        p LIKE ztable-conwa,
      END OF ty_line_layout1.

TYPES ty_layout1 TYPE SORTED TABLE OF ty_line_layout1 WITH NON-UNIQUE
KEY mfrpn mfrnr.

DATA: layout1 TYPE ty_layout1 WITH HEADER LINE.
.
.
.

FORM retrieve_data.

  SELECT z~matnr z~mfrnr z~mfrpn z~kunnr z~werks COUNT(*) AS count
  FROM ztable AS z INNER JOIN knvv AS k ON z~kunnr = k~kunnr
  INTO CORRESPONDING FIELDS OF layout1
  WHERE z~kunnr IN customer AND
        z~datum IN datum AND
        k~vwerk IN dlvplant AND
        z~mfrpn &amp;lt;&amp;gt; '' AND
        z~mfrnr &amp;lt;&amp;gt; ''
  GROUP BY z~matnr z~mfrnr z~mfrpn z~kunnr z~werks.

    INSERT layout1.  "error 
  ENDSELECT.
.
.
.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i receive following short dump:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Runtime errors         TABLE_ILLEGAL_STATEMENT
Error analysis                                                                                
You attempted to change, delete or create a line in the                
internal table "\PROGRAM=ZZ\DATA=LAYOUT1[]", but no valid cursor exists
for the table.                                                         
Possible reasons:                                                      
1. The relevent ABAP/4 statement does not include the addition         
   "...INDEX...", although the statement is not                        
   inside a "LOOP...ENDLOOP" loop processing this table.               
2. The relevent ABAP/4 statement was called from within a              
   "LOOP...ENDLOOP" loop after a DELETE "\PROGRAM=ZZ\DATA=LAYOUT1[]".  &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;error is triggered at insert statement. I don't understand. Why?&lt;/P&gt;&lt;P&gt;please someone elaborate me. i'm stuck in this weird problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Mar 2010 11:30:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-into-sorted-table/m-p/6678092#M1449148</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-05T11:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: insert into sorted table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-into-sorted-table/m-p/6678093#M1449149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could simplify your code, instead of inserting inside the select statement, just change the INTO CORRESPONDING FIELDS OF layout1 by INTO CORRESPONDING FIELDS OF TABLE layout1 and you won't need the insert statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Mar 2010 11:37:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-into-sorted-table/m-p/6678093#M1449149</guid>
      <dc:creator>PedroGuarita</dc:creator>
      <dc:date>2010-03-05T11:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: insert into sorted table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-into-sorted-table/m-p/6678094#M1449150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND layout1. Instead of INSERT layout1..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maverick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Mar 2010 11:37:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-into-sorted-table/m-p/6678094#M1449150</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-05T11:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: insert into sorted table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-into-sorted-table/m-p/6678095#M1449151</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;Please mention INSERT from where to where. I hope you are retrieveing the data and get it's stored on work are LAYOUT1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you are trying to insert the data to table. But you have inserted into LAYOUT1. It will not work If you are trying to insert work &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;area to table. Try to store an internal table and then try to insert. It will work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Mar 2010 11:38:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-into-sorted-table/m-p/6678095#M1449151</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-05T11:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: insert into sorted table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-into-sorted-table/m-p/6678096#M1449152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't use tables with header lines, use separate work areas.&lt;/P&gt;&lt;P&gt;Then you can insert the work area into the table using "INSERT wa INTO TABLE itab" for sorted tables.&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/abapdocu_70/en/ABAPINSERT_ITAB_POSITION.htm#!ABAP_ALTERNATIVE_1@1@" target="test_blank"&gt;http://help.sap.com/abapdocu_70/en/ABAPINSERT_ITAB_POSITION.htm#!ABAP_ALTERNATIVE_1@1@&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Mar 2010 12:01:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-into-sorted-table/m-p/6678096#M1449152</guid>
      <dc:creator>ThomasZloch</dc:creator>
      <dc:date>2010-03-05T12:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: insert into sorted table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-into-sorted-table/m-p/6678097#M1449153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you friends.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;before i've post i tried with work area&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
insert wa into layout1.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but correct is:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
insert wa into TABLE layout1.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i've also tried with append and it works for first append. at second append i have receive a short dump&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Mar 2010 12:50:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-into-sorted-table/m-p/6678097#M1449153</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-03-05T12:50:40Z</dc:date>
    </item>
  </channel>
</rss>

