<?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: Display header for dynamic table using cl_salv in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/display-header-for-dynamic-table-using-cl-salv/m-p/6557727#M1430734</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Loop thru dynamic structure named idetails, &lt;/P&gt;&lt;P&gt;I query against table DD03VT to get the short text, medium text and long text for each field in structure and set colum text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If someone know a better way please share.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:&lt;/P&gt;&lt;P&gt;          xdetails type abap_compdescr,&lt;/P&gt;&lt;P&gt;          xfname   type lvc_fname,&lt;/P&gt;&lt;P&gt;          xftext   type string,&lt;/P&gt;&lt;P&gt;          s_text   type scrtext_s,&lt;/P&gt;&lt;P&gt;          m_text   type scrtext_m,&lt;/P&gt;&lt;P&gt;          l_text   type scrtext_l.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; loop at idetails into xdetails.&lt;/P&gt;&lt;P&gt;    xfname = xdetails-name .&lt;/P&gt;&lt;P&gt;    select single scrtext_s scrtext_m scrtext_l&lt;/P&gt;&lt;P&gt;      from dd03vt into&lt;/P&gt;&lt;P&gt;      (s_text, m_text, l_text)&lt;/P&gt;&lt;P&gt;      where ( tabname = p_table and&lt;/P&gt;&lt;P&gt;            fieldname = xfname  and&lt;/P&gt;&lt;P&gt;            ddlanguage = 'EN' ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    try.&lt;/P&gt;&lt;P&gt;        lr_column ?= lr_columns-&amp;gt;get_column(&lt;/P&gt;&lt;P&gt;                columnname = xfname ).&lt;/P&gt;&lt;P&gt;        lr_column-&amp;gt;set_short_text( value = s_text ).&lt;/P&gt;&lt;P&gt;        lr_column-&amp;gt;set_medium_text( value = m_text ).&lt;/P&gt;&lt;P&gt;        lr_column-&amp;gt;set_long_text( value = l_text ).&lt;/P&gt;&lt;P&gt;      catch cx_salv_not_found into gr_error.&lt;/P&gt;&lt;P&gt;    endtry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 Feb 2010 16:23:04 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-02-19T16:23:04Z</dc:date>
    <item>
      <title>Display header for dynamic table using cl_salv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/display-header-for-dynamic-table-using-cl-salv/m-p/6557724#M1430731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it possible to display header of dynamic table using cl_salv.  In my program, I create a dynamic structure based on user input of the table name and display as ALV report.  &lt;/P&gt;&lt;P&gt;However the header is missing because the structure does not use DDICT.  Is there a way to display header text without any hard coding because of the dynamic structure? Here is my code:&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT z_dynamic.&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;data : idetails type abap_compdescr_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data: gr_table type ref to cl_salv_table.&lt;/P&gt;&lt;P&gt;data: gr_functions type ref to cl_salv_functions.&lt;/P&gt;&lt;P&gt;data: lr_text type ref to cl_salv_form_text.&lt;/P&gt;&lt;P&gt;data: lr_label type ref to cl_salv_form_label.&lt;/P&gt;&lt;P&gt;data: lr_grid type ref to cl_salv_form_layout_grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; parameters: p_table(30) type c default 'ZXX'.      "Table name&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 display.&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:&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;  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.                    "create_dynamic_itab&lt;/P&gt;&lt;P&gt;&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 corresponding fields of  table &amp;lt;dyn_table&amp;gt;&lt;/P&gt;&lt;P&gt;     from (p_table) up to 10 rows.&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 display.&lt;/P&gt;&lt;P&gt;try.&lt;/P&gt;&lt;P&gt;      cl_salv_table=&amp;gt;factory(&lt;/P&gt;&lt;P&gt;          exporting list_display   = abap_false&lt;/P&gt;&lt;P&gt;          importing r_salv_table   = gr_table&lt;/P&gt;&lt;P&gt;          changing  t_table        = &amp;lt;dyn_table&amp;gt; ).&lt;/P&gt;&lt;P&gt;    catch cx_salv_msg .&lt;/P&gt;&lt;P&gt;  endtry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  gr_functions = gr_table-&amp;gt;get_functions( ).&lt;/P&gt;&lt;P&gt;  gr_functions-&amp;gt;set_all( abap_true ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; CREATE OBJECT lr_grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  lr_label = lr_grid-&amp;gt;create_label(&lt;/P&gt;&lt;P&gt;               text   = 'Table Info'&lt;/P&gt;&lt;P&gt;               row    = 1&lt;/P&gt;&lt;P&gt;               column = 1 ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  lr_text = lr_grid-&amp;gt;create_text(&lt;/P&gt;&lt;P&gt;              text   = '1.2 TEXT'&lt;/P&gt;&lt;P&gt;              row    = 1&lt;/P&gt;&lt;P&gt;              column = 2 ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  lr_label-&amp;gt;set_label_for( lr_text ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  lr_text = lr_grid-&amp;gt;create_text(&lt;/P&gt;&lt;P&gt;              text   = '2.2 TEXT'&lt;/P&gt;&lt;P&gt;              row    = 2&lt;/P&gt;&lt;P&gt;              column = 2 ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  gr_table-&amp;gt;set_top_of_list( lr_grid ).&lt;/P&gt;&lt;P&gt;  gr_table-&amp;gt;display( ). &lt;/P&gt;&lt;P&gt;endform.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Feb 2010 18:25:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/display-header-for-dynamic-table-using-cl-salv/m-p/6557724#M1430731</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-18T18:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Display header for dynamic table using cl_salv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/display-header-for-dynamic-table-using-cl-salv/m-p/6557725#M1430732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Solved it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Feb 2010 19:59:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/display-header-for-dynamic-table-using-cl-salv/m-p/6557725#M1430732</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-18T19:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: Display header for dynamic table using cl_salv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/display-header-for-dynamic-table-using-cl-salv/m-p/6557726#M1430733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great that you solved it, but please share what you did.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Feb 2010 16:17:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/display-header-for-dynamic-table-using-cl-salv/m-p/6557726#M1430733</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-19T16:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Display header for dynamic table using cl_salv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/display-header-for-dynamic-table-using-cl-salv/m-p/6557727#M1430734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Loop thru dynamic structure named idetails, &lt;/P&gt;&lt;P&gt;I query against table DD03VT to get the short text, medium text and long text for each field in structure and set colum text.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If someone know a better way please share.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:&lt;/P&gt;&lt;P&gt;          xdetails type abap_compdescr,&lt;/P&gt;&lt;P&gt;          xfname   type lvc_fname,&lt;/P&gt;&lt;P&gt;          xftext   type string,&lt;/P&gt;&lt;P&gt;          s_text   type scrtext_s,&lt;/P&gt;&lt;P&gt;          m_text   type scrtext_m,&lt;/P&gt;&lt;P&gt;          l_text   type scrtext_l.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; loop at idetails into xdetails.&lt;/P&gt;&lt;P&gt;    xfname = xdetails-name .&lt;/P&gt;&lt;P&gt;    select single scrtext_s scrtext_m scrtext_l&lt;/P&gt;&lt;P&gt;      from dd03vt into&lt;/P&gt;&lt;P&gt;      (s_text, m_text, l_text)&lt;/P&gt;&lt;P&gt;      where ( tabname = p_table and&lt;/P&gt;&lt;P&gt;            fieldname = xfname  and&lt;/P&gt;&lt;P&gt;            ddlanguage = 'EN' ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    try.&lt;/P&gt;&lt;P&gt;        lr_column ?= lr_columns-&amp;gt;get_column(&lt;/P&gt;&lt;P&gt;                columnname = xfname ).&lt;/P&gt;&lt;P&gt;        lr_column-&amp;gt;set_short_text( value = s_text ).&lt;/P&gt;&lt;P&gt;        lr_column-&amp;gt;set_medium_text( value = m_text ).&lt;/P&gt;&lt;P&gt;        lr_column-&amp;gt;set_long_text( value = l_text ).&lt;/P&gt;&lt;P&gt;      catch cx_salv_not_found into gr_error.&lt;/P&gt;&lt;P&gt;    endtry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Feb 2010 16:23:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/display-header-for-dynamic-table-using-cl-salv/m-p/6557727#M1430734</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-02-19T16:23:04Z</dc:date>
    </item>
  </channel>
</rss>

