<?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: getting column headers dynamically from input parameters in alv. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950829#M1488669</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;U&gt;Step 2&lt;/U&gt;: Display the dynamic table as an ALV using the factory method of SALV:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* Create the ALV using the Factory Method
  cl_salv_table=&amp;gt;factory(
  IMPORTING
    r_salv_table = lr_alv
  CHANGING
    t_table      = &amp;lt;fs_tab&amp;gt; ).

  DATA: lr_functions TYPE REF TO cl_salv_functions_list.

  lr_functions = lr_alv-&amp;gt;get_functions( ).
  lr_functions-&amp;gt;set_default( abap_true ).

  DATA: lr_columns TYPE REF TO cl_salv_columns.

  lr_columns = lr_alv-&amp;gt;get_columns( ).
  lr_columns-&amp;gt;set_optimize( abap_true ).

  PERFORM set_column_names USING lr_columns.

  lr_alv-&amp;gt;display( ).
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  SET_COLUMN_NAMES
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM set_column_names
  USING ir_columns TYPE REF TO cl_salv_columns.

  DATA: lr_column TYPE REF TO cl_salv_column,
        lt_column TYPE salv_t_column_ref,
        ls_column TYPE salv_s_column_ref,
        lv_coltxt TYPE scrtext_m.

  lt_column = ir_columns-&amp;gt;get( ).

  LOOP AT lt_column INTO ls_column.
    lv_coltxt = ls_column-columnname.
    REPLACE ALL OCCURRENCES OF '_' IN lv_coltxt WITH ` `.
    ls_column-r_column-&amp;gt;set_medium_text( lv_coltxt ).
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Jun 2010 12:43:59 GMT</pubDate>
    <dc:creator>SuhaSaha</dc:creator>
    <dc:date>2010-06-03T12:43:59Z</dc:date>
    <item>
      <title>getting column headers dynamically from input parameters in alv.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950825#M1488665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am new to abap, can any one help me in getting column header dynamically through parameters in alv ?&lt;/P&gt;&lt;P&gt;Eg:-&lt;/P&gt;&lt;P&gt;i Have parametars for days field ,&lt;/P&gt;&lt;P&gt;user inputs days as 10 20 30 40.&lt;/P&gt;&lt;P&gt;Now I want to display in alv column headers as:-&lt;/P&gt;&lt;P&gt;1st column-  'FROM 0 TO 10' &lt;/P&gt;&lt;P&gt;2nd column- 'FROM 10 TO 20 '&lt;/P&gt;&lt;P&gt;3rd column- 'FROM 20 TO 30'&lt;/P&gt;&lt;P&gt;4th column- 'FROM 30 TO 40'&lt;/P&gt;&lt;P&gt;5th column- 'FROM 40 TO 50'&lt;/P&gt;&lt;P&gt;6th column- 'FROM 50 TO 60'&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, 03 Jun 2010 09:01:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950825#M1488665</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-03T09:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: getting column headers dynamically from input parameters in alv.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950826#M1488666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Deven&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Welcome to SDN&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u will get the values to want to diplay in column header fill those values in a work area and display as following&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; WA_FIELDCAT-ROW_POS    = 1.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-COL_POS    = 9.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-FIELDNAME  = 'W_DAY1'.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-TABNAME    = 'IT_OUTPUT'.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-COLTEXT    = WA_WEEK-DAY1. *dynamic header as per value&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-OUTPUTLEN  = 09.&lt;/P&gt;&lt;P&gt;  APPEND WA_FIELDCAT TO IT_FIELDCAT.&lt;/P&gt;&lt;P&gt;  CLEAR WA_FIELDCAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-ROW_POS    = 1.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-COL_POS    = 10.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-FIELDNAME  = 'W_DAY2'.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-TABNAME    = 'IT_OUTPUT'.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-COLTEXT    = WA_WEEK-DAY2. *dynamic header as per value&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-OUTPUTLEN  = 09.&lt;/P&gt;&lt;P&gt;  APPEND WA_FIELDCAT TO IT_FIELDCAT.&lt;/P&gt;&lt;P&gt;  CLEAR WA_FIELDCAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-ROW_POS    = 1.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-COL_POS    = 11.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-FIELDNAME  = 'W_DAY3'.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-TABNAME    = 'IT_OUTPUT'.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-COLTEXT    = WA_WEEK-DAY3. *dynamic header as per value&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-OUTPUTLEN  = 09.&lt;/P&gt;&lt;P&gt;  APPEND WA_FIELDCAT TO IT_FIELDCAT.&lt;/P&gt;&lt;P&gt;  CLEAR WA_FIELDCAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-ROW_POS    = 1.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-COL_POS    = 12.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-FIELDNAME  = 'W_DAY4'.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-TABNAME    = 'IT_OUTPUT'.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-COLTEXT    = WA_WEEK-DAY4. *dynamic header as per value&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-OUTPUTLEN  = 09.&lt;/P&gt;&lt;P&gt;  APPEND WA_FIELDCAT TO IT_FIELDCAT.&lt;/P&gt;&lt;P&gt;  CLEAR WA_FIELDCAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-ROW_POS    = 1.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-COL_POS    = 13.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-FIELDNAME  = 'W_DAY5'.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-TABNAME    = 'IT_OUTPUT'.&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-COLTEXT    = WA_WEEK-DAY5. *dynamic header as per value&lt;/P&gt;&lt;P&gt;  WA_FIELDCAT-OUTPUTLEN  = 09.&lt;/P&gt;&lt;P&gt;  APPEND WA_FIELDCAT TO IT_FIELDCAT.&lt;/P&gt;&lt;P&gt;  CLEAR WA_FIELDCAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: gaurav.singh on Jun 3, 2010 11:19 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jun 2010 09:18:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950826#M1488666</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-03T09:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: getting column headers dynamically from input parameters in alv.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950827#M1488667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Deven,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to create the column header by concatenating the parameters and then pass it to the field catalog as follows :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g. If user enters,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;param1  = 10&lt;/P&gt;&lt;P&gt;param2  = 20&lt;/P&gt;&lt;P&gt;param3  = 30&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use, &lt;/P&gt;&lt;P&gt;CONCATENATE  'FROM'  '0'     'TO' param1 INTO var1 SEPARATED BY space.&lt;/P&gt;&lt;P&gt;CONCATENATE  'FROM'  param1  'TO' param2 INTO var2 SEPARATED BY space.&lt;/P&gt;&lt;P&gt;CONCATENATE  'FROM'  param2  'TO' param3 INTO var3 SEPARATED BY space. and so on....&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pass every header to field catalog  ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_fieldcat_brand_org-fieldname = &amp;lt;fieldname&amp;gt;.&lt;/P&gt;&lt;P&gt;wa_fieldcatalog-seltext_l =  var1.&lt;/P&gt;&lt;P&gt;APPEND wa_fieldcatalog to it_fieldcatalog.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;wa_fieldcat_brand_org-fieldname = &amp;lt;fieldname&amp;gt;.&lt;/P&gt;&lt;P&gt;wa_fieldcatalog-seltext_l =  var2.&lt;/P&gt;&lt;P&gt;APPEND wa_fieldcatalog to it_fieldcatalog.&lt;/P&gt;&lt;P&gt;.......&lt;/P&gt;&lt;P&gt;wa_fieldcat_brand_org-fieldname = &amp;lt;fieldname&amp;gt;.&lt;/P&gt;&lt;P&gt;wa_fieldcatalog-seltext_l =  var3.&lt;/P&gt;&lt;P&gt;APPEND wa_fieldcatalog to it_fieldcatalog.     and so on....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;V Joshi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jun 2010 09:32:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950827#M1488667</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-03T09:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: getting column headers dynamically from input parameters in alv.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950828#M1488668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this code snippet: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Step 1&lt;/U&gt;: Create a dynamic table based on the input in the selection screen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TYPE-POOLS: abap.

DATA:
  lr_structdescr    TYPE REF TO cl_abap_structdescr,
  lr_tabledescr     TYPE REF TO cl_abap_tabledescr,
  lr_datadescr      TYPE REF TO cl_abap_datadescr,
  lt_components     TYPE abap_component_tab,
  ls_component      TYPE abap_componentdescr,
  lr_wa             TYPE REF TO data,
  lr_tab            TYPE REF TO data.

DATA: lv_index TYPE sy-index.
DATA: lv_index_num(5) TYPE n.
DATA: lv_index_char(5) TYPE c,
      lv_iter TYPE i,
      lv_low TYPE numc2 VALUE 0,
      lv_high TYPE numc2 VALUE 10.


DATA: lr_alv TYPE REF TO cl_salv_table.

FIELD-SYMBOLS: &amp;lt;fs_field&amp;gt; TYPE ANY.
FIELD-SYMBOLS: &amp;lt;fs_wa&amp;gt; TYPE ANY.
FIELD-SYMBOLS: &amp;lt;fs_tab&amp;gt; TYPE table.

PARAMETERS p_numcol(2) TYPE n DEFAULT 50.

START-OF-SELECTION.

  lv_iter = p_numcol DIV 10.

  DO lv_iter TIMES.

    IF sy-index &amp;gt; 1.
      lv_low = lv_low + 10.
      lv_high = lv_high + 10.
    ENDIF.

    lv_index_num = sy-index.
    lv_index_char = lv_index_num.
    CONCATENATE 'FROM' lv_low 'TO' lv_high INTO ls_component-name
    SEPARATED BY '_'.
    ls_component-type =
    cl_abap_elemdescr=&amp;gt;get_p( p_length = 10 p_decimals = 2 ).
    INSERT ls_component INTO TABLE lt_components.
  ENDDO.

* get structure descriptor -&amp;gt; lr_STRUCTDESCR
  lr_structdescr
  = cl_abap_structdescr=&amp;gt;create( p_components = lt_components
                                 p_strict = space ).

* create work area of structure lr_STRUCTDESCR -&amp;gt; lr_WA
  CREATE DATA lr_wa TYPE HANDLE lr_structdescr.
  ASSIGN lr_wa-&amp;gt;* TO &amp;lt;fs_wa&amp;gt;.

  lr_datadescr = lr_structdescr.
  lr_tabledescr
  = cl_abap_tabledescr=&amp;gt;create( lr_datadescr ).

* Create dynamic internal table
  CREATE DATA lr_tab TYPE HANDLE lr_tabledescr.
  ASSIGN lr_tab-&amp;gt;* TO &amp;lt;fs_tab&amp;gt;.


* Populate the internal table
  DO 10 TIMES.
    DO.
      lv_index = sy-index.
      ASSIGN COMPONENT  lv_index  OF STRUCTURE &amp;lt;fs_wa&amp;gt; TO &amp;lt;fs_field&amp;gt;.
      IF sy-subrc &amp;lt;&amp;gt; 0.
        EXIT.
      ENDIF.
      &amp;lt;fs_field&amp;gt; = sy-index.
    ENDDO.
    APPEND &amp;lt;fs_wa&amp;gt; TO &amp;lt;fs_tab&amp;gt;.
  ENDDO.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jun 2010 12:40:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950828#M1488668</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-06-03T12:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: getting column headers dynamically from input parameters in alv.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950829#M1488669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;U&gt;Step 2&lt;/U&gt;: Display the dynamic table as an ALV using the factory method of SALV:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* Create the ALV using the Factory Method
  cl_salv_table=&amp;gt;factory(
  IMPORTING
    r_salv_table = lr_alv
  CHANGING
    t_table      = &amp;lt;fs_tab&amp;gt; ).

  DATA: lr_functions TYPE REF TO cl_salv_functions_list.

  lr_functions = lr_alv-&amp;gt;get_functions( ).
  lr_functions-&amp;gt;set_default( abap_true ).

  DATA: lr_columns TYPE REF TO cl_salv_columns.

  lr_columns = lr_alv-&amp;gt;get_columns( ).
  lr_columns-&amp;gt;set_optimize( abap_true ).

  PERFORM set_column_names USING lr_columns.

  lr_alv-&amp;gt;display( ).
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  SET_COLUMN_NAMES
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM set_column_names
  USING ir_columns TYPE REF TO cl_salv_columns.

  DATA: lr_column TYPE REF TO cl_salv_column,
        lt_column TYPE salv_t_column_ref,
        ls_column TYPE salv_s_column_ref,
        lv_coltxt TYPE scrtext_m.

  lt_column = ir_columns-&amp;gt;get( ).

  LOOP AT lt_column INTO ls_column.
    lv_coltxt = ls_column-columnname.
    REPLACE ALL OCCURRENCES OF '_' IN lv_coltxt WITH ` `.
    ls_column-r_column-&amp;gt;set_medium_text( lv_coltxt ).
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jun 2010 12:43:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950829#M1488669</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2010-06-03T12:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: getting column headers dynamically from input parameters in alv.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950830#M1488670</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;ur suggestion solve dmy problem........&lt;/P&gt;&lt;P&gt;thanks a lot.&lt;/P&gt;&lt;P&gt;loking forward for more inputs from u..&lt;/P&gt;&lt;P&gt;thanks again..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Jun 2010 04:40:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950830#M1488670</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-06-04T04:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: getting column headers dynamically from input parameters in alv.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950831#M1488671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i ve a same question but i need to concatenate the select option low and high value , how do i do that . &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Sep 2016 09:30:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/getting-column-headers-dynamically-from-input-parameters-in-alv/m-p/6950831#M1488671</guid>
      <dc:creator>bilal_zafar</dc:creator>
      <dc:date>2016-09-06T09:30:54Z</dc:date>
    </item>
  </channel>
</rss>

