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

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.

  • Alv report Print out Problem

    Hi Experts,
       I am having problem while taking print out of Alv report format. In that report, 1 column contains  Unit  Values.
    Eg.  Unit value - 'LE' , AFTER USING CONVERSION EXIT LOGIC it is converted into 'AU'  which is finally displayed in the Alv -Report display format. 
    while taking Print-out of that report , that field Unit Value 'AU' is Shown in this format  "****'.
    Please give me your Valuable Suggestions.
    Thanks and Regards
    BalaNarasimman M

    while defining filed catalog define the data type also
      clear l_fieldcat.
      l_fieldcat-fieldname  = 'MEINS'.
      l_fieldcat-datatype = 'UNIT'.
    l_fieldcat-no_out     = ' '.
      l_fieldcat-do_sum = 'X'.
      l_fieldcat-seltext_l  = 'UOM'.
      append l_fieldcat to p_fieldtab.
    may be it would help.
    anya

  • 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

  • ALV Report Print Problem.

    Hi,
    When I Print any ALV Report then In the First Row BackColor is white,
    but in Second it is Gray,and this alternative for all remaining rows,
    How Can I SET it to White For ALL Rows.
    Thx,
    Hitesh Jain.

    Hi Jain,
    I'm not aware of a way to wrap the test or set break points in an ALV report.  Typically I just try to reduce the number of columns to print and determine if the data is truly needed or just redundant.
    To change the font, you need to change the Format setting.  This setting is in the same popup box I described earlier.  This time under General Properties, double click on Format.  Just play around with the different Format options loaded.  If you need additional formats, you should work with your BASIS team because it depends on the Output Devices that are loaded in your system. 
    Otherwise, you may just need to export the ALV report into Excel to make it "pretty".  In Excel, you could create a macro to automate your formatting steps.  Just a thought.
    Good luck,
    Cindy

  • ALV Report Print problem after 255 character line size

    Hi ABAP Gurus,
    I have created one alv report where i am getting output more then 255 character line size.
    so whenever i tried to print this report it print only line upto first 255 character and truncated after it in printing.
    is there any way i can print this report without truncation ....
    Thanks,
    Jack

    no there is no such way because you acan print at most 99 columns and utmost 255 characters .
    and alternative is take your filed in separate screen and make it appear through hotspot in another filedcatalog.then u will get more space .
    reward if useful
    keep rockin
    vivek

  • 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.

  • 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.

  • 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

  • Importing problems in alv report (stored versions)

    HI ALL, i have;
    DATA gt_results TYPE sp_data_type OCCURS 0 WITH HEADER LINE .
    FORM X .
    EXPORT gt_results TO DATABASE sp_ver_dat ID INDXKEY.
    ENDFORM .
    FORM Y .
    IMPORT gt_results  FROM DATABASE sp_ver_dat ID INDXKEY.
    ENDFORM .
    I coded this for storing alv datas as a version . Suppose i executed "form x" in 2008. After 1 year later, i would like to see this 2008 record. But my internal table type (sp_data_type) was changed (This change is obligatory). In example new 2 fields were added and 1 field was deleted. In spite of this, i have an error when i am attempting to run "form y"  because clustered data in database does not fit gt_results anymore. 
    How can i run such old stored versions of this alv report? How should i design this subroutines so there will be no problems even if internal table type frequently change in future..?
    I am expecitng your suggestions..
    Thanks..

    I think this is good solution for the versions which we will be created .  Unfortunately there is no way to save (excute) old versions in which structure of internal table  has changed  many times. We have to handle them manually..
    It means, we can save future but not past.. 
    ISN'T IT?
    Thanks all

  • Filter Function problems on ALV report. [Resolved]

    Hi,
    I developed an ALV report by using function as below:
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
             EXPORTING
                  I_CALLBACK_PROGRAM = G_REPID
    *            I_CALLBACK_PF_STATUS_SET = status_set
    *            I_CALLBACK_USER_COMMAND  = USER_COMMAND
                  I_STRUCTURE_NAME = 'T_BSIK'
                  IS_LAYOUT        = GS_LAYOUT
                  IT_FIELDCAT      = GT_FIELDCAT[]
             TABLES
                  T_OUTTAB    = TAB_BSIK.
    And this ALV custom report is referenced from standard function FBL5N.
    After i completed this report, i made an comparision of FBL5N and my custom report.
    When I apply the filter function, for example, on the document type, I cannot input 2 characters in the document type field under the filter function. The field length is only 1 character. Similar case results on the field document date.
    While the standard function FBL5N works very nice.
    What should i do to make the filter function of my own ALV report as the same as the standard function FBL5N do?
    Thanks in advance.
    Lala
    Message was edited by:
            Hoo lala

    Oh, i found where the problem is...
    add below 2 statements, then the question is resolved.
      LS_FIELDCAT-ref_fieldname = ****
      LS_FIELDCAT-ref_tabname = ***
    FORM FIELDCAT_INIT tables RT_FIELDCAT.
    CLEAR LS_FIELDCAT.
      LS_FIELDCAT-COL_POS   =  3.
      LS_FIELDCAT-FIELDNAME = 'BLART'.
      LS_FIELDCAT-TABNAME   = 'TAB_BSIK'.
      LS_FIELDCAT-SELTEXT_L = 'Document Type'.
      LS_FIELDCAT-ref_fieldname = 'BLART'.
      LS_FIELDCAT-ref_tabname = 'BSIK'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    endform.
    Fine now.
    Lala

  • ALV Report Print

    Hi All,
    can any one tel the solution fort me
    is there any function module to print ALV report with out giving print option manually( user press print button)

    Hi,
    execute that report and on output list GOTO LIST->PRINT.
    OR
    if u want to print the code itself then PROGRAM->PRINT.
    In the output screen
    GOTO LIST IN THE MENU
    SELECT EXPORT IN IT
    THEN SELECT EXPORT SPREAD SHEET
    to get other basic format for the alv output.
    -Thanks & Regards
    Saurabh Goel

  • ALV report Print out.

    Hi,
    I have developed a ALV report .
    I also want to take the print out of this report.
    How can i do this.

    Hi,
    Refer this code
    DATA : wa_variant  TYPE disvariant,       "Work area for variant
           wa_variant1 TYPE disvariant,       "Work area for variant
           wa_layout   TYPE slis_layout_alv,  "Work area for layout
           wa_print    TYPE slis_print_alv,   "Work area for print
    *&      Form  sub_alv_display                                          *
    This form displays the output using REUSE_ALV_GRID_DISPLAY          *
    function module                                                     *
    FORM sub_alv_display .
    *--Local Internal Table
      DATA : li_sort  TYPE slis_t_sortinfo_alv.
    *--Define print list
      wa_print-no_print_listinfos = c_chk.
      wa_print-no_coverpage = c_chk.
    *--If the No zero stock lines is checked in the selection screen
      IF  p_sline IS NOT INITIAL.
        DELETE i_final WHERE einme = c_zero.
      ENDIF.
      IF NOT i_final[] IS INITIAL.
    *--Call the function module to display the ALV report
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program = v_repid
            is_layout          = wa_layout
            it_fieldcat        = i_fieldcat
            i_default          = c_chk
            i_save             = c_save
            is_variant         = wa_variant
            it_events          = i_events
            is_print           = wa_print
            it_sort            = li_sort
          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.
      ELSE.
    *--No data found for the given selection criteria.
        MESSAGE i001.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM.                                  "sub_alv_display
    Regards,
    Prashant

  • ALV report - Print issues

    When trying to print an ALV report (Ctrl+P), printer has issues due to the shading (backgound colors) of the report.
    So here is my question,
    Is there a way to supress the report formatting while printing?
        or
    Can you convert an ALV into an unfomatted basic report?

    In the output screen
    GOTO  LIST IN THE MENU
    SELECT EXPORT IN IT
    THEN SELECT EXPORT SPREAD SHEET
    to get other basic format for the alv output.

Maybe you are looking for

  • No audio in 7.1

    I have tons of .mov files, but none of them are playing any audio since I upgraded to 7.1. Has anyone had a similar problem?   Windows XP Pro  

  • I upgraded my iphone os into 5.1 I found out I'm no longer able to connect into my home Wi Fi....please help :(

    I upgraded my iphone os into 5.1 I found out I'm no longer able to connect into my home Wi Fi....please help

  • Quick Switch Between Mic & Speakers?

    I prefer recording sections through an external mic and then listening to the recording from the main speakers in the computer. Is there a shortcut for doing this? Every time I have to unplug the USB and hit YES to use the main speakers for audio and

  • SAP Business Object Methodology

    Hi Experts, I'd like to know which are the methodologies to implement SAP Business Object, excluding SAP BW and includin SAP BW. I know for SAP the ASAP methodology is used, but I don´t know for SAP BO. Greetings & regards, Leonel

  • Set up DataSource on Tomcat

    Hi, I'm porting my faces app to Tomcat 5.5.9. I create a DataSource in the tomcat/admin tool. I've got 2 questions: do I specify "com.sun.sql.datasource.DriverAdapter" as the driverClass (just like in SunOne8)? Also, which .jar is this class located