<?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: 'INTO' is invalid (due to grammar) error while SQL in BAPI in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/into-is-invalid-due-to-grammar-error-while-sql-in-bapi/qaa-p/13660425#M4824449</link>
    <description>What is the error that is returned?</description>
    <pubDate>Fri, 05 Apr 2024 11:42:14 GMT</pubDate>
    <dc:creator>Ryan-Crosby</dc:creator>
    <dc:date>2024-04-05T11:42:14Z</dc:date>
    <item>
      <title>'INTO' is invalid (due to grammar) error while SQL in BAPI</title>
      <link>https://community.sap.com/t5/technology-q-a/into-is-invalid-due-to-grammar-error-while-sql-in-bapi/qaq-p/13640559</link>
      <description>&lt;P&gt;Hi guys!&lt;/P&gt;
&lt;P&gt;The error occurs in the first INTO of the first SELECT. I have&amp;nbsp;'INTO' is invalid (due to grammar)&lt;BR /&gt;I need to return several tables that will become arrays in an application that will call this BAPI remotely (RFC). However, when I add this code to the SAP that will run the RFC, it gives a problem with the INTO clause.&lt;BR /&gt;INTO is invalid here (due to grammar), but I don't know what I'm doing wrong, because I've already run this function in other SAPs and it worked normally.&lt;BR /&gt;The logic of this RFC is to return the data from the MARD, MARC, MAKT and MBEW tables based on the MARA table. Then I perform a select with where in the MARA table that will return a series of items, and based on the code of these items I perform a FOR ALL ENTRIES to search for these same materials in other tables and return them separately. I can't use joins. And then I come across the INTO clause error when I use anything between the word MARA (FROM MARA) and INTO. (In this case it's the order by)&lt;BR /&gt;I need the up to to be able to limit the lines of this return.&lt;BR /&gt;Can anyone help me?&lt;/P&gt;
&lt;P&gt;Code (also attached):&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FUNCTION Z_GET_MATERIAL_FULL_CUSTOM.&lt;BR /&gt;*"----------------------------------------------------------------------&lt;BR /&gt;*"*"Local Interface:&lt;BR /&gt;*" IMPORTING&lt;BR /&gt;*" REFERENCE(MARA_MAX_ROWS) TYPE INT4&lt;BR /&gt;*" REFERENCE(MARA_SKIP_ROWS) TYPE INT4&lt;BR /&gt;*" TABLES&lt;BR /&gt;*" MARA_TABLE STRUCTURE MARA&lt;BR /&gt;*" MARD_TABLE STRUCTURE MARD&lt;BR /&gt;*" MARC_TABLE STRUCTURE MARC&lt;BR /&gt;*" MAKT_TABLE STRUCTURE MAKT&lt;BR /&gt;*" MBEW_TABLE STRUCTURE MBEW&lt;BR /&gt;*"----------------------------------------------------------------------&lt;BR /&gt;SELECT MATNR, MEINS, MTPOS_MARA FROM MARA WHERE MTPOS_MARA = 'ZMAP' OR MTPOS_MARA = 'ZMAN' ORDER BY MATNR INTO CORRESPONDING FIELDS OF TABLE &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1413348"&gt;@Mara&lt;/a&gt;_TABLE UP TO &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1413348"&gt;@Mara&lt;/a&gt;_MAX_ROWS ROWS OFFSET &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1413348"&gt;@Mara&lt;/a&gt;_SKIP_ROWS .&lt;/P&gt;
&lt;P&gt;SELECT MATNR, LABST, LGPBE FROM MARD FOR ALL ENTRIES IN &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1413348"&gt;@Mara&lt;/a&gt;_TABLE WHERE MATNR = &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1413348"&gt;@Mara&lt;/a&gt;_TABLE-MATNR INTO CORRESPONDING FIELDS OF TABLE @MARD_TABLE.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;SELECT MATNR, MINBE, MABST, PLIFZ, DISMM, STEUC FROM MARC FOR ALL ENTRIES IN &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1413348"&gt;@Mara&lt;/a&gt;_TABLE WHERE MATNR = &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1413348"&gt;@Mara&lt;/a&gt;_TABLE-MATNR INTO CORRESPONDING FIELDS OF TABLE &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1382985"&gt;@Marc&lt;/a&gt;_TABLE.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;SELECT MATNR, MAKTX FROM MAKT FOR ALL ENTRIES IN &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1413348"&gt;@Mara&lt;/a&gt;_TABLE WHERE MATNR = &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1413348"&gt;@Mara&lt;/a&gt;_TABLE-MATNR AND SPRAS = 'P' INTO CORRESPONDING FIELDS OF TABLE @Former Member&lt;/a&gt;_TABLE.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;SELECT MATNR, VERPR FROM MBEW FOR ALL ENTRIES IN &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1413348"&gt;@Mara&lt;/a&gt;_TABLE WHERE MATNR = &lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/1413348"&gt;@Mara&lt;/a&gt;_TABLE-MATNR INTO CORRESPONDING FIELDS OF TABLE @MBEW_TABLE.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;ENDFUNCTION.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2024 08:25:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/into-is-invalid-due-to-grammar-error-while-sql-in-bapi/qaq-p/13640559</guid>
      <dc:creator>igma5</dc:creator>
      <dc:date>2024-04-05T08:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: 'INTO' is invalid (due to grammar) error while SQL in BAPI</title>
      <link>https://community.sap.com/t5/technology-q-a/into-is-invalid-due-to-grammar-error-while-sql-in-bapi/qaa-p/13660425#M4824449</link>
      <description>What is the error that is returned?</description>
      <pubDate>Fri, 05 Apr 2024 11:42:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/into-is-invalid-due-to-grammar-error-while-sql-in-bapi/qaa-p/13660425#M4824449</guid>
      <dc:creator>Ryan-Crosby</dc:creator>
      <dc:date>2024-04-05T11:42:14Z</dc:date>
    </item>
  </channel>
</rss>

