<?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: Dynamic Selection in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-selection/m-p/3299363#M789694</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Diwakar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Display of flight connections after input of airline and flight number:
PARAMETERS: carr_id TYPE spfli-carrid,
            conn_id TYPE spfli-connid.
 
DATA:       where_clause TYPE  STRING,
            and(4),
            wa_spfli TYPE spfli.
 
IF carr_id IS NOT INITIAL.
  CONCATENATE 'CARRID = ''' carr_id '''' INTO where_clause.
  and = ' AND'.
ENDIF.
IF conn_id IS NOT INITIAL.
  CONCATENATE where_clause and ' CONNID = ''' conn_id ''''
    INTO where_clause.
ENDIF.
SELECT * FROM spfli INTO wa_spfli WHERE (where_clause).
  WRITE: / wa_spfli-carrid, wa_spfli-connid, wa_spfli-cityfrom,
           wa_spfli-cityto, wa_spfli-deptime.
ENDSELECT. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Award points if helpful&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 02 Feb 2008 06:28:50 GMT</pubDate>
    <dc:creator>former_member156446</dc:creator>
    <dc:date>2008-02-02T06:28:50Z</dc:date>
    <item>
      <title>Dynamic Selection</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-selection/m-p/3299361#M789692</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;&lt;/P&gt;&lt;P&gt;Please help in Using dynamic SELECT statements &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Diwakar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Feb 2008 06:25:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-selection/m-p/3299361#M789692</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-02T06:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Selection</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-selection/m-p/3299362#M789693</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;&lt;A href="http://www.sap-img.com/abap/how-can-we-give-dynamic-table-name-in-select-statement.htm" target="test_blank"&gt;http://www.sap-img.com/abap/how-can-we-give-dynamic-table-name-in-select-statement.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/67/93b80914a911d2953c0000e8353423/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/67/93b80914a911d2953c0000e8353423/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dynamic fields in select statement: - &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.saptechies.com/dynamic-fields-in-select-statement/" target="test_blank"&gt;http://www.saptechies.com/dynamic-fields-in-select-statement/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Useful link on dynamic open SQL statements: - &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.susanto.id.au/papers/DynOpenSQL.asp" target="test_blank"&gt;http://www.susanto.id.au/papers/DynOpenSQL.asp&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, declare an internal table with a single text field&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF GT_CONDITION OCCURS 0,&lt;/P&gt;&lt;P&gt;LINE,&lt;/P&gt;&lt;P&gt;END OF GT_CONDITION.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then insert or concatenate in the table the conditions as a text&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;gt_condition-line = &amp;#145;mandt eq &amp;#145;000&amp;#146;&amp;#145;.&lt;/P&gt;&lt;P&gt;append gt_condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: In order to insert the quotations in the field, you&amp;#146;ll need to do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;concatenate &amp;#145;mandt eq&amp;#146; &amp;#145;&amp;#146;&amp;#145;&amp;#146; &amp;#145;000&amp;#146; &amp;#145;&amp;#146;&amp;#145;&amp;#146; into gt_condition-line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the selection can be done as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from table where (gt_condition).&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;&lt;/P&gt;&lt;P&gt;Reward points for helpful answers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Feb 2008 06:27:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-selection/m-p/3299362#M789693</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-02T06:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Selection</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-selection/m-p/3299363#M789694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Diwakar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Display of flight connections after input of airline and flight number:
PARAMETERS: carr_id TYPE spfli-carrid,
            conn_id TYPE spfli-connid.
 
DATA:       where_clause TYPE  STRING,
            and(4),
            wa_spfli TYPE spfli.
 
IF carr_id IS NOT INITIAL.
  CONCATENATE 'CARRID = ''' carr_id '''' INTO where_clause.
  and = ' AND'.
ENDIF.
IF conn_id IS NOT INITIAL.
  CONCATENATE where_clause and ' CONNID = ''' conn_id ''''
    INTO where_clause.
ENDIF.
SELECT * FROM spfli INTO wa_spfli WHERE (where_clause).
  WRITE: / wa_spfli-carrid, wa_spfli-connid, wa_spfli-cityfrom,
           wa_spfli-cityto, wa_spfli-deptime.
ENDSELECT. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Award points if helpful&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Feb 2008 06:28:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-selection/m-p/3299363#M789694</guid>
      <dc:creator>former_member156446</dc:creator>
      <dc:date>2008-02-02T06:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Selection</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-selection/m-p/3299364#M789695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi diwakar,&lt;/P&gt;&lt;P&gt;try this link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw70/helpdata/en/67/93b80914a911d2953c0000e8353423/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw70/helpdata/en/67/93b80914a911d2953c0000e8353423/content.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Feb 2008 06:29:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-selection/m-p/3299364#M789695</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-02T06:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Selection</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-selection/m-p/3299365#M789696</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;The very useful SELECT statement could be fully dynamic from release 6.10 and up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example of a fully dynamic select. &lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT zdany_dynamic_select. &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;We use some parameters to dynamically control the select, this is not very &lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;clever but this is just a test program !!&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETER : p_tabnam TYPE tabname DEFAULT 'SFLIGHT',           &lt;/P&gt;&lt;P&gt;            p_selfl1 TYPE edpline DEFAULT 'CARRID',            &lt;/P&gt;&lt;P&gt;	    p_selfl2 TYPE edpline DEFAULT 'CONNID',            &lt;/P&gt;&lt;P&gt;	    p_selfl3 TYPE edpline DEFAULT 'FLDATE',        &lt;/P&gt;&lt;P&gt;            p_selfl4 TYPE edpline DEFAULT 'PRICE',           &lt;/P&gt;&lt;P&gt;            p_selfl5 TYPE edpline DEFAULT 'CURRENCY',           &lt;/P&gt;&lt;P&gt;            p_where1 TYPE edpline DEFAULT 'PRICE &amp;gt; 300',            &lt;/P&gt;&lt;P&gt;            p_where2 TYPE edpline DEFAULT 'AND CURRENCY = ''EUR'''. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS : &amp;lt;lt_outtab&amp;gt; TYPE ANY TABLE,               &lt;/P&gt;&lt;P&gt;                &amp;lt;ls_outtab&amp;gt; TYPE ANY,                &lt;/P&gt;&lt;P&gt;                &amp;lt;l_fld&amp;gt; TYPE ANY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;DATA: lt_where    TYPE TABLE OF edpline,     &lt;/P&gt;&lt;P&gt;      lt_sel_list TYPE TABLE OF edpline,      &lt;/P&gt;&lt;P&gt;      lt_group    TYPE TABLE OF edpline,      &lt;/P&gt;&lt;P&gt;      l_having    TYPE string,      &lt;/P&gt;&lt;P&gt;      l_wa_name   TYPE string,      &lt;/P&gt;&lt;P&gt;      l_sel_list  TYPE edpline,      &lt;/P&gt;&lt;P&gt;      dref        TYPE REF TO data,      &lt;/P&gt;&lt;P&gt;      itab_type   TYPE REF TO cl_abap_tabledescr,      &lt;/P&gt;&lt;P&gt;      struct_type TYPE REF TO cl_abap_structdescr,      &lt;/P&gt;&lt;P&gt;      elem_type   TYPE REF TO cl_abap_elemdescr,      &lt;/P&gt;&lt;P&gt;      comp_tab    TYPE cl_abap_structdescr=&amp;gt;component_table,      &lt;/P&gt;&lt;P&gt;      comp_fld    TYPE cl_abap_structdescr=&amp;gt;component. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: f_count TYPE i. &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;Creation of the output table including a non standard field, f_count&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;see ABAP FAQ #14 for more information on this topic&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;struct_type ?= cl_abap_typedescr=&amp;gt;describe_by_name( p_tabnam ).&lt;/P&gt;&lt;P&gt;elem_type   ?= cl_abap_elemdescr=&amp;gt;describe_by_name( 'F_COUNT' ).&lt;/P&gt;&lt;P&gt;comp_tab = struct_type-&amp;gt;get_components( ).&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;We remove the unnecessary fields&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT comp_tab INTO comp_fld.   &lt;/P&gt;&lt;P&gt; IF comp_fld-name &amp;lt;&amp;gt; p_selfl1 AND      &lt;/P&gt;&lt;P&gt;    comp_fld-name &amp;lt;&amp;gt; p_selfl2 AND      &lt;/P&gt;&lt;P&gt;    comp_fld-name &amp;lt;&amp;gt; p_selfl3 AND      &lt;/P&gt;&lt;P&gt;    comp_fld-name &amp;lt;&amp;gt; p_selfl4 AND      &lt;/P&gt;&lt;P&gt;    comp_fld-name &amp;lt;&amp;gt; p_selfl5.        &lt;/P&gt;&lt;P&gt;          DELETE TABLE comp_tab WITH TABLE KEY name = comp_fld-name.   &lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;comp_fld-name = 'F_COUNT'.&lt;/P&gt;&lt;P&gt;comp_fld-type = elem_type.&lt;/P&gt;&lt;P&gt;APPEND comp_fld TO comp_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; struct_type = cl_abap_structdescr=&amp;gt;create( comp_tab ).&lt;/P&gt;&lt;P&gt;itab_type   = cl_abap_tabledescr=&amp;gt;create( struct_type ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; l_wa_name = 'l_WA'.&lt;/P&gt;&lt;P&gt;CREATE DATA dref TYPE HANDLE itab_type.&lt;/P&gt;&lt;P&gt;ASSIGN dref-&amp;gt;* TO &amp;lt;lt_outtab&amp;gt;.&lt;/P&gt;&lt;P&gt;CREATE DATA dref TYPE HANDLE struct_type.&lt;/P&gt;&lt;P&gt;ASSIGN dref-&amp;gt;* TO &amp;lt;ls_outtab&amp;gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Creation of the selection fields and the "group by" clause&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;APPEND p_selfl1 TO lt_sel_list.APPEND p_selfl1 TO lt_group.&lt;/P&gt;&lt;P&gt;APPEND p_selfl2 TO lt_sel_list.APPEND p_selfl2 TO lt_group.&lt;/P&gt;&lt;P&gt;APPEND p_selfl3 TO lt_sel_list.APPEND p_selfl3 TO lt_group.&lt;/P&gt;&lt;P&gt;APPEND p_selfl4 TO lt_sel_list.APPEND p_selfl4 TO lt_group.&lt;/P&gt;&lt;P&gt;APPEND p_selfl5 TO lt_sel_list.APPEND p_selfl5 TO lt_group.&lt;/P&gt;&lt;P&gt;APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.&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;creation of the "where" clause&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;APPEND p_where1 TO lt_where.&lt;/P&gt;&lt;P&gt;APPEND p_where2 TO lt_where. &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;Creation of the "having" clause&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;l_having = 'count(*) &amp;gt;= 1'. &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;THE dynamic selectSELECT          (lt_sel_list)  &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     FROM     (p_tabnam)       &lt;/P&gt;&lt;P&gt;     INTO CORRESPONDING FIELDS OF TABLE &amp;lt;lt_outtab&amp;gt;      &lt;/P&gt;&lt;P&gt;     WHERE    (lt_where)       &lt;/P&gt;&lt;P&gt;     GROUP BY (lt_group)       &lt;/P&gt;&lt;P&gt;     HAVING   (l_having)       &lt;/P&gt;&lt;P&gt;     ORDER BY (lt_group). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;display of the results&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;LOOP AT &amp;lt;lt_outtab&amp;gt; ASSIGNING &amp;lt;ls_outtab&amp;gt;.  &lt;/P&gt;&lt;P&gt;   LOOP AT comp_tab INTO comp_fld.      &lt;/P&gt;&lt;P&gt;   ASSIGN COMPONENT comp_fld-name OF STRUCTURE &amp;lt;ls_outtab&amp;gt; TO &amp;lt;l_fld&amp;gt;.     &lt;/P&gt;&lt;P&gt;   WRITE: &amp;lt;l_fld&amp;gt;.   &lt;/P&gt;&lt;P&gt;   ENDLOOP. &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt; SKIP.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Reward Points if found helpfull..&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Cheers,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Chandra Sekhar.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Feb 2008 09:17:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-selection/m-p/3299365#M789696</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-02T09:17:57Z</dc:date>
    </item>
  </channel>
</rss>

