Dynamic header in ALV

Hi gurus,
header must be populate on change of every new PO Number.
how do i do it in ALV.

Hi
Look at the sample code.
TYPE-POOLS: abap,
            col.
*& Dynamic Table
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
               <dyn_wa>,
               <fs>.
DATA: gt_dyn          TYPE REF TO data,
      gw_dyn          TYPE REF TO data,
      r_table         TYPE REF TO cl_salv_table,
      r_header        TYPE REF TO cl_salv_form_element,
      r_footer        TYPE REF TO cl_salv_form_element,
      r_columns_table TYPE REF TO cl_salv_columns_table,
      r_column_table  TYPE REF TO cl_salv_column_table,
      r_datadescr     TYPE REF TO cl_abap_datadescr,
      r_structdescr   TYPE REF TO cl_abap_structdescr,
      gw_component    TYPE abap_componentdescr,
      gt_component    TYPE abap_component_tab.
START-OF-SELECTION.
  PERFORM build_dynamic_table.
  PERFORM get_data.
END-OF-SELECTION.
  PERFORM display_report.
*&      Form  build_dynamic_table
FORM build_dynamic_table .
  DATA: l_idx    TYPE c,
        l_desc   TYPE char50,
        l_hslxx  TYPE p LENGTH 5 DECIMALS 2,
        lt_color TYPE lvc_t_scol.
Column 1
  r_datadescr ?= cl_abap_datadescr=>describe_by_data( l_desc ).
  gw_component-name = 'COLUMN'.
  gw_component-type = r_datadescr.
  APPEND gw_component TO gt_component.
Column 2 - Types of color for each line
Do not display this column
  r_datadescr ?= cl_abap_datadescr=>describe_by_data( lt_color ).
  gw_component-name = 'COLOR'.
  gw_component-type = r_datadescr.
  APPEND gw_component TO gt_component.
  DO 5 TIMES.
    l_idx = sy-index.
    r_datadescr ?= cl_abap_datadescr=>describe_by_data( l_hslxx ).
    CONCATENATE 'COL' l_idx INTO gw_component-name.
    gw_component-type = r_datadescr.
    APPEND gw_component TO gt_component.
  ENDDO.
  TRY.
      r_structdescr = cl_abap_structdescr=>create( p_components = gt_component ).
    CATCH cx_sy_struct_creation .
      WRITE: / 'CX_SY_STRUCT_CREATION ERROR'.
  ENDTRY.
Fill the table with data from GT_DATA
  CREATE DATA gw_dyn TYPE HANDLE r_structdescr.
  ASSIGN gw_dyn->* TO <dyn_wa>.
  CREATE DATA gt_dyn LIKE STANDARD TABLE OF <dyn_wa>.
  ASSIGN gt_dyn->* TO <dyn_table>.
ENDFORM.                    " build_dynamic_table
*&      Form  get_data
FORM get_data .
select statement
ENDFORM.                    " get_data
*&      Form  display_report
FORM display_report .
  PERFORM display_header.   " Display ALV Header
  PERFORM display_footer.   " DIsplay ALV Footer
  PERFORM fill_data.        " Fill data
  PERFORM set_color.        " Set color
  PERFORM display_list.     " Display the ALV
ENDFORM.                    " display_report
*&      Form  display_header
FORM display_header .
  DATA: lr_grid   TYPE REF TO cl_salv_form_layout_grid.
  CREATE OBJECT lr_grid.
  lr_grid->create_text(
    row    = 1
    column = 1
    text   = 'Header Line 1' ).
  lr_grid->create_text(
    row    = 2
    column = 1
    text   = 'Header Line 2' ).
  r_header = lr_grid.
ENDFORM.                    " display_header
*&      Form  display_footer
FORM display_footer .
  DATA: lr_grid   TYPE REF TO cl_salv_form_layout_grid.
  CREATE OBJECT lr_grid.
  lr_grid->create_text(
    row    = 1
    column = 1
    text   = text-266 ).
  lr_grid->create_text(
    row    = 2
    column = 1
    text   = text-267 ).
  r_footer = lr_grid.
ENDFORM.                    " display_footer
*&      Form  set_color
FORM set_color.
  DATA: lt_color TYPE lvc_t_scol,
        ls_color LIKE LINE OF lt_color,
        l_idx    TYPE sy-tabix.
  FIELD-SYMBOLS: <fs_color>.
  LOOP AT <dyn_table> INTO <dyn_wa>.
    l_idx = sy-tabix.
    ASSIGN COMPONENT 'COLOR' OF STRUCTURE <dyn_wa> TO <fs_color>.
    ls_color-color-col = col_total.
   ls_color-color-col = col_normal.
   ls_color-color-col = col_group.
    APPEND ls_color TO lt_color.
    <fs_color> = lt_color.
    MODIFY <dyn_table> FROM <dyn_wa> INDEX l_idx.
    UNASSIGN: <fs_color>.
  ENDLOOP.
ENDFORM.                    " set_color
*&      Form  display_list
FORM display_list.
  DATA: r_display TYPE REF TO cl_salv_display_settings.
Prepare the internal table for display
  cl_salv_table=>factory(
    EXPORTING
      list_display   = 'X'
    IMPORTING
      r_salv_table   = r_table
    CHANGING
      t_table        = <dyn_table> ).
Set report page title
  r_table->set_top_of_list( r_header ).
Set report footer
  r_table->set_end_of_list( r_footer ).
  r_display = r_table->get_display_settings( ).
r_display->set_vertical_lines( ' ' ).
Assign all the column names
  PERFORM set_column_attr.
Display the report
  r_table->display( ).
ENDFORM.                    " display_list
*&      Form  set_column_attr
FORM set_column_attr.
  DATA: l_idx     TYPE c,
        l_text(4) TYPE c,
        colname   TYPE lvc_fname,
        outps     TYPE scrtext_s,
        outpm     TYPE scrtext_m,
        outpl     TYPE scrtext_l.
  r_columns_table = r_table->get_columns( ).
r_columns_table->set_headers_visible( abap_false ).
column 2
set color column
  r_columns_table->set_color_column( 'COLOR' ).
  DO 5 TIMES.
    l_idx = sy-index.
    CONCATENATE 'COL' l_idx INTO colname.
    outps = colname.
    outpm = colname.
    outpl = colname.
    r_column_table ?= r_columns_table->get_column( colname ).
    r_column_table->set_optimized( value  = abap_true ).
    r_column_table->set_alignment( value  = 1 ).
    r_column_table->set_zero( value  = space ).
    r_column_table->set_short_text( outps ).
    r_column_table->set_medium_text( outpm ).
    r_column_table->set_long_text( outpl ).
  ENDDO.
ENDFORM.                    "set_column_attr
*&      Form  fill_data
FORM fill_data .
  DATA:  l_idx TYPE c,
         l_col  TYPE string.
  DO 5 TIMES.
    l_idx = sy-index.
    CONCATENATE 'COL' l_idx INTO l_col.
    ASSIGN COMPONENT l_col OF STRUCTURE <dyn_wa> TO <fs>.
    <fs> = 0.
    UNASSIGN <fs>.
  ENDDO.
  DO 5 TIMES.
    l_idx = sy-index.
    ASSIGN COMPONENT 'COLUMN' OF STRUCTURE <dyn_wa> TO <fs>.
    CONCATENATE 'Row' l_idx INTO <fs> SEPARATED BY space.
    UNASSIGN <fs>.
    APPEND <dyn_wa> TO <dyn_table>.
  ENDDO.
ENDFORM.                    " fill_data
Hope it helps.

