ALV report - SAving layout

Hi,
I have created an ALV report using the class CL_GUI_ALV_GRID. The report has a toolbar which allows the layout of the report to be changed. But, it doesn't have any provision to save layouts. How do I enable this functionality?
Any help would be appreciated.
Thanks,
Divyaman

Hi,
while calling method grid1->set_table_for_first_display
pass parameter i_save = 'A'.
CALL METHOD grid1->set_table_for_first_display
    EXPORTING
      i_structure_name = 'ZCA0FCSTFTOP'
      is_layout        = grid_layout
      is_variant       = s_variant
      i_save           = 'A'
    CHANGING
      it_outtab        = t_zca0fcstftop
      it_fieldcatalog  = fieldcat.
regards,
vikas.
plz reward if helpful...

Similar Messages

  • Download alv report using layout variant in background

    Hi All,
    I want to download an Alv report using layout varaint in background job.
    can any one please help me.
    i.e...
    I am facing a problem in downloading a text file to the Application server.
    My requirement is, when the user downloads a file with the layout variant, the file should have only the columns which was selected in the variant.
    Will rewards to helpfull ans
    regards
    Chetan

    hey seshu,
    I am facing a problem in downloading a text file to the Application server.
    My requirement is, when the user downloads a file with the layout variant, the file should have only the columns which was selected in the variant.

  • ALV  Report Changed  Layout Cannot be saved .

    IN an ALV report if i changed the layout with selected fields .i cannot save it
    the save button on standard toll bar is disiabled
    as well as menu items to save the laout ...
    i can only chane the layout..
    ..please guide me in how to allow the end user to save the layout .....

    hi Vijay,
    when you call the ALV FM, beware of importing paramter i_save:
      CALL FUNCTION 'REUSE_ALV_...
       i_save                            = 'A'
    hope this helps
    ec

  • ALV report - copy layout to another user

    Hello,
    I have a question about ALV reports.
    In ALV we have option to select layout and save it by user-specific.
    How to copy this layout to another user?
    Is there some function/Bapi?
    Thanks in advance,
    Michal

    Hi Michael,
    Here are the steps I documented for managing this procedure:
    First Step is to READ the Layout into the Program
         The parameters for the layout can be found in table LTDX
    Goto SE37 and enter: LT_DBDATA_READ_FROM_LTDX
    When (READ) you will input information for the following parameters:
    Report Name
    Handle
    Log Group
    User
    Variant
    Type
    An example is shown below:
    <screen shots didn't load in my response> email if you'd like the document with screen shots>
    Execute.
    Now our next step is to WRITE the information from the program into table: LTDX
    While at the Function Builder Screen enter the new function module: LT_DBDATA_WRITE_TO_LTDX
    When you (WRITE) you will input information for the following parameters:
    Report Name
    Handle
    Log Group
    User
    Variant
    Type
    When completed, your input screen for (WRITE) should look like the screen below:
      <screen shots didn't load in my response> email if you'd like the document with screen shots>
    IMPORTANT     When entering information for IS_VARKEY, remember to use the u201Cnew useru201D ID
    When entering information for IS_VARIANT, remember to enter information exactly as found in table LTDX and remember that the parameter:  DEPENDVARS may be needed to complete your entry
    Now Execute the Function Module.  When completed go to table: LTDX and confirm that your new entry has been added.
    Pre Checklist:
    1.)     Capture entries (users) you want to copy from table: LTDX
    2.)     Make sure you have access to execute function modules/eCATT scripts
    3.)     Make sure you have table display access (needed to find and validate updates)
    If you'd like the documentation with screen shots please reply with your email address.
    Cheers,
    Robert

  • Download ALV report with layout to application server

    Hi Gurus,
    I have a problem as follows:
    I have one ALV Grid report. This report is very time consuming.
    That is why, user wants this to be run in background every night and in the morning when user comes to the office that ALV report should be on user's drive in excel format.
    However, it should run with one specific variant and that variant should be dynamically populated. (I have handled this part)
    It should also apply specific layout that has many filtering conditions.
    As I can not download ALV to excel in background, I decided to download it to the Application server.
    My problem is that when run in background, in spool ALV report shows o/p with proper filter conditions that is 5 out of 20 records.
    But, when I write this report o/p to Application server, it writes all the records in there, i.e., all 20 records. It does not take into account all the filters. [:(]
    I also tried downloading spool to excel, but o/p is not neatly formatted. All columns are fying here and there.
    Any suggestion, how can I write ALV o/p to Application server with layout into consideration?
    P.S. I have searched forum for this type of query, but no apt responses.
    Thanks

    did u downloaded the report with standard option provided in the alv and checked the data? that is populating all 20 records?. if so then use coding for achieving the standard one
    at the end of selection do like this ..
    SET USER-COMMAND ' %PC' .
    and in the user-command use like this..
    case sy-ucomm.
    when '  %PC'.
    give the file name ..
    do processing ..
    endcase.

  • IN ALV Report 'SAVE LAYOUT' option missing

    Dear All,
                 I have created one report in ALV GRID using ABAP OBJECTS(Using class CL_GUI_CUSTOM_CONTAINER and
    CL_GUI_ALV_GRID).But in output when i click on change layout option i am not getting SAVE layout option.
    I have already passed I_SAVE parameter = 'A' while calling metod SET_TABLE_FOR_FIRST_DISPLAY. But i didnt worked.
               Please do needful.
    Regards,
    Mayank

    Hi,
    You can manage display variants by using parameters, “is_variant” and “i_save” of “set_table_for_first_display”. Here are options for variant handling. <structure_name> is the variant-defining structure of type “DISVARIANT”. The field “report” in this structure should contain the value of “sy-repid.”
    Hope this helps. Reward points if helpful.
    Thanks,
    Balaji

  • Downloading ALV Report using Layout Variant

    I want to download an Alv grid report output using layout varaint to Presentation server and also wants to mail to user .
    i.e...
    I am facing a problem in downloading and in sending mail.
    My requirement is, user  will choose  layout variant
    As per Variant chosen, i have to download that alv grid output to presentation server and also to mail.
    These download and mail sending options is in selction screen
    Will rewards to helpfull ans

    Hello,
    Do like this.
    FORM DOWNLOAD_FILE TABLES P_T_LISTE STRUCTURE G_T_LISTE.
      G_R_DISP_VARIANT-REPORT = SY-REPID.
      G_R_DISP_VARIANT-VARIANT = PA_VAR.
      CALL FUNCTION 'REUSE_ALV_VARIANT_SELECT'
           EXPORTING
                I_DIALOG            = 'N'
                I_USER_SPECIFIC     = 'A'
                I_DEFAULT           = 'X'
                IT_DEFAULT_FIELDCAT = G_T_FIELDCAT
                I_LAYOUT            = G_R_LAYOUT
           IMPORTING
                ET_FIELDCAT         = G_T_FIELDCAT
                ES_LAYOUT           = G_R_LAYOUT
           CHANGING
                CS_VARIANT          = G_R_DISP_VARIANT
           EXCEPTIONS
                ERROR_MESSAGE       = 4
                OTHERS              = 4.
      LOOP AT G_T_FIELDCAT INTO G_R_FIELDCAT WHERE NO_OUT NE 'X'
                                               AND TECH IS INITIAL
                                               AND FIELDNAME NE 'ICON'.
        MOVE-CORRESPONDING G_R_FIELDCAT TO IS_FIELDCAT.
        IS_FIELDCAT-FIELDNAME = G_R_FIELDCAT-FIELDNAME.
        IS_FIELDCAT-INTTYPE   = G_R_FIELDCAT-INTTYPE.
        IS_FIELDCAT-OUTPUTLEN = G_R_FIELDCAT-OUTPUTLEN.
        IS_FIELDCAT-REF_FIELD = G_R_FIELDCAT-FIELDNAME.
        IS_FIELDCAT-REF_TABLE = G_R_FIELDCAT-REF_TABNAME.
        APPEND IS_FIELDCAT TO IT_FIELDCAT.
      ENDLOOP.
      DATA: WA_LISTE LIKE P_T_LISTE.
      CLEAR:IT_OUTTAB.
      REFRESH: IT_OUTTAB.
      LOOP AT P_T_LISTE INTO WA_LISTE.
        WA_OUTTAB-PSPID = WA_LISTE-PSPID .
        WA_OUTTAB-POSID = WA_LISTE-POSID.
        WA_OUTTAB-POST1 = WA_LISTE-POST1.
        WA_OUTTAB-STTXT_INT = WA_LISTE-STTXT_INT.
        WA_OUTTAB-STTXT_EXT = WA_LISTE-STTXT_EXT.
        APPEND WA_OUTTAB TO IT_OUTTAB.
      ENDLOOP.
    **dynamic table creation for data
      ASSIGN LT_DATA TO <FS_DATA>.
    * Create a new Table
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
      EXPORTING
            IT_FIELDCATALOG = IT_FIELDCAT
      IMPORTING
            EP_TABLE = <FS_DATA>
      EXCEPTIONS
          GENERATE_SUBPOOL_DIR_FULL = 1
          OTHERS                    = 2.
      IF SY-SUBRC = 0.
        ASSIGN <FS_DATA>->* TO <FS_1>.
        CREATE DATA NEW_LINE LIKE LINE OF <FS_1>.
    *** A field-symbol to access that work area
        ASSIGN NEW_LINE->*  TO <FS_2>.
    **MOVE DATA
        LOOP AT IT_OUTTAB INTO WA_OUTTAB.
          CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
               EXPORTING
                    INPUT  = WA_OUTTAB-PSPID
               IMPORTING
                    OUTPUT = WA_OUTTAB-PSPID.
          CALL FUNCTION 'CONVERSION_EXIT_ABPSN_OUTPUT'
               EXPORTING
                    INPUT  = WA_OUTTAB-POSID
               IMPORTING
                    OUTPUT = WA_OUTTAB-POSID.
          LOOP AT G_T_FIELDCAT INTO G_R_FIELDCAT
                              WHERE NO_OUT IS INITIAL
                                AND TECH IS INITIAL.
            ASSIGN COMPONENT G_R_FIELDCAT-FIELDNAME OF STRUCTURE
                                                    WA_OUTTAB TO <FS_5>.
            ASSIGN COMPONENT G_R_FIELDCAT-FIELDNAME OF STRUCTURE
                                                    <FS_2> TO <FS_3>.
            <FS_3> = <FS_5>.
          ENDLOOP.
          INSERT <FS_2> INTO TABLE <FS_1>.
        ENDLOOP.
      ELSE.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE.
      IF SY-SUBRC EQ 0.
        LOOP AT <FS_1> ASSIGNING <FS_2>.
          TRANSFER  <FS_2> TO P_FILE.
        ENDLOOP.
      ELSE.
        MESSAGE E041(S9) WITH P_FILE.
      ENDIF.
      CLOSE DATASET P_FILE.
    ENDFORM.                    " download_file
    * 002 vsm1kor 13.06.06 - en
    Regards,
    Vasanth

  • Displaying an ALV report using a saved layout.

    Dear friends
    In ALV report there are 2 standard buttons.
    One says "select Layout CTRLF9" and another one says "Save Layout CTRLF10".
    Using this I can select the layout and save it using some variable.
    Now I want to create a field in the main screen so that when
    I enter this saved name  and run  the ALV report, it should show
    report using the layout I entered selected (which was saved earlier).
    Where will this variable get saved and how can i access this and make it
    display using this layout.
    Any feed back will be greatly appreciated.
    Thanks
    Ram

    Hi Ram,
    Try this code..
    BR
    Rakesh
    **// INITIALIZATION.
    initialization.
      perform initialize_variables.
    **// AT SELECTION-SCREEN.
    at selection-screen.
      if p_vari is initial.
        variant_init.
      endif.
      perform check_email.
    at selection-screen on value-request for p_vari.
      alv_f4_for_variant.                                       "#EC
    at selection-screen on p_vari.
      alv_pai_of_selection_screen.
                                  M A C R O S                            *
    define variant_init.
      clear: disvariant,
             vartext.
      if v_pgm is initial.
        disvariant-report     = sy-cprog.
      else.
        disvariant-report     = v_pgm.
      endif.
    end-of-definition.
    define alv_f4_for_variant.
      variant_init.
      call function 'REUSE_ALV_VARIANT_F4'
           exporting
                is_variant = disvariant
                i_save     = xsave
           importing
                e_exit     = i_exit
                es_variant = disvariant
           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.
      elseif i_exit = space.
        p_vari  = disvariant-variant.
        vartext = disvariant-text.
        refresh i_dynpread.
        i_dynpread-fieldname  = 'VARTEXT'.
        i_dynpread-fieldvalue = disvariant-text.
        append i_dynpread.
        call function 'DYNP_VALUES_UPDATE'
             exporting
                  dyname     = v_pgm
                  dynumb     = '1000'
             tables
                  dynpfields = i_dynpread.
        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.
        variant_init.
      endif.
    end-of-definition.
    define alv_pai_of_selection_screen.
      if not p_vari is initial.
        move p_vari to disvariant-variant.
        call function 'REUSE_ALV_VARIANT_EXISTENCE'
             exporting
                  i_save     = xsave
             changing
                  cs_variant = disvariant.
        vartext = disvariant-text.
      else.
        variant_init.
      endif.
    end-of-definition.

  • 'Save layout' button missing in the ALV report layout screen

    Hi Friends,
         In one of our ALV report the 'save layout' button is missing in the report output screen.i have used the OO concept for creating the ALV output and not the function module.I have attached the code below used for creating the ALV grid.
    CREATE OBJECT alv_grid
          EXPORTING i_parent = g_container_2.
    CALL METHOD alv_grid->set_table_for_first_display
         exporting
                   i_structure_name = 'PA0002'
                   is_layout =
           CHANGING
                     it_outtab = gt_outtab
                     it_fieldcatalog = wa_fieldcat.
    But i'm not able to trace why the 'save layout' button is missing in the output.Can anyone of you help me in sorting out this problem.
    Thanks and Regards,
    Vadivel.

    Pass <u><i><b>A to I_SAVE</b></i></u> parameter. That will give the options to the user to save the layout outs.
    I_SAVE = SPACE
    Layouts cannot be saved.
    I_SAVE = 'U'
    Only user-defined layouts can be saved.
    I_SAVE = 'X'
    Only global layouts can be saved.
    I_SAVE = 'A'
    Both user-defined and global layouts can be saved.
    Regards,
    Ravi
    Note : Please mark all the helpful answers
    Message was edited by: Ravikumar Allampallam

  • While Saving ALV report in Local File getting error

    Hello Experts,
    Did one alv report.
    Getting output properly , but while saving(downloading) the output result getting Dump from system.
    Runtime Errors         GETWA_NOT_ASSIGNED
    Short text
         Field symbol has not yet been assigned.
    What happened?
         Error in the ABAP Application Program
         The current ABAP program "SAPLKKBL" had to be terminated because it has
         come across a statement that unfortunately cannot be executed.
    NOT GETTING WHERE EXACTLY IT IS WRONG....
    Please suggest the solution..
    Thanks in advance

    Usually this is due to wrong fieldcatalog, or inconsistenecy between field catalog, internal table or some fields of the layout (bselect box or lights for example) -> The FIRST thing to do is the execution of [The Consistency Check|http://help.sap.com/saphelp_470/helpdata/en/d6/23253963143e6ae10000000a11402f/frameset.htm], then correct the program to adjust field catalog or layout.
    Regards,
    Raymond

  • How can I add a custom title to multiple ALV reports selected by layout?

    Greetings and good day, everyone!
    Within the past week or so, I posted a question asking the best way to create a program that would generate multiple ALV reports.  I got some great ideas, and I've actually coded up a few simple demos based on your feedback -- thank you!
    Here's the issue I'm running into:  Many of you suggested that I put all report records into one table, and create a field that I could use to filter on later to determine which fields I want to display for the report.  For example, if I have 3 different reports, I put all the fields for all 3 reports into a table.  I then add a "report key" field.  As I put records into the report table for report 1, I code "01" into the "report key" field.  I do the same for reports 2 and 3, assigning each a "report key" of "02" and "03", respectively.
    I then set up layouts in the ALV for each of the three reports, using the filter option to only pull records with the "report key" value for that particular report.  This all works wonderfully!  However, I seem to have lost the ability to show a custom title for each layout.  I can create a generic TITLEBAR (like "Reporting Center") but I don't know how to reset the grid's title when a layout is selected.  I was hoping that SAP might use the layout description as the title on each page, but it doesn't -- it uses the TITLEBAR text.
    Any ideas?  I think this might be the best way to program multiple ALV reports, but if I can't display the right report title for a particular layout, I'll probably have to go back to my other alternative of putting each report in its own container/screen, and having a button to access each report from the application toolbar.
    Thanks,

    Srikanth,
    I don't have any Selection Screen radio buttons for the user to select a particular report; in my case, they specify some needed criteria by the program in the Selection Screen, the program goes off and does a fair bit of processing/updating, and then displays the ALV reports when finished.  They don't want to choose one particular report to view ahead of time; they want to have all 3 (in my case) there to see what processed correctly, what was eligible to process but kicked out with errors, and what failed some matching checks done up front (this layout includes additional fields from the input file so they can see what didn't match up against R/3).
    So, while I do like the code example you presented, I don't think it's going to help me in my case.

  • Error while saving layout  for report

    Using BIEE 11. (Win64 Server 2003 R2 - russian edition)
    When designing layout for report and putting text field (dos'nt matter - russ or engl) - I get an error during saving - 'Error when saving layout' (trunslated from russ)
    This happens only when putting text field, with other types of filds all is ok!
    Where can I find more detailed info about my error?
    Also when I choose layout from existing e.g. - Dashboard.xpt and save - I get the same error. When I cut off all text fields from this template - I can successfully save it.
    Thanks

    Check the OSS note 550760 regarding the issue.

  • Problem in saving layout in ALV's

    Hi all!
         I am getting a strange problem in ALV's .For an ALV report some users are able to save the layouts where as some are not able to save .Why is it happening so? I have mentioned IS_SAVE = 'X' in my func.module REUSE_ALV_GRID_DISPLAY.Please help.

    Hi,
    You Have to call the Fm Reuse_alv_variant_f4
    SELECTION-SCREEN : BEGIN OF BLOCK blk3 WITH FRAME TITLE text-003.
    PARAMETER:p_var TYPE disvariant-variant MODIF ID p2.                    "Variant Part
    SELECTION-SCREEN:END OF BLOCK blk3.
    Data: wa_variant   TYPE   disvariant,
             wa_variant1  TYPE   disvariant.
    CONSTANTS:c_x(1)             TYPE c VALUE'X',
                        lc_a(1)            TYPE c VALUE 'A',
    FORM alv_variant .
      wa_variant-username = sy-uname.
      wa_variant-report = sy-repid.
    *For variant Part
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant    = wa_variant
          i_save        = lc_a
        IMPORTING
          es_variant    = wa_variant1
        EXCEPTIONS
          not_found     = 1
          program_error = 2
          OTHERS        = 3.
      IF sy-subrc <> 0.
        p_var = wa_variant-variant.
      ELSE.
        p_var = wa_variant1-variant.
      ENDIF.
    ENDFORM.                       " alv_variant
    After That
    *display variant
      wa_variant-report = sy-repid.
      IF NOT p_var IS INITIAL.
        wa_variant-variant = p_var.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = sy-repid
          i_callback_pf_status_set = 'PF_STATUS'
          i_callback_user_command  = 'USER_COMMAND'
          is_layout                = lwa_layout
          it_fieldcat              = gi_fieldcat
          is_variant               = wa_variant
          i_default                = c_x
          i_save                   = lc_a
        TABLES
          t_outtab                 = gi_final
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
    Regards
    Sandipan

  • Create a ALV report with fields editable and  entry to be saved in ztable

    Hello Experts,
    I have created the ALV report which has two of the fields editable. Now whenever user puts an entry in the ALV it has to be saved in the ZTABLE.
    The report is displayed with editable fields but i'm not sure what has to be written in the 'USER COMMAND' subroutine to save the entries in ztable.
    Please see my code belwo:-
      gd_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program      = gd_repid
               i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
                i_callback_user_command = 'ALV_USER_COMM'
               i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
               it_special_groups       = gd_tabgroup
               it_events               = gt_events
               is_print                = gd_prntparams
                 i_save                  = 'X'
               is_variant              = z_template
           TABLES
                t_outtab                = it_bg2
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
      IF sy-subrc <> 0.
    Thanks,
    Naveen
    Edited by: jaikrishna on Sep 4, 2010 8:13 AM

    Hi,
    I have worked on similar requirement. You can do that on sy-ucomm value only and you have to call a FM and a method. For that end user has to click on a button which you need to create in the application toolbar. Say that button function code is 'SAVE'. Write the following code in your user command :
    *&      Form  USER_COMMAND
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
            RS_SELFIELD TYPE SLIS_SELFIELD.
    *Code to reflect the changes done in the internal table
      DATA : REF_GRID TYPE REF TO CL_GUI_ALV_GRID.
      DATA: L_VALID TYPE C.
      IF REF_GRID IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            E_GRID = REF_GRID.
      ENDIF.
      IF NOT REF_GRID IS INITIAL.
        CALL METHOD REF_GRID->CHECK_CHANGED_DATA
          IMPORTING
            E_VALID = L_VALID.
      ENDIF.
      CASE SY-UCOMM.
        WHEN 'SAVE'.
    *Data will come with the edited values from ALV
    *Here you write your code to save entries into Z table
    ENDCASE.
    ENDFORM. "USER_COMMAND
    Thanks & Regards,
    Rock.

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

Maybe you are looking for

  • Purchase order and goods receipt

    Hello to everyone, is there any way to view only the last purchase order and the last goods receipt for several materials? Regards

  • I want to call components of an internal table in ABAP-Objects!!!!

    Hy all, I am trying to call the component my_query_info-compuid. But if I do it that way like shown below I get a Syntax error message. "MY_QUERY_INFO" is a table without a header line and therefore has no component called "COMPUID". And in Classes a

  • How to free up memory in MacBook Pro?

    How to free up memory in MacBook Pro? (How to avoid getting the revolving rainbow?)

  • PO line item question

    What is "PO line item"? in which table can I find it? I've joined ABAP development team and worked on MM report. Thanks!

  • TV Out Card (MS-6957-020)

    I am buying the Mega Barebone PC, anyone have any clue where to get the TV Out Card (MS-6957-020) for it.  I cant find it anywhere!