Couldn't print header of ALV list

Hi All,
I couldn't print header for the alv list. Code is below.
REPORT ztest123456 .
TYPE-POOLS: slis.
DATA: wa_fieldcat TYPE slis_fieldcat_alv,
      g_t_tfieldcat TYPE slis_t_fieldcat_alv,
      itab1 TYPE STANDARD TABLE OF cdhdr,
      g_t_event TYPE slis_t_event,
      wa_event TYPE slis_alv_event,
      g_pos TYPE i VALUE 1,
      head TYPE slis_t_listheader,
      wa_head TYPE slis_listheader.
START-OF-SELECTION.
  SELECT * FROM cdhdr INTO TABLE itab1
  WHERE objectclas = 'COND_A'
    AND tcode = 'VK12'.
  SORT itab1 BY objectclas.
  wa_head-typ  = 'H'.
  wa_head-info = 'Records in cdhdr table'.
  APPEND wa_head TO head.
  PERFORM sub_fldctlg USING: 'OBJECTCLAS' 'ITAB1' 13 'Object class'.
      FORM sub_fldctlg                                              *
FORM sub_fldctlg USING u_fname TYPE slis_fieldcat_alv-fieldname
                       u_tname TYPE slis_fieldcat_alv-tabname
                       u_outlen TYPE slis_fieldcat_alv-outputlen
                       u_seltext TYPE slis_fieldcat_alv-seltext_l.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = g_pos.          "Column Position
  wa_fieldcat-fieldname = u_fname.      "Field Name
  wa_fieldcat-tabname = u_tname.        "Table Name
  wa_fieldcat-outputlen = u_outlen.     "Output column Length
  wa_fieldcat-seltext_l = u_seltext.    "Column Header
  g_pos = g_pos + 1.                    "Incrementing column position
  APPEND wa_fieldcat TO g_t_tfieldcat.    "Appending field Catalog
ENDFORM.
*&      Form  sub_top
FORM sub_top.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
       EXPORTING
            it_list_commentary = head.
ENDFORM.                    " sub_top
END-OF-SELECTION.
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       IMPORTING
            et_events = g_t_event.
  READ TABLE g_t_event INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.
  IF sy-subrc EQ 0.
    wa_event-form = 'SUB_TOP'.
    MODIFY g_t_event FROM wa_event INDEX sy-tabix.
  ENDIF.
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
   EXPORTING
     i_callback_program             = sy-repid
     it_fieldcat                    = g_t_tfieldcat
     it_events                      = g_t_event
    TABLES
      t_outtab                       = itab1.
Thanks in advance.

Hi,
The issue is resolved. I just pass the program name (SY-REPID) through a variable to the function module that displays list/grid. I came to know that these system variable behavior is UN-predictable in SAP and hence passed program name through a global variable instead of using a system variable value.
Thanks..

