Printing problem in ALV report.

Hi,
I have made an ALV report using 'REUSE_ALV_LIST_DISPLAY' FM. There are 18 coloumns in this report which i want to print in A4 paper. Thses all coloumns are printing but the font size is too small and also printing start from left most i.e. no margin for FILING. How to increase font size and left margin for filing. Kindly suggest.
Regards,
Rajesh Vasudeva

Hi
The font size depends on the format you've choosen for the print.
The abap list arranges the page as grid: colunmXrow.
Every colunm of a page means a character.
If you use the standard format X_65_200, it means you're page is arranged for 65 row and 200 colunm:
that means the size of a character is optimized to can print 200 chararcter in a A4 page.
If you use the standard format X_65_132 it means you're page is arranged for 65 row and132 colunm:
that means the size of a character is optimized to can print 132 chararcter in a A4 page.
So that mean the size of format X_65_132 will be bigger than X_65_200, because in the same space (page A4) it needs to write 132 char instead of 200.
If your report print NN char, u should use the format wiith number colunm is closer to NN.
If there isn't a format or u use the first available format or u create a new one by trx SPAD.
Max

Similar Messages

  • Problem in ALV report

    Hi Friends,
    I have the following 2 problems in ALV report
    1) Logo is not getting displayed in the report.
    2) When i click on the Purchase order number in the report  the interactive report is not working,i am not able to see report of First interactive level.
    can you help it out friends.
    Thanks and regards
    Dinesh
    REPORT  YSDBALV1
    tables: ekko , ekpo .
    type-pools: slis .
    Table for Display Header
    data:i_header type slis_t_listheader with header line.
    *Fieldcat Declaration
    data:fieldcatalog type slis_T_fieldcat_alv  WITH HEADER LINE.
    *Table of Events
    data:i_event type slis_t_event with header line .
    For Layout
    data:i_layout type slis_layout_alv .
    data: text(30) .
    *Internal Table Declaration
    data: begin of it_final occurs 0 ,
          ebeln like ekko-ebeln ,           "Purchasing Document No.
          bedat like ekko-bedat ,           "Purchasing Document Date
          matnr like ekpo-matnr ,           "Material No.
          netwr like ekpo-netwr ,         "Net Order Value in PO Currancy
          meins like ekpo-meins ,           "UOM
          chk(1) ,
          light(1) ,
          change like ekpo-menge ,
          end of it_final .
    **select option Declaration
    selection-screen begin of block block.
    select-options: s_ebeln for ekko-ebeln  .
    selection-screen end of block block .
    selection-screen begin of block block1 .
    parameters:grid radiobutton group r .
    parameters:list radiobutton group r .
    selection-screen end of block block1 .
    at selection screen
    at selection-screen .
    select single * from ekko where ebeln in s_ebeln .
    if sy-subrc <> 0 .
       message e000(8I) WITH 'No Data Exists' .
    endif .
    start-of-selection .
    if grid = 'X' .
    perform get_data .
    perform event using i_event[] .
    perform field using fieldcatalog[] .
    perform layout using i_layout .
    perform grid_display .
    endif .
    *&      Form  get_data
          text
    -->  p1        text
    <--  p2        text
    form get_data .
    *DATA Retrieval from tables
    SELECT EKKO~EBELN
           EKKO~BEDAT
           EKPO~EBELP
           EKPO~MATNR
           EKPO~NETWR
           EKPO~MEINS
           EKPO~MENGE
           EKPO~BPRME
           INTO CORRESPONDING FIELDS OF  table IT_FINAL
           FROM EKKO INNER JOIN EKPO ON EKKOEBELN = EKPOEBELN
           WHERE EKKO~EBELN IN S_EBELN.
           APPEND IT_FINAL.
    endform.                    " get_data
    *Getting the Event for Top of Page display.
    *&      Form  event
          text
         -->P_I_event[]  text
    form event  using    p_i_event type slis_t_event.
      clear p_i_event .
      refresh p_i_event .
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
       I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = p_i_event
    EXCEPTIONS
       LIST_TYPE_WRONG       = 1
       OTHERS                = 2
    read table p_i_event with key name = slis_ev_top_of_page into i_event.
          if sy-subrc = 0.
                 move 'TOP_OF_PAGE_PO' to i_event-form.
                 modify p_i_event from i_event index sy-tabix transporting form.
          endif.
          clear i_event.
    endform.                    " event
    *Display Top-of –Page Details and Logo
    form top_of_page_po .
           clear i_header .
           refresh i_header .
           write sy-datum to text.
           i_header-typ = 'H'.
           i_header-info = 'PURCHASE OREDER DETAILS'.
           append i_header.
          *Logo Display
          CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
                 EXPORTING
                     it_list_commentary       = i_header[]
                     I_LOGO                   = 'ENJOYSAPLOGO'.
    endform .
    *Field Catalog Append
    *&      Form  field
          text
         -->P_fieldCATALOG[]  text
    form field using  p_fieldcatalog type slis_t_fieldcat_alv.
         clear fieldcatalog.
          fieldcatalog-fieldname   = 'EBELN'.
          fieldcatalog-seltext_m   = 'Purchase Order No'.
          fieldcatalog-col_pos     = 1.
          append fieldcatalog .
          clear fieldcatalog.
          fieldcatalog-fieldname   = 'BEDAT'.
          fieldcatalog-seltext_m   = 'PO Date'.
          fieldcatalog-col_pos     = 2.
          append fieldcatalog .
          clear fieldcatalog.
          fieldcatalog-fieldname   = 'MATNR'.
          fieldcatalog-seltext_m   = 'Material No'.
          fieldcatalog-col_pos     = 4.
          fieldcatalog-outputlen   = 20.
          append fieldcatalog .
          clear fieldcatalog.
          fieldcatalog-fieldname   = 'NETWR'.
          fieldcatalog-seltext_m   = 'Net Value '.
          fieldcatalog-col_pos     = 5.
          fieldcatalog-outputlen   = 20.
          fieldcatalog-do_sum = 'X'.
          append fieldcatalog .
          clear fieldcatalog.
          fieldcatalog-fieldname   = 'MEINS'.
          fieldcatalog-seltext_m   = 'Units'.
          fieldcatalog-col_pos     = 6.
          fieldcatalog-outputlen   = 4.
          append fieldcatalog .
          clear fieldcatalog.
    endform.                    " field
    *&      Form  layout
          text
    form layout  using    p_i_layout TYPE SLIS_LAYOUT_ALV .
    i_layout-zebra  = 'X'.
        i_layout-lights_fieldname = 'LIGHT'.
        i_layout-lights_tabname = 'IT_FINAL'.
        i_layout-box_fieldname = 'CHK'.
        i_layout-box_tabname  = 'IT_FINAL'.
        i_layout-edit = ' '.
    endform.
    *To display Buttons in the MENU BAR if needed
    FORM SET_PO_PF_STATUS USING  P_I_EXTAB TYPE
                     SLIS_T_EXTAB.
                     SET PF-STATUS 'MENUPO'.
      ENDFORM.
    *Event for Interactive display of ALV report
    form USER_COMMAND  using r_ucomm like sy-ucomm
                             rs_selfield type slis_selfield .
      if r_ucomm = '&IC1'.
      READ TABLE IT_FINAL  index   rs_selfield-tabindex.
      write:/ IT_FINAL-ebeln.
      endif.
    endform .
    *Parameters of FM  REUSE_ALV_GRID_DISPLAY
    *&      Form  grid_display
          text
    -->  p1        text
    <--  p2        text
    form grid_display .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM                = SY-REPID
       I_CALLBACK_PF_STATUS_SET          = 'SET_PO_PF_STATUS'
        I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
        IS_LAYOUT                         = I_LAYOUT
        IT_FIELDCAT                       = FIELDCATALOG[]
        IT_EVENTS                         = I_EVENT[]
      TABLES
        t_outtab                          = IT_FINAL.
    endform.                    " grid_display

    *& Report  YSDBALV1
    REPORT  YSDBALV1.
    tables: ekko , ekpo .
    type-pools: slis .
    Table for Display Header
    data:i_header type slis_t_listheader with header line.
    *Fieldcat Declaration
    data:fieldcatalog type slis_T_fieldcat_alv WITH HEADER LINE.
    *Table of Events
    data:i_event type slis_t_event with header line ,
         wa_event type line of slis_t_event.
    For Layout
    data:i_layout type slis_layout_alv .
    data: text(30) .
    *Internal Table Declaration
    data: begin of it_final occurs 0 ,
    ebeln like ekko-ebeln , "Purchasing Document No.
    bedat like ekko-bedat , "Purchasing Document Date
    matnr like ekpo-matnr , "Material No.
    netwr like ekpo-netwr , "Net Order Value in PO Currancy
    meins like ekpo-meins , "UOM
    chk(1) ,
    light(1) ,
    change like ekpo-menge ,
    end of it_final .
    **select option Declaration
    selection-screen begin of block block.
    select-options: s_ebeln for ekko-ebeln .
    selection-screen end of block block .
    selection-screen begin of block block1 .
    parameters:grid radiobutton group r .
    parameters:list radiobutton group r .
    selection-screen end of block block1 .
    at selection screen
    at selection-screen .
    select single * from ekko where ebeln in s_ebeln .
    if sy-subrc <> 0 .
    message e000(8I) WITH 'No Data Exists' .
    endif .
    start-of-selection .
    if grid = 'X' .
    perform get_data .
    perform event using i_event[] .
    perform field using fieldcatalog[] .
    perform layout using i_layout .
    perform grid_display .
    endif .
    *& Form get_data
    text
    --> p1 text
    <-- p2 text
    form get_data .
    *DATA Retrieval from tables
    SELECT EKKO~EBELN
    EKKO~BEDAT
    EKPO~EBELP
    EKPO~MATNR
    EKPO~NETWR
    EKPO~MEINS
    EKPO~MENGE
    EKPO~BPRME
    INTO CORRESPONDING FIELDS OF table IT_FINAL
    FROM EKKO INNER JOIN EKPO ON EKKOEBELN = EKPOEBELN
    WHERE EKKO~EBELN IN S_EBELN.
    APPEND IT_FINAL.
    endform. " get_data
    *Getting the Event for Top of Page display.
    *& Form event
    text
    -->P_I_event[] text
    form event using p_i_event type slis_t_event.
    clear p_i_event .
    refresh p_i_event .
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
    I_LIST_TYPE = 0
    IMPORTING
    ET_EVENTS = p_i_event.
    EXCEPTIONS
    LIST_TYPE_WRONG = 1
    OTHERS = 2.
    read table p_i_event with key name = slis_ev_top_of_page into wa_event.
    if sy-subrc = 0.
    move 'TOP_OF_PAGE_PO' to i_event-form.
    modify p_i_event from i_event index sy-tabix transporting form.
    endif.
    clear i_event.
    endform. " event
    *Display Top-of –Page Details and Logo
    form top_of_page_po .
    clear i_header .
    refresh i_header .
    write sy-datum to text.
    i_header-typ = 'H'.
    i_header-info = 'PURCHASE OREDER DETAILS'.
    append i_header.
    *Logo Display
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = i_header[]
    I_LOGO = 'ENJOYSAP_LOGO'.
    endform .
    *Field Catalog Append
    *& Form field
    text
    -->P_fieldCATALOG[] text
    form field using p_fieldcatalog type slis_t_fieldcat_alv.
    clear fieldcatalog.
    fieldcatalog-fieldname = 'EBELN'.
    fieldcatalog-seltext_m = 'Purchase Order No'.
    fieldcatalog-col_pos = 1.
    append fieldcatalog .
    clear fieldcatalog.
    fieldcatalog-fieldname = 'BEDAT'.
    fieldcatalog-seltext_m = 'PO Date'.
    fieldcatalog-col_pos = 2.
    append fieldcatalog .
    clear fieldcatalog.
    fieldcatalog-fieldname = 'MATNR'.
    fieldcatalog-seltext_m = 'Material No'.
    fieldcatalog-col_pos = 4.
    fieldcatalog-outputlen = 20.
    append fieldcatalog .
    clear fieldcatalog.
    fieldcatalog-fieldname = 'NETWR'.
    fieldcatalog-seltext_m = 'Net Value '.
    fieldcatalog-col_pos = 5.
    fieldcatalog-outputlen = 20.
    fieldcatalog-do_sum = 'X'.
    append fieldcatalog .
    clear fieldcatalog.
    fieldcatalog-fieldname = 'MEINS'.
    fieldcatalog-seltext_m = 'Units'.
    fieldcatalog-col_pos = 6.
    fieldcatalog-outputlen = 4.
    append fieldcatalog .
    clear fieldcatalog.
    endform. " field
    *& Form layout
    text
    form layout using p_i_layout TYPE SLIS_LAYOUT_ALV .
    i_layout-zebra = 'X'.
    i_layout-lights_fieldname = 'LIGHT'.
    i_layout-lights_tabname = 'IT_FINAL'.
    i_layout-box_fieldname = 'CHK'.
    i_layout-box_tabname = 'IT_FINAL'.
    i_layout-edit = ' '.
    endform.
    *To display Buttons in the MENU BAR if needed
    FORM SET_PO_PF_STATUS USING P_I_EXTAB TYPE
    SLIS_T_EXTAB.
    SET PF-STATUS 'MENUPO'.
    ENDFORM.
    *Event for Interactive display of ALV report
    form USER_COMMAND using r_ucomm like sy-ucomm
    rs_selfield type slis_selfield .
    if r_ucomm = '&IC1'.
    READ TABLE IT_FINAL index rs_selfield-tabindex.
    set parameter id 'VL1' field it_final-ebeln.
    call transaction 'ME23N'.
    endif.
    endform .
    *Parameters of FM REUSE_ALV_GRID_DISPLAY
    *& Form grid_display
    text
    --> p1 text
    <-- p2 text
    form grid_display .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    I_CALLBACK_PF_STATUS_SET = 'SET_PO_PF_STATUS'
    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
    IS_LAYOUT = I_LAYOUT
    IT_FIELDCAT = FIELDCATALOG[]
    IT_EVENTS = I_EVENT[]
    TABLES
    t_outtab = IT_FINAL.
    endform. " grid_display
    Regards,
    Rusidar S.

  • 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

  • Problem in Print Out of ALV report

    Dear All..
    I am trying to take print out of an ALV report. there are 36 columns in my report. when i try to take print out, warning appears which says system cannot print the last 277 columns of report.
    i have tried using different formats for printer like :
    Format                  Description
    X_PAPER                 ABAP/4 list: Default list formatting
    X_SPOOLERR          ABAP list: Spooler problem report
    ZX_65_284               65 Rows and 285 Columns
    X_65_255                ABAP/4 list: At least 65 rows with a maximum number of c
    X_65_200                ABAP list: at least 65 lines with 200 columns (not for a
    X_58_170                ABAP/4 list: At least 58 rows by 170 columns
    X_65_132                ABAP list: At least 65 rows by 132 columns
    X_90_120                ABAP list: At least 90 rows by 120 columns
    X_44_120                ABAP/4 list: At least 44 rows by 120 columns
    X_65_80                 ABAP/4 list: At least 65 rows by 80 columns
    but every time the same message appears even on A3 size paper..
    i am using REUSE_ALV_GRID_DISPLAY to display ALV.
    Please help to to take out prints(can be in condensed mode) so that all columns appear on the print out..

    HI sujeet,
    Thanks for ur response. i had already checked the printer settings.. i think there is no problem with this. Can u Please suggest something else. thanks
    Hiii jyojit..
    Thanks for reply. I had already checked the said check box in spool admin. but the problem still exists. Please suggest something to get rid of the problem.

  • Problem in ALV report printing

    Hi,
    I am facing issue while printing the ALV report. The no. of columns in output are dynamic.
    System is giving the printout for 9 columns . If no. of columns are increasing than its printing only one line with garbage values.
    Can anybody help to fix this issue. We need print of 27 (3 static + 24 dynamic (for 12 months)) columns in one go.
    Thanks in advance,
    Vijeta
    Moderator message - Moved to the correct forum
    Edited by: Rob Burbank on Jun 9, 2009 9:30 AM

    Hi
    The font size depends on the format you've choosen for the print.
    The abap list arranges the page as grid: colunmXrow.
    Every colunm of a page means a character.
    If you use the standard format X_65_200, it means you're page is arranged for 65 row and 200 colunm:
    that means the size of a character is optimized to can print 200 chararcter in a A4 page.
    If you use the standard format X_65_132 it means you're page is arranged for 65 row and132 colunm:
    that means the size of a character is optimized to can print 132 chararcter in a A4 page.
    So that mean the size of format X_65_132 will be bigger than X_65_200, because in the same space (page A4) it needs to write 132 char instead of 200.
    If your report print NN char, u should use the format wiith number colunm is closer to NN.
    If there isn't a format or u use the first available format or u create a new one by trx SPAD.
    Max

  • Problems in ALV Report

    Hi all,
    I have a Problem with the ALV report felated to FI Data. Where in the Selection screen I have two fields Commitment Item, Fund Center and Fiscal Year. When i am executing the report it is printing correctly.
    The Problem is that when i give a commitment which is not related to the Fund Center It is displaying all the records.
    That is nothing but it is displaying all the data where the data of the selection screen is not in the internal table.
    instead i should display a message that the Commitment item is not related to Fund Center. and the ALV Should not print any values. How do i achieve this?
    Please help me in solving the problem. Rewards will be awarded.
    Message was edited by:
            sravan varanasi

    Hi,
    Here is a small ex.
    SELECT mtart mtbez FROM t134t
      INTO CORRESPONDING FIELDS OF TABLE it_t134t
      WHERE mtart IN so_mtart AND spras = 'EN'.
      IF sy-subrc = 0.
        *********PERFORM display   
      ELSE.
        MESSAGE ID 'Selection error' TYPE 'E' NUMBER '0040'.
      ENDIF.
    Hope useful.
    Regards
    Harish.

  • Printing logo in ALV report

    Hi,
    I've created an ALV report with a logo in the header.
    But, when i'm taking the printout ,the logo is not printed.
    How to solve this problem,..please help me .
    Thanks and regards.
    Rajesh

    It is not possible to Print the logo, which you are showing in ALV Grid.
    But you have to work with Cl_DD_DOCUMENT class
    Check this program DD_ADD_PICTURE, Here you can print the logo.the same you can try to implement if you want.

  • Problem in alv report output

    Hi friends,
    i have created alv report .no problem of getting output . but i m getting question mark in the standard menu. it is displaying 10 question mark (sub menu has print preview etc), edit ,question marks(ABC Analysis) ,question marks (abap list viewer etc ), settings ,system , help.
    i don't want these question marks. how to candle this.i haven't moved to test or production , but iwant  to know  in development  why it is coming..
    if any one knows please let me know.
    thanks and regards,
    kani.

    The Problem is with some GUI inconsistency.
    to overcome there are 2 solutions.
    1. You need to run a program Which i don't remember exactly.
    2. Using the Status event.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
        i_callback_program = sy-repid
        it_fieldcat        = it_fieldcat
    I_CALLBACK_PF_STATUS_SET = 'STATUS'  "important
        it_sort            = it_sort
      TABLES
        t_outtab           = it_data
      EXCEPTIONS
        program_error      = 1.
    form status using extab tyoe slis_t_extab.
    "This status you can set using the program SAPLKKBL
    " go to se41 transaction, enter the program name SAPLKKBL
    "status as STANDARD , and click the Button Copy status
    "Now in the popup for Option to enter your program name and
    "press ok, then save and activate the status
    "now come here and activate the code and test now..
    set pf-status 'STANDARD' excluding extab.
    endform.

  • Overlapping of Columns in the Print Preview of ALV Report

    Hi ,
          I have created a ALV report  which has 62 columns, when i see the print preview, the rows overlaps one another. I want a printout where no line items or rows should overlap each other. Never mind if the extra overlapped columns get truncated. Kindly help me to solve this problem.
    Regards,
    shivu

    U need to increase u201Cno. of columns fieldu201D in the Format typesu201D. For details pl. see this link.
    http://www.****************/Tutorials/ALV/Spool/width.htm
    Regards,
    Joy.

  • Data missing when Exporting or print preview from ALV report

    Hi
    I have a alv report which is showing fine but when i try to export it to say excel sheet or do print preview some of the data is missing. Can anyone tell me how to fix this. or at least point to some document that discuss this problem.
    Here is my ALV CODE
    *  CALL_ALV
    form call_alv.
    *  v_repid = sy-repid.
      perform build_field_catalog using field_tab[].
      perform build_eventtab      using events[].
      perform comment_build       using header_alv[].
      perform build_sorttab       using gt_sort[].
    *  perform build_layout.
    *  v_variant-variant = '/TEST3'.
    * Call ABAP List Viewer
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program      = v_repid
          i_callback_user_command = ''
          i_structure_name        = 'REC'
          it_fieldcat             = field_tab[]
          it_special_groups       = gt_sp_group[]
          it_sort                 = gt_sort[]
          i_save                  = v_save
          is_variant              = v_variant
          it_events               = events[]
    *      is_layout               = gd_layout
        tables
          t_outtab                 = REC
        exceptions
          program_error            = 1
          others                   = 2.
    endform.
    From my Catalog this data is missing
    * BUILD_FIELD_CATALOG
    form build_field_catalog USING pt_fieldcat type
                                   slis_t_fieldcat_alv.
      data:  ls_fieldcat type slis_fieldcat_alv.
      clear: fieldcat, pt_fieldcat[].
      ls_fieldcat-tabname        =                'REC'.
      ls_fieldcat-edit           =                ' '.
        ls_fieldcat-fieldname      =                'PERNR'.
        ls_fieldcat-seltext_s      =                'Employee #     '.
        ls_fieldcat-seltext_m      =                'Employee #           '.
        ls_fieldcat-seltext_l      =                'Employee #           '.
        ls_fieldcat-datatype       =                'C'.
        append ls_fieldcat to pt_fieldcat.
    There r coupole that's missing
    But there couple that show's up like this one
        ls_fieldcat-fieldname      =                'STIME'.
        ls_fieldcat-seltext_s      =                'ST   '.
        ls_fieldcat-seltext_m      =                'St Tm     '.
        ls_fieldcat-seltext_l      =                'Start Time          '.
        ls_fieldcat-datatype       =                'C'.
        append ls_fieldcat to pt_fieldcat.
        ls_fieldcat-fieldname      =                'ETIME'.
        ls_fieldcat-seltext_s      =                'ET      '.
        ls_fieldcat-seltext_m      =                'Et Tm           '.
        ls_fieldcat-seltext_l      =                'End Time             '.
        append ls_fieldcat to pt_fieldcat.
    I always reward points.
    Thanks

    hi Anwarul,
    Try the following code:
    *  CALL_ALV
    form call_alv.
    *  v_repid = sy-repid.
      perform build_field_catalog using field_tab[].
      perform build_eventtab      using events[].
      perform comment_build       using header_alv[].
      perform build_sorttab       using gt_sort[].
    *  perform build_layout.
    *  v_variant-variant = '/TEST3'.
    * Call ABAP List Viewer
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program      = v_repid
          i_callback_user_command = ''
          i_structure_name        = 'REC'
          it_fieldcat             = field_tab[]
          it_special_groups       = gt_sp_group[]
          it_sort                 = gt_sort[]
          i_save                  = v_save
          is_variant              = v_variant
          it_events               = events[]
    *      is_layout               = gd_layout
        tables
          t_outtab                 = REC
        exceptions
          program_error            = 1
          others                   = 2.
    endform.
    form build_field_catalog USING pt_fieldcat type
                                   slis_t_fieldcat_alv.
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
    I_PROGRAM_NAME  = sy-repid
    I_STRUCTURE_NAME = 'REC'
    changing
    CT_FIELDCAT          = pt_fieldcat.
    When you export to excel, the character fields and numeric columns gets re-arranged, but all the fields will be displayed in this case.
    hope this helps.

  • Print or download ALV report with sort options

    Dear friends,
    How i can download into excel or print ALV report with sort options, like customer name column with similar values should not repeat in the print out or download file.
    Regards,
    Praveen Lobo

    Hi Praveen,
    Use this code, its working:-
    *FOR SORTING DATA
    DATA : it_sort TYPE slis_t_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    *          SORT W.R.T. CUSTOMER NAME
      wa_sort-spos = 1.
      wa_sort-fieldname = 'NAME1'. "field customer name
      wa_sort-tabname = 'IT_KNA1'. "internal table with records
      wa_sort-up = 'X'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    "this will sort the ALV o/p for customer with same name
    "now the name will not be repeated
    "records with same name will be grouped
    *          DISPLAY RECORDS IN ALV GRID
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program                = sy-repid "report id
        it_fieldcat                       = it_field "field catalog
        it_sort                           = it_sort "sort info
      TABLES
        t_outtab                          = it_kna1 "internal table
      EXCEPTIONS
        program_error                     = 1
        OTHERS                            = 2.
      IF sy-subrc <> 0.
      ENDIF.
    Hope this solves your problem.
    Thanks & Regards,
    Tarun Gambhir
    Edited by: Tarun Gambhir on Dec 31, 2008 1:13 PM

  • Error in print preview in ALV report

    Hi....All,
    Good Day.
    I have developed a ALV report. It is displaying all data properly. The problem is...
    When I am pressing the print preview button... it is getting dump.
    The dump short message is....... "Field symbol has not yet been assigned".
    Hope that I will get a solution from you as previous.
    With Thanks
    Sohel

    Do you use a field for coloring a column or cell?
    If the coding is not too large it could be helpfull to post the coding as well.
    Regards,
    John.

  • Problem Saving ALV Report

    Hi
    I have this ALV Report when I run and change the layout (add/remove column and add column for sorting) it works fine but when i come back i get the change columns but it doesn't save the sorting options that i made.
    Here is my Code
    *& Report  ZAKTIME                                                     *
    *& AKABIR             02/06/2007         New Report for Cluster B2     *
    REPORT  ZAKTIME no standard page heading message-id zw line-size 255.
    *                Dictionary tables/structures
    tables: pa0007, PA0002.
    DATA: IT_T549Q TYPE T549Q OCCURS 0 WITH HEADER LINE,
             IT_ZL TYPE PC2BF OCCURS 0 WITH HEADER LINE,
             IT_PT TYPE PDCPT OCCURS 0 WITH HEADER LINE,
            IT_ALP TYPE PC20E OCCURS 0 WITH HEADER LINE,
             IT_C1 TYPE PC25X OCCURS 0 WITH HEADER LINE,
            IT_PSP TYPE PC2BA OCCURS 0 WITH HEADER LINE.
    * Global ALV Data Declarations
    type-pools slis.
    DATA:  BEGIN OF tgetbuff occurs 0,
    x(10),
         END OF tgetbuff.
    include rpcxB200.
    INCLUDE RPTBAL01.
    * infotypes: 0001.     "Org. Zuordnung
    Data: TempHours LIKE PC2BF-BEGUZ,
          even type i value 0.
    data: begin of hd,
          struc like dd03l-tabname,
          end of hd.
    DATA: BEGIN OF REC OCCURS 0,
          PERNR LIKE PERNR-PERNR,
          SSN   Like pa0002-perid,
          NAME(25),
          TYPE(1),
          WRKS LIKE PC2BA-TPROG,
          DATE(10),
          STIME(8),
          ETIME(8),
          HOURS  LIKE PC2BF-BEGUZ,
          PNUMB  LIKE PC20E-PRAKN,
          PID    LIKE PC20E-PRAKZ,
          UNIT   LIKE PC20E-ANZHL,
          VALU   LIKE PC20E-BWGRL,
          AMOUNT LIKE PC20E-BETRG,
          XPAYID LIKE PC20E-AUFKZ,
          CCNTR  LIKE PC25X-KOSTL,
          CCODE  LIKE PC25X-BUKRS,
          AUFNR  LIKE PC25X-AUFNR,
          KTEXT  LIKE CAUFV-KTEXT,
          LGART  LIKE PC2BF-LGART,
          LGTXT  LIKE T512T-LGTXT,
          STER   LIKE PDCPT-BTERM,
          ETER   LIKE PDCPT-ETERM.
    DATA: END OF REC.
    data:
        begin of x_sortinfo_alv occurs 0,
          spos                  like alvdynp-sortpos,
          fieldname             type slis_fieldname,
          tabname               type slis_fieldname,
          up                    like alvdynp-sortup,
          down                  like alvdynp-sortdown,
          group                 like alvdynp-grouplevel,
          subtot                like alvdynp-subtotals,
          comp(1)               type c,
          expa(1)               type c,
          obligatory(1)         type c,
        end   of x_sortinfo_alv,
        v_variant        like disvariant,
        v_repid          like sy-repid,
        v_save(1)        type c,
        lv_sortseq       type i,
        s_title(20),     "Maximum selection field description 20 bytes.
        fieldcat         type slis_t_fieldcat_alv,
        ls_line          type slis_listheader,
        gd_layout        type slis_layout_alv,
        gt_sort          type slis_t_sortinfo_alv,
        ls_sort          type slis_sortinfo_alv,
        events           type slis_t_event,
        list_top_of_page type slis_t_listheader,
        top_of_page      type slis_formname value 'TOP_OF_PAGE',
        v_exit(1)               type c.
    constants:
      alv_slis_formname       type slis_formname value 'ALV_USER_COMMAND',
      c_yes                   like space value 'X',
      c_no                    like space value space.
    DATA: BEGIN OF E_NAME,
          NACHN LIKE PA0002-NACHN,
          VORNA LIKE PA0002-VORNA.
    DATA: END OF E_NAME.
    * define selection screen
    selection-screen begin of block elmo with frame title text-001.
    selection-screen begin of line.
       selection-screen comment 1(22) text-005.
       select-options  opt4 for pa0007-schkz.
    selection-screen end of line.
    parameters:   debg_lst as checkbox default 'X'.
    selection-screen end of block elmo.
    selection-screen begin of block blk2 with frame title text-002.
    PARAMETERS: p_vari like disvariant-variant.
    selection-screen end   of block blk2.
    *  Form  Initialization
    initialization.
    clear: REC.
    refresh: REC.
      v_repid = sy-repid.
      v_save = 'A'.
      clear v_variant.
      v_variant-report = v_repid.
    * Get default variant
      alv_variant = v_variant.
      call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
        exporting
          i_save     = v_save
        changing
          cs_variant = alv_variant
        exceptions
          not_found  = 2.
      if sy-subrc = 0.
        p_vari = alv_variant-variant.
      endif.
    *                       At Selection-Screen event (value help)
    at selection-screen on value-request for p_vari.
      perform f4_for_variant.
    *                       At Selection-Screen event (check input data)
    at selection-screen on p_vari.
      if p_vari <> space.
        v_variant-report  = v_repid.
        v_variant-variant = p_vari.
        call function 'REUSE_ALV_VARIANT_SELECT'
          EXPORTING
            i_dialog            = c_no
            it_default_fieldcat = field_tab[]
            i_layout            = gs_layout
          CHANGING
            cs_variant          = v_variant.
        if sy-subrc <> 0.
          call function 'REUSE_ALV_VARIANT_SELECT'
            EXPORTING
              i_dialog            = c_yes
              it_default_fieldcat = field_tab[]
              i_layout            = gs_layout
            CHANGING
              cs_variant          = v_variant.
        endif.
      endif.
    *                       main logic
    TOP-OF-PAGE.
    START-OF-SELECTION.
            GET PERNR.
            RP-PROVIDE-FROM-LAST P0001 SPACE PNPBEGDA PNPENDDA.
    * process the data according to the payroll area
       IF PERNR-WERKS EQ P0001-WERKS AND PERNR-BTRTL EQ P0001-BTRTL
          AND PERNR-KOSTL EQ P0001-KOSTL AND PERNR-BUKRS EQ P0001-BUKRS
          AND PERNR-ABKRS EQ P0001-ABKRS AND PERNR-KOKRS EQ P0001-KOKRS.
            PERFORM RETRIEVE_Time.
        ENDIF.
    END-OF-SELECTION.
        Perform call_alv.
    *======================================================================*
    *                        forms                                         *
    *======================================================================*
    FORM RETRIEVE_Time.
    DATA: date_modified(10), V_STIME(8), V_ETIME(8).
    DATA: Flag(1),
          v_lgtxt like T512T-LGTXT,
          v_ktext like caufv-ktext,
          v_WRKS LIKE PC2BA-TPROG.
    CALL FUNCTION 'HR_PAYROLL_PERIODS_GET'
    EXPORTING
      get_begda = PNPBEGDA
      get_endda = PNPENDDA
    TABLES
      get_periods = it_t549q
    EXCEPTIONS
      no_period_found = 1
      no_valid_permo = 2.
      CHECK sy-subrc = 0.
    LOOP AT it_t549q.
      FLAG = 0.
      CALL FUNCTION 'HR_TIME_RESULTS_GET'
       EXPORTING
         get_pernr = PERNR-PERNR
         get_pabrj = it_t549q-pabrj
         get_pabrp = it_t549q-pabrp
       TABLES
         GET_TBUFF     = TGETBUFF
         get_zl  = it_zl
         get_pt  = it_PT
         get_alp = it_ALP
         get_c1  = it_C1
         get_psp = it_psp
       EXCEPTIONS
         no_period_specified = 1
         wrong_cluster_version = 2
         no_read_authority = 3
         cluster_archived = 4
         technical_error = 5.
      LOOP AT it_zl.
        IF it_ZL-DATUM >= PNPBEGDA AND it_ZL-DATUM <= PNPENDDA.
    * Include PSP Data if Exists.
          LOOP AT IT_PSP.
            IF it_psp-ZMODN IN OPT4 AND it_zl-DATUM EQ it_psp-DATUM.
                MOVE it_psp-ZMODN TO REC-WRKS.
                FLAG = 1.
                Move:
                  Pernr-Pernr To REC-PERNR,
                          'Z' To REC-TYPE,
                  it_ZL-LGART TO REC-LGART,
                  it_ZL-ANZHL TO REC-HOURS.
                perform get_ssn.
                perform get_wage_type_text using REC-LGART v_lgtxt.
                move v_lgtxt to REC-LGTXT.
                CONCATENATE it_zl-DATUM+4(2) '/' it_zl-DATUM+6(2) '/' it_zl-DATUM(4) INTO date_modified.
                IF it_ZL-BEGUZ <> ''.
                  CONCATENATE it_ZL-BEGUZ(2) ':' it_ZL-BEGUZ+2(2) ':' it_ZL-BEGUZ+4(2) INTO V_STIME.
                ELSE.
                  V_STIME = ''.
                ENDIF.
                IF it_ZL-ENDUZ <> ''.
                  CONCATENATE it_ZL-ENDUZ(2) ':' it_ZL-ENDUZ+2(2) ':' it_ZL-ENDUZ+4(2) INTO V_ETIME.
                ELSE.
                  V_ETIME = ''.
                ENDIF.
                Move:
                     date_modified To REC-DATE,
                           V_STIME To REC-STIME,
                           V_ETIME To REC-ETIME.
    * Include ALP Data if Exists else include Blanks.
                  MOVE:
                          '' TO REC-UNIT,
                          '' TO REC-PNUMB,
                          '' TO REC-PID,
                          '' TO REC-VALU,
                          '' TO REC-AMOUNT,
                          '' TO REC-XPAYID.
                IF it_ZL-ALZNR GT 0.
                  LOOP AT IT_ALP.
                    IF it_zl-ALZNR EQ it_ALP-ALZNR.
                      MOVE:
                          it_ALP-ANZHL TO REC-UNIT,
                          it_ALP-PRAKN TO REC-PNUMB,
                          it_ALP-PRAKZ TO REC-PID,
                          it_ALP-BWGRL TO REC-VALU,
                          it_ALP-BETRG TO REC-AMOUNT,
                          it_ALP-AUFKZ TO REC-XPAYID.
                    ENDIF.
                  ENDLOOP.
                ENDIF.
    * Include C1 Data if Exists Else Include Blanks.
                 MOVE:
                      '' TO REC-CCODE,
                      '' TO REC-CCNTR,
                      '' To REC-AUFNR,
                      '' TO REC-KTEXT.
                IF it_ZL-C1ZNR GT 0.
                  LOOP AT IT_C1.
                    IF it_zl-C1ZNR EQ it_c1-C1ZNR.
                      MOVE:
                          it_C1-BUKRS TO REC-CCODE,
                          it_C1-KOSTL TO REC-CCNTR,
                          it_C1-AUFNR To REC-AUFNR.
                      perform get_service_order_text using REC-AUFNR v_ktext.
                      move v_ktext to rec-ktext.
                    ENDIF.
                  ENDLOOP.
                ENDIF.
              APPEND REC.
    * ENDIF FOR the IF on IT_PSP
            ENDIF.
          ENDLOOP.
    * ENDIF FOR the IF on Date Check
        ENDIF.
    * ENDLOOP ON IT_ZL
      ENDLOOP.
      LOOP AT it_pt.
        IF it_PT-LDATE >= PNPBEGDA AND it_PT-LDATE <= PNPENDDA.
    * Include PSP Data if Exists.
          LOOP AT IT_PSP.
            IF IT_PSP-ZMODN IN OPT4 AND it_pt-LDATE EQ it_psp-DATUM.
              MOVE it_psp-ZMODN TO REC-WRKS.
              FLAG = 1.
              Move:
                Pernr-Pernr To REC-PERNR,
                'P' to REC-TYPE,
                it_pt-BTERM TO REC-STER,
                it_pt-ETERM TO REC-ETER.
              perform get_ssn.
              CONCATENATE it_pt-LDATE+4(2) '/' it_pt-LDATE+6(2) '/' it_pt-LDATE(4) INTO date_modified.
              IF it_pt-BEGTM NE ''.
                 CONCATENATE it_pt-BEGTM(2) ':' it_pt-BEGTM+2(2) ':' it_pt-BEGTM+4(2) INTO V_STIME.
              ELSE.
                 V_STIME = ''.
              ENDIF.
              IF it_pt-ENDTM NE ''.
                 CONCATENATE it_pt-ENDTM(2) ':' it_pt-ENDTM+2(2) ':' it_pt-ENDTM+4(2) INTO V_ETIME.
              ELSE.
                 V_ETIME = ''.
              ENDIF.
              Move:
                    date_modified To REC-DATE,
                    V_STIME To REC-STIME,
                    V_ETIME To REC-ETIME.
              TempHours = ''.
              IF it_pt-BEGTM LT it_pt-ENDTM.
                  TempHours = it_pt-ENDTM(4) - it_pt-BEGTM(4).
                  TempHours = TempHours / 100.
              ENDIF.
              MOVE:
                    TempHours TO REC-HOURS,
                           '' TO REC-LGART,
                           '' TO REC-LGTXT,
                           '' TO REC-UNIT,
                           '' TO REC-PNUMB,
                           '' TO REC-PID,
                           '' TO REC-VALU,
                           '' TO REC-AMOUNT,
                           '' TO REC-XPAYID,
                           '' TO REC-CCODE,
                           '' TO REC-CCNTR,
                           '' TO REC-AUFNR,
                           '' TO REC-KTEXT.
              APPEND REC.
            ENDIF.
          ENDLOOP.
        ENDIF.
      ENDLOOP.
      IF FLAG = 0 AND debg_lst = 'X'.
         Move:
              Pernr-Pernr To REC-PERNR,
                       '' To REC-TYPE,
                       '' TO REC-DATE,
                       '' TO REC-STIME,
                       '' TO REC-ETIME,
                       '' TO REC-LGART,
                       '' TO REC-LGTXT,
                       '' TO REC-HOURS,
                       '' TO REC-UNIT,
                       '' TO REC-PNUMB,
                       '' TO REC-PID,
                       '' TO REC-VALU,
                       '' TO REC-AMOUNT,
                       '' TO REC-XPAYID,
                       '' TO REC-CCODE,
                       '' TO REC-CCNTR,
                       '' To REC-AUFNR,
                       '' To REC-KTEXT,
                       '' TO REC-STER,
                       '' TO REC-ETER.
         perform get_ssn.
         PERFORM LOAD_SHIFT using v_WRKS.
         Move v_WRKS TO REC-WRKS.
         IF REC-WRKS IN OPT4.
           APPEND REC.
         ENDIF.
      ENDIF.
    ENDLOOP.
    ENDFORM.                            " RETRIEVE_PAYROLL
    *  CALL_ALV
    form call_alv.
    *  v_repid = sy-repid.
      perform build_field_catalog using field_tab[].
      perform build_eventtab      using events[].
      perform comment_build       using header_alv[].
      perform build_sorttab       using gt_sort[].
      perform build_layout.
    *  v_variant-variant = '/TEST3'.
    * Call ABAP List Viewer
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          it_fieldcat             = field_tab[]
          i_structure_name        = 'REC'
          i_callback_program      = v_repid
          is_variant              = v_variant
          it_events               = events[]
          it_sort                 = gt_sort[]
          i_save                  = v_save
          is_layout               = gd_layout
        tables
          t_outtab                 = REC
        exceptions
          program_error            = 1
          others                   = 2.
    endform.
    * BUILD_FIELD_CATALOG
    form build_field_catalog USING pt_fieldcat type
                                   slis_t_fieldcat_alv.
      clear: fieldcat, pt_fieldcat[].    refresh: fieldcat.
      data:  ls_fieldcat type slis_fieldcat_alv.
      ls_fieldcat-tabname        =                'REC'.
      ls_fieldcat-edit           =                ' '.
        ls_fieldcat-fieldname      =                'PERNR'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'PERNR'.
        ls_fieldcat-seltext_l      =                'Employee #'.
        ls_fieldcat-outputlen      =                15.
        ls_fieldcat-no_sum         = 'X'.           "Don't use field for totals
        ls_fieldcat-datatype       =                'NUMC'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'NAME'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'NAME'.
        ls_fieldcat-seltext_l      =                'Employee Name'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'TYPE'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'TYPE'.
        ls_fieldcat-seltext_m      =                'Type'.
        ls_fieldcat-outputlen      =                4.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'DATE'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'DATE'.
        ls_fieldcat-seltext_l      =                'Date'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'WRKS'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'WRKS'.
        ls_fieldcat-seltext_m      =                'Daily Sch'.
        ls_fieldcat-outputlen      =                10.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'STIME'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'STIME'.
        ls_fieldcat-seltext_l      =                'Start Time'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'ETIME'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'ETIME'.
        ls_fieldcat-seltext_l      =                'End Time'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'HOURS'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'HOURS'.
        ls_fieldcat-seltext_s      =                'Hours'.
        ls_fieldcat-datatype       =                'NUMC'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'PNUMB'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'PNUMB'.
        ls_fieldcat-seltext_l      =                'Premium #'.
        ls_fieldcat-datatype       =                'NUMC'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'PID'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'PID'.
        ls_fieldcat-seltext_l      =                'Premium Id'.
        ls_fieldcat-datatype       =                'NUMC'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'UNIT'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'UNIT'.
        ls_fieldcat-seltext_s      =                'Unit'.
        ls_fieldcat-datatype       =                'NUMC'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'VALU'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'VALU'.
        ls_fieldcat-seltext_s      =                'Valuation Basis'.
        ls_fieldcat-datatype       =                'NUMC'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'AMOUNT'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'AMOUNT'.
        ls_fieldcat-seltext_s      =                'Amount'.
        ls_fieldcat-datatype       =                'NUMC'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'XPAYID'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'XPAYID'.
        ls_fieldcat-seltext_s      =                'Extra Pay ID'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'CCNTR'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'CCNTR'.
        ls_fieldcat-seltext_l      =                'Cost Center'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'CCODE'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'CCODE'.
        ls_fieldcat-seltext_l      =                'Company Code'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'AUFNR'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'AUFNR'.
        ls_fieldcat-seltext_l      =                'Service Number'.
        ls_fieldcat-datatype       =                'NUMC'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'KTEXT'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'KTEXT'.
        ls_fieldcat-seltext_l      =                'Service Number Text'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'LGART'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'LGART'.
        ls_fieldcat-seltext_l      =                'Wage Type'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'LGTXT'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'LGTXT'.
        ls_fieldcat-seltext_l      =                'Wage Type Text'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'STER'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'STER'.
        ls_fieldcat-seltext_l      =                'Starting Terminal'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-fieldname      =                'ETER'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'ETER'.
        ls_fieldcat-seltext_l      =                'Ending Terminal'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
        ls_fieldcat-edit           =                ' '.
    endform.
    * BUILD_EVENTTAB
    form build_eventtab using events type slis_t_event.
    * Registration of events to happen during list display
      data: tmp_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
        exporting
          i_list_type = 0
        importing
          et_events   = events.
      read table events with key name = slis_ev_top_of_page into tmp_event.
       if sy-subrc = 0.
         move top_of_page to tmp_event-form.
         append tmp_event to events.
       endif.
    endform.
    * COMMENT_BUILD
    form comment_build using pt_top_of_page type slis_t_listheader.
      data: v_head_string(255) value space, d1(2), m1(2), y1(2), d2(2), m2(2), y2(2).
      clear: ls_line, pt_top_of_page.
      ls_line-typ  = 'H'.
      data pnpfrom(10).
      data pnpto(10).
      data: print_date(10).
      data: print_time(10).
      d1 = PNPBEGDA+6(2).          d2 = PNPENDDA+6(2).
      m1 = PNPBEGDA+4(2).          m2 = PNPENDDA+4(2).
      y1 = PNPBEGDA+2(2).          y2 = PNPENDDA+2(2).
      concatenate m1 '/' d1 '/' y1 into pnpfrom.
      concatenate m2 '/' d2 '/' y2 into pnpto.
      d1 = sy-datum+6(2).          d2 = sy-uzeit+2(2).
      m1 = sy-datum+4(2).          m2 = sy-uzeit+0(2).
      y1 = sy-datum+2(2).          y2 = sy-uzeit+4(2).
      concatenate m1 '/' d1 '/' y1 into print_date.
      concatenate m2 ':' d2 ':' y2 into print_time.
      ls_line-info = sy-repid.
      append ls_line to pt_top_of_page.
      concatenate 'Printed by:' sy-uname 'on' print_date 'at' print_time
      into ls_line-info separated by space.
      append ls_line to pt_top_of_page.
      ls_line-info = 'BGM INDUSTRIES, INC.'.
      append ls_line to pt_top_of_page.
      concatenate 'Supply Period:' pnpfrom 'to' pnpto
      into ls_line-info separated by space.
      append ls_line to pt_top_of_page.
    endform.
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
      gd_layout-info_fieldname    = 'LINE_COLOR'.
    endform.                    " BUILD_LAYOUT
    * TOP_OF_PAGE
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
           i_logo             = 'Z_BGLOGO'
           it_list_commentary = header_alv.
    endform.
    *&      Form  build_sorttab
    *       Set up the sorting for the report.
    form build_sorttab using pt_sort type slis_t_sortinfo_alv.
      clear lv_sortseq.
      perform build_sort tables pt_sort changing ls_sort.
      ls_sort-fieldname = 'PERNR'.
      ls_sort-subtot    = 'X'.
      append ls_sort to pt_sort.
      ls_sort-subtot    = ' '.
      perform build_sort tables pt_sort changing ls_sort.
      ls_sort-fieldname = 'NAME'.
      ls_sort-subtot    = 'X'.
      append ls_sort to pt_sort.
      ls_sort-subtot    = ' '.
    endform.                    " build_sorttab
    *  Use to add another sort field.
    form build_sort
      tables   pt_sort
      changing ls_sort structure x_sortinfo_alv.
      clear ls_sort.
      add 1 to lv_sortseq.
      ls_sort-spos = lv_sortseq.
      ls_sort-up = 'X'.
      ls_sort-tabname = 'REC'.
    endform.                    "build_sort
    *}   INSERT
    *&      Form  GET_SSN & EMP Name
    *       text
    FORM GET_SSN.
        SELECT SINGLE * FROM PA0002 WHERE PERNR = PERNR-PERNR.
        IF SY-SUBRC EQ 0.
            MOVE: PA0002-PERNR TO REC-SSN,
                  PA0002-VORNA TO E_NAME-VORNA,
                  PA0002-NACHN TO E_NAME-NACHN.
            CONDENSE E_NAME.
            MOVE: E_NAME TO REC-NAME.
        ENDIF.
    ENDFORM.                    " GET_SSN
    *   Form  GET_WAGE_TYPE_TEXT
    form get_wage_type_text using rec-LGART p_v_lgtxt.
      select single LGTXT from T512T into p_v_lgtxt
                            where LGART = rec-LGART.
    endform.                    " GET_WAGE_TYPE_TEXT
    *   Form  GET_SERVICE_ORDER_TEXT
    form get_service_order_text using rec-AUFNR p_v_ktext.
      select single ktext from caufv into p_v_ktext
                          where aufnr = rec-aufnr.
    endform.                    " GET_SERVICE_ORDER_TEXT
    *&      Form  LOAD_SHIFT
    *       text
    FORM LOAD_SHIFT USING V_WRKS.
        SELECT SINGLE * FROM PA0007 WHERE PERNR = REC-PERNR.
        IF SY-SUBRC EQ 0.
           MOVE: PA0007-SCHKZ TO V_WRKS.
        ENDIF.
    ENDFORM.
    *&      Form  f4_for_variant
    form f4_for_variant.
      call function 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = v_variant
          i_save     = v_save
        IMPORTING
          e_exit     = v_exit
          es_variant = alv_variant
        EXCEPTIONS
          not_found  = 2.
      if sy-subrc = 2.
        message id sy-msgid type 'S' number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      else.
        if v_exit = space.
          p_vari = alv_variant-variant.
        endif.
      endif.
    endform.                    " f4_for_variant
    Please help. I will reward Points for the right answers.
    Thanks

    Ok found the problem at last
        ls_fieldcat-fieldname      =                'PERNR'.
        ls_fieldcat-ref_tabname    =                'REC'.
        ls_fieldcat-ref_fieldname  =                'PERNR'.
        ls_fieldcat-seltext_l      =                'Employee #'.
        ls_fieldcat-outputlen      =                15.
        ls_fieldcat-no_sum         = 'X'.           "Don't use field for totals
        ls_fieldcat-datatype       =                'NUMC'.
        append ls_fieldcat to pt_fieldcat.
        clear ls_fieldcat.
    In my build catalog i was clearing every field using the
      clear ls_fieldcat.
    which was some how clearing the sortings...
    SO commented them out and it works.

  • Problem with ALV Report Column

    Hi
    I have ALV report that got tons of columns and most of them are showing correctly. But there are two or three where i have a do sum checked got a small problem. The HEADING of the columns says NUMBER instead of its column name...
    Look at my code:
      ls_fieldcat-fieldname      =      'ETIME'.
      ls_fieldcat-ref_tabname    =      'REC'.
      ls_fieldcat-ref_fieldname  =      'ETIME'.
      ls_fieldcat-seltext_s      =      'ET      '.
      ls_fieldcat-seltext_m      =      'Et Tm           '.
      ls_fieldcat-seltext_l      =   'End Time             '.
      append ls_fieldcat to pt_fieldcat.
      ls_fieldcat-fieldname      =                'HOURS'.
      ls_fieldcat-ref_tabname    =                'PC2BF'.
      ls_fieldcat-ref_fieldname  =                'ANZHL'.
      ls_fieldcat-seltext_s      =                'Hrs    '.
      ls_fieldcat-seltext_m      =                'Hors '.
      ls_fieldcat-seltext_l      =                'Hours'.
      ls_fieldcat-decimals_out = 2.
      ls_fieldcat-no_zero = 'X'.
      ls_fieldcat-datatype = 'DEC'.
      ls_fieldcat-do_sum = 'X'.
      append ls_fieldcat to pt_fieldcat.
      ls_fieldcat-no_zero = ''.
      ls_fieldcat-datatype = ''.
      ls_fieldcat-outputlen = ''.
      ls_fieldcat-do_sum = ''.
      ls_fieldcat-decimals_out = ''.
      ls_fieldcat-fieldname = ''.
      ls_fieldcat-fieldname      =                'PNUMB'.
      ls_fieldcat-ref_tabname    =                'PC20E'.
      ls_fieldcat-ref_fieldname  =                'PRAKN'.
      ls_fieldcat-seltext_s      =                'P#     '.
      ls_fieldcat-seltext_m      =     'Pre #       '.
      ls_fieldcat-seltext_l      =   'Premium #           '.
      ls_fieldcat-datatype       =                'NUMC'.
      append ls_fieldcat to pt_fieldcat.
      ls_fieldcat-datatype       = ''.
    The column with Hours is showing NUMBER with the total sum but the column before and after that shows correctly.
    I have tried taken out the
    <b> ls_fieldcat-do_sum = 'X'.</b>
    Then its shows correctly but i need it to do the sum.
    Is there anything i need to do in order to show the columns correctly?
    Please help. <b><REMOVED BY MODERATOR></b>. thanks
    Message was edited by:
            Anwarul Kabir
    Message was edited by:
            Anwarul Kabir
    Message was edited by:
            Alvaro Tejada Galindo

    here is the whole program. you can upload this run it for your self if that helps in any way...
    *& Report  ZHEADCOUNT       *
    REPORT  ZHEADCOUNT no standard page
    heading message-id zw line-size 255.
    *       Dictionary tables/structures
    tables: teven,
            ZSHIFTS,
            ZHEADCT.
    * Global ALV Data Declarations
    type-pools slis.
    include: rpcxB200, RPTBAL01.
    DATA: BEGIN OF REC OCCURS 0,
      PERNR LIKE TEVEN-PERNR,
      LDATE LIKE TEVEN-LDATE,
      LTIME LIKE TEVEN-LTIME,
      SATZA LIKE TEVEN-SATZA,
      TERID LIKE TEVEN-TERID,
      PLANS LIKE TEVEN-PLANS.
    DATA: END OF REC.
    data:
      begin of x_sortinfo_alv occurs 0,
          spos                  like alvdynp-sortpos,
          fieldname             type slis_fieldname,
          tabname               type slis_fieldname,
          up                    like alvdynp-sortup,
          down                  like alvdynp-sortdown,
          group                 like alvdynp-grouplevel,
          subtot                like alvdynp-subtotals,
          comp(1)               type c,
          expa(1)               type c,
          obligatory(1)         type c,
        end   of x_sortinfo_alv,
        d                like scal-indicator,  
        v_variant        like disvariant,
        v_repid          like sy-repid,
        v_save(1)        type c,
        lv_sortseq       type i,
        s_title(20),    
        fieldcat         type slis_t_fieldcat_alv,
        ls_line          type slis_listheader,
        gd_layout        type slis_layout_alv,
        gt_sp_group      type slis_t_sp_group_alv,
        gt_sort          type slis_t_sortinfo_alv,
        ls_sort          type slis_sortinfo_alv,
        events           type slis_t_event,
        list_top_of_page type slis_t_listheader,
        top_of_page      type slis_formname value 'TOP_OF_PAGE',
        v_exit(1)        type c,
        v_pdsnr like assob-pdsnr,
        ls_fieldcat type slis_t_fieldcat_alv.
    constants:
      alv_slis_formname       type slis_formname value 'ALV_USER_COMMAND',
      c_yes                   like space value 'X',
      c_no                    like space value space,
      c_dev LIKE  sy-sysid VALUE 'DEV',
      c_device(4) TYPE c   VALUE 'LOCL'.
    * define selection screen
    selection-screen begin of block elmo with frame title text-001.
    selection-screen begin of line.
    selection-screen comment 1(30) text-002.
    select-options  p_terid for TEVEN-TERID.
    selection-screen end of line.
    selection-screen begin of line.
    selection-screen comment 1(30) text-003.
    select-options p_shift for ZSHIFTS-DWS.
    selection-screen end of line.
    selection-screen end of block elmo.
    selection-screen begin of block blk2 with frame title text-004.
    PARAMETERS: p_vari like disvariant-variant.
    selection-screen end   of block blk2.
    *  Form  Initialization
    initialization.
      v_repid = sy-repid.
      v_save = 'A'.
      clear v_variant.
      v_variant-report = v_repid.
    * Get default variant
      alv_variant = v_variant.
      call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save     = v_save
        CHANGING
          cs_variant = alv_variant
        EXCEPTIONS
          not_found  = 2.
      if sy-subrc = 0.
        p_vari = alv_variant-variant.
      endif.
    *  At Selection-Screen event (value help)
    at selection-screen on value-request for p_vari.
      perform f4_for_variant.
    *  At Selection-Screen event (check input data)
    at selection-screen on p_vari.
      if p_vari <> space.
        v_variant-report  = v_repid.
        v_variant-variant = p_vari.
        call function 'REUSE_ALV_VARIANT_SELECT'
          EXPORTING
            i_dialog            = c_no
            it_default_fieldcat = field_tab[]
            i_layout            = gs_layout
          CHANGING
            cs_variant          = v_variant.
        if sy-subrc <> 0.
          call function 'REUSE_ALV_VARIANT_SELECT'
            EXPORTING
              i_dialog            = c_yes
              it_default_fieldcat = field_tab[]
              i_layout            = gs_layout
            CHANGING
              cs_variant          = v_variant.
        endif.
      endif.
    *                       main logic
    TOP-OF-PAGE.
    START-OF-SELECTION.
    GET PERNR.
      RP-PROVIDE-FROM-LAST P0001 SPACE PNPBEGDA PNPENDDA.
    * process the data according to the payroll area
      IF PERNR-WERKS EQ P0001-WERKS AND PERNR-BTRTL EQ P0001-BTRTL
         AND PERNR-KOSTL EQ P0001-KOSTL AND PERNR-BUKRS EQ P0001-BUKRS
         AND PERNR-ABKRS EQ P0001-ABKRS AND PERNR-KOKRS EQ P0001-KOKRS.
        PERFORM RETRIEVE_Time.
      ENDIF.
    END-OF-SELECTION.
      Perform call_alv.
    *==================================*
    *=================================*
    FORM RETRIEVE_Time.
    Clear: REC.
           Select * from teven where PERNR EQ PERNR-PERNR
                                 AND TERID IN p_terid
                                 AND LDATE >= PNPBEGDA
                                 AND LDATE <= PNPENDDA.
                MOVE:
                     TEVEN-PERNR TO REC-PERNR,
                     TEVEN-LDATE TO REC-LDATE,
                     TEVEN-LTIME TO REC-LTIME,
                     TEVEN-SATZA TO REC-SATZA,
                     TEVEN-TERID TO REC-TERID,
                     TEVEN-PLANS TO REC-PLANS.
                APPEND REC.
           endselect.
    ENDFORM.                            " RETRIEVE_PAYROLL
    *  CALL_ALV
    form call_alv.
      perform build_field_catalog using field_tab[].
      perform build_eventtab      using events[].
      perform comment_build       using header_alv[].
      perform build_sorttab       using gt_sort[].
      perform build_layout.
    * Call ABAP List Viewer
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program      = v_repid
          i_callback_user_command = 'ALV_USER_COMMAND'
          i_structure_name        = 'REC'
          it_fieldcat             = field_tab
          it_special_groups       = gt_sp_group
          it_sort                 = gt_sort
          i_save                  = v_save
          is_variant              = v_variant
          it_events               = events
          is_layout               = gd_layout
        tables
          t_outtab                 = REC
        exceptions
          program_error            = 1
          others                   = 2.
    endform.                    "call_alv
    * BUILD_FIELD_CATALOG
    form build_field_catalog USING pt_fieldcat type
                                   slis_t_fieldcat_alv.
    *  data:  ls_fieldcat type slis_fieldcat_alv.
      clear: fieldcat, pt_fieldcat[].
      data : l_tabname type slis_tabname. " Table Name
       l_tabname = 'REC'.
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
        exporting
          i_program_name = v_repid
          i_internal_tabname = l_tabname
          i_inclname = v_repid
        changing
          ct_fieldcat = ls_fieldcat
        exceptions
          inconsistent_interface = 1
          program_error = 2
          others = 3.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
        with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      else.
    *    append ls_fieldcat to pt_fieldcat.
      endif.
    endform.                    "build_field_catalog
    * BUILD_EVENTTAB
    form build_eventtab using events type slis_t_event.
    * Registration of events to happen during list display
      data: tmp_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = events.
      read table events with key name = slis_ev_top_of_page into tmp_event.
      if sy-subrc = 0.
        move top_of_page to tmp_event-form.
        append tmp_event to events.
      endif.
    endform.                    "build_eventtab
    * COMMENT_BUILD
    form comment_build using pt_top_of_page type slis_t_listheader.
      data: v_head_string(255) value space, d1(2), m1(2), y1(2), d2(2), m2(2), y2(2).
      clear: ls_line, pt_top_of_page.
      ls_line-typ  = 'H'.
      data pnpfrom(10).
      data pnpto(10).
      data: print_date(10).
      data: print_time(10).
      d1 = PNPBEGDA+6(2).          d2 = PNPENDDA+6(2).
      m1 = PNPBEGDA+4(2).          m2 = PNPENDDA+4(2).
      y1 = PNPBEGDA+2(2).          y2 = PNPENDDA+2(2).
      concatenate m1 '/' d1 '/' y1 into pnpfrom.
      concatenate m2 '/' d2 '/' y2 into pnpto.
      ls_line-info = sy-repid.
      append ls_line to pt_top_of_page.
      concatenate 'Printed by:' sy-uname 'on' print_date 'at' print_time
      into ls_line-info separated by space.
      append ls_line to pt_top_of_page.
      ls_line-info = 'BGM INDUSTRIES, INC.'.
      append ls_line to pt_top_of_page.
      concatenate 'Period:' pnpfrom 'to' pnpto
      into ls_line-info separated by space.
      append ls_line to pt_top_of_page.
    endform.                    "comment_build
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
    *  gd_layout-totals_text       = 'Totals'(255).
    *  gd_layout-info_fieldname    = 'LINE_COLOR'.
    endform.                    " BUILD_LAYOUT
    * TOP_OF_PAGE
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          i_logo             = 'Z_BGLOGO'
          it_list_commentary = header_alv.
    endform.                    "top_of_page
    *&      Form  build_sorttab
    *       Set up the sorting for the report.
    form build_sorttab using pt_sort type slis_t_sortinfo_alv.
      clear lv_sortseq.
      perform build_sort tables pt_sort changing ls_sort.
      ls_sort-fieldname = 'PERNR'.
      ls_sort-subtot    = 'X'.
    endform.                    " build_sorttab
    *  Use to add another sort field.
    form build_sort
      tables   pt_sort
      changing ls_sort structure x_sortinfo_alv.
      clear ls_sort.
      add 1 to lv_sortseq.
      ls_sort-spos = lv_sortseq.
      ls_sort-up = 'X'.
      ls_sort-tabname = 'REC'.
    endform.                    "build_sort
    *&      Form  f4_for_variant
    form f4_for_variant.
      call function 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = v_variant
          i_save     = v_save
        IMPORTING
          e_exit     = v_exit
          es_variant = alv_variant
        EXCEPTIONS
          not_found  = 2.
      if sy-subrc = 2.
        message id sy-msgid type 'S' number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      else.
        if v_exit = space.
          p_vari = alv_variant-variant.
        endif.
      endif.
    endform.
    Message was edited by:
            Anwarul Kabir

  • Reg : Print Issue in ALV Report

    Hi Experts,
                     I have created an ALV Report for USER Requirement and it is working fine. While taking printout the SORTED Field is not working, it gets repeated in the Print... How to rectify..?

    hi,
    did u use SORT-UP equal to 'X'?
    wa_sort-up = c_x.
    ags.

Maybe you are looking for

  • Syncing Apps from iPhone 3GS to 4S

    Hey folks, I recently upgraded from iPhone 3GS to iPhone 4S. I synced up my 3GS to iTunes and then connected my new phone. When I synced them I chose the restore from existing option. This worked great and I have all of my messages, email account set

  • New itunes wont run in windows 7 64 bit even after full uninstall and reinstall

    after the new itunes 2.2 came out i have been unable to get it to open or run i have fully uninstalled all elements and reinstalled and still it wont run

  • Add Cost center description in FB01

    Hi All, I want to add new field in txn FB01 for item level. There is field Cost center in the Item level, i want to display description of the cost center. On second screen(300/310), we enter the cost center and after that if we hit save ,a new scree

  • Songs saved in two different locations, why?

    I was looking around my hd today and found that I have two copies of many of my mp3 files, some of which i deleted months ago. The first set of songs are in the "Music" folder and are only sorted by file name. The second set is located in music>itune

  • Why are my 4x6 and 5x7 prints being clipped?

    My prints are getting clipped no matter what I try to do.  I am losing approximately 1/8" from all sides of the finished print.  From what I can tell, the picture is actually printing larger than the specified size. This is my process: In the Develop