<?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: Select statements in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794515#M652203</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi White,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check these links.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;SELECT statement&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/select.htm" target="test_blank"&gt;http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/select.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/62/10a423384746e8bf5f15ccdd36e8b1/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/62/10a423384746e8bf5f15ccdd36e8b1/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Inner/Outer Joins:&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ec77446011d189700000e8322d00/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ec77446011d189700000e8322d00/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_erp2004/helpdata/en/67/7e4b3eaf72561ee10000000a114084/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_erp2004/helpdata/en/67/7e4b3eaf72561ee10000000a114084/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vinay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Aug 2007 09:59:17 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-08-30T09:59:17Z</dc:date>
    <item>
      <title>Select statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794512#M652200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;could anybody send me some material about using select statements, inner- and outer joins, etc...&lt;/P&gt;&lt;P&gt;My email address is: bstripes81@gmail.com&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>Thu, 30 Aug 2007 09:53:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794512#M652200</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-30T09:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: Select statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794513#M652201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stripes,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT result&lt;/P&gt;&lt;P&gt;FROM source&lt;/P&gt;&lt;P&gt;INTO|APPENDING target&lt;/P&gt;&lt;P&gt;[[FOR ALL ENTRIES IN itab] WHERE sql_cond]&lt;/P&gt;&lt;P&gt;&lt;A href="GROUP BY group"&gt;&lt;/A&gt; &lt;A href="HAVING group_cond"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="ORDER BY sort_key"&gt;&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.sap.com/ENDSELECT"&gt;&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect&lt;/P&gt;&lt;P&gt;SELECT is an Open-SQL-statement for reading data from one or several database tables into data objects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The select statement reads a result set (whose structure is determined in result ) from the database tables specified in source, and assigns the data from the result set to the data objects specified in target. You can restrict the result set using the WHERE addition. The addition GROUP BY compresses several database rows into a single row of the result set. The addition HAVING restricts the compressed rows. The addition ORDER BY sorts the result set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data objects specified in target must match the result set result. This means that the result set is either assigned to the data objects in one step, or by row, or by packets of rows. In the second and third case, the SELECT statement opens a loop, which which must be closed using ENDSELECT. For every loop pass, the SELECT-statement assigns a row or a packet of rows to the data objects specified in target. If the last row was assigned or if the result set is empty, then SELECT branches to ENDSELECT . A database cursor is opened implicitly to process a SELECT-loop, and is closed again when the loop is ended. You can end the loop using the statements from section leave loops.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Up to the INTO resp. APPENDING addition, the entries in the SELECTstatement define which data should be read by the database in which form. This requirement is translated in the database interface for the database system´s programming interface and is then passed to the database system. The data are read in packets by the database and are transported to the application server by the database server. On the application server, the data are transferred to the ABAP program´s data objects in accordance with the data specified in the INTO and APPENDING additions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;System Fields&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The SELECT statement sets the values of the system fields sy-subrc and sy-dbcnt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sy-subrc Relevance&lt;/P&gt;&lt;P&gt;0 The SELECT statement sets sy-subrc to 0 for every pass by value to an ABAP data object. The ENDSELECT statement sets sy-subrc to 0 if at least one row was transferred in the SELECT loop.&lt;/P&gt;&lt;P&gt;4 The SELECT statement sets sy-subrc to 4 if the result set is empty, that is, if no data was found in the database.&lt;/P&gt;&lt;P&gt;8 The SELECT statement sets sy-subrc to 8 if the FOR UPDATE addition is used in result, without the primary key being specified fully after WHERE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After every value that is transferred to an ABAP data object, the SELECT statement sets sy-dbcnt to the number of rows that were transferred. If the result set is empty, sy-dbcnt is set to 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Notes&lt;/P&gt;&lt;P&gt;Outside classes, you do not need to specify the target area with INTO or APPENDING if a single database table or a single view is specified statically after FROM, and a table work area dbtab was declared with the TABLES statement for the corresponding database table or view. In this case, the system supplements the SELECT-statement implicitly with the addition INTO dbtab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Although the WHERE-condition is optional, you should always specify it for performance reasons, and the result set should not be restricted on the application server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT-loops can be nested. For performance reasons, you should check whether a join or a sub-query would be more effective.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Within a SELECT-loop you cannot execute any statements that lead to a database commit and consequently cause the corresponding database cursor to close.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT - result&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax&lt;/P&gt;&lt;P&gt;... lines columns ... .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect&lt;/P&gt;&lt;P&gt;The data in result defines whether the resulting set consists of multiple rows (table-like structure) or a single row ( flat structure). It specifies the columns to be read and defines their names in the resulting set. Note that column names from the database table can be changed. For single columns, aggregate expressions can be used to specify aggregates. Identical rows in the resulting set can be excluded, and individual rows can be protected from parallel changes by another program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data in result consists of data for the rows lines and for the columns columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT - lines&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax&lt;/P&gt;&lt;P&gt;... { SINGLE &lt;A href="FOR UPDATE"&gt;&lt;/A&gt; }&lt;/P&gt;&lt;P&gt;| { &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; { } } ... .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatives:&lt;/P&gt;&lt;P&gt;1. ... SINGLE &lt;A href="FOR UPDATE"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. ... &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; { }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect&lt;/P&gt;&lt;P&gt;The data in lines specifies that the resulting set has either multiple lines or a single line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternative 1&lt;/P&gt;&lt;P&gt;... SINGLE &lt;A href="FOR UPDATE"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect&lt;/P&gt;&lt;P&gt;If SINGLE is specified, the resulting set has a single line. If the remaining additions to the SELECT command select more than one line from the database, the first line that is found is entered into the resulting set. The data objects specified after INTO may not be internal tables, and the APPENDING addition may not be used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An exclusive lock can be set for this line using the FOR UPDATE addition when a single line is being read with SINGLE. The SELECT command is used in this case only if all primary key fields in logical expressions linked by AND are checked to make sure they are the same in the WHERE condition. Otherwise, the resulting set is empty and sy-subrc is set to 8. If the lock causes a deadlock, an exception occurs. If the FOR UPDATE addition is used, the SELECT command circumvents SAP buffering.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note&lt;/P&gt;&lt;P&gt;When SINGLE is being specified, the lines to be read should be clearly specified in the WHERE condition, for the sake of efficiency. When the data is read from a database table, the system does this by specifying comparison values for the primary key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternative 2&lt;/P&gt;&lt;P&gt;... &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; { }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect&lt;/P&gt;&lt;P&gt;If SINGLE is not specified and if columns does not contain only aggregate expressions, the resulting set has multiple lines. All database lines that are selected by the remaining additions of the SELECT command are included in the resulting list. If the ORDER BY addition is not used, the order of the lines in the resulting list is not defined and, if the same SELECT command is executed multiple times, the order may be different each time. A data object specified after INTO can be an internal table and the APPENDING addition can be used. If no internal table is specified after INTO or APPENDING, the SELECT command triggers a loop that has to be closed using ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If multiple lines are read without SINGLE, the DISTINCT addition can be used to exclude duplicate lines from the resulting list. If DISTINCT is used, the SELECT command circumvents SAP buffering. DISTINCT cannot be used in the following situations:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If a column specified in columns has the type STRING, RAWSTRING, LCHAR or LRAW&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the system tries to access pool or cluster tables and single columns are specified in columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note&lt;/P&gt;&lt;P&gt;When specifying DISTINCT, note that you have to carry out sort operations in the database system for this.&lt;/P&gt;&lt;P&gt;SELECT - columns&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax&lt;/P&gt;&lt;P&gt;... *&lt;/P&gt;&lt;P&gt;| { {col1|aggregate( &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; col1 )} &lt;A href="AS a1"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;{col2|aggregate( &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; col2 )} &lt;A href="AS a2"&gt;&lt;/A&gt; ... }&lt;/P&gt;&lt;P&gt;| (column_syntax) ... .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatives:&lt;/P&gt;&lt;P&gt;1. ... *&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. ... {col1|aggregate( &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; col1 )} &lt;A href="AS a1"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;{col2|aggregate( &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; col2 )} &lt;A href="AS a2"&gt;&lt;/A&gt; ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. ... (column_syntax)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect&lt;/P&gt;&lt;P&gt;The input in columns determines which columns are used to build the resulting set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternative 1&lt;/P&gt;&lt;P&gt;... *&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect&lt;/P&gt;&lt;P&gt;If * is specified, the resulting set is built based on all columns in the database tables or views specified after FROM, in the order given there. The columns in the resulting set take on the name and data type from the database tables or views. Only one data object can be specified after INTO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note&lt;/P&gt;&lt;P&gt;If multiple database tables are specified after FROM, you cannot prevent multiple columns from getting the same name when you specify *.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternative 2&lt;/P&gt;&lt;P&gt;... {col1|aggregate( &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; col1 )} &lt;A href="AS a1"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;{col2|aggregate( &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; col2 )} &lt;A href="AS a2"&gt;&lt;/A&gt; ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect&lt;/P&gt;&lt;P&gt;A list of column labels col1 col2 ... is specified in order to build the resulting list from individual columns. An individual column can be specified directly or as an argument of an aggregate function aggregate. The order in which the column labels are specified is up to you and defines the order of the columns in the resulting list. Only if a column of the type LCHAR or LRAW is listed does the corresponding length field also have to be specified directly before it. An individual column can be specified multiple times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The addition AS can be used to define an alternative column name a1 a2 ... with a maximum of fourteen digits in the resulting set for every column label col1 col2 .... The system uses the alternative column name in the additions INTO|APPENDING CORRESPONDING FIELDS and ORDER BY. .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Column labels&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following column labels are possible:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If only a single database table or a single view is specified after FROM, the column labels in the database table - that is, the names of the components comp1 comp2... - can be specified directly for col1 col2 ... in the structure of the ABAP Dictionary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the name of the component occurs in multiple database tables of the FROM addition, but the desired database table or the view dbtab is only specified once after FROM, the names dbtab~comp1 dbtab~comp2 ... have to be specified for col1 col2 .... comp1 comp2 ... are the names of the components in the structure of the ABAP Dictionary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the desired database table or view occurs multiple times after FROM, the names tabalias~comp1 tabalias~comp2 ... have to be specified for col1 col2 .... tabalias is the alternative table name of the database table or view defined after FROM, and comp1 comp2 ... are the names of the components in the structure of the ABAP Dictionary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data type of a single column in the resulting list is the datatype of the corresponding component in the ABAP Dictionary. The corresponding data object after INTO or APPENDING has to be selected accordingly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note&lt;/P&gt;&lt;P&gt;If multiple database tables are specified after FROM, you can use alternative names when specifying single columns to avoid having multiple columns with the same name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;Read specific columns of a single row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA wa TYPE spfli.&lt;/P&gt;&lt;P&gt;SELECT SINGLE carrid connid cityfrom cityto&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF wa&lt;/P&gt;&lt;P&gt;FROM spfli&lt;/P&gt;&lt;P&gt;WHERE carrid EQ 'LH' AND connid EQ '0400'.&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;P&gt;WRITE: / wa-carrid, wa-connid, wa-cityfrom, wa-cityto.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternative 3&lt;/P&gt;&lt;P&gt;... (column_syntax)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect&lt;/P&gt;&lt;P&gt;Instead of static data, a data object column_syntax in brackets can be specified, which, when the command is executed, either contains the syntax shown with the static data, or is initial. The data object column_syntax can be a character-type data object or an internal table with a character-type data type. The syntax in column_syntax, like in the ABAP editor, is not case-sensitive. When specifying an internal table, you can distribute the syntax over multiple rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If column_syntax is initial when the command is executed, columns is implicitly set to * and all columns are read.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If columns are specificied dynamically without the SINGLE addition, the resulting set is always regarded as having multiple rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Notes&lt;/P&gt;&lt;P&gt;Before Release 6.10, you could only specify an internal table with a flat character-type row type for column_syntax with a maximum of 72 characters. Also, before Release 6.10, if you used the DISTINCT addition for dynamic access to pool tables or cluster tables, this was ignored, but since release 6.10, this causes a known exception.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If column_syntax is an internal table with header line, the table body and not the header line is evaluated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;Read out how many flights go to and from a city. The SELECT command is implemented only once in a sub-program. The column data, including aggregate function and the data after GROUP BY, is dynamic. Instead of adding the column data to an internal l_columns table, you could just as easily concatenate it in a character-type l_columns field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PERFORM my_select USING `CITYFROM`.&lt;/P&gt;&lt;P&gt;ULINE.&lt;/P&gt;&lt;P&gt;PERFORM my_select USING `CITYTO`.&lt;/P&gt;&lt;P&gt;FORM my_select USING l_group TYPE string.&lt;/P&gt;&lt;P&gt;DATA: l_columns TYPE TABLE OF string,&lt;/P&gt;&lt;P&gt;l_container TYPE string,&lt;/P&gt;&lt;P&gt;l_count TYPE i.&lt;/P&gt;&lt;P&gt;APPEND l_group TO l_columns.&lt;/P&gt;&lt;P&gt;APPEND `count( * )` TO l_columns.&lt;/P&gt;&lt;P&gt;SELECT (l_columns)&lt;/P&gt;&lt;P&gt;FROM spfli&lt;/P&gt;&lt;P&gt;INTO (l_container, l_count)&lt;/P&gt;&lt;P&gt;GROUP BY (l_group).&lt;/P&gt;&lt;P&gt;WRITE: / l_count, l_container.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT - aggregate&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax&lt;/P&gt;&lt;P&gt;... { MAX( &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; col )&lt;/P&gt;&lt;P&gt;| MIN( &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; col )&lt;/P&gt;&lt;P&gt;| AVG( &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; col )&lt;/P&gt;&lt;P&gt;| SUM( &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; col )&lt;/P&gt;&lt;P&gt;| COUNT( DISTINCT col )&lt;/P&gt;&lt;P&gt;| COUNT( * )&lt;/P&gt;&lt;P&gt;| count(*) } ... .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect&lt;/P&gt;&lt;P&gt;As many of the specified column labels as you like can be listed in the SELECT command as arguments of the above aggregate expression. In aggregate expressions, a single value is calculated from the values of multiple rows in a column as follows (note that the addition DISTINCT excludes double values from the calculation):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MAX( &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; col ) Determines the maximum value of the value in the column col in the resulting set or in the current group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MIN( &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; col ) Determines the minimum value of the content of the column col in the resulting set or in the current group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AVG( &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; col ) Determines the average value of the content of the column col in the resulting set or in the current group. The data type of the column has to be numerical.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM( &lt;A href="https://community.sap.com/DISTINCT"&gt;&lt;/A&gt; col ) Determines the sum of the content of the column col in the resulting set or in the current group. The data type of the column has to be numerical.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COUNT( DISTINCT col ) Determines the number of different values in the column col in the resulting set or in the current group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COUNT( * ) (or count(*)) Determines the number of rows in the resulting set or in the current group. No column label is specified in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using aggregate expressions, all column labels that are not listed as an argument of an aggregate function are listed after the addition GROUP BY. The aggregate functions evaluate the content of the groups defined by GROUP BY in the database system and transfer the result to the combined rows of the resulting set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data type of aggregate expressions with the function MAX, MIN or SUM is the data type of the corresponding column in the ABAP Dictionary. Aggregate expressions with the function AVG have the data type FLTP, and those with COUNT have the data type INT4. The corresponding data object after INTO or APPENDING has to be selected accordingly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note the following points when using aggregate expressions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the addition FOR ALL ENTRIES is used in front of WHERE, or if cluster or pool tables are listed after FROM, no other aggregate expressions apart from COUNT( * ) can be used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Columns of the type STRING or RAWSTRING cannot be used with aggregate functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When aggregate expressions are used, the SELECT command makes it unnecessary to use SAP buffering.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Null values are not included in the calculation for the aggregate functions. The result is a null value only if all the rows in the column in question contain the null value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If only aggregate expressions are used after SELECT, the results set has one row and the addition GROUP BY is not necessary. If a non-table type target area is specified after INTO, the command ENDSELECT cannot be used together with the addition SINGLE. If the aggregate expression count( * ) is not being used, an internal table can be specified after INTO, and the first row of this table is filled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If aggregate functions are used without GROUP BY being specified at the same time, the resulting set also contains a row if no data is found in the database. If count( * ) is used, the column in question contains the value 0. The columns in the other aggregate functions contain initial values. This row is assigned to the data object specified after INTO, and unless count( * ) is being used exclusively, sy-subrc is set to 0 and sy-dbcnt is set to 1. If count( *) is used exclusively, the addition INTO can be omitted and if no data can be found in the database, sy-subrc is set to 4 and sy-dbcnt is set to 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;K.Kiran.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2007 09:58:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794513#M652201</guid>
      <dc:creator>kiran_k8</dc:creator>
      <dc:date>2007-08-30T09:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: Select statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794514#M652202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="532606"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2007 09:58:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794514#M652202</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-30T09:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: Select statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794515#M652203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi White,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check these links.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;SELECT statement&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/select.htm" target="test_blank"&gt;http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/select.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/62/10a423384746e8bf5f15ccdd36e8b1/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/62/10a423384746e8bf5f15ccdd36e8b1/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Inner/Outer Joins:&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ec77446011d189700000e8322d00/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ec77446011d189700000e8322d00/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_erp2004/helpdata/en/67/7e4b3eaf72561ee10000000a114084/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_erp2004/helpdata/en/67/7e4b3eaf72561ee10000000a114084/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Vinay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2007 09:59:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794515#M652203</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-30T09:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Select statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794516#M652204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are basically 3 types of SELECT statements :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. To Read multiple rows from DB table into Work area (Row by row in a loop)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT &amp;lt;FIELDS&amp;gt; FROM &amp;lt;DB TABLE&amp;gt; INTO &amp;lt;WA&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. To read a single row from dB table into work area(Based on Primary key)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SINGLE &amp;lt;FIELDS&amp;gt; FROM &amp;lt;DBTABLE&amp;gt; into &amp;lt;WA&amp;gt; where &amp;lt;cond&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. To read a group of rows from DB table into Internal Table (Array fetch)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT &amp;lt;fields&amp;gt; from &amp;lt;DBTABLE&amp;gt; into TABLE &amp;lt;ITAB&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both 2 and 3 are efficient performance wise.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAP's OPEN SQL, syntax of the SELECT statement&lt;/P&gt;&lt;P&gt;Basic form:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT result FROM source [INTO target] [WHERE condition] [GROUP BY fields] [ORDER BY order].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT clause&lt;/P&gt;&lt;P&gt;Variants:&lt;/P&gt;&lt;P&gt;1. SELECT [SINGLE [FOR UPDATE] DISTINCT] *&lt;/P&gt;&lt;P&gt;2. SELECT [SINGLE [FOR UPDATE] DISTINCT] s1 ... sn&lt;/P&gt;&lt;P&gt;3. SELECT [SINGLE [FOR UPDATE] DISTINCT] (itab)&lt;/P&gt;&lt;P&gt;FROM clause&lt;/P&gt;&lt;P&gt;Variants:&lt;/P&gt;&lt;P&gt;1. ... FROM dbtab&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additions:&lt;/P&gt;&lt;P&gt;1. ... CLIENT SPECIFIED&lt;/P&gt;&lt;P&gt;2. ... BYPASSING BUFFER&lt;/P&gt;&lt;P&gt;3. ... UP TO n ROWS&lt;/P&gt;&lt;P&gt;2. ... FROM (dbtabname)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additions:&lt;/P&gt;&lt;P&gt;1. ... CLIENT SPECIFIED&lt;/P&gt;&lt;P&gt;2. ... BYPASSING BUFFER&lt;/P&gt;&lt;P&gt;3. ... UP TO n ROWS&lt;/P&gt;&lt;P&gt;INTO target&lt;/P&gt;&lt;P&gt;(This form of the FROM clause works only in conjunction with the INTO clause.)&lt;/P&gt;&lt;P&gt;INTO clause&lt;/P&gt;&lt;P&gt;Variants:&lt;/P&gt;&lt;P&gt;1. ... INTO wa&lt;/P&gt;&lt;P&gt;2. ... INTO CORRESPONDING FIELDS OF wa&lt;/P&gt;&lt;P&gt;3. ... INTO (f1, ..., fn)&lt;/P&gt;&lt;P&gt;4. ... INTO TABLE itab&lt;/P&gt;&lt;P&gt;5. ... INTO CORRESPONDING FIELDS OF TABLE itab&lt;/P&gt;&lt;P&gt;6. ... APPENDING TABLE itab&lt;/P&gt;&lt;P&gt;7. ... APPENDING CORRESPONDING FIELDS OF TABLE itab&lt;/P&gt;&lt;P&gt;WHERE clause&lt;/P&gt;&lt;P&gt;Variants:&lt;/P&gt;&lt;P&gt;1. ... WHERE f op g&lt;/P&gt;&lt;P&gt;2. ... WHERE f [NOT] BETWEEN g1 AND g2&lt;/P&gt;&lt;P&gt;3. ... WHERE f [NOT] LIKE g&lt;/P&gt;&lt;P&gt;4. ... WHERE f [NOT] IN (g1, ..., gn)&lt;/P&gt;&lt;P&gt;5. ... WHERE f [NOT] IN itab&lt;/P&gt;&lt;P&gt;6. ... WHERE f IS [NOT] NULL&lt;/P&gt;&lt;P&gt;7. ... WHERE NOT cond&lt;/P&gt;&lt;P&gt;8. ... WHERE cond1 AND cond2&lt;/P&gt;&lt;P&gt;9. ... WHERE cond1 OR cond2&lt;/P&gt;&lt;P&gt;10. ... WHERE (itab)&lt;/P&gt;&lt;P&gt;11. ... WHERE cond AND (itab)&lt;/P&gt;&lt;P&gt;12. ... FOR ALL ENTRIES IN itab WHERE cond&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Operator Meaning&lt;/P&gt;&lt;P&gt;EQ or = equal to&lt;/P&gt;&lt;P&gt;NE or &amp;lt; &amp;gt; not equal to&lt;/P&gt;&lt;P&gt;LT or &amp;lt; less than&lt;/P&gt;&lt;P&gt;LE or &amp;lt; = less than or equal to&lt;/P&gt;&lt;P&gt;GT or &amp;gt; greater than&lt;/P&gt;&lt;P&gt;GE or &amp;gt;= greater than or equal to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GROUP-BY clause&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variants:&lt;/P&gt;&lt;P&gt;1. ... GROUP BY f1 ... fn&lt;/P&gt;&lt;P&gt;2. ... GROUP BY (itab)&lt;/P&gt;&lt;P&gt;ORDER-BY clause&lt;/P&gt;&lt;P&gt;Variants:&lt;/P&gt;&lt;P&gt;1. ... ORDER BY PRIMARY KEY&lt;/P&gt;&lt;P&gt;2. ... ORDER BY f1 ... fn&lt;/P&gt;&lt;P&gt;3. ... ORDER BY (itab)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/62/10a423384746e8bf5f15ccdd36e8b1/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/62/10a423384746e8bf5f15ccdd36e8b1/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm" target="test_blank"&gt;http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.erpgenie.com/abap/example_code.htm" target="test_blank"&gt;http://www.erpgenie.com/abap/example_code.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;_______________________________&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joins are used to fetch data fast from Database tables:&lt;/P&gt;&lt;P&gt;Tables are joined with the proper key fields to fetch the data properly.&lt;/P&gt;&lt;P&gt;If there are no proper key fields between tables don't use Joins;&lt;/P&gt;&lt;P&gt;Important thing is that don't USE JOINS FOR CLUSTER tableslike BSEG and KONV.&lt;/P&gt;&lt;P&gt;Only use for Transparenmt tables.&lt;/P&gt;&lt;P&gt;You can also use joins for the database VIews to fetch the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;JOINS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... FROM tabref1 [INNER] JOIN tabref2 ON cond&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect&lt;/P&gt;&lt;P&gt;The data is to be selected from transparent database tables and/or views determined by tabref1 and tabref2. tabref1 and tabref2 each have the same form as in variant 1 or are themselves Join expressions. The keyword INNER does not have to be specified. The database tables or views determined by tabref1 and tabref2 must be recognized by the ABAP Dictionary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a relational data structure, it is quite normal for data that belongs together to be split up across several tables to help the process of standardization (see relational databases). To regroup this information into a database query, you can link tables using the join command. This formulates conditions for the columns in the tables involved. The inner join contains all combinations of lines from the database table determined by tabref1 with lines from the table determined by tabref2, whose values together meet the logical condition (join condition) specified using ON&amp;gt;cond.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inner join between table 1 and table 2, where column D in both tables in the join condition is set the same:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table 1 Table 2&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;A&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;B&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;C&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;D&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;D&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;E&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;F&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;G&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;H&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;e1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;f1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;g1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;h1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;e2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;f2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;g2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;h2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;e3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;f3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;g3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;h3&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;\ /&lt;/P&gt;&lt;P&gt;\ /&lt;/P&gt;&lt;P&gt;\ /&lt;/P&gt;&lt;P&gt;\ /&lt;/P&gt;&lt;P&gt;\/&lt;/P&gt;&lt;P&gt;Inner Join&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;A&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;B&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;C&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;D&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;D&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;E&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;F&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;G&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;H&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;e1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;f1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;g1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;h1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;e1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;f1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;g1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;h1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;e2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;f2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;g2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;h2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;Output a list of all flights from Frankfurt to New York between September 10th and 20th, 2001 that are not sold out:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: DATE LIKE SFLIGHT-FLDATE,&lt;/P&gt;&lt;P&gt;CARRID LIKE SFLIGHT-CARRID,&lt;/P&gt;&lt;P&gt;CONNID LIKE SFLIGHT-CONNID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT F&lt;SUB&gt;CARRID F&lt;/SUB&gt;CONNID F~FLDATE&lt;/P&gt;&lt;P&gt;INTO (CARRID, CONNID, DATE)&lt;/P&gt;&lt;P&gt;FROM SFLIGHT AS F INNER JOIN SPFLI AS P&lt;/P&gt;&lt;P&gt;ON F&lt;SUB&gt;CARRID = P&lt;/SUB&gt;CARRID AND&lt;/P&gt;&lt;P&gt;F&lt;SUB&gt;CONNID = P&lt;/SUB&gt;CONNID&lt;/P&gt;&lt;P&gt;WHERE P~CITYFROM = 'FRANKFURT'&lt;/P&gt;&lt;P&gt;AND P~CITYTO = 'NEW YORK'&lt;/P&gt;&lt;P&gt;AND F~FLDATE BETWEEN '20010910' AND '20010920'&lt;/P&gt;&lt;P&gt;AND F&lt;SUB&gt;SEATSOCC &amp;lt; F&lt;/SUB&gt;SEATSMAX.&lt;/P&gt;&lt;P&gt;WRITE: / DATE, CARRID, CONNID.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there are columns with the same name in both tables, you must distinguish between them by prefixing the field descriptor with the table name or a table alias.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note&lt;/P&gt;&lt;P&gt;In order to determine the result of a SELECT command where the FROM clause contains a join, the database system first creates a temporary table containing the lines that meet the ON condition. The WHERE condition is then applied to the temporary table. It does not matter in an inner join whether the condition is in the ON or WHEREclause. The following example returns the same solution as the previous one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;Output of a list of all flights from Frankfurt to New York between September 10th and 20th, 2001 that are not sold out:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: DATE LIKE SFLIGHT-FLDATE,&lt;/P&gt;&lt;P&gt;CARRID LIKE SFLIGHT-CARRID,&lt;/P&gt;&lt;P&gt;CONNID LIKE SFLIGHT-CONNID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT F&lt;SUB&gt;CARRID F&lt;/SUB&gt;CONNID F~FLDATE&lt;/P&gt;&lt;P&gt;INTO (CARRID, CONNID, DATE)&lt;/P&gt;&lt;P&gt;FROM SFLIGHT AS F INNER JOIN SPFLI AS P&lt;/P&gt;&lt;P&gt;ON F&lt;SUB&gt;CARRID = P&lt;/SUB&gt;CARRID&lt;/P&gt;&lt;P&gt;WHERE F&lt;SUB&gt;CONNID = P&lt;/SUB&gt;CONNID&lt;/P&gt;&lt;P&gt;AND P~CITYFROM = 'FRANKFURT'&lt;/P&gt;&lt;P&gt;AND P~CITYTO = 'NEW YORK'&lt;/P&gt;&lt;P&gt;AND F~FLDATE BETWEEN '20010910' AND '20010920'&lt;/P&gt;&lt;P&gt;AND F&lt;SUB&gt;SEATSOCC &amp;lt; F&lt;/SUB&gt;SEATSMAX.&lt;/P&gt;&lt;P&gt;WRITE: / DATE, CARRID, CONNID.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note&lt;/P&gt;&lt;P&gt;Since not all of the database systems supported by SAP use the standard syntax for ON conditions, the syntax has been restricted. It only allows those joins that produce the same results on all of the supported database systems:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only a table or view may appear to the right of the JOIN operator, not another join expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only AND is possible in the ON condition as a logical operator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Each comparison in the ON condition must contain a field from the right-hand table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If an outer join occurs in the FROM clause, all the ON conditions must contain at least one "real" JOIN condition (a condition that contains a field from tabref1 amd a field from tabref2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note&lt;/P&gt;&lt;P&gt;In some cases, '*' may be specified in the SELECT clause, and an internal table or work area is entered into the INTO clause (instead of a list of fields). If so, the fields are written to the target area from left to right in the order in which the tables appear in the FROM clause, according to the structure of each table work area. There can then be gaps between table work areas if you use an Alignment Request. For this reason, you should define the target work area with reference to the types of the database tables, not simply by counting the total number of fields. For an example, see below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variant 3&lt;/P&gt;&lt;P&gt;... FROM tabref1 LEFT [OUTER] JOIN tabref2 ON cond&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect&lt;/P&gt;&lt;P&gt;Selects the data from the transparent database tables and/or views specified in tabref1 and tabref2. tabref1 und tabref2 both have either the same form as in variant 1 or are themselves join expressions. The keyword OUTER can be omitted. The database tables or views specified in tabref1 and tabref2 must be recognized by the ABAP-Dictionary.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In order to determine the result of a SELECT command where the FROM clause contains a left outer join, the database system creates a temporary table containing the lines that meet the ON condition. The remaining fields from the left-hand table (tabref1) are then added to this table, and their corresponding fields from the right-hand table are filled with ZERO values. The system then applies the WHERE condition to the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Left outer join between table 1 and table 2 where column D in both tables set the join condition:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table 1 Table 2&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;A&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;B&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;C&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;D&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;D&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;E&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;F&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;G&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;H&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;e1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;f1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;g1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;h1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;e2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;f2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;g2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;h2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;e3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;f3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;g3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;h3&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;\ /&lt;/P&gt;&lt;P&gt;\ /&lt;/P&gt;&lt;P&gt;\ /&lt;/P&gt;&lt;P&gt;\ /&lt;/P&gt;&lt;P&gt;\/&lt;/P&gt;&lt;P&gt;Left Outer Join&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;A&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;B&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;C&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;D&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;D&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;E&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;F&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;G&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;H&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;e1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;f1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;g1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;h1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;e1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;f1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;g1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;h1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;NULL&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;NULL&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;NULL&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;NULL&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;NULL&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;a4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;b4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;c4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;e2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;f2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;g2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;h2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;TD&gt;&lt;HR originaltext="---" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;Output a list of all custimers with their bookings for October 15th, 2001:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: CUSTOMER TYPE SCUSTOM,&lt;/P&gt;&lt;P&gt;BOOKING TYPE SBOOK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT SCUSTOM&lt;SUB&gt;NAME SCUSTOM&lt;/SUB&gt;POSTCODE SCUSTOM~CITY&lt;/P&gt;&lt;P&gt;SBOOK&lt;SUB&gt;FLDATE SBOOK&lt;/SUB&gt;CARRID SBOOK&lt;SUB&gt;CONNID SBOOK&lt;/SUB&gt;BOOKID&lt;/P&gt;&lt;P&gt;INTO (CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,&lt;/P&gt;&lt;P&gt;BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,&lt;/P&gt;&lt;P&gt;BOOKING-BOOKID)&lt;/P&gt;&lt;P&gt;FROM SCUSTOM LEFT OUTER JOIN SBOOK&lt;/P&gt;&lt;P&gt;ON SCUSTOM&lt;SUB&gt;ID = SBOOK&lt;/SUB&gt;CUSTOMID AND&lt;/P&gt;&lt;P&gt;SBOOK~FLDATE = '20011015'&lt;/P&gt;&lt;P&gt;ORDER BY SCUSTOM&lt;SUB&gt;NAME SBOOK&lt;/SUB&gt;FLDATE.&lt;/P&gt;&lt;P&gt;WRITE: / CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,&lt;/P&gt;&lt;P&gt;BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,&lt;/P&gt;&lt;P&gt;BOOKING-BOOKID.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there are columns with the same name in both tables, you must distinguish between them by prefixing the field descriptor with the table name or using an alias.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note&lt;/P&gt;&lt;P&gt;For the resulting set of a SELECT command with a left outer join in the FROM clause, it is generally of crucial importance whether a logical condition is in the ON or WHERE condition. Since not all of the database systems supported by SAP themselves support the standard syntax and semantics of the left outer join, the syntax has been restricted to those cases that return the same solution in all database systems:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only a table or view may come after the JOIN operator, not another join statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only logical operator allowed in the ON condition is AND.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Each comparison in the ON condition must contain a field from the right-hand table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Comparisons in the WHERE condition must not contain a field from the right-hand table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ON condition must contain at least one "real" JOIN condition (a condition in which a field from tabref1 as well as from tabref2 occurs).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note&lt;/P&gt;&lt;P&gt;In some cases, '*' may be specivied as the field list in the SELECT clause, and an internal table or work area is entered in the INTO clause (instead of a list of fields). If so, the fields are written to the target area from left to right in the order in which the tables appear in the llen in der FROM clause, according to the structure of each table work area. There can be gaps between the table work areas if you use an Alignment Request. For this reason, you should define the target work area with reference to the types of the database tables, as in the following example (not simply by counting the total number of fields).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;Example of a JOIN with more than two tables: Select all flights from Frankfurt to New York between September 10th and 20th, 2001 where there are available places, and display the name of the airline.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF WA,&lt;/P&gt;&lt;P&gt;FLIGHT TYPE SFLIGHT,&lt;/P&gt;&lt;P&gt;PFLI TYPE SPFLI,&lt;/P&gt;&lt;P&gt;CARR TYPE SCARR,&lt;/P&gt;&lt;P&gt;END OF WA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * INTO WA&lt;/P&gt;&lt;P&gt;FROM ( SFLIGHT AS F INNER JOIN SPFLI AS P&lt;/P&gt;&lt;P&gt;ON F&lt;SUB&gt;CARRID = P&lt;/SUB&gt;CARRID AND&lt;/P&gt;&lt;P&gt;F&lt;SUB&gt;CONNID = P&lt;/SUB&gt;CONNID )&lt;/P&gt;&lt;P&gt;INNER JOIN SCARR AS C&lt;/P&gt;&lt;P&gt;ON F&lt;SUB&gt;CARRID = C&lt;/SUB&gt;CARRID&lt;/P&gt;&lt;P&gt;WHERE P~CITYFROM = 'FRANKFURT'&lt;/P&gt;&lt;P&gt;AND P~CITYTO = 'NEW YORK'&lt;/P&gt;&lt;P&gt;AND F~FLDATE BETWEEN '20010910' AND '20010920'&lt;/P&gt;&lt;P&gt;AND F&lt;SUB&gt;SEATSOCC &amp;lt; F&lt;/SUB&gt;SEATSMAX.&lt;/P&gt;&lt;P&gt;WRITE: / WA-CARR-CARRNAME, WA-FLIGHT-FLDATE, WA-FLIGHT-CARRID,&lt;/P&gt;&lt;P&gt;WA-FLIGHT-CONNID.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;srinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2007 10:01:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794516#M652204</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-30T10:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: Select statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794517#M652205</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;type select in abap editor and press F1 -&amp;gt; help there u can get a lot of info for select statement and follow same for inner join,..............&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if helpful reward some points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with regards,&lt;/P&gt;&lt;P&gt;Suresh Aluri.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2007 10:03:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794517#M652205</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-30T10:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Select statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794518#M652206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2007 12:56:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794518#M652206</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-30T12:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Select statements</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794519#M652207</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;   &amp;lt;b&amp;gt;Select statements&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from mara &lt;/P&gt;&lt;P&gt;        where spart = 'PA'&lt;/P&gt;&lt;P&gt;          and not ( zatacd = space ) &lt;/P&gt;&lt;P&gt;        order by matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gets information from Confirmed schedule file (EKES) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Illustrates the usage of group by: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;   select ebeln eindt vbeln&lt;/P&gt;&lt;P&gt;            into (po_ebeln, po_eindt, po_vbeln)&lt;/P&gt;&lt;P&gt;            from ekes&lt;/P&gt;&lt;P&gt;            where ebeln = wa_vbfa-vbeln&lt;/P&gt;&lt;P&gt;            group by ebeln eindt vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joining the vendor files (LFA1 and LFB1)&lt;/P&gt;&lt;P&gt;This outputs the fields into a table named TAB&lt;/P&gt;&lt;P&gt; select a1&lt;SUB&gt;sortl a1&lt;/SUB&gt;name1 a1&lt;SUB&gt;name2         a1&lt;/SUB&gt;pstlz  a1&lt;SUB&gt;ort01  a1&lt;/SUB&gt;regio   a1&lt;SUB&gt;pfach           a1&lt;/SUB&gt;land1   a1&lt;SUB&gt;lifnr   a1&lt;/SUB&gt;stras          from lfa1 as a1 join lfb1 as b1                      on a1&lt;SUB&gt;lifnr = b1&lt;/SUB&gt;lifnr                     into tab                   where a1&lt;SUB&gt;lifnr in s_lifnr                     and a1&lt;/SUB&gt;loevm &amp;lt;&amp;gt; 'X'                     and b1&lt;SUB&gt;bukrs in s_bukrs                     and b1&lt;/SUB&gt;loevm &amp;lt;&amp;gt; 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joining MARA and MBEW&lt;/P&gt;&lt;P&gt;the material master and the accounting view by plant  (gets plant cost for an item)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;s_werks for mvke-dwerk obligatory.        " Plant&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select marc&lt;SUB&gt;matnr marc&lt;/SUB&gt;werks marc&lt;SUB&gt;disgr mbew&lt;/SUB&gt;salk3&lt;/P&gt;&lt;P&gt; into table t_marc&lt;/P&gt;&lt;P&gt; from marc join mbew on ( mbew&lt;SUB&gt;bwkey = marc&lt;/SUB&gt;werks and&lt;/P&gt;&lt;P&gt;                         mbew&lt;SUB&gt;matnr = marc&lt;/SUB&gt;matnr )&lt;/P&gt;&lt;P&gt; where werks in s_werks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joining VBAP and VBUP &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This produces a list of open line items &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at itab_vbak.&lt;/P&gt;&lt;P&gt; select&lt;/P&gt;&lt;P&gt;  vbap&lt;SUB&gt;vbeln vbap&lt;/SUB&gt;posnr vbap&lt;SUB&gt;matnr vbap&lt;/SUB&gt;kwmeng vbap&lt;SUB&gt;werks vbap&lt;/SUB&gt;arktx&lt;/P&gt;&lt;P&gt;  into bolines&lt;/P&gt;&lt;P&gt;  from vbap join vbup&lt;/P&gt;&lt;P&gt;  on ( vbap&lt;SUB&gt;vbeln = vbup&lt;/SUB&gt;vbeln and vbap&lt;SUB&gt;posnr = vbup&lt;/SUB&gt;posnr )&lt;/P&gt;&lt;P&gt;  where vbap~vbeln = itab_vbak-vbeln&lt;/P&gt;&lt;P&gt;  and lfsta = 'C'.&lt;/P&gt;&lt;P&gt; endselect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table ITAB_VBAK contains a list of open orders. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Code to demonstrate select command&lt;/P&gt;&lt;P&gt;*Code to demonstrate select into internal table command&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF t_bkpf,&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt; include structure bkpf.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  bukrs LIKE bkpf-bukrs,&lt;/P&gt;&lt;P&gt;  belnr LIKE bkpf-belnr,&lt;/P&gt;&lt;P&gt;  gjahr LIKE bkpf-gjahr,&lt;/P&gt;&lt;P&gt;  bldat LIKE bkpf-bldat,&lt;/P&gt;&lt;P&gt;  monat LIKE bkpf-monat,&lt;/P&gt;&lt;P&gt;  budat LIKE bkpf-budat,&lt;/P&gt;&lt;P&gt;  xblnr LIKE bkpf-xblnr,&lt;/P&gt;&lt;P&gt;  awtyp LIKE bkpf-awtyp,&lt;/P&gt;&lt;P&gt;  awkey LIKE bkpf-awkey,&lt;/P&gt;&lt;P&gt; END OF t_bkpf.&lt;/P&gt;&lt;P&gt;DATA: it_bkpf TYPE STANDARD TABLE OF t_bkpf INITIAL SIZE 0,&lt;/P&gt;&lt;P&gt;      wa_bkpf TYPE t_bkpf.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF t_bseg,&lt;/P&gt;&lt;P&gt;*include structure bseg.&lt;/P&gt;&lt;P&gt;  bukrs     LIKE bseg-bukrs,&lt;/P&gt;&lt;P&gt;  belnr     LIKE bseg-belnr,&lt;/P&gt;&lt;P&gt;  gjahr     LIKE bseg-gjahr,&lt;/P&gt;&lt;P&gt;  buzei     LIKE bseg-buzei,&lt;/P&gt;&lt;P&gt;  mwskz     LIKE bseg-mwskz,         "Tax code&lt;/P&gt;&lt;P&gt;  umsks     LIKE bseg-umsks,         "Special G/L transaction type&lt;/P&gt;&lt;P&gt;  prctr     LIKE bseg-prctr,         "Profit Centre&lt;/P&gt;&lt;P&gt;  hkont     LIKE bseg-hkont,         "G/L account&lt;/P&gt;&lt;P&gt;  xauto     LIKE bseg-xauto,&lt;/P&gt;&lt;P&gt;  koart     LIKE bseg-koart,&lt;/P&gt;&lt;P&gt;  dmbtr     LIKE bseg-dmbtr,&lt;/P&gt;&lt;P&gt;  mwart     LIKE bseg-mwart,&lt;/P&gt;&lt;P&gt;  hwbas     LIKE bseg-hwbas,&lt;/P&gt;&lt;P&gt;  aufnr     LIKE bseg-aufnr,&lt;/P&gt;&lt;P&gt;  projk     LIKE bseg-projk,&lt;/P&gt;&lt;P&gt;  shkzg     LIKE bseg-shkzg,&lt;/P&gt;&lt;P&gt;  kokrs     LIKE bseg-kokrs,&lt;/P&gt;&lt;P&gt; END OF t_bseg.&lt;/P&gt;&lt;P&gt;DATA: it_bseg TYPE STANDARD TABLE OF t_bseg INITIAL SIZE 0,&lt;/P&gt;&lt;P&gt;      wa_bseg TYPE t_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Select directly into an internal table&lt;/P&gt;&lt;P&gt;SELECT bukrs belnr gjahr buzei mwskz umsks prctr hkont xauto koart&lt;/P&gt;&lt;P&gt;       dmbtr mwart hwbas aufnr projk shkzg kokrs&lt;/P&gt;&lt;P&gt;  FROM bseg&lt;/P&gt;&lt;P&gt;  INTO TABLE it_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select directly into an internal table where fields are in a&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;different order or not all fields are specified &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SELECT bukrs belnr gjahr buzei mwskz umsks prctr hkont xauto koart&lt;/P&gt;&lt;P&gt;       dmbtr mwart hwbas aufnr projk shkzg kokrs&lt;/P&gt;&lt;P&gt;  FROM bseg&lt;/P&gt;&lt;P&gt;  INTO CORRESPONDING FIELDS OF TABLE it_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Select... endselect command&lt;/P&gt;&lt;P&gt;SELECT bukrs belnr gjahr buzei mwskz umsks prctr hkont xauto koart&lt;/P&gt;&lt;P&gt;       dmbtr mwart hwbas aufnr projk shkzg kokrs&lt;/P&gt;&lt;P&gt;  FROM bseg&lt;/P&gt;&lt;P&gt;  INTO wa_bseg.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  APPEND wa_bseg TO it_bseg.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Select FOR ALL ENTRIES command&lt;/P&gt;&lt;P&gt;SELECT bukrs belnr gjahr bldat monat budat xblnr awtyp awkey&lt;/P&gt;&lt;P&gt;  UP TO 100 ROWS&lt;/P&gt;&lt;P&gt;  FROM bkpf&lt;/P&gt;&lt;P&gt;  INTO TABLE it_bkpf.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;The FOR ALL ENTRIES comand only retrieves data which matches&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;entries within a particular internal table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT bukrs belnr gjahr buzei mwskz umsks prctr hkont xauto koart&lt;/P&gt;&lt;P&gt;         dmbtr mwart hwbas aufnr projk shkzg kokrs&lt;/P&gt;&lt;P&gt;    FROM bseg&lt;/P&gt;&lt;P&gt;    INTO TABLE it_bseg&lt;/P&gt;&lt;P&gt;    FOR ALL ENTRIES IN it_bkpf&lt;/P&gt;&lt;P&gt;    WHERE bukrs EQ it_bkpf-bukrs AND&lt;/P&gt;&lt;P&gt;          belnr EQ it_bkpf-belnr AND&lt;/P&gt;&lt;P&gt;          gjahr EQ it_bkpf-gjahr.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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;&lt;/P&gt;&lt;P&gt;Kumar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2007 13:22:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-statements/m-p/2794519#M652207</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-30T13:22:08Z</dc:date>
    </item>
  </channel>
</rss>