Similar Messages

  • Displaying a header on alv list

    hi there,
    i want to display a header on alv list.
    i have already used
    call method alvgrid->set_table_for_first_display
    regrads

    Hi,
    use the TOP_OF_PAGE event and add the event to the IT_EVENTS internal table..
    In the subroutine that is assigned to the event..
    FORM top_of_page.
            CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
              EXPORTING
                it_list_commentary = heading.
    ENDFORM.
    Thanks,
    Naren

  • How to Change Column header in ALV List

    hello,
    is there a way to change the column header/label of an ALV list other than inheriting it from the source table it is bound to?
    thanks,
    sid

    Yes, you can.  If you are using a field catalog, you can change the field labels in your program.
    For example.
      data: fc_tmp type slis_fieldcat_alv .
      clear: fieldcat. refresh: fieldcat.
      clear: fc_tmp.
    <b>  fc_tmp-reptext_ddic    = 'Material Number'.</b>
      fc_tmp-fieldname  = 'MATNR'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '18'.
      fc_tmp-col_pos    = 2.
      append fc_tmp to fieldcat.
    If you are using the MERGE funciton module to get your field catalog, then you just need to loop thru it and change the field which is holding the description, then modify the line of the field catalog.
    REgards,
    Rich Heilman

  • How To Create Header in ALV List Report

    Hi All,
    I want to create a Header for <b>MY ALV List Report</b>!
    How can i achieve the same. It should come above <b>ALV</b>.
    ALV report i had already written and it is coming correctly.
    Heading should look like this:
    <i>1st Line</i>
    <b>PROGRAM NAME: XXXXXX      CLIENT: XXXXXXXXXX   PAGE:XX</b>
    <i>2nd Line</i>
    <b>RUN DATE/TIME: XXXXX - XXXX     REPORT NAME/HEADER</b>
    How can i acheive the same in <b>ALV List Report</b>!
    I am amking use of <b>REUSE_ALV_LIST_DISPLAY</b> Function module.
    Thanks in advance.
    Thanks & Regards,
    Prasad.

    Hi Prasad,
    Use the sample code specified below as the guideline. For more info. refer to the documentation of the FM 'REUSE_ALV_COMMENTARY_WRITE'.
    DATA: first(01) type c,
    events type slis_t_event,
    gt_list_top_of_page type slis_t_listheader,
    ls_event type slis_alv_event.
    initialization.
    call function 'REUSE_ALV_EVENTS_GET'
    EXPORTING
    I_LIST_TYPE = 0
    IMPORTING
    ET_EVENTS = events
    EXCEPTIONS
    LIST_TYPE_WRONG = 1
    OTHERS = 2.
    read table events with key name = 'TOP_OF_PAGE'
    into ls_event.
    if sy-subrc = 0.
    move: 'TOP_OF_PAGE' to ls_event-form.
    append ls_event to events.
    clear ls_event.
    endif.
    End of additions
    Start-of-selection
    START-OF-SELECTION.
    Top-of-page
    TOP-OF-PAGE.
    PERFORM TOP_OF_PAGE.
    FORM TOP_OF_PAGE .
    data: ls_line type slis_listheader.
    if first is initial.
    ls_line-typ = 'S'.
    ls_line-key = 'Run Date :'.
    write: sy-datum to ls_line-key+10 mm/dd/yyyy.
    ls_line-info = 'Billing Date:'.
    write: s_fkdat-low to ls_line-info+15 mm/dd/yyyy.
    ls_line-info+28 = 'To'.
    write s_fkdat-high to ls_line-info+32 mm/dd/yyyy.
    append ls_line to gt_list_top_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = gt_list_top_of_page.
    first = 'N'.
    else.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = gt_list_top_of_page.
    endif.
    ENDFORM. " top_of_page
    <b>Please mark helpful answer.</b>
    Regards,
    Amit Mishra

  • Long header in ALV list

    Hi,
    how to add a long header line ( more than 60 characters ) to an ALV list, please ?
    I tried with filling a table with structure SLIS_T_LISTHEADER, but this only allows lines up to 60 characters...
    thanks,
    Rolf

    Unless you can break it into 2 lines, you're pretty much stuck with the 60 char line.
    I seem to remember we tried doing this using the HTML option for the header, but we found that it was inconsistent and
    not to our liking.  We reverted to 2 lines.

  • Multiple header in ALV list

    hi abapers,
    i got a requirement to disply material no.'s in descending order in lav grid/list both..
    now, when i did sorting of the column, grid is displaying the output fine but in list HEADER IS GETTING PRINTED MULTIPLE TIMES, one for each new matnr [although it gets descendigly sorted],
    below is my code of sorting, could you please expalin why is this happening,. ?? is this compatibiltiy issue ??
    *&      Form  ZF_SORTING
          text
         -->P_I_SORTINFO  text
    FORM zf_sorting USING p_i_sortinfo TYPE slis_t_sortinfo_alv.
      DATA l_sortinfo TYPE slis_sortinfo_alv.
      REFRESH p_i_sortinfo.
      CLEAR l_sortinfo.
    *&-- passing attributes to sort the column
    L_SORTINFO-SPOS = '1'.           " 1 sorting position
      l_sortinfo-fieldname = 'MATNR'.      "fieldname
      l_sortinfo-tabname = 'I_FINAL'.      "final table
      l_sortinfo-down = 'X'.          "enable
      l_sortinfo-group = ' * '.      "DONT REPEAT COMMON ITEM
      APPEND l_sortinfo TO p_i_sortinfo.
    ENDFORM.                    " ZF_SORTING
    *&      Form  zf_display_alv_list
          text
    -->  p1        text
    <--  p2        text
    FORM zf_display_alv_list .
    *&--calling FM to display LIST LAYOUT
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program       = v_progname
          I_CALLBACK_PF_STATUS_SET = 'ZF_PF_STATUS_SET'
          is_layout                = wa_layout
          it_fieldcat              = i_fieldcat
          I_DEFAULT                = 'X'
          it_events                = i_eventcat
          it_sort                  = i_sortinfo
          I_SAVE                   = C_SAVE        "all user/default
          IS_VARIANT               = IT_VARIANT1
        TABLES
          t_outtab                 = i_final
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " zf_display_alv_list
    Please help,

    Hi,
    Did you find a solution for this?, I am also having a similar requirement.
    If you have any work around please share.
    Thanks.

  • Icon in Header of ALV list

    Hello friends,
    I want to display icon in ALV header list.
    Caould you please tell me how can i achieve this.
    Currently instead of icon it is showing as '@5B@'.
    CREATE OBJECT document.
    CALL METHOD document->add_icon
    EXPORTING
    sap_icon = 'ICON_LED_GREEN'.
    ls_header-typ  = 'S'.
    write ICON_LED_GREEN AS ICON TO text_001.
    CONCATENATE 'Aufnr:'
                               p_aufnr
                              text_001
                  INTO ls_header-info.
      APPEND ls_header TO lt_header.
      CLEAR: ls_header.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
       EXPORTING
         it_list_commentary       =  lt_header
        I_LOGO                   =
        I_END_OF_LIST_GRID       =
        I_ALV_FORM               =

    Hi,
    Check this
    w_events-name = 'TOP_OF_PAGE'.
      w_events-form = 'TOP_OF_PAGE'.
      APPEND w_events TO i_events.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = sy-repid
          it_fieldcat        = i_fieldcat
          it_events          = i_events
        TABLES
          t_outtab           = it_data.
    FORM top_of_page.
      WRITE:/ '@08@',"  Green light; positive
              '@09@',"  Yellow light; neutral
              '@0A@'."  Red light; negative
    ENDFORM.                    "top_of_page

  • Display Logo in ALV LIST header

    Hi Experts!!
    I need the logo to be displayed in the header of ALV LIST but not the grid display. I searched for this, and got the results for ALV grid display. Kindly let me know if there's any way of printing the logo in the ALV List display. I hope that's possible with oops.
    Please help me out.
    Thanks and Regards,
    Seenu

    hello srinivas,
    Check the Examples in LIBS trxn,
    see the example One-Line List with Top of Page
    regards,
    Shweta

  • Header in every page of ALV List

    Hi All,
    I am working in ALV list now the requirement is that i have to fetch the data based on inputs given when the report executed. and the values which i gave in the input is printed as header of ALV list.
    I have done everything except that when i am printing the Header it is coming only on the first page but we want it in every page the list spreads. please help me ASAP.
    Regards,
    hrk

    Hi,
    As my knowledge, It can not do the thing you told (you can do this thing with Smartforms). but you can separate your report with a condition to break page. Here an example that you can break page with condition when company code changes or GL account changes.
    firstly, build a sort table:
    FORM sort_build CHANGING pt_sort TYPE slis_t_sortinfo_alv.
    *-- company code
      gs_sort-spos      = 1.
      gs_sort-fieldname = 'BUKRS'.
      gs_sort-tabname   = 'GT_FKONT'.
      gs_sort-up        = 'X'.
      gs_sort-group     = '*'.
      gs_sort-subtot    = 'X'.
      APPEND gs_sort TO gt_sort.
    *-- Account
      gs_sort-spos      = 2.
      gs_sort-fieldname = 'SAKNR'.
      gs_sort-tabname   = 'GT_FKONT'.
      gs_sort-up        = 'X'.
      gs_sort-group     = '*'.
      gs_sort-subtot    = 'X'.
      APPEND gs_sort TO gt_sort.
    ENDFORM.     
    and attach the sorted table to FM:
    FORM alv_list_display TABLES pt_itab
                          USING  pv_pf_status_set
                                 pv_user_command.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program       = gv_repid
          i_callback_user_command  = pv_user_command
          i_callback_pf_status_set = pv_pf_status_set
          is_layout                = gs_layout
          i_save                   = gv_save
          it_excluding             = gt_excluding[]
          is_variant               = gs_variant
          it_events                = gt_events[]
          it_event_exit            = gt_event_exit[]
          it_fieldcat              = gt_fieldcat[]
          *it_sort                  = gt_sort[]*   "sort table
        IMPORTING
          e_exit_caused_by_caller  = gv_exit_caused_by_caller
          es_exit_caused_by_user   = gt_exit_caused_by_user
        TABLES
          t_outtab                 = pt_itab.
    ENDFORM.
    regards,
    Thien
    Edited by: Thien Pham on Dec 1, 2009 2:48

  • Changing the status of heading in ALV

    HI Gurus,
    I am creating a ALV report program. When I execute the statements (with select options and parameters only)
    I get the output selection screen. But the header comes as the report program name like ZRR_ALV_LIST..
    But I need to change this to some other text of my choice.
    Please help me on this.
    Thanks & Regards,
    Gopinath GS.
    Edited by: Gopigs on May 20, 2011 8:35 AM
    Moderator Message: Basic Question.
    Edited by: kishan P on May 20, 2011 12:31 PM

    This is the simple code that I have done.
    REPORT  zrr_alv_list NO STANDARD PAGE HEADING.
    TABLES:anla.
    TYPE-POOLS: slis.
    SELECTION-SCREEN BEGIN OF BLOCK b100 WITH FRAME TITLE text-bl0.
    SELECT-OPTIONS: s_bukrs FOR anla-bukrs,
                    s_anln1 FOR anla-anln1,
                    s_anln2 for anla-anln2.
      PARAMETERS: p_date LIKE anla-erdat.
    SELECTION-SCREEN END OF BLOCK b100.
    When I execute I get the selection screen. But the header of the selection screen gives the report program name 'zrr_alv_list'.
    Instead i need to put up the header as 'ALV LIST DISPLAY'.
    Also one more query I got just now.
    How can I get the current fiscal year end date and default it to the Parameters field p_date??
    Gs.
    Edited by: Gopigs on May 20, 2011 9:00 AM

  • How to print header lines at the top of every page with Alv list display?

    Dear all,
    I need a requirement with printing issue. A program list should be printed with the function reuse_alv_list_display.
    The list has several pages and then can be printed but the header lines appear only first page when they printed. The other pages don't have header lines, they continue with the next record of the list remaining from previous page. I use the alv parameters as below:
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program       = l_repid
          i_callback_pf_status_set = 'ALV_PF_STATUS'
          is_layout                = ls_layo
          it_fieldcat              = lt_fcat
          i_default                = 'X'
          i_save                   = 'A'
          is_variant               = ls_variant
          it_events                = lt_events
        TABLES
          t_outtab                 = lt_data
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
    and lt_events as below:
      ls_event-name = 'END_OF_LIST'.
      ls_event-form = 'ALV_END_OF_LIST'.
      APPEND ls_event TO lt_events.
      ls_event-name = 'END_OF_PAGE'.
      ls_event-form = 'ALV_END_OF_PAGE'.
      APPEND ls_event TO lt_events.
      ls_event-name = 'TOP_OF_LIST'.
      ls_event-form = 'ALV_TOP_OF_LIST'.
      APPEND ls_event TO lt_events.
      ls_event-name = 'TOP_OF_PAGE'.
      ls_event-form = 'ALV_TOP_OF_PAGE'.
      APPEND ls_event TO lt_events.
    So, how can I print header lines for every page?
    Best Regards,

    Hello Saba,
    Your point might be very close to solution.
    Because in the selection screen of the program there are two radio buttons, one of them visits 'REUSE_ALV_COMMENTARY_WRITE' function and the other doesn't. The one which visits has a problem with header liens in every page when printing. But I couldn't find out the solution yet.
    reuse_alv_list_display uses 4 event and of course I call subroutine. There are end_of_list, end_of_page, top_of_list and top_of_page. I use in the subroutine for top_of_page:
      CALL FUNCTION 'LVC_TRANSFER_TO_SLIS'
        EXPORTING
          it_fieldcat_lvc         = gt_fcat
        IMPORTING
          et_fieldcat_alv         = lt_fcat
        EXCEPTIONS
          it_data_missing         = 1
          it_fieldcat_lvc_missing = 2
          OTHERS                  = 3.
      CALL FUNCTION 'REUSE_ALV_LIST_WIDTH_GET'
        EXPORTING
          it_fieldcat = lt_fcat
        IMPORTING
          e_width     = l_width.
    WRITE l_reptx TO l_reptx CENTERED.
      NEW-LINE.
      WRITE: AT (l_width) l_reptx CENTERED.
      SUBTRACT 10 FROM l_width.
      WRITE: AT l_width sy-pagno RIGHT-JUSTIFIED.
        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
          EXPORTING
            it_list_commentary       = lt_header
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
    Do you have other suggestions ?

  • How many lines we can print using Non-alv report list ?

    Hi Experts,
    How many lines we can print using Non-alv report list ?
    regards
    vishnu

    Hi,
    It depends on the page size according to the page size we can set the no. of lines as follows,
    REPORT  program_name   NO STANDARD PAGE HEADING
    LINE-SIZE 290
    LINE-COUNT 65.
    Hope it helps you,
    Regards,
    Abhijit G. Borkar

  • Multiple Lines Header and Records in ALV List

    Dear All,
    I am faced with a wierd user requirement to print multiple line header in ALV. Currently we have a classical report where we are displaying a huge text for example 400 characters in a single cell of a column of the report.
    Now we will have to convert this to ALV report where I need to show that data in a single cell. I am wondering how is it possible in ALV list/grid. Please let me know if you guys have any clue.
    Regards,
    Bikramjit

    Hi,
    Did you find a solution for this?, I am also having a similar requirement.
    If you have any work around please share.
    Thanks.

  • Font is small while printing alv list report

    Hi,
    while printing ALV list report font is too small, can you tell me where i can increase the font size. I tried in GUI font ,In which i can increase the font for GUI, not for ALV priniting . Can any body help me to solve this problem?
    Regards,
    siva kumar

    HI Kushboo,
    I think You are talking about header text in ALV , while printing ALV list i need to increase all the font size.. In fieldcatlog there is no option called Style...for increasing ALV font line item details. Can you tell me which style you are talking about?
    Regards,
    siva kumar

  • How to print two alv lists in one spool request

    Hello,
    I have made a report which has one alv list based on CL_SALV_TABLE and a message box displayed in a splitter container based on SBAL. In dialog mode everything is fine.
    If I run the report in batch mode, I have put the alv table to
    list_display = abap_true.
    For printing the messages I am using FM BAL_DSP_LOG_PRINT. It has this nice parameter
    i_s_list_append = abap_true.
    Unfortunatly the messages are not appended to the alv list, nor are they in the same spool request.
    I think the system will put it only into the first spool request, when the name, the printer, the number of prints and the format are the same and of couse, if the spool request is still open for appenfing (which it is).
    The name and the format are not the same in my case. So I tried to set the name to TEST using the print options of the FM
    ls_print_options-print_ctrl-pri_params-plist = 'TEST'.
    But unfortunately it is not working. No changes to the name, when I run the report in batch mode.
    Who has experiance with that? Why are both lists not in the same spool request? Are my findings right? Why isn't the name changed?
    Thank you for your help,
    Peter

    do 2 times
    perform write_form.
    end do.
    for header u can give condtion in form.
    use if condition in the editor...
    this will help u...
    Reward IF....... <= IF what? Points removed... read [the rules|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement]!
    Regards
    Anbu
    Edited by: Julius Bussche on Jul 17, 2008 7:01 PM

Maybe you are looking for