ALV Sort problem

Hi Experts,
I have encountered a peculiar situation with respect to ALV, using sort. The problem is as follows:
1. I have an internal table with 3 fields, upon which I am supposed to implement a sort criteria on the first two fields.
2. My data is something like this, for ex:
abc  1  a
abc  1  b
cde  1  a
cde  1  b
3. I have applied sort criteria, on the first two fields and passed to the fm "REUSE_ALV_GRID_DISPLAY'.
4. Now the output is as follows:
abc  1  a
  --  b
cde --  a
---   --  b
Here ( -- ) dotted lines mean the identical entry from the previous row...
5. My requirement is I want the output as:
abc  1  a
---  --   b
cde  1  a
---   --  b 
I mean the sort critetia of the second column should follow the first(adjacent column) sort criteria
I hope it is clearly explained, and kindly let me know how this can be solved..
Thank you,
Shashi

Hi Bala,
The suggested solution is not giving the desired results..
This happens because, when i sort the entries i mentioned earlier, remains the same, even after the two explicit sort statements on the internal table.
Kindly check the same and let me know.
Regards,
Shashi

Similar Messages

  • Sorting Problem in FND_MENU_ENTRIES_TL Table

    Hi,
    FND_MENU_ENTRIES_TL Table storing the record FND_MENU_ENTRIES_TL_N1(MENU_ID,PROMPT,LANGUAGE) wise in R12. But whereas in 11i, records stored FND_MENU_ENTRIES_TL_U1(MENU_ID,ENTRY_SEQUENCE,LANGUAGE).
    I am confused, whether i need to recreate the index in R12, so the records will get store MENU_ID,ENTRY_SEQUENCE,LANGUAGE wise.
    Could any one please suggest me how to resolve this problem.
    Thanks,
    Praba T

    815667 wrote:
    Hi,
    FND_MENU_ENTRIES_TL Table storing the record FND_MENU_ENTRIES_TL_N1(MENU_ID,PROMPT,LANGUAGE) wise in R12. But whereas in 11i, records stored FND_MENU_ENTRIES_TL_U1(MENU_ID,ENTRY_SEQUENCE,LANGUAGE).
    I am confused, whether i need to recreate the index in R12, so the records will get store MENU_ID,ENTRY_SEQUENCE,LANGUAGE wise.
    Could any one please suggest me how to resolve this problem.
    Thanks,
    Praba TPl do not abuse the forums by cross-posting in multiple forums
    Sorting Problem in FND_MENU_ENTRIES_TL Table
    Sorting Problem in FND_MENU_ENTRIES_TL Table
    Your issue is related to EBS, not to database upgrades (which is the topic of this forum)
    Srini

  • Sorting problems in Grid View

    Hi, I'm having a bit of a sorting problem when it comes to an artist with name variations. The example I'm going to use is DJ Tiesto.
    There are album I have where he is credited as DJ Tiesto, and others where he is simply Tiesto.
    In the end, I'd like these albums sorted chronologically under one name (say DJ Tiesto), while still preserving and showing the proper artist name for each album. I have it set to sort by "Album by Year", which is working fine.
    The major problem I am having is that I can't get it to display properly across all iTunes viewing methods: List mode, Grid mode, and Coverflow.
    I've tried leaving the Artist field alone, and changing the Sort Artist field to "DJ Tiesto" for all songs, and that almost works:
    -List mode groups them all under "DJ Tiesto", while showing each albums Artist as the correct artist name.
    -Grid mode sorted by Album groups them all under "DJ Tiesto", while showing each albums Artist as the correct artist name.
    -Coverflow sorts them all in chronological order, while showing each albums Artist as the correct artist name.
    Problem is, Grid mode sorted by ARTIST creates two separate artists! Some for DJ Tiesto and some for Tiesto!
    To correct this I tried changing the Album Artist field for all songs to "DJ Tiesto", which solved that problem but created a bunch of new ones:
    -List mode is still correctly grouping them under "DJ Tiesto", while showing each albums Artist as the correct artist name.
    -Grid mode sorted by Album is still correctly grouping them under "DJ Tiesto", *however now it is not displaying the correct Artist name for each album!*
    -Grid mode sorted by Artist is now grouping them all under "DJ Tiesto", *however it is not displaying the correct Artist name for each album!*
    -Coverflow is sorting them in correct chronological order, *however it as well is not displaying the correct Artist name for each album!*
    Using the Album Artist tag has created more problems that it has solved! Is there anyone who knows a way to achieve what I am trying to do? I have tried seemingly every option I can and have still not found a way to do this!!
    Thanks!

    My own method of working involves renaming the files upon import to:
    i "shotdate_sequencenumber"
    Files are therefore typically named
    b 2007-11-25_001
    etc.
    This way, sorting by Filename automatically sorts by Date by default. And it wouldn't even matter if you added a descriptive text in between the date and number (
    b 2007-11-25_Scotland_001

  • Hotspot-clicking (Insert function) plus ALV Sorting

    Hi,
    I have a requirement where the ALV display has to be SORTED based on values entered/changed on a certain column. The sort works ok when used with a custom APPEND button for new records (always inserted at the bottom of the list).
    However, it does not work correctly when used with the Hotspot-click (INSERT functionality). It looks like if you CLICK on a particular record onscreen, you are actually addressing the original record in that position before the SORT was effected. 
    Is the Hotspot-clicking (Insert functionality) possible with ALV sorting? The ideal solution would be to have the ALV sorted at PBO and also at PAI so that the user can change existing records and add new ones with the sorting being updated everytime ON_DATA_CHANGED is triggered.
    Will appreciate any help on this.
    Thanks!
    Michael

    Hello Michael
    Thanks for further specifying your requirements. I have created the sample variant ZUS_SDN_ALVGRID_HOTSPOT_SORT_1 which contains two differences as compared to its template:
    Replace table VBAK with VBAP (so we have two levels of sorting: VBELN, POSNR)
    Move SET_TABLE_FOR_FIRST_DISPLAY method call into PBO
    When I click on the hotspot (VBELN) a new row entry for the order number is created. The sorting (VBELN, POSNR) is kept even though the new row has been appended to the itab.
    *& Report  ZUS_SDN_ALVGRID_HOTSPOT_SORT
    *& Thread: Hotspot-clicking (Insert function) plus ALV Sorting
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1159431"></a>
    REPORT  zus_sdn_alvgrid_hotspot_sort.
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE TYPE vbap.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    DATA: gt_outtab    TYPE ty_t_outtab.
    DATA:
      gd_okcode        TYPE ui_func,
      gd_repid         TYPE syrepid,
      gt_sort          TYPE lvc_t_sort,
      gt_fcat          TYPE lvc_t_fcat,
      gs_layout        TYPE lvc_s_layo,
      gs_variant       TYPE disvariant,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_grid          TYPE REF TO cl_gui_alv_grid.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA:
          ms_sel_row    TYPE lvc_s_row. " selected row
        CLASS-METHODS:
          handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid
            IMPORTING
              er_data_changed
              e_onf4
              e_onf4_before
              e_onf4_after
              sender,
          handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
            IMPORTING
              e_row_id
              e_column_id
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_data_changed.
        FIELD-SYMBOLS: <lt_outtab>  TYPE ty_t_outtab.
        BREAK-POINT.
      ENDMETHOD.                    "handle_data_changed
      METHOD handle_hotspot_click.
        " define local data
        DATA: ls_outtab    TYPE ty_s_outtab,
              ld_msg        TYPE bapi_msg.
        BREAK-POINT.
        CLEAR: lcl_eventhandler=>ms_sel_row.
        ms_sel_row = e_row_id.
        READ TABLE gt_outtab INTO ls_outtab INDEX e_row_id-index.
        CONCATENATE 'Selected Sales Order = ' ls_outtab-vbeln ' / '
                                              ls_outtab-posnr
          INTO ld_msg.
          message i398(00) with ld_msg.
        " Trigger PAI
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = 'INSERT'
    *      IMPORTING
    *        rc       =
      ENDMETHOD.                    "handle_hotspot_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    PARAMETERS:
      p_vkorg      TYPE vkorg  DEFAULT '0001'  OBLIGATORY.
    START-OF-SELECTION.
    **  SELECT  * FROM  vbak INTO CORRESPONDING FIELDS OF TABLE gt_outtab
    **    UP TO 200 ROWS
    **         WHERE  vkorg = p_vkorg.
      SELECT * FROM vbap INTO CORRESPONDING FIELDS OF TABLE gt_outtab
        UP TO 100 ROWS.
      PERFORM init_controls.
    * Build fieldcatalog and set hotspot for field KUNNR
      PERFORM build_fieldcatalog.
      PERFORM set_layout_and_variant.
      PERFORM set_sorting.
      " Register EDIT event
      CALL METHOD go_grid->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_enter
        EXCEPTIONS
          error      = 1
          OTHERS     = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      SET HANDLER:
        lcl_eventhandler=>handle_data_changed  FOR go_grid,
        lcl_eventhandler=>handle_hotspot_click FOR go_grid.
    * Link the docking container to the target dynpro
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * ok-code field = GD_OKCODE
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    * Display data
      CALL METHOD go_grid->set_table_for_first_display
        EXPORTING
          i_bypassing_buffer            = abap_true
          is_variant                    = gs_variant
          i_save                        = 'A'
    *      i_default                     = 'X'
          is_layout                     = gs_layout
    *      is_print                      =
    *      it_special_groups             =
    *      it_toolbar_excluding          =
    *      it_hyperlink                  =
    *      it_alv_graphics               =
    *      it_except_qinfo               =
    *      ir_salv_adapter               =
        CHANGING
          it_outtab                     = gt_outtab
          it_fieldcatalog               = gt_fcat
          it_sort                       = gt_sort
    *      it_filter                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    **  CALL METHOD go_grid->refresh_table_display
    ***        EXPORTING
    ***          IS_STABLE      =
    ***          I_SOFT_REFRESH =
    **    EXCEPTIONS
    **      finished       = 1
    **      OTHERS         = 2.
    **  IF sy-subrc ne 0.
    ***       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    ***                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    **  ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'EXIT'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN 'INSERT'.
          PERFORM insert_row.
        WHEN OTHERS.
          " Check for changed data at the frontend (= grid control)
          CALL METHOD go_grid->check_changed_data( ).
      ENDCASE.
      CALL METHOD go_grid->refresh_table_display
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 1
          OTHERS         = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  INIT_CONTROLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          others = 6.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD go_docking->set_extension
        EXPORTING
          extension  = 99999
        EXCEPTIONS
          cntl_error = 1
          OTHERS     = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create ALV grid
      CREATE OBJECT go_grid
        EXPORTING
          i_parent = go_docking
        EXCEPTIONS
          others   = 5.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " INIT_CONTROLS
    *&      Form  BUILD_FIELDCATALOG
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog.
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'VBAP'  " 'VBAK'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc NE 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    **  LOOP AT gt_fcat INTO ls_fcat.
    **    CASE ls_fcat-fieldname.
    **      WHEN 'VBELN'  OR
    **           'ERDAT'  OR
    **           'ERZET'  OR
    **           'ERNAM'  OR
    **           'AUART'  OR
    **           'NETWR'  OR
    **           'WAERK'.
    **        CONTINUE.
    **      WHEN OTHERS.
    **        ls_fcat-no_out = abap_true.
    **    ENDCASE.
    **    MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
    **  ENDLOOP.
    * Only non-key fields are editable
    **  ls_fcat-edit = 'X'.
    **  MODIFY gt_fcat FROM ls_fcat
    **    TRANSPORTING edit
    **    WHERE ( fieldname NE space ).
      ls_fcat-hotspot = abap_true.
      MODIFY gt_fcat FROM ls_fcat
        TRANSPORTING hotspot
        WHERE ( fieldname = 'AUART'   OR
                fieldname = 'VBELN' ).
    **  DELETE gt_fcat FROM 15 TO 99.
    ENDFORM.                    " BUILD_FIELDCATALOG_KNB1
    *&      Form  SET_LAYOUT_AND_VARIANT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_layout_and_variant .
      CLEAR: gs_layout,
             gs_variant.
      gs_layout-cwidth_opt = abap_true.
      gs_variant-report = syst-repid.
      gs_variant-handle = 'GRID'.
    ENDFORM.                    " SET_LAYOUT_AND_VARIANT
    *&      Form  SET_SORTING
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_sorting .
    * define local data
      DATA: ls_sort   TYPE lvc_s_sort.
      REFRESH: gt_sort.
      CLEAR: ls_sort.
      ls_sort-spos = 1.
      ls_sort-fieldname = 'VBELN'.
      ls_sort-up = abap_true.
      APPEND ls_sort TO gt_sort.
      CLEAR: ls_sort.
      ls_sort-spos = 1.
      ls_sort-fieldname = 'POSNR'.
      ls_sort-up = abap_true.
      APPEND ls_sort TO gt_sort.
    ENDFORM.                    " SET_SORTING
    *&      Form  INSERT_ROW
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM insert_row .
    * define local data
      DATA: ls_outtab   TYPE ty_s_outtab,
            ld_order    TYPE vbeln.
      READ TABLE gt_outtab INTO ls_outtab
                           INDEX lcl_eventhandler=>ms_sel_row-index.
      ld_order = ls_outtab-vbeln.
      " Find last item of sales order
      LOOP AT gt_outtab INTO ls_outtab
                        WHERE ( vbeln = ld_order ).
      ENDLOOP.
      " Create next item:
      add 10 to ls_outtab-posnr.
      " NOTE: added at the end of the list
      APPEND ls_outtab TO gt_outtab.
      " NOTE: insert new row AFTER selected row => works, too
    **  INSERT ls_outtab INTO gt_outtab
    **                   INDEX lcl_eventhandler=>ms_sel_row-index.
    ENDFORM.                    " INSERT_ROW

  • Sorting problem in standard vendor search help

    Hi all,
    I'm enhancing the vendor search help.
    I found that there is a sorting problem in the original standard search help.
    The 1st time to search vendor in the search help returns a correct list, then I just sort the vendor in ascending order. This time the column name of the hit list changes and mismatch the actual values.
    Any one faced this problem before?
    What's wrong are there ?
    Thanks.

    Thanks Peluka.
    But even I don't enhance the vendor search help, I still found that the original standard version has this problem after sorting.
    Is that the program bug?
    Have anyone encountered this problem before?

  • ALV Sort

    Hi Guru's
    i am use alv sort in my report .
    i use following code.
    but it gives me DUMP ERROR.
    my code like this.
    DATA : it_sort TYPE slis_t_sortinfo_alv WITH HEADER LINE.
    FORM do_sort .
      it_sort-spos = 1.
      it_sort-fieldname = 'vbeln'.
      it_sort-tabname = 'it_vbak'.
      it_sort-up = 'X'.
      it_sort-subtot = 'X'.
    it_sort-group = '*'.
    it_sort-expa = 'X'.
      APPEND it_sort.
      it_sort-spos = 2.
      it_sort-fieldname = 'posnr'.
      it_sort-tabname = 'it_vbap'.
      it_sort-up = 'X'.
      it_sort-subtot = 'X'.
    it_sort-group = '*'.
    it_sort-expa = 'X'.
      APPEND it_sort.
    ENDFORM.  
    please tell me where is the error.
    Thanks in advance.
    Regards.
    Sam.

    Hi,
    Try the following code
    DATA : it_sort TYPE slis_t_sortinfo_alv WITH HEADER LINE.
    FORM do_sort .
    it_sort-spos = 1.
    it_sort-fieldname = 'VBELN'.
    it_sort-tabname = 'IT_VBAK'.
    it_sort-up = 'X'.
    it_sort-subtot = 'X'.
    it_sort-group = '*'.
    it_sort-expa = 'X'.
    APPEND it_sort.
    it_sort-spos = 2.
    it_sort-fieldname = 'POSNR'.
    it_sort-tabname = 'IT_VBAP'.
    it_sort-up = 'X'.
    it_sort-subtot = 'X'.
    it_sort-group = '*'.
    it_sort-expa = 'X'.
    APPEND it_sort.
    ENDFORM.
    Hope this will have u.
    If it is helpful provide point.
    Thanks.

  • Sorting problem in ALV

    I am facing the following problem:
    I have an ALV list in the following format:
    fld1          fld2          fld3
    bb1          bb2          comp1
    <blank>          <blank>          comp2
    <blank>          <blank>          comp3
    aa1          aa2          comp4
    <blank>          <blank>          comp5
    <blank>          <blank>          comp6
    <blank>          <blank>          comp7
    <blank> - spaces are displayed
    where:
    comp1 ; comp2 ; comp3 -> belong to bb1 (fld1) field and
    comp4 ; comp5 ; comp6 ; comp7 -> belong to aa1 (fld1) field
    Now, when the user is sorting the ALV report by field: "Fld1" (by clicking on the ascending or descending sort buttons on ALV), the ALV list is displayed in the following format:
    fld1          fld2          fld3
    <blank>          <blank>          comp2
    <blank>          <blank>          comp3
    <blank>          <blank>          comp5
    <blank>          <blank>          comp6
    <blank>          <blank>          comp7
    aa1          aa2          comp4
    bb1          bb2          comp1
    where as, I was expecting the output to be in this format:
    fld1          fld2          fld3
    aa1          aa2          comp4
    <blank>          <blank>          comp5
    <blank>          <blank>          comp6
    <blank>          <blank>          comp7
    bb1          bb2          comp1
    <blank>          <blank>          comp2
    <blank>          <blank>          comp3
    Problem: The "<blanks>" in the ALV are also sorted and fld3 is not attached with fld1 and fld2.
    Is there any way by which I can avoid this problem??
    I am using "set_table_for_first_display" method to display the ALV report.
    I have already tried grouping fld3 (comp's) by fld1 and fld2 using nested internal table (both statically and using pointers) and passing it to ALV via. "r_alv_grid->set_table_for_first_display" method. However, this didnt work.
    Please help.

    REPORT ZBLOCK_ALV.
    CONSTANTS :
      c_x VALUE 'X'.
    Macro definition
    DEFINE m_fieldcat.
      ls_fieldcat-fieldname = &1.
      ls_fieldcat-ref_tabname = &2.
      ls_fieldcat-tabname = &3.
      append ls_fieldcat to lt_fieldcat.
    END-OF-DEFINITION.
    DEFINE m_sort.
      ls_sort-fieldname = &1.
      ls_sort-up        = c_x.
      append ls_sort to lt_sort.
    END-OF-DEFINITION.
    TYPE-POOLS: slis.                      " ALV Global types
    TYPES:
    1st Table
      BEGIN OF ty_kna1,
        kunnr TYPE kna1-kunnr,             " Customer number
        ernam TYPE kna1-ernam,             " Name of Person who Created
        erdat TYPE kna1-erdat,             " Creation date
        name1 TYPE kna1-name1,             " Name 1                    .
      END OF ty_kna1,
    2nd Table
      BEGIN OF ty_mara,
        matnr TYPE mara-matnr,             " Material number
        ernam TYPE mara-ernam,             " Name of Person who Created
        ersda TYPE mara-ersda,             " Creation date
        mtart TYPE mara-mtart,             " Material type
        matkl TYPE mara-matkl,             " Material group
      END OF ty_mara,
    3rd Table
      BEGIN OF ty_vbak,
        vbeln TYPE vbak-vbeln,             " Sales document
        vkorg TYPE vbak-vkorg,             " Sales organization
        vtweg TYPE vbak-vtweg,             " Distribution channel
        kunnr TYPE vbak-kunnr,             " Sold-to party
        erdat TYPE vbak-erdat,             " Creation date
      END OF ty_vbak.
    DATA:
      gs_layout TYPE slis_layout_alv,
      gt_kna1 TYPE TABLE OF ty_kna1,
      gt_mara TYPE TABLE OF ty_mara,
      gt_vbak TYPE TABLE OF ty_vbak.
    SELECTION-SCREEN :
      SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.    "#EC NEEDED
    PARAMETERS p_max(2) TYPE n DEFAULT '02' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    INITIALIZATION.
      v_1 = 'Maximum of records to read'.
    START-OF-SELECTION.
    Read data
      SELECT kunnr ernam erdat name1
        FROM kna1
       UP TO p_max ROWS
        INTO TABLE gt_kna1.
      SELECT matnr ernam ersda mtart matkl
        FROM mara
       UP TO p_max ROWS
        INTO TABLE gt_mara.
      SELECT vbeln vkorg vtweg kunnr erdat
        FROM vbak
       UP TO p_max ROWS
        INTO TABLE gt_vbak.
    END-OF-SELECTION.
      PERFORM f_display_data.
          FORM USER_COMMAND                                             *
    FORM user_command USING u_ucomm     TYPE sy-ucomm
                            us_selfield TYPE slis_selfield.     "#EC CALLED
      DATA:
        ls_vbak TYPE ty_vbak.
      CASE u_ucomm.
        WHEN '&IC1'.                       " Pick
          CASE us_selfield-tabname.
            WHEN 'GT_MARA'.
            WHEN 'GT_KNA1'.
            WHEN 'GT_VBAK'.
              READ TABLE gt_vbak INDEX us_selfield-tabindex INTO ls_vbak.
              IF sy-subrc EQ 0.
                SET PARAMETER ID 'AUN' FIELD ls_vbak-vbeln.
                CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
              ENDIF.
          ENDCASE.
      ENDCASE.
    ENDFORM.                               " USER_COMMAND
          Form  f_display_data
    FORM f_display_data.
      DATA :
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
        ls_sort     TYPE slis_sortinfo_alv,
        lt_sort     TYPE slis_t_sortinfo_alv, " Sort table
        lt_events   TYPE slis_t_event,
        ls_event    TYPE slis_alv_event.
      gs_layout-group_change_edit = c_x.
      gs_layout-colwidth_optimize = c_x.
      gs_layout-zebra             = c_x.
      gs_layout-detail_popup      = c_x.
      gs_layout-get_selinfos      = c_x.
    Build field catalog and sort table
      m_fieldcat  'KUNNR' 'KNA1' 'GT_KNA1'.
      m_fieldcat  'ERNAM' 'KNA1' 'GT_KNA1'.
      m_fieldcat  'ERDAT' 'KNA1' 'GT_KNA1'.
      m_fieldcat  'NAME1' 'KNA1' 'GT_KNA1'.
      m_sort  'KUNNR'.
    Build Event Table
      MOVE        'TOP_OF_PAGE'        TO ls_event-name.
      MOVE        'TOP_OF_PAGE'        TO ls_event-form.
      APPEND ls_event TO lt_events.
      MOVE        'END_OF_LIST'        TO ls_event-name.
      MOVE        'END_OF_LIST'        TO ls_event-form.
      APPEND ls_event TO lt_events.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program      = sy-cprog
          i_callback_user_command = 'USER_COMMAND'
          it_fieldcat             = lt_fieldcat
          is_layout               = gs_layout
          it_events               = lt_events
          it_sort                 = lt_sort
          i_save                  = 'A'
        TABLES
          t_outtab                = gt_kna1.
    ENDFORM.                               " F_DISPLAY_DATA
          FORM top_of_page                                              *
    FORM top_of_page.                                           "#EC CALLED
      ULINE.
      WRITE : sy-uname, sy-title(56) CENTERED, sy-datum.
      ULINE.
    ENDFORM.                               " TOP_OF_PAGE
          FORM End_of_list                                              *
    FORM end_of_list.                                           "#EC CALLED
      DATA :
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
        ls_sort     TYPE slis_sortinfo_alv,
        lt_sort     TYPE slis_t_sortinfo_alv, " Sort table
        lt_events   TYPE slis_t_event,
        ls_event    TYPE slis_alv_event.
    Build field catalog and sort table
      m_fieldcat 'MATNR' 'MARA' 'GT_MARA'.
      m_fieldcat 'ERNAM' 'MARA' 'GT_MARA'.
      m_fieldcat 'ERSDA' 'MARA' 'GT_MARA'.
      m_fieldcat 'MTART' 'MARA' 'GT_MARA'.
      m_fieldcat 'MATKL' 'MARA' 'GT_MARA'.
      m_sort 'MATNR'.
    Build Event Table
      MOVE 'END_OF_LIST'   TO ls_event-name.
      MOVE 'END_OF_LIST_2' TO ls_event-form.
      APPEND ls_event TO lt_events.
      gs_layout-list_append = c_x.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = sy-cprog
          it_fieldcat        = lt_fieldcat
          is_layout          = gs_layout
          it_sort            = lt_sort
          it_events          = lt_events
          i_save             = 'A'
        TABLES
          t_outtab           = gt_mara.
    ENDFORM.                               " END_OF_LIST
          FORM End_of_list_2                                            *
    FORM end_of_list_2.                                         "#EC CALLED
      DATA :
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
        ls_sort     TYPE slis_sortinfo_alv,
        lt_sort     TYPE slis_t_sortinfo_alv, " Sort table
        lt_events   TYPE slis_t_event,
        ls_event    TYPE slis_alv_event.
    Build field catalog and sort table
      m_fieldcat 'VBELN' 'VBAK' 'GT_VBAK'.
      m_fieldcat 'VKORG' 'VBAK' 'GT_VBAK'.
      m_fieldcat 'VTWEG' 'VBAK' 'GT_VBAK'.
      m_fieldcat 'KUNNR' 'VBAK' 'GT_VBAK'.
      m_fieldcat 'ERDAT' 'VBAK' 'GT_VBAK'.
      m_sort 'VBELN'.
    Build Event Table
      MOVE 'TOP_OF_PAGE' TO ls_event-name.
      MOVE 'TOP_OF_PAGE' TO ls_event-form.
      APPEND ls_event TO lt_events.
      gs_layout-list_append = c_x.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program = sy-cprog
          it_fieldcat        = lt_fieldcat
          is_layout          = gs_layout
          it_sort            = lt_sort
          it_events          = lt_events
          i_save             = 'A'
        TABLES
          t_outtab           = gt_vbak.
    ENDFORM.                               " END_OF_LIST_2

  • ALV print problems for reports with two sort fields and subtotal at each

    When a report has two sort fields and subtotal at each of them, the print function is not working correctly. Please see the report below.
    The second "" (single star) record (the 10 RL record) and the '*' (double star) record (the 12 RL record)  are not printing.
    This is happening for any standard SAP reports. Any resolution? Any OSS Notes?
         Material/Stock Code          Grade       Units Count     Unit Type     Set Position     LFT
         520085V000          7818     1     RL     A     19,682 LF
         520085V000          7818     1     RL     A     19,682 LF
    *     520085V000               2     RL          
         599098V000               1     RL          
         599098V000               1     RL          
         599098V000               1     RL          
         599098V000               1     RL          
         599098V000               1     RL          
         599098V000               1     RL          
         599098V000               1     RL          
         599098V000               1     RL          
         599098V000               1     RL          
         599098V000          7717     1     RL     A     36,167 LF
    *     599098V000               10     RL          
    **                    12     RL          
    ***                    12               
    Thanks
    Anand
    Edited by: Anand Velayudhan on Feb 9, 2009 11:50 PM

    Hi,
    Check these OSS Notes..
    Note 975777 - ALV total: Subtotals disappear from printout
    Note 1039655 - ALV total: Subtotals disappear from printout II
    Thanks
    Naren

  • ALV sort column problem

    Hi all - I have an ALV with standard sort functionality in each column. Let's say that I have 20 rows with 5 columns, the first column has a record in every row but another column in some rows are empty but in other rows that column has data.
    If I click the sort functionality (next to the label of the column) in a column that has empty spaces and values it will show the data sorted but the empty spaces are shown like a whole blank column (it losses the line that divided the rows) and it's kind of confusing, if the column is completely empty and I click sort of course nothing will get sort but the column looks all white (no lines at the row level)
    Is there anyway that I can eliminate that white space and if is empty is empty I dont want to lose the line that divide the rows?
    thanks!
    Jason P-V

    hi
    it might be dumping as in your mentioned code snippet you are not taking the reference of the field and so it will be intial
    Try using the following code instead -
    DATA: lo_cmp_usage            TYPE ref to if_wd_component_usage.
      DATA: lr_salv_wd_table        TYPE REF TO iwci_salv_wd_table.
    DATA: lr_function_settings    TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
    Data: lr_field_curr                   TYPE REF TO CL_SALV_WD_FIELD.
    *create an instance of ALV component
      lo_cmp_usage =   wd_this->wd_cpuse_OVERVIEW_PAYMENT_ALV( ). "My ALV Usage Name OVERVIEW_PAYMENT_ALV
    * if not initialized, then initialize
      if lo_cmp_usage->has_active_component( ) is initial.
        lo_cmp_usage->create_component( ).
      endif.
    * get ALV component
      lr_salv_wd_table = wd_this->wd_cpifc_OVERVIEW_PAYMENT_ALV( ).
      lr_function_settings ? = lr_salv_wd_table->get_model( ).
            CALL METHOD LR_FUNCTION_SETTINGS->IF_SALV_WD_FIELD_SETTINGS~GET_FIELD
              EXPORTING
                FIELDNAME = 'CON_CURR'  " ALV Column Name
              RECEIVING
                VALUE     = lr_field_curr.
            CALL METHOD LR_FIELD_CURR->IF_SALV_WD_SORT~SET_GROUPING_ALLOWED ( exporting value = abap_false ).
    Hope this helps

  • ALV GRID Problem with reading contents

    Hi there! I'm quite new with ABAP and I have some problems with the syntax of it. Maybe I should first describe my aim and then I'll show you my code.
    1. I read contents from two database tables, called 'zbc_dan_registry' and 'zbc_dan_category'.
    'zbc_dan_registry' has 2 columns: name, value.
    zbc_dan_category' has 1 column: category.
    Now I want to have an ALV Grid, that displays the contents of 'zbc_dan_registry' and one additional column with dropdown fields, where the user can select a category for each row. This is, what my code already does.
    Now I want to save the contents of the whole table in a new table 'zbc_dan_registrz' (you see: 'registrz', not 'registry'!) with 3 columns:
    name, category, value.
    My problem is, how can I read the contents of the ALV Grid, with the user selected category for each row, and save them in an internal table? I've tried to adapt the code of "BCALV_EDIT_04", but I don't get it running.
    Some detailled help would be great, you know, I'm really working hard to understand ABAP, but it's really hard for me. Thanks for your support and help!!
    Here's my code so far:
    *& Report  ZBC400_DAN_TESTNO4
    REPORT  ZBC400_DAN_TESTNO4.
    DATA: lt_registrz TYPE TABLE OF zbc_dan_regstrz WITH HEADER LINE,
          lt_category TYPE TABLE OF zbc_dan_category WITH HEADER LINE,
          ls_category TYPE zbc_dan_category, "Struktur Kategorie
          ok_code LIKE sy-ucomm,
          container_r TYPE REF TO cl_gui_custom_container,
          grid_r TYPE REF TO cl_gui_alv_grid,
          gc_custom_control_name TYPE scrfname VALUE 'CONTAINER_REG',
          fieldcat_r TYPE lvc_t_fcat,
          layout_r TYPE lvc_s_layo,
          lt_ddval TYPE lvc_t_drop,
          ls_ddval TYPE lvc_s_drop,
          c TYPE i.
    CLASS lcl_event_receiver DEFINITION DEFERRED.
      DATA g_verifier TYPE REF TO lcl_event_receiver.
      DATA: BEGIN OF gt_outtab OCCURS 0.
        INCLUDE STRUCTURE zbc_dan_regstrz.
        DATA: celltab TYPE lvc_t_styl.
      DATA: END OF gt_outtab.
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
      TYPES: BEGIN OF lt_registrz_key.         "Struktur mit den Schlüsseln der Tabelle 'Registry'
        TYPES:  name TYPE zbc_dan_name,
                value TYPE zbc_dan_value,
                category TYPE zbc_dan_cat.
      TYPES: END OF lt_registrz_key.
      TYPES:  ls_registrz_keys TYPE STANDARD TABLE OF lt_registrz_key,
              ls_registrz_table TYPE STANDARD TABLE OF zbc_dan_regstrz.
      METHODS: get_inserted_rows EXPORTING inserted_rows TYPE ls_registrz_keys.
      METHODS: refresh_delta_tables.
      METHODS: handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING er_data_changed.
    *  METHODS: get_inserted_rows EXPORTING inserted_rows TYPE registrz_keys.
    *  METHODS: refresh_delta_tables.
      PRIVATE SECTION.
      DATA: inserted_rows TYPE ls_registrz_keys.
      DATA: error_in_data TYPE c.
      METHODS: get_cell_values IMPORTING row_id TYPE int4 pr_data_changed TYPE REF TO cl_alv_changed_data_protocol EXPORTING key TYPE lt_registrz_key.
    ENDCLASS.
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_data_changed.
        DATA: ls_good TYPE lvc_s_modi,
              ls_new TYPE lvc_s_moce.
        error_in_data = space.
        IF error_in_data = 'X'.
          CALL METHOD er_data_changed->display_protocol.
        ENDIF.
      ENDMETHOD.
      METHOD get_cell_values.
        CALL METHOD pr_data_changed->get_cell_value
          EXPORTING i_row_id = row_id i_fieldname = 'NAME'
            IMPORTING e_value = key-name.
        CALL METHOD pr_data_changed->get_cell_value
          EXPORTING i_row_id = row_id i_fieldname = 'VALUE'
            IMPORTING e_value = key-value.
        CALL METHOD pr_data_changed->get_cell_value
          EXPORTING i_row_id = row_id i_fieldname = 'CATEGORY'
            IMPORTING e_value = key-category.
      ENDMETHOD.
      METHOD get_inserted_rows.
        inserted_rows = me->inserted_rows.
      ENDMETHOD.
      METHOD refresh_delta_tables.
        clear me->inserted_rows[].
      ENDMETHOD.
    ENDCLASS.
    START-OF-SELECTION.
        SELECT client name value
          INTO CORRESPONDING FIELDS OF TABLE lt_registrz FROM zbc_dan_regstry.
        SELECT category INTO CORRESPONDING FIELDS OF TABLE lt_category FROM zbc_dan_category.
    CALL SCREEN 0100.
    MODULE user_command_0100 INPUT.
      CASE ok_code.
        WHEN 'BACK'.
          SET SCREEN 0.
          MESSAGE ID 'BC400' TYPE 'S' NUMBER '057'.
        WHEN 'SAVE'.
          PERFORM save_data.
        WHEN OTHERS.
      ENDCASE.
    ENDMODULE.
    MODULE clear_ok_code OUTPUT.
      CLEAR ok_code.
    ENDMODULE.
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'DYNPRO100'.
      SET TITLEBAR 'D0100'.
    ENDMODULE.
    MODULE display_alv OUTPUT.
      PERFORM display_alv.
    ENDMODULE.
    FORM display_alv.
    IF grid_r IS INITIAL.
    *----Creating custom container instance
      CREATE OBJECT container_r
      EXPORTING
        container_name = gc_custom_control_name
      EXCEPTIONS
        cntl_error = 1
        cntl_system_error = 2
        create_error = 3
        lifetime_error = 4
        lifetime_dynpro_dynpro_link = 5
        others = 6.
        IF sy-subrc <> 0.
    *--Exception handling
        ENDIF.
    *----Creating ALV Grid instance
        CREATE OBJECT grid_r
        EXPORTING
          i_parent = container_r
        EXCEPTIONS
          error_cntl_create = 1
          error_cntl_init = 2
          error_cntl_link = 3
          error_dp_create = 4
          others = 5.
          IF sy-subrc <> 0.
    *--Exception handling
          ENDIF.
          CREATE OBJECT g_verifier.
          SET HANDLER g_verifier->handle_data_changed FOR grid_r.
    *----Preparing field catalog.
          PERFORM prepare_field_catalog CHANGING fieldcat_r.
    *----Preparing layout structure
          PERFORM prepare_layout CHANGING layout_r.
    *----Here will be additional preparations
    *--e.g. initial sorting criteria, initial filtering criteria, excluding
    *--functions
          CALL METHOD grid_r->set_table_for_first_display
          EXPORTING
    * I_BUFFER_ACTIVE =
    * I_CONSISTENCY_CHECK =
    * I_STRUCTURE_NAME =
    * IS_VARIANT =
    * I_SAVE =
    * I_DEFAULT = 'X'
            is_layout = layout_r
    * IS_PRINT =
    * IT_SPECIAL_GROUPS =
    * IT_TOOLBAR_EXCLUDING =
    * IT_HYPERLINK =
          CHANGING
            it_outtab = lt_registrz[]
            it_fieldcatalog = fieldcat_r
    * IT_SORT =
    * IT_FILTER =
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error = 2
            too_many_lines = 3
            OTHERS = 4.
          IF sy-subrc <> 0.
    *--Exception handling
          ENDIF.
          ELSE.
            CALL METHOD grid_r->refresh_table_display
    * EXPORTING
    * IS_STABLE =
    * I_SOFT_REFRESH =
          EXCEPTIONS
            finished = 1
            OTHERS = 2.
          IF sy-subrc <> 0.
    *--Exception handling
          ENDIF.
        ENDIF.
        CALL METHOD grid_r->register_edit_event
          EXPORTING
            i_event_id = cl_gui_alv_grid=>mc_evt_enter.
        CALL METHOD grid_r->register_edit_event
          EXPORTING
            i_event_id = cl_gui_alv_grid=>mc_evt_modified.
    ENDFORM.
    FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
      EXPORTING
        i_structure_name = 'ZBC_DAN_REGSTR2'
      CHANGING
        ct_fieldcat = pt_fieldcat[]
      EXCEPTIONS
        inconsistent_interface = 1
        program_error = 2
        OTHERS = 3.
      IF sy-subrc <> 0.
    *--Exception handling
      ENDIF.
      LOOP AT pt_fieldcat INTO ls_fcat.
        CASE ls_fcat-fieldname.
          WHEN 'NAME'.
            ls_fcat-coltext = 'Name'.
            ls_fcat-outputlen = '40'.
            MODIFY pt_fieldcat FROM ls_fcat.
          WHEN 'VALUE'.
            ls_fcat-coltext = 'Wert'.
            ls_fcat-outputlen = '30'.
            MODIFY pt_fieldcat FROM ls_fcat.
          WHEN 'CATEGORY'.
              LOOP AT lt_category into ls_category.
                ls_ddval-handle = 1.
                ls_ddval-value = ls_category-category.
    *            ls_ddval-style = cl_gui_alv_grid=>mc_style_enabled.
                APPEND ls_ddval TO lt_ddval.
             ENDLOOP.
             CALL METHOD grid_r->set_drop_down_table
                EXPORTING it_drop_down = lt_ddval.
            ls_fcat-edit = 'X'.
            ls_fcat-drdn_hndl = '1'.
            ls_fcat-coltext = 'Kategorie'.
            MODIFY pt_fieldcat FROM ls_fcat.
        ENDCASE.
      ENDLOOP.
    ENDFORM.
    FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo.
      ps_layout-zebra = 'X'.
      ps_layout-grid_title = 'Kategorie zur Registry hinzufügen'.
      ps_layout-smalltitle = 'X'.
    ENDFORM.
    FORM save_data.
      DATA: ls_ins_keys TYPE g_verifier->ls_registrz_keys,
            ls_ins_key TYPE g_verifier->lt_registrz_key,
            ls_registrz TYPE zbc_dan_regstrz,
            ls_outtab LIKE LINE OF gt_outtab,
            lt_instab TYPE TABLE OF zbc_dan_regstrz.
      CALL METHOD g_verifier->get_inserted_rows IMPORTING inserted_rows = ls_ins_keys.
      LOOP AT ls_ins_keys INTO ls_ins_key.
        READ TABLE gt_outtab INTO ls_outtab
        WITH KEY  name = ls_ins_key-name
                  value = ls_ins_key-value
                  category = ls_ins_key-category.
        IF sy-subrc = 0.
          MOVE-CORRESPONDING ls_outtab TO ls_registrz.
          APPEND ls_registrz TO lt_instab.
        ENDIF.
      ENDLOOP.
      INSERT zbc_dan_regstrz FROM TABLE lt_instab.
      CALL METHOD g_verifier->refresh_delta_tables.
      ENDFORM.

    Hi Hans,
    You raised the Question in the Webdynpro ABAP forum. Here its very diffcult to get the answer from this forum. Please close it here and raise the same question in ABAP General Forum there you will get faster and so many anwsers.
    Please close the question here.
    Warm Regards,
    Vijay

  • ALV list problem

    Hi all,
    I am facing a strange problem in ALV. i have two internal tables one is for alv header and another is alv line items. i have a proper data in in both internal tables.
    when i pass the data of these two internal tables to the function REUSE_ALV_HIERSEQ_LIST_DISPLAY i found in the output that line items date changes.
    actually date is in format 04112005 but when i see the output its showing like this 05.20.0411 .
    please help me to solve the problem.
    Regards,
    Lisa

    Hii
    use this func module
    <b>CONVERT_DATE_TO_INTERN_FORMAT</b>
    <b>CONVERSION_EXIT_PDATE_INPUT</b>
    Thsi will give the dtae in YYYY.MM.DD format
    check this program for reference
    REPORT  Z_50657_ALV_EX1
            MESSAGE-ID ZZ .
                                Type Pools                               *
    TYPE-POOLS: SLIS.
                                 Tables                                  *
    TABLES: LFA1, "Vendor Master
            LFB1, "Vendor Master (Company Code)
            LFM1. "purchasing organization data
                            Internal Tables                              *
    TABLE TO HOLD DATA FROM VENDOR MASTER
    DATA: BEGIN OF IT_LFA1 OCCURS 0,
            LIFNR LIKE LFA1-LIFNR,  "Account Number of Vendor
            KTOKK LIKE LFA1-KTOKK,  "Vendor account group
            NAME1 LIKE LFA1-NAME1,  "Name
            STRAS LIKE LFA1-STRAS,  "House Number and Street
            ORT01 LIKE LFA1-ORT01,  "City
            REGIO LIKE LFA1-REGIO,  "Region
            PFORT LIKE LFA1-PFORT,  "PO Box City
            PSTLZ LIKE LFA1-PSTLZ,  "Postal Code
            PSTL2 LIKE LFA1-PSTL2,  "P.O. Box
            TELF1 LIKE LFA1-TELF1,  "First telephone number
          END OF IT_LFA1.
    TABLE TO HOLD DATA ABOUT COMPANY
    DATA: BEGIN OF IT_LFB1 OCCURS 0,
            LIFNR LIKE LFB1-LIFNR, "Account Number of Vendor
            BUKRS LIKE LFB1-BUKRS, "COMP CODE
          END OF IT_LFB1.
    TABLE TO HOLD DATA ABOUT PURCHASING ORG
    DATA: BEGIN OF IT_LFM1 OCCURS 0,
            LIFNR LIKE LFM1-LIFNR, "Account Number of Vendor
            EKORG LIKE LFM1-EKORG, "Purchasing Organization
          END OF IT_LFM1.
    TABLE TO HOLD DATA FOR FINAL DISPLAY
    DATA: BEGIN OF IT_FINAL OCCURS 0,
            LIFNR LIKE LFB1-LIFNR,  "Account Number of Vendor
            BUKRS LIKE LFB1-BUKRS,  "COMP CODE
            EKORG LIKE LFM1-EKORG,  "Purchasing Organization
            KTOKK LIKE LFA1-KTOKK,  "Vendor account group
            NAME1 LIKE LFA1-NAME1,  "Name
            STRAS LIKE LFA1-STRAS,  "House Number and Street
            ORT01 LIKE LFA1-ORT01,  "City
            REGIO LIKE LFA1-REGIO,  "Region
            PFORT LIKE LFA1-PFORT,  "PO Box City
            PSTLZ LIKE LFA1-PSTLZ,  "Postal Code
            PSTL2 LIKE LFA1-PSTL2,  "P.O. Box
            TELF1 LIKE LFA1-TELF1,  "First telephone number
          END OF IT_FINAL.
    DATA: V_INDEX TYPE SY-TABIX.
                                Work Areas                               *
    *WORK AREAS DEFINED FOR ALV'S
    DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
          IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
          L_LAYOUT TYPE SLIS_LAYOUT_ALV.
                          Selection-Screen                               *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_LIFNR FOR LFA1-LIFNR, "ACCOUNT NUMBER
                    S_BUKRS FOR LFB1-BUKRS, "COMPANY CODE
                    S_EKORG FOR LFM1-EKORG, "PURCHASING ORG
                    S_KTOKK FOR LFA1-KTOKK. "ACCOUNT GROUP
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    PARAMETERS: LIST RADIOBUTTON GROUP G1, "ALV LIST DISPLAY
                GRID RADIOBUTTON GROUP G1. "ALV GRID DISPLAY
    SELECTION-SCREEN END OF BLOCK B2.
                        At  Selection-Screen                             *
    AT SELECTION-SCREEN.
      PERFORM VALIDATION.
                          Start of Selection                             *
    START-OF-SELECTION.
    *POPULATE DATA INTO ITAB_FINAL USING INNER JOINS OF IT_LFA1 IT_LFB1
    *IT_LFM1
      PERFORM GET_DATA.
    *CHECK FOR RADIO BUTTON SELECTION AND ACCORDINGLY DISPLAY ALV GRID/LIST
      PERFORM CHECK_SEL.
    *&      Form  VALIDATION
          text
    FORM VALIDATION.
      IF S_LIFNR IS NOT INITIAL.
        SELECT SINGLE LIFNR FROM LFA1 INTO IT_LFA1 WHERE LIFNR IN S_LIFNR.
        IF SY-SUBRC <> 0.
          MESSAGE I000 WITH 'THIS IS NOT A VALID VENDOR NUMBER'.
          STOP.
        ELSE.
          IF S_BUKRS IS NOT INITIAL.
            SELECT SINGLE BUKRS FROM LFB1 INTO IT_LFB1-BUKRS WHERE BUKRS IN
            S_BUKRS.
            IF SY-SUBRC <> 0.
              MESSAGE I000 WITH 'THIS IS NOT A VALID COMPANY CODE'.
              STOP.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
      CLEAR IT_LFA1.
      CLEAR IT_LFB1.
    ENDFORM.                    "VALIDATION
    *&      Form  GET_DATA
          text
    FORM GET_DATA.
      SELECT LIFNR
             KTOKK
             NAME1
             STRAS
             ORT01
             REGIO
             PFORT
             PSTLZ
             PSTL2
             TELF1
             FROM LFA1
             INTO TABLE IT_LFA1
             WHERE LIFNR IN S_LIFNR AND KTOKK IN S_KTOKK.
      SORT IT_LFA1 BY LIFNR.
      IF NOT IT_LFA1[] IS INITIAL.
        SELECT LIFNR
               BUKRS
               FROM LFB1
               INTO TABLE IT_LFB1
               FOR ALL ENTRIES IN IT_LFA1 WHERE LIFNR = IT_LFA1-LIFNR AND
                                                BUKRS IN S_BUKRS.
        SORT IT_LFB1 BY LIFNR BUKRS.
        SELECT LIFNR
               EKORG
               FROM LFM1
               INTO TABLE IT_LFM1
               FOR ALL ENTRIES IN IT_LFA1 WHERE LIFNR = IT_LFA1-LIFNR.
        SORT IT_LFM1 BY LIFNR.
      ENDIF.
      IT_FINAL[] = IT_LFB1[].
      LOOP AT IT_FINAL.
        V_INDEX = SY-TABIX.
        READ TABLE IT_LFA1 WITH KEY LIFNR = IT_FINAL-LIFNR BINARY SEARCH.
        IF SY-SUBRC = 0.
          MOVE: IT_LFA1-KTOKK TO IT_FINAL-KTOKK,
                IT_LFA1-NAME1 TO IT_FINAL-NAME1,
                IT_LFA1-STRAS TO IT_FINAL-STRAS,
                IT_LFA1-ORT01 TO IT_FINAL-ORT01,
                IT_LFA1-REGIO TO IT_FINAL-REGIO,
                IT_LFA1-PFORT TO IT_FINAL-PFORT,
                IT_LFA1-PSTLZ TO IT_FINAL-PSTLZ,
                IT_LFA1-PSTL2 TO IT_FINAL-PSTL2,
                IT_LFA1-TELF1 TO IT_FINAL-TELF1.
        ENDIF.
        READ TABLE IT_LFM1 WITH KEY LIFNR = IT_FINAL-LIFNR BINARY SEARCH.
        IF SY-SUBRC = 0.
          MOVE IT_LFM1-EKORG TO IT_FINAL-EKORG.
        ENDIF.
        MODIFY IT_FINAL INDEX V_INDEX.
      ENDLOOP.
    LOOP AT IT_LFA1.
       LOOP AT IT_FINAL WHERE LIFNR = IT_LFA1-LIFNR.
         MOVE IT_LFA1-KTOKK TO IT_FINAL-KTOKK.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-NAME1 TO IT_FINAL-NAME1.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-STRAS TO IT_FINAL-STRAS.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-ORT01 TO IT_FINAL-ORT01.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-REGIO TO IT_FINAL-REGIO.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-PFORT TO IT_FINAL-PFORT.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-PSTLZ TO IT_FINAL-PSTLZ.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-PSTL2 TO IT_FINAL-PSTL2.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-TELF1 TO IT_FINAL-TELF1.
         MODIFY IT_FINAL INDEX SY-TABIX.
       ENDLOOP.
    ENDLOOP.
    LOOP AT IT_LFM1.
       LOOP AT IT_FINAL WHERE LIFNR = IT_LFM1-LIFNR.
         MOVE IT_LFM1-EKORG TO IT_FINAL-EKORG.
         MODIFY IT_FINAL INDEX SY-TABIX.
       ENDLOOP.
    ENDLOOP.
    SORT IT_FINAL BY LIFNR BUKRS EKORG.
    ENDFORM.                    "GET_DATA
    *&      Form  CHECK_SEL
          text
    FORM CHECK_SEL.
    X_FIELDCAT-FIELDNAME = 'LIFNR'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'VENDOR'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 10.
    X_FIELDCAT-COL_POS    = 1.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'BUKRS'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'COMPANY'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 4.
    X_FIELDCAT-COL_POS    = 2.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'EKORG'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'PURCHASING ORGANISATION'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 4.
    X_FIELDCAT-COL_POS    = 3.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'KTOKK'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'ACCOUNT GROUP'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 4.
    X_FIELDCAT-COL_POS    = 4.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'NAME1'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'VENDOR NAME'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 35.
    X_FIELDCAT-COL_POS    = 5.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'STRAS'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'STREET'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 10.
    X_FIELDCAT-COL_POS    = 6.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'ORT01'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'CITY NAME'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 20.
    X_FIELDCAT-COL_POS    = 7.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'REGIO'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'REGION NAME'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 2.
    X_FIELDCAT-COL_POS    = 8.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
      IF LIST = 'X'.
        CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
          EXPORTING
            I_PROGRAM_NAME         = SY-REPID
            I_INTERNAL_TABNAME     = 'IT_FINAL'
            I_INCLNAME             = SY-REPID
          CHANGING
            CT_FIELDCAT            = IT_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.
        ENDIF.
        L_LAYOUT-ZEBRA = 'X'.
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
          EXPORTING
            I_CALLBACK_PROGRAM = SY-REPID
            IS_LAYOUT          = L_LAYOUT
            IT_FIELDCAT        = IT_FIELDCAT
          TABLES
            T_OUTTAB           = IT_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.
        CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
          EXPORTING
            I_PROGRAM_NAME         = SY-REPID
            I_INTERNAL_TABNAME     = 'IT_FINAL'
            I_INCLNAME             = SY-REPID
          CHANGING
            CT_FIELDCAT            = IT_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.
        ENDIF.
        L_LAYOUT-ZEBRA = 'X'.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            I_CALLBACK_PROGRAM = SY-REPID
            IS_LAYOUT          = L_LAYOUT
            IT_FIELDCAT        = IT_FIELDCAT
          TABLES
            T_OUTTAB           = IT_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.
      ENDIF.
    Regards
    Naresh

  • Getting row information after an ALV sort

    I am using cl_gui_alv_grid.  My problem occurs after a user sorts the table.  All of the index values no longer match to the original table I passed to the class.  How do I match the results from
    CALL METHOD my_catlistgrid->get_selected_rows
       IMPORTING
        et_index_rows  = selected_rows.
    to my original itab?

    Let me be more specific.  I have an object that is handling the events double_click(), I have a button on the APP toolbar that will end up calling any or all of the following methods.
      CALL METHOD my_catlistgrid->get_selected_rows
       IMPORTING
        et_index_rows  = selected_rows.
      CALL METHOD my_catlistgrid->get_selected_cells_id
       IMPORTING
          ET_CELLS  =   selected_cells_id.
      CALL METHOD my_catlistgrid->get_selected_cells
       IMPORTING
          ET_CELL  =   selected_cells.
    Each of this methid returns to me the index(position) of the selected row in the ALVgrid.  After a sort in the ALV grid, row 1 does not relate to row 1 in the itab I passed to the ALV grid anymore.

  • ALV Sort by time

    Hi Experts!
    I have a problem in sorting.
    I have a field called Remaining time having data type char20.
    Format is HH:MM:SS.
    The problem is, i want it to be sorted in a way that a number is sorted.
    Example (descending):
    I want it to be sorted this way:
    121:89
    111:00
    12:34
    10:78
    00:00
    -01:44
    -10:22
    -11:45
    -109:11
    but in my program, it is sorted as text:
    121:89
    12:34
    111:00
    10:78
    -109:11
    -11:45
    -10:22
    -01:44
    00:00
    Edited by: navi on Aug 11, 2008 4:04 PM

    Hi,
    Step 1. Sort your internal table by time field before passing it to
               ALV.
    Step 2. Pass the sorted table.
    OR
    use function module reuse_alv_grid_display.                           
      IMPORTING
         REFERENCE(I_INTERFACE_CHECK) DEFAULT SPACE
         VALUE(I_BYPASSING_BUFFER) TYPE  CHAR01 DEFAULT SPACE
         VALUE(I_BUFFER_ACTIVE) DEFAULT SPACE
         REFERENCE(I_CALLBACK_PROGRAM) LIKE  SY-REPID DEFAULT SPACE
         REFERENCE(I_CALLBACK_PF_STATUS_SET) TYPE  SLIS_FORMNAME DEFAULT
           SPACE
         REFERENCE(I_CALLBACK_USER_COMMAND) TYPE  SLIS_FORMNAME DEFAULT
           SPACE
         REFERENCE(I_CALLBACK_TOP_OF_PAGE) TYPE  SLIS_FORMNAME DEFAULT
           SPACE
         REFERENCE(I_CALLBACK_HTML_TOP_OF_PAGE) TYPE  SLIS_FORMNAME
           DEFAULT SPACE
         REFERENCE(I_CALLBACK_HTML_END_OF_LIST) TYPE  SLIS_FORMNAME
           DEFAULT SPACE
         REFERENCE(I_STRUCTURE_NAME) LIKE  DD02L-TABNAME OPTIONAL
         REFERENCE(I_BACKGROUND_ID) TYPE  SDYDO_KEY DEFAULT SPACE
         REFERENCE(I_GRID_TITLE) TYPE  LVC_TITLE OPTIONAL
         REFERENCE(I_GRID_SETTINGS) TYPE  LVC_S_GLAY OPTIONAL
         REFERENCE(IS_LAYOUT) TYPE  SLIS_LAYOUT_ALV OPTIONAL
         REFERENCE(IT_FIELDCAT) TYPE  SLIS_T_FIELDCAT_ALV OPTIONAL
         REFERENCE(IT_EXCLUDING) TYPE  SLIS_T_EXTAB OPTIONAL
         REFERENCE(IT_SPECIAL_GROUPS) TYPE  SLIS_T_SP_GROUP_ALV OPTIONAL
         REFERENCE(IT_SORT) TYPE  SLIS_T_SORTINFO_ALV OPTIONAL   ---> uncomment this (see details bellow)
        REFERENCE(IT_FILTER) TYPE  SLIS_T_FILTER_ALV OPTIONAL
         REFERENCE(IS_SEL_HIDE) TYPE  SLIS_SEL_HIDE_ALV OPTIONAL
         REFERENCE(I_DEFAULT) DEFAULT 'X'
         REFERENCE(I_SAVE) DEFAULT SPACE
         REFERENCE(IS_VARIANT) LIKE  DISVARIANT STRUCTURE  DISVARIANT
           OPTIONAL
         REFERENCE(IT_EVENTS) TYPE  SLIS_T_EVENT OPTIONAL
         REFERENCE(IT_EVENT_EXIT) TYPE  SLIS_T_EVENT_EXIT OPTIONAL
         REFERENCE(IS_PRINT) TYPE  SLIS_PRINT_ALV OPTIONAL
         REFERENCE(IS_REPREP_ID) TYPE  SLIS_REPREP_ID OPTIONAL
         REFERENCE(I_SCREEN_START_COLUMN) DEFAULT 0
         REFERENCE(I_SCREEN_START_LINE) DEFAULT 0
         REFERENCE(I_SCREEN_END_COLUMN) DEFAULT 0
         REFERENCE(I_SCREEN_END_LINE) DEFAULT 0
         REFERENCE(I_HTML_HEIGHT_TOP) TYPE  I DEFAULT 0
         REFERENCE(I_HTML_HEIGHT_END) TYPE  I DEFAULT 0
         REFERENCE(IT_ALV_GRAPHICS) TYPE  DTC_T_TC OPTIONAL
         REFERENCE(IT_HYPERLINK) TYPE  LVC_T_HYPE OPTIONAL
         REFERENCE(IT_ADD_FIELDCAT) TYPE  SLIS_T_ADD_FIELDCAT OPTIONAL
         REFERENCE(IT_EXCEPT_QINFO) TYPE  SLIS_T_QINFO_ALV OPTIONAL
         REFERENCE(IR_SALV_FULLSCREEN_ADAPTER) TYPE REF TO
            CL_SALV_FULLSCREEN_ADAPTER OPTIONAL
      EXPORTING
         REFERENCE(E_EXIT_CAUSED_BY_CALLER)
        REFERENCE(ES_EXIT_CAUSED_BY_USER) TYPE  SLIS_EXIT_BY_USER
      TABLES
          T_OUTTAB
      EXCEPTIONS
          PROGRAM_ERROR
    ( Using internal table IT_SORT, the caller determines the sort order and/or the subtotalling of the basic list.)
    Regards,
    anirban

  • ALV sort/group disfunction ?!

    Hi there,
    I'm a bit helpless because of the sort/group function my ALV should do. Current situation is that I'm using an CL_GUI_ALV_GRID.
    CALL METHOD gr_config_alv_1_2->set_table_for_first_display
        EXPORTING
          is_layout                     = ls_layout
        CHANGING
          it_sort                       = sort_table
          it_outtab                     = config_1_2_table
          it_fieldcatalog               = cat_config_fieldcat_alv
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3.
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
    So you can see that I'm using it_sort to tell the ALV how to sort the it_outtab. [Result looks like this|http://fabianvogt.com/alv_1.jpg].
    What the it_sort does is sorting the it_outtab ASCENDING for the coloum "GRP" (display-name: "Bezugstyp"). So far so good...But I know that CL_GUI_ALV_GRID normally does some kind of grouping by merging cells with the same content. [This would look like that|http://fabianvogt.com/alv_2.jpg].
    In my case it does not work and I don't have any idea why. I searched the CLASS for a hint or maybe an attribute which has to be filled/flagged to do this kind of grouping.
    Looking forword to your help!

    Hi everyone!
    I've checked BCALV_TEST_GRID. Basically they do it the same way I'm trying. I found out that I have the possibility to set ls_layout-no_merging to control, whether cells with the same content are merged or not. By default no_merging is set SPACE, so the cells should be merged - NOT in my case.
    Even if I set no_merging  =  '  ' (SPACE) manually, the merging won't be done.
    Running out ouf ideas ...
    NEWS:
    I did some kind of a workaround, in my opinion even a nicer way to realize my purpose. So take a look at what I did right now:
    (take a look at the screenshots in my previous posts for your better understanding)
    - The old 'GRP' field (old content: 'B',' K', 'M') is now filled with 'Belegbezug', 'Kundenbezug', 'Materialbezug' and is set NO_OUT (fieldcatalogue).
    - I insterted a field called 'CNT' type I, which i use to create Totals/Subtotals.
    - NO_TOTLINE  = 'X' (Layout) --> total line is not shown; only subtotals
    - TOTALS_BEF (Layout) --> subtotals are placed on top
    [So this is what I got now|http://fabianvogt.com/alv3.jpg]. Much better than before!!!
    My only problem is now, that the 'CNT' coloum looks pretty ugly and has no function except doing the sum thing.
    I tried to make it invisible using the fieldcatalogue (NO_OUT / TECH), but then the total lines disappear :/
    Any suggestions?
    Edited by: Fabian Vogt on Oct 4, 2010 4:35 PM

  • Alv layout problem ?

    Hi everyone,
    I generating 2 alv reports within a program.In the selection screen there are 2 radio buttons for different alv reports. First i selected the 1st radio button and executed the prog to get a alv report.Then i went to change layout and selected the required columns from the columns set and then saved the layout as the default layout.
    Then I came back to the selection screen again.In the selection screen, in the parameter p_var there is default variant,so i cleared the parameter with no layout variant selected.then i selected the 2nd radio button and executed the program.Here the program is again taking the default layout (even though i cleared it in the selection screen )and generating the alv report according to that.But i don't want to use the default layout when i select the 2nd radio button,unless i select it from the variant list.How can i do that?
    Any suggestions please?

    Hi Hymavathi,
    Thanks for the reply.Below is my code for the layout.If u can see any problem in the code please tell me the changes.Thank you.
    PARAMETERS: P_VAR LIKE DISVARIANT-VARIANT.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VAR.
      PERFORM GET_VARIANT CHANGING P_VAR.               " ALV Layout
    FORM GET_VARIANT CHANGING X_VAR.
      PERFORM F4_ALV_LAYOUT(PPIO_ENTRY) USING I_GRID-PROGRAM
                                     CHANGING X_VAR.
    ENDFORM.
    perform alv_display.
    FORM ALV_DISPLAY.
      DATA: I_GRID-LAYOUT TYPE SLIS_LAYOUT_ALV.
      SORT I_HEADER BY PLNBEZ AUFNR.
    Define layout.
      CLEAR I_GRID-LAYOUT.
      I_GRID-LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    Set up Variant
      I_GRID-VARIANT-VARIANT = P_VAR.     " Variant
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM             = I_GRID-PROGRAM
        IS_LAYOUT                      = I_GRID-LAYOUT
        IT_FIELDCAT                    = I_GRID-FIELDCAT
        I_SAVE                         = 'A'
        IS_VARIANT                     = I_GRID-VARIANT
      TABLES
         T_OUTTAB                      = I_HEADER
       EXCEPTIONS
        PROGRAM_ERROR                  = 1
        OTHERS                         = 2.
    ALV Failed.
      IF SY-SUBRC <> 0.
        WRITE: / 'Failed with',SY-SUBRC.
      ENDIF.
    ENDFORM.
    PERFORM ALV_DISPLAY_2.
    FORM ALV_DISPLAY_2.
      DATA: I_GRID-LAYOUT TYPE SLIS_LAYOUT_ALV.
      SORT I_HEADER BY PLNBEZ AUFNR.
    Define layout.
      CLEAR I_GRID-LAYOUT.
      I_GRID-LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    Set up Variant
    I_GRID-VARIANT-VARIANT = P_VAR.     " Variant
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM             = I_GRID-PROGRAM
        I_CALLBACK_PF_STATUS_SET       = I_GRID-PF_STATUS_SET
        I_CALLBACK_USER_COMMAND        = I_GRID-USER_COMMAND
        IS_LAYOUT                      = i_grid-layout
        IT_FIELDCAT                    = I_GRID-FIELDCAT
       I_SAVE                         = 'A'
       IS_VARIANT                     = I_GRID-VARIANT
       TABLES
         T_OUTTAB                      = I_HEADER
       EXCEPTIONS
        PROGRAM_ERROR                  = 1
        OTHERS                         = 2.
    ALV Failed.
      IF SY-SUBRC <> 0.
        WRITE: / 'Failed with',SY-SUBRC.
      ENDIF.
    ENDFORM.                    " ALV_DISPLAY_2

Maybe you are looking for