<?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: about selecting data from a db table.... in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/about-selecting-data-from-a-db-table/m-p/3195676#M761500</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi..&lt;/P&gt;&lt;P&gt;suppose p_table is the selection variable containing table name..&lt;/P&gt;&lt;P&gt;then u can rite like this&lt;/P&gt;&lt;P&gt;select  *  into v_table from (p_table).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sample code&lt;/P&gt;&lt;P&gt;data:w_matnr type mara-matnr.&lt;/P&gt;&lt;P&gt;parameter:p_mara type char4 default 'MARA'.&lt;/P&gt;&lt;P&gt;select single matnr into w_matnr from (p_mara)&lt;/P&gt;&lt;P&gt;where matnr = 'BOLT'.&lt;/P&gt;&lt;P&gt;write:w_matnr.&lt;/P&gt;&lt;P&gt;Edited by: Sheeba Bhaskaran on Dec 26, 2007 4:49 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Sheeba Bhaskaran on Dec 26, 2007 4:53 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Dec 2007 11:18:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-12-26T11:18:40Z</dc:date>
    <item>
      <title>about selecting data from a db table....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/about-selecting-data-from-a-db-table/m-p/3195675#M761499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi frienz, in a requirement, if a table name is given in selection screen, data is to be selected from that table. For ex, if MARA is entered in selection screen, data from mara to be selected, if VBAK is selected, fows from VBAK should be selected. Pls guide me on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Suresh....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Dec 2007 10:51:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/about-selecting-data-from-a-db-table/m-p/3195675#M761499</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-26T10:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: about selecting data from a db table....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/about-selecting-data-from-a-db-table/m-p/3195676#M761500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi..&lt;/P&gt;&lt;P&gt;suppose p_table is the selection variable containing table name..&lt;/P&gt;&lt;P&gt;then u can rite like this&lt;/P&gt;&lt;P&gt;select  *  into v_table from (p_table).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sample code&lt;/P&gt;&lt;P&gt;data:w_matnr type mara-matnr.&lt;/P&gt;&lt;P&gt;parameter:p_mara type char4 default 'MARA'.&lt;/P&gt;&lt;P&gt;select single matnr into w_matnr from (p_mara)&lt;/P&gt;&lt;P&gt;where matnr = 'BOLT'.&lt;/P&gt;&lt;P&gt;write:w_matnr.&lt;/P&gt;&lt;P&gt;Edited by: Sheeba Bhaskaran on Dec 26, 2007 4:49 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Sheeba Bhaskaran on Dec 26, 2007 4:53 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Dec 2007 11:18:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/about-selecting-data-from-a-db-table/m-p/3195676#M761500</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-26T11:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: about selecting data from a db table....</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/about-selecting-data-from-a-db-table/m-p/3195677#M761501</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hai,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the example code to select data from database table dynamically:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;report z_dynamic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;type-pools : abap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;field-symbols: &amp;lt;dyn_table&amp;gt; type standard table,&lt;/P&gt;&lt;P&gt;               &amp;lt;dyn_wa&amp;gt;,&lt;/P&gt;&lt;P&gt;               &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: dy_table type ref to data,&lt;/P&gt;&lt;P&gt;      dy_line  type ref to data,&lt;/P&gt;&lt;P&gt;      xfc type lvc_s_fcat,&lt;/P&gt;&lt;P&gt;      ifc type lvc_t_fcat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;selection-screen begin of block b1 with frame.&lt;/P&gt;&lt;P&gt;parameters: p_table(30) type c default 'T001'.&lt;/P&gt;&lt;P&gt;selection-screen end of block b1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  perform get_structure.&lt;/P&gt;&lt;P&gt;  perform create_dynamic_itab.&lt;/P&gt;&lt;P&gt;  perform get_data.&lt;/P&gt;&lt;P&gt;  perform write_out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form get_structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : idetails type abap_compdescr_tab,&lt;/P&gt;&lt;P&gt;       xdetails type abap_compdescr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : ref_table_des type ref to cl_abap_structdescr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Get the structure of the table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  ref_table_des ?= &lt;/P&gt;&lt;P&gt;      cl_abap_typedescr=&amp;gt;describe_by_name( p_table ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     idetails [ ]  =   ref_table_des-&amp;gt;components  [ ].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  loop at idetails into xdetails.&lt;/P&gt;&lt;P&gt;    clear xfc.&lt;/P&gt;&lt;P&gt;    xfc-fieldname = xdetails-name .&lt;/P&gt;&lt;P&gt;    xfc-datatype = xdetails-type_kind.&lt;/P&gt;&lt;P&gt;    xfc-inttype = xdetails-type_kind.&lt;/P&gt;&lt;P&gt;    xfc-intlen = xdetails-length.&lt;/P&gt;&lt;P&gt;    xfc-decimals = xdetails-decimals.&lt;/P&gt;&lt;P&gt;    append xfc to ifc.&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form create_dynamic_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create dynamic internal table and assign to FS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  call method cl_alv_table_create=&amp;gt;create_dynamic_table&lt;/P&gt;&lt;P&gt;               exporting&lt;/P&gt;&lt;P&gt;                  it_fieldcatalog = ifc&lt;/P&gt;&lt;P&gt;               importing&lt;/P&gt;&lt;P&gt;                  ep_table        = dy_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  assign dy_table-&amp;gt;* to &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create dynamic work area and assign to FS&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  create data dy_line like line of &amp;lt;dyn_table&amp;gt;.&lt;/P&gt;&lt;P&gt;  assign dy_line-&amp;gt;* to &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form get_data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Select Data from table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  select * into table &amp;lt;dyn_table&amp;gt;&lt;/P&gt;&lt;P&gt;             from (p_table).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form write_out.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Write out data from table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  loop at &amp;lt;dyn_table&amp;gt; into &amp;lt;dyn_wa&amp;gt;.&lt;/P&gt;&lt;P&gt;    do.&lt;/P&gt;&lt;P&gt;      assign component  sy-index  &lt;/P&gt;&lt;P&gt;         of structure &amp;lt;dyn_wa&amp;gt; to &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;      if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;        exit.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;      if sy-index = 1.&lt;/P&gt;&lt;P&gt;        write:/ &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;      else.&lt;/P&gt;&lt;P&gt;        write: &amp;lt;dyn_field&amp;gt;.&lt;/P&gt;&lt;P&gt;      endif.&lt;/P&gt;&lt;P&gt;    enddo.&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Dec 2007 11:28:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/about-selecting-data-from-a-db-table/m-p/3195677#M761501</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-26T11:28:46Z</dc:date>
    </item>
  </channel>
</rss>

