<?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: internal table with same variable and one select query in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-with-same-variable-and-one-select-query/m-p/7514507#M1559960</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi rajesh.nayakbola,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;although this is not quite the right place for this, let me give you some notes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Code should be &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;formatted as code &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; by markin it with mouse and use above &amp;amp;lt;&amp;amp;gt; button.&lt;/P&gt;&lt;P&gt;2. Internal tables shoult not be declared using OCCURS clause - this is last century style&lt;/P&gt;&lt;P&gt;3. Internal tables do not need and should not have a header line, they should use TYPES for declaration&lt;/P&gt;&lt;P&gt;4. Data should not be declared using LIKE: If they refer to dictionary TYPES, use TYPE. LIKE is only mandatory for data objects declared in your program, i.e. DATA IT_some_ORDERDETAILS like IT_ORDERDETAILS.&lt;/P&gt;&lt;P&gt;5. If you get an error here, never write "I am getting error" but copy and paste the error message fully.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- The fields in brackets in  the INTO clause never have ~ character, there is no IT_ORDERDETAILS~vbak, only &lt;STRONG&gt;IT_ORDERDETAILS-vbeln&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;It could be something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES:
  BEGIN OF TY_ORDERDETAILS,
  VBELN TYPE VBAK-VBELN, "Order number
  BSTNK TYPE VBAK-BSTNK, "customer PO
  ERDAT TYPE VBAK-ERDAT, " Order created date
  MATNR TYPE VBAP-MATNR, "Sales order line item
  KWMENG TYPE VBAP-KWMENG, "Quantity
  D_VBELN TYPE likp-vbeln, " delivery no
  POSNR TYPE lips-posnr, " delivery item
  KUNNR TYPE LIKP-KUNNR, "ship quantity
END OF TY_ORDERDETAILS.
DATA:
  IT_ORDERDETAILS TYPE TABLE OF TY_ORDERDETAILS.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT VBAK~VBELN
  VBAK~BSTNK 
  VBAK~ERDAT
  VBAP~MATNR
  VBAP~KWMENG  
  likp~vbeln AS D_VBELN
  lips~posnr
  LIKP~KUNNR
INTO CORRSPONDING FIELDS OF TABLE IT_ORDERDETAILS
FROM VBAK left outer JOIN VBAP ON ( VBAK~VBELN = VBAP~VBELN )
  left outer JOIN LIPS ON ( VBAK~VBELN = LIPS~VGBEL )
  join LIKP on ( LIPS~VBELN = LIKP~VBELN )
WHERE VBAK~ERDAT IN CR_DATE.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Dec 2010 20:59:14 GMT</pubDate>
    <dc:creator>Clemenss</dc:creator>
    <dc:date>2010-12-14T20:59:14Z</dc:date>
    <item>
      <title>internal table with same variable and one select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-with-same-variable-and-one-select-query/m-p/7514503#M1559956</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 am a new bee here with may be a silly question. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a internal table as below.&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF IT_ORDERDETAILS OCCURS 0,&lt;/P&gt;&lt;P&gt;        VBELN LIKE VBAK-VBELN,        "Order number&lt;/P&gt;&lt;P&gt;        BSTNK LIKE VBAK-BSTNK,        "customer PO&lt;/P&gt;&lt;P&gt;        ERDAT LIKE VBAK-ERDAT,        " Order created date&lt;/P&gt;&lt;P&gt;        MATNR LIKE VBAP-MATNR,        "Sales order line item&lt;/P&gt;&lt;P&gt;        KWMENG LIKE VBAP-KWMENG,      "Quantity&lt;/P&gt;&lt;P&gt;        D_VBELN like likp-vbeln,      " delivery no&lt;/P&gt;&lt;P&gt;        POSNR like lips-posnr,        " delivery item&lt;/P&gt;&lt;P&gt;        KUNNR LIKE LIKP-KUNNR,        "ship quantity&lt;/P&gt;&lt;P&gt;  END OF IT_ORDERDETAILS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where VBELN field is in VBAK and LIKP table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VBELN in VBAK table = order #&lt;/P&gt;&lt;P&gt;VBELN in LIKP table is = Delivery #&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to use join to fetch data in single select query. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the select query &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; SELECT VBAK~VBELN &lt;/P&gt;&lt;P&gt;        VBAK~BSTNK &lt;/P&gt;&lt;P&gt;        VBAK~ERDAT &lt;/P&gt;&lt;P&gt;        VBAP~MATNR &lt;/P&gt;&lt;P&gt;        VBAP~KWMENG&lt;/P&gt;&lt;P&gt;        likp~vbeln&lt;/P&gt;&lt;P&gt;        lips~posnr&lt;/P&gt;&lt;P&gt;        LIPS~VGBEL&lt;/P&gt;&lt;P&gt;      INTO (IT_ORDERDETAILS&lt;SUB&gt;vbak, IT_ORDERDETAILS&lt;/SUB&gt;bstnk,     IT_ORDERDETAILS&lt;SUB&gt;erdat, IT_ORDERDETAILS&lt;/SUB&gt;matnr, IT_ORDERDETAILS&lt;SUB&gt;kwmeng, IT_ORDERDETAILS&lt;/SUB&gt;d_vbeln,IT_ORDERDETAILS&lt;SUB&gt;posnr, IT_ORDERDETAILS&lt;/SUB&gt;kunnr)&lt;/P&gt;&lt;P&gt; FROM VBAK left outer JOIN VBAP ON ( VBAK&lt;SUB&gt;VBELN = VBAP&lt;/SUB&gt;VBELN )&lt;/P&gt;&lt;P&gt; left outer JOIN LIPS ON ( VBAK&lt;SUB&gt;VBELN = LIPS&lt;/SUB&gt;VGBEL )&lt;/P&gt;&lt;P&gt;  join LIKP on ( LIPS&lt;SUB&gt;VBELN = LIKP&lt;/SUB&gt;VBELN )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; WHERE VBAK~ERDAT IN CR_DATE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am getting error in the query. &lt;/P&gt;&lt;P&gt;Please suggest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Rajesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Dec 2010 14:38:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-with-same-variable-and-one-select-query/m-p/7514503#M1559956</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-14T14:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: internal table with same variable and one select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-with-same-variable-and-one-select-query/m-p/7514504#M1559957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rajesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Either use the statement &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select single &amp;lt;rest of your query&amp;gt; -&lt;/P&gt;&lt;HR originaltext="-----------------" /&gt;&lt;P&gt;if u planning for only one set of data   &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; SELECT VBAK~VBELN &lt;/P&gt;&lt;P&gt;VBAK~BSTNK &lt;/P&gt;&lt;P&gt;VBAK~ERDAT &lt;/P&gt;&lt;P&gt;VBAP~MATNR &lt;/P&gt;&lt;P&gt;VBAP~KWMENG&lt;/P&gt;&lt;P&gt;likp~vbeln&lt;/P&gt;&lt;P&gt;lips~posnr&lt;/P&gt;&lt;P&gt;LIPS~VGBEL&lt;/P&gt;&lt;P&gt;INTO  corresponding fields of table IT_ORDERDETAILS&lt;/P&gt;&lt;P&gt;FROM VBAK left outer JOIN VBAP ON ( VBAK&lt;SUB&gt;VBELN = VBAP&lt;/SUB&gt;VBELN )&lt;/P&gt;&lt;P&gt;left outer JOIN LIPS ON ( VBAK&lt;SUB&gt;VBELN = LIPS&lt;/SUB&gt;VGBEL )&lt;/P&gt;&lt;P&gt;join LIKP on ( LIPS&lt;SUB&gt;VBELN = LIKP&lt;/SUB&gt;VBELN )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this may be helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sharin.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Dec 2010 14:45:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-with-same-variable-and-one-select-query/m-p/7514504#M1559957</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-14T14:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: internal table with same variable and one select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-with-same-variable-and-one-select-query/m-p/7514505#M1559958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The suggestion above will not work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT VBAK~VBELN&lt;/P&gt;&lt;P&gt;VBAK~BSTNK&lt;/P&gt;&lt;P&gt;VBAK~ERDAT&lt;/P&gt;&lt;P&gt;VBAP~MATNR&lt;/P&gt;&lt;P&gt;VBAP~KWMENG&lt;/P&gt;&lt;P&gt;likp~vbeln&lt;/P&gt;&lt;P&gt;lips~posnr&lt;/P&gt;&lt;P&gt;---&amp;gt; &lt;STRONG&gt;LIPS~VGBEL&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;INTO &lt;STRONG&gt;corresponding fields of table&lt;/STRONG&gt; IT_ORDERDETAILS&lt;/P&gt;&lt;P&gt;FROM VBAK left outer JOIN VBAP ON ( VBAK&lt;SUB&gt;VBELN = VBAP&lt;/SUB&gt;VBELN )&lt;/P&gt;&lt;P&gt;left outer JOIN LIPS ON ( VBAK&lt;SUB&gt;VBELN = LIPS&lt;/SUB&gt;VGBEL )&lt;/P&gt;&lt;P&gt;join LIKP on ( LIPS&lt;SUB&gt;VBELN = LIKP&lt;/SUB&gt;VBELN )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You did not difine a field named VGBEL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would write the following:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TYPES:
BEGIN OF lty_s_order,
  VBELN TYPE VBAK-VBELN, "Order number
  BSTNK TYPE VBAK-BSTNK, "customer PO
  ERDAT TYPE VBAK-ERDAT, " Order created date
  MATNR TYPE VBAP-MATNR, "Sales order line item
  KWMENG TYPE VBAP-KWMENG, "Quantity
  D_VBELN TYPE likp-vbeln, " delivery no
  POSNR TYPE lips-posnr, " delivery item
  KUNNR TYPE LIKP-KUNNR, "ship-to party
END OF lty_s_order,
lty_t_order TYPE STANDARD TABLE OF lty_s_order.
DATA: lt_order TYPE lty_t_order.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT a~vbeln a~bstnk a~erdat b~matnr b~kwmeng c~vbeln d~posnr c~kunnr
INTO TABLE lt_order
FROM vbak as a
INNER JOIN vbap as b ON a~vbeln = b~vbeln
INNER JOIN lips as d ON b~vbeln = d~vgbel
                                 AND b~posnr = d~vgpos
INNER JOIN likp as c ON c~vbeln = d~vbeln
WHERE a~erdat IN cr_date.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, this SELECT does not seem to be the high-performance solution. The parties are stored in VBPA, e.g.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Dec 2010 14:58:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-with-same-variable-and-one-select-query/m-p/7514505#M1559958</guid>
      <dc:creator>dennis_bastian</dc:creator>
      <dc:date>2010-12-14T14:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: internal table with same variable and one select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-with-same-variable-and-one-select-query/m-p/7514506#M1559959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rajesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Read carefully  the keyword documentation of JOIN keyword. You can get that from editor itself by highlighting the keyword and then pressing F1 key or through tcode 'ABAPDOCU' .  I'm sure you will spot the error after going through this . That is the best way to learn on your own.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Dec 2010 15:20:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-with-same-variable-and-one-select-query/m-p/7514506#M1559959</guid>
      <dc:creator>tushar_shukla</dc:creator>
      <dc:date>2010-12-14T15:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: internal table with same variable and one select query</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-with-same-variable-and-one-select-query/m-p/7514507#M1559960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi rajesh.nayakbola,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;although this is not quite the right place for this, let me give you some notes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Code should be &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;formatted as code &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; by markin it with mouse and use above &amp;amp;lt;&amp;amp;gt; button.&lt;/P&gt;&lt;P&gt;2. Internal tables shoult not be declared using OCCURS clause - this is last century style&lt;/P&gt;&lt;P&gt;3. Internal tables do not need and should not have a header line, they should use TYPES for declaration&lt;/P&gt;&lt;P&gt;4. Data should not be declared using LIKE: If they refer to dictionary TYPES, use TYPE. LIKE is only mandatory for data objects declared in your program, i.e. DATA IT_some_ORDERDETAILS like IT_ORDERDETAILS.&lt;/P&gt;&lt;P&gt;5. If you get an error here, never write "I am getting error" but copy and paste the error message fully.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- The fields in brackets in  the INTO clause never have ~ character, there is no IT_ORDERDETAILS~vbak, only &lt;STRONG&gt;IT_ORDERDETAILS-vbeln&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;It could be something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES:
  BEGIN OF TY_ORDERDETAILS,
  VBELN TYPE VBAK-VBELN, "Order number
  BSTNK TYPE VBAK-BSTNK, "customer PO
  ERDAT TYPE VBAK-ERDAT, " Order created date
  MATNR TYPE VBAP-MATNR, "Sales order line item
  KWMENG TYPE VBAP-KWMENG, "Quantity
  D_VBELN TYPE likp-vbeln, " delivery no
  POSNR TYPE lips-posnr, " delivery item
  KUNNR TYPE LIKP-KUNNR, "ship quantity
END OF TY_ORDERDETAILS.
DATA:
  IT_ORDERDETAILS TYPE TABLE OF TY_ORDERDETAILS.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT VBAK~VBELN
  VBAK~BSTNK 
  VBAK~ERDAT
  VBAP~MATNR
  VBAP~KWMENG  
  likp~vbeln AS D_VBELN
  lips~posnr
  LIKP~KUNNR
INTO CORRSPONDING FIELDS OF TABLE IT_ORDERDETAILS
FROM VBAK left outer JOIN VBAP ON ( VBAK~VBELN = VBAP~VBELN )
  left outer JOIN LIPS ON ( VBAK~VBELN = LIPS~VGBEL )
  join LIKP on ( LIPS~VBELN = LIKP~VBELN )
WHERE VBAK~ERDAT IN CR_DATE.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Dec 2010 20:59:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/internal-table-with-same-variable-and-one-select-query/m-p/7514507#M1559960</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2010-12-14T20:59:14Z</dc:date>
    </item>
  </channel>
</rss>