Similar Messages

  • Dynamic Header in ALV output

    Hi All,
    I have requirement like below
    i have company code in the selection screen as select options.
    i need to give the output in such a way that
    suppose the end user given the company code as 100 110 120 then  i need to display in the
    <b>header section</b>
    100 - description
    and in list (body) the should contain the records related to 100(Company code ) only
    in the next page
    <b>header section</b> contains the
    110 - description
    and in the ALV list needs to contain only the records related to 110.
    and so on.
    Please help me how to proceed; I have bit knowledge in container programming.
    Thanks in Advance
    Chand

    Hi,
    I did something very similar to your requirement.
    There is a predefined event for Reuse_alv_list_display called 'BEFORE_LINE_OUTPUT'. In the event table, you have to specify the <event>-name = 'BEFORE_LINE_OUTPUT' and the <event>-form = 'ALV_BEFORE_LINE_OUTPUT'.
    Then you need a form like
    FORM alv_before_line_output
      USING ps_lineinfo TYPE kkblo_lineinfo.                    "#EC CALLED
      FIELD-SYMBOLS:
        <prot> TYPE typ_prot.
      READ TABLE gt_prot INDEX ps_lineinfo-tabindex
        ASSIGNING <prot>.
      CHECK g_file_no <> <prot>-file_no.
      g_file_no = <prot>-file_no.
      NEW-PAGE.
    ENDFORM.                    "alv_before_line_output
    In my program the global table displayed in ALV was gt_prot (of line type typ_prot) and the requirement was to start a new page for each file processed. The form stores the file processed in
    g_file_no. If a new file is processed, a NEW-PAGE will trigger the TOP_OF_PAGE event of the alv. I will not copy the form here because we also issued some statistical values, system and user informations and so on.
    But I hope you get it done.
    The only remaining issue may be that the before_line_output event will cost some time because it is triggered for every output line. But my report was still quite fast.
    regards,
    Clemens

  • Dynamic header in oo-alv

    Hi
    I have a requirement to display  Dynamical  header in ALV.
    I am displaying the SUM of my list in ALV header . This I am able to do , as I can calculate before displaying ALV for the first time.
    But when the user filters the list the SUM should change according to the new entries displayed after filtering .
    How can i do this .
    Line: -
    All the helpful answers will be rewarded for sure.
    Thanks.
    Regards,
    Sandeep.

             fieldname type slis_fieldname,
             tabname type slis_tabname,
             seltext(40),
             valuf(80),
             valut(80),
             valuf_int(80),
             valut_int(80),
             sign0(1),
             sign_icon(4),
             optio(2),
             stype(1),
             decimals like dfies-decimals,
             intlen like dfies-intlen,
             convexit like dfies-convexit,
             edit_mask type slis_edit_mask,
             lowercase like dfies-lowercase,
             inttype like dfies-inttype,
             datatype like dfies-datatype,
             exception(1) type c,
             no_sign(1) type c,
             or(1) type c,
             order type order,
             cqvalue(5) type c,
             ref_fieldname like dfies-fieldname,
             ref_tabname like dfies-tabname,
             ddic_outputlen like dfies-outputlen,
    The following are the example code for filter settings.
              lv_filter-fieldname = u2018FIELDNAMEu2019.
              lv_filter-valuf_int =  u2018VALUEu2019.
              lv_filter-sign0     = u2018SIGNu2019.
              lv_filter-optio     = u2018OPTIONu2019.
              APPEND lv_filter TO gt_filter_list.
    Where gt_filter_list is of type slis_t_filter_alv.
    This populated internal table is then passed as the import parameter u2018it_filteru2019 of the display ALV FM.
    I hope this help u...!

  • Dynamic header in oo alv print_top_of_page based on current line

    I would expect this to be a common problem with the solution easily to google/find, but somehow...
    dynamic header generation during alv print_top_of_page:
    - i print an oo alv grid, sorted by kunnr
    - for each new kunnr a new page
    -> now I want during print-out to: at each top of page, read the first (or any) line of the current page, i.e. the current kunnr, and select data on basis of that kunnr to be written to the header.
    My problem is that sy-tabix is not being filled correctly (always 1).
    Strange thing is that in another report with a non-dynamic itab to display, sy-tabix is actuall being filled more or less correctly. (with the minor drawback that on the first page the tabix might not be 1 but more likely to be 2; but that's easy to fix and for the next pages sy-tabix is correct)
    Kind regards, A
    baanbrecher

    In the handle_print_top_of_page method, use :
    FIELD-SYMBOLS : <lv_line> TYPE ANY.
    ASSIGN ('(SAPLKKBL)G_INDEX') TO <lv_line>.
    if <lv_line> = 0. "First time, G_INDEX is equal to zero
       <lv_line> = 1.
    endif.
    So in <lv_line> you will always have the good index of your table.

  • ALV Dynamic header

    LAYOUT FORMAT
    Program Title
    Client Name     Run Date/Time :
    Program            : Program Name
    User ID              : Page                  : X of Y
    Pernr:                                                            
    Name:
    IC Number:
    RBAF / Reference Number:
    Rank:
    Service:
    Unit:
    Sub Unit:
    No.|  Position| Leave Taken| From|Leave Taken To| Type of Leave|
    Leave Entitlement| No. Of Leave Taken|     Present Balance of Leave|
    Please help to program dynamic alv header for above format. I have used page break on Pernr but the header is not coming according to pernr. Though I managed
    dynamic header when we press Print Preview. But that is not a solution.

    Hi,
    I did something very similar to your requirement.
    There is a predefined event for Reuse_alv_list_display called 'BEFORE_LINE_OUTPUT'. In the event table, you have to specify the <event>-name = 'BEFORE_LINE_OUTPUT' and the <event>-form = 'ALV_BEFORE_LINE_OUTPUT'.
    Then you need a form like
    FORM alv_before_line_output
      USING ps_lineinfo TYPE kkblo_lineinfo.                    "#EC CALLED
      FIELD-SYMBOLS:
        <prot> TYPE typ_prot.
      READ TABLE gt_prot INDEX ps_lineinfo-tabindex
        ASSIGNING <prot>.
      CHECK g_file_no <> <prot>-file_no.
      g_file_no = <prot>-file_no.
      NEW-PAGE.
    ENDFORM.                    "alv_before_line_output
    In my program the global table displayed in ALV was gt_prot (of line type typ_prot) and the requirement was to start a new page for each file processed. The form stores the file processed in
    g_file_no. If a new file is processed, a NEW-PAGE will trigger the TOP_OF_PAGE event of the alv. I will not copy the form here because we also issued some statistical values, system and user informations and so on.
    But I hope you get it done.
    The only remaining issue may be that the before_line_output event will cost some time because it is triggered for every output line. But my report was still quite fast.
    regards,
    Clemens

  • Dynamic selection in ALV report

    Hi Guru's
    I have cpoied a standatrd program(RFBILA00) into Z-program.
    I need to display the profit centre from dynamic selection in ALV header  output when profit centre is selected.If not no need to display it.
    Please do the needful.
    Thanks,
    Sunil.

    hi,
    Refer to the link,
    http://www.abapcode.info/2007/06/dynamic-selection-on-alv-at-run-time.html
    This may help you.
    Regards
    Sumit Aagrwal

  • Display a dynamic header

    Dear Vinod,
    IMHO i don't think this is a spec dumping. I did try to search and even tried hands on it. Unfortunately i didn't get any luck with that.
    Morever i'm not asking for any spoon feeding...It's just about some pointer's or any ideas that would help me.
    Hope that clarifies much better.
    Thanks in advance,
    Arya.
    My selection screen has a parameter P_WEEK.
    Suppose if user enter's a week no for ex: 5. My ALV header should display as
    Week5  Week6  Week7  Week8  Week9  Week10
    i.e. Up to next 5 weeks. How to design a ALV that would display a dynamic header?
    Any ideas or suggestion would be of great help.
    Thanks,
    Arya
    Moderator message : Search for available information. Moved to basic(points-free) forum.
    Edited by: Vinod Kumar on Oct 19, 2011 3:37 PM
    Edited by: arya.soumya on Oct 19, 2011 12:22 PM
    Edited by: Suhas Saha on Oct 19, 2011 4:08 PM

    Hi,
    you just try to write below logic in TOP-OF-PAGE routine in your program.
    parameter: p_week(3) type c.
    Form top_of_page .
    do p_week times.
    pass the required data to your internal table and append it.
    enddo.
    Endform.
    Ram.

  • Dynamic Header help in PDF Portfolio

    Need some help please, to create and load a Dynamic Header when creating a PDF Portfolio in LiveCycle ES2.  Have input parameter of a [name] and an [image file] to place in the Header.  Process flowing out of Assembler (PDF Generator).  Currently other PDFs being inserted within the Portfolio, and Navigation parameter being received ok, and setting up custom navigation.  Any help w/ creating Dynamic Header is very much appreciated.

    By "Dynamic Header" do you mean the PDF cover page, or the interactive portfolio navigator?
    If its the cover page then it should be a fairly easy thing to do.  You can create a form (XDP or PDF template) with a field for the name and one for the image.  Then you would use something like LC Forms or Form Data Integration to merge the data (image and name) with the template.
    The one thing you would have to do is to put the image and data into an XML format before you merge it with the form. That means you will need to convert the image to a base64 encoded format.  Fortunately there is a built in function for doing the conversion in a SetValue operation (its under Document Object Functions).
    If you are talking about the Navigator (portfolio shell) then it gets a bit more tricky.  The navigator is actually a Flex application and not a PDF.  You'll have to code a new one using Flash Builder, then import the resulting .nav file into your LiveCycle application. Merging the data with it is not something I've done before, but it should be possible (the LiveCycle Interactive Statement Solution Accelerator does something similar).
    If it is new navigator you need, check out some of the following links:
    http://joelgeraci.com/adobe/devjunkie/web/portfolios_p1_outer.shtml
    http://acrobatusers.com/tutorials/modifying-pdf-portfolio-navigator
    http://acrobatusers.com/navigator-contest-faq  (for the development software links)

  • SSRS 2008 R2 - Dynamic header data stays the same when exporting

    Background:
    I have a SSRS 2008 R2 report with a single Tablix.
    The data is grouped by InvoiceID, with each appearing on a separate page.
    I'm displaying some of the detail data in the group header row using Expressions similar to the following:
    ="Invoice # "  & ReportItems!InvoiceID.Value"
    The data referred to by my ReportItems statements are all hidden in the detail row (Advanced Mode, the Hidden Value for the Static Row Group is set to false).
    Problem:
    When I Preview the report in Visual Studio, everything looks as it should - the dynamic header data changes correctly with each group.
    However, whenever I export the results (I've tried all the formats), the header data is the same for every group - its taking the values from the first group and using it in all the groups.
    I've copied the same expressions into my Totals row, and the data is correct when exported; its only happening in my header rows.
    Any help in resolving this is greatly appreciated, thank you.

    Hi Alex,
    According to your description, you have a header with expression contains ReportItems. Now you find it shows incorrect result when exporting to a file. Right?
    In Reporting Services, it has reported some similar issue that the ReportItem returns unexpected result when exporting.  In this scenario, since you just want to show the group name in each page as a header for detail rows. So you can make the
    detail rows group on the Group. Then delete the Group column but still keep the group. After that add a row above detail row (Out side of group) and put in "=Fields!InvoiceID.Value". Now it will show the corresponding Group name
    when you set page break between each group instance. We have tested this case in our local environment. Here are screenshots for your reference:
    Reference:
    SSRS
    field expressions using ReportItem refrences have unexpected results when exporting
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Variable Text not working as dynamic header in Crystal report

    Dear Experts,
    I'm working Crystal report that connected to Query BEX SAP BW trough SAP integration kit,
    currently i have case that need report dynamic header using variable text from BEX query, but seem the variable text not working in Crystal reports. the header in Crystal report shown as Desription\technical name, not result from the variable text in Query BEX in SAP.
    In https://wiki.sdn.sap.com/wiki/display/BOBJ/Crystal%20Reports%20and%20BW%20query%20elements stated that the "Text variable" with "replacement path" is supported, but i don't know in my query is not working.
    i already set in Database -> options->  table and fields -> Show Both, but the text variable still not working.
    can you help me
    Crystal Reports 2008 12.2.0.290
    SAP Integration KIT 12.1.0.890
    Thanks
    Luqman

    Post your question BEX and B1 and classic SAP data source issues to the Integration Kit forum

  • Dynamic Header for a website.    DOUBLE POINTS FOR ANSWER!!

    I don't even know where to start with this one, let me try explain this:
    I am looking for ideas on how to create some sort of dynamic header for an affiliate website, we have launched a new affiliate program for http://www.africancures.com/ the affiliate program is done through 1shoppingcart.com and each affiliate is given an ID like:
    http://www.1shoppingcart.com/app/?af=812264
    Once the affiliate signs up they choose their own website URL like: mikeshealth.com, then we point the affiliate URL mikeshealth.com to http://www.1shoppingcart.com/app/?af=812264 which in turn comes to our main website: http://www.africancures.com/ now here is where the problem comes in, how do I make the website display Mikes Health instead of African Cures .
    I hope I was able to explain this well enough as it seems to be a bit confusing to me when I write it down. I really hope there is someone out there who has worked on something like this before or if there is someone who thinks they know how to do this.
    Thank you
    So here is something else I was thinking of, but I am not much of a programmer anymore:
    Have a list of all the affiliate ids and their corresponding website names, eg:
    Affiliate ID=812264 Website name= Mikes Health, then when someone comes to the site the jave works out which affiliate id sent them to the site, eg
    Get(AffiliateID)from Refering.URL then Display.Header(AffiliateID) on main page, do you think you could help me now Sabre150?

    I'm still trying to see what this has to do with Java. Each host name such as mikeshealth.com will need to be registered with name servers with the IP address of www.1shoppingcart.com. Your web server will then need to be configured to perform perform any mapping.
    Again, what has this to do with Java?

  • Dynamic header / footer

    Hi all,
    I created an Adobe Form and defined on the MasterPage a header, a footer and a main area (content are) in-between. The areas were defined with a fixed size (somehow it was the only way because "fit height" and "fit width" was innactive).
    Because the form is used in different countries the amount of information in the different areas is not the same. Therefore I am looking for a dynamic header and footer (and main area). That should help to optimise the space exploitation on a page. The header should grow from top of the page down, the footer bottom up and the main area fill the gap.
    I know that this is a very sophisticated demand. Nevertheless, I hope that someone else had similar ideas and could solve that task.
    I appreciate any help, hints and good advices which leads to a solution of my problem.
    Thanks & regards,
    Phil

    Hi Andres,
    thanks a lot for your quick answer!
    In your MasterPage, add only the items that will remain static during the execution.
    Every object that will behave in a dynamic manner should go in the BodyPage.
    Very good hint, thanks!
    What you can do is set a Subform with flowed Western Text between your Header/Footer
    (Static) of your MasterPage. Within that main Subform set three more, "Western Text" as well.
    One will be for your Dynamic Header, the middle one for your Main and the bottom one for your
    Dynamic Footer.
    I think I did not really get it! As far as I understand this works for one page...my form - when filled with data - can have more than one page!
    Some questions came up when I read your solution:
    1) why is the flowed content "western text" and not "top to bottom"?
    2) what happens exactly with the area of the static header / footer? It's above the dynamic header and below dynamic footer -> is that space not wasted in the end?
    3) The dynamic footer is directly below the main area - not necessarily at the bottom of the page!?
    4)  How is the "pagination" defined for each of the three dynamic areas (header / main / footer)?
    I hope you'll find the time to answer my question soon!
    Thanks & regards,
    Phil

  • Multiple Heading in ALV Grid

    Hello ,
    I have a requirement to display Multiple heading in ALV Grid, I am using the Class 'cl_gui_alv_grid'. please let me know if you have Any suggestions.
    Ex:
    |                 Divison                     |     
    Sub D:1
    Sub D: 2
    Sub D: 3
        Like wise i have few more divisions to display and Under we need to display the Sub Division also .
    Thanks in Advance..  Waiting for your suggestions.
    With Best Regards
    Nags

    Hi,
    I had attempted to do it in the object oriented way, but found no ready solution, so I settled for the below solution.
    Please use the function REUSE_ALV_COMMENTARY_WRITE.
    This allows you to print multiple lines in the header.
    I had a requirement of showing 5 lines in the header.
    So i went on like:
    DATA: it_list_commentary TYPE slis_t_listheader,
               wa_list_commentary TYPE slis_listheader.
    wa_list_commentary-typ = 'H'.
    wa_list_commentary-info = <text>.
    APPEND wa_list_commentary TO it_list_commentary.
    wa_list_commentary-typ = 'S'.
    wa_list_commentary-info = <text>.
    APPEND wa_list_commentary TO it_list_commentary.
    I fed he internal table with all 5 lines like above.
    Finally I called the function.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = it_list_commentary.
    Regards,
    Prosenjit.
    Edited by: prosenjit chaudhuri on Jan 28, 2009 6:14 AM

  • Section Break conflicts with Dynamic Header in RTF which loads XML data

    Hi,
    I have dynamic header in my rtf file which loads data from XML generated by rdf file.
    I have section break on start group of body. but it does not display dynamic header value. If i remove section break then it display dynamic header.
    I have to display dynamic header and section break is also required there.
    Please give me solution of this issue.
    Regards
    Farooq
    Edited by: user8849418 on Jun 27, 2012 12:05 AM

    flyeminent wrote:
    However in my particular case, the dynamic list is not known until the user choose to view a table. Then move the call from the getter to the bean's action method.

  • Dynamic sort in ALV

    hi all,
    HOw can we write the dynamic sort in ALV.
    regards,
    AJ

    Hi,
    Please find the sample code for dynamic sort in OO ALV
      perform built_sort_table.
    form built_sort_table.
      data ls_sort_wa type lvc_s_sort.
      ls_sort_wa-spos = 1.
      ls_sort_wa-fieldname = 'MATNR'.    "<< here your pass fieldname to sort dynamically
      ls_sort_wa-up = selected.
      ls_sort_wa-subtot = ''.
      append ls_sort_wa to gt_sort.
      ls_sort_wa-spos = 2.
      ls_sort_wa-fieldname = 'STATUS'.  "<< here your pass fieldname to sort dynamically
      ls_sort_wa-up = selected.
      ls_sort_wa-subtot = ''.
      append ls_sort_wa to gt_sort.
    endform.                               " BUILT_SORT_TABLE
        call method grid1->set_table_for_first_display
          exporting
            is_layout                     = gs_layout
            is_variant                    = gs_variant
            i_save                        = 'A'
            it_toolbar_excluding          = i_exclude[]
          changing
            it_outtab                     = i_output[]
            it_fieldcatalog               = i_fieldcat[]
            it_sort                       = gt_sort[]
          exceptions
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            others                        = 4.
    aRs

Maybe you are looking for