Sutotal Problem in ALV for three sorted columns

Hello experts,
i am developing one ALV report for purcj=hase history vendor wise and material group wise.
i am fetching data from rbkp,rseg,mara,makt.
i am also fetching tax code.problem is that that there are 3 columns have group wise and i need sutotal on tax code wise and vendor wise quantity.
please help me for sort problem.
thanks

Hi Abhishek,
Click on below links:
[http://wiki.sdn.sap.com/wiki/display/Snippets/DisplaysubtotaltextinALV+grid]
[ALV - Sort - Subtotal;
BR
Dep

Similar Messages

  • Problem  in  specifing the intial sorting column of  a report

    hi
    we have a report based on a table with 6 columns in our home page .we display all the six columns as sortable.
    we also need to sort the contents of the report by 4th column by default when ever the user logs in ,but what happens is ,report gets sorted automatically depening upon the previous sorting column selected
    is there any way of telling htmldb to sort the report by 4th column ..
    many thanks
    S.Jawahar

    hi ,
    this infotype has a interesting solution . In my case it was  for US country .
    We select the veteran status and this is field P0077-VETST  which is stored in DB table .
    Now based on this value and the molga of that pernr  we need to look at the T5UVT table for the combinations avaliable for MOLGA AND  VETST .
    Based on the config's of this table the screen values are getting populated .
    It dosent allow any combinations and the picked values are passed to the screen for fields Q0077-VETS1 VETS2 VETS3 VETS4 .
    Br,
    Vijay.

  • 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

  • Problem with ALV Report Column

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

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

  • Problem in ALV during Filter for display  of no. of records on header

    Hi
    In one of the ALV report I am using FM: 'reuse_alv_grid_display' by passing the final internal table t_final. Also I am using the FM: 'reuse_alv_commentary_write' for header and displaying the No. of records by describing the t_final internal table.
    If the user does Filtering in the ALV output and displays the filtered records, the no. of records count is not getting changed and showing up the total no. of records that displayed originally. How can I display the No. of records that are filtered in the header after filtering in ALV output. I appreciate if any one throw light to resolve this problem.
    Thanks
    Usha
    Edited by: usha k on Jan 16, 2008 3:20 PM
    Edited by: usha k on Jan 16, 2008 3:21 PM

    Hi Usha, check this,
    I am using REUSE_ALV_LIST_DISPLAY to display a report. The sample report as below :
    Matnr qty1 qty2
    1234 1.00 0.00
    ABCD 0.00 0.00
    5678 0.00 1.00
    After display of the report, user wants to filter on the quantity fields where qty1 = 0.00 AND qty2 = 0.00.
    User will execute the report. Output is displayed. Then user clicks on qty1 and qty2 field heading. Then user clicks on filter (funnel) button. Then a small popup will appear which will display two filter fields qty1 and qty2. Then user will enter filter criteria for qty1/qty2 columns as :
    qty1 = 0.00 (here '=' symbol is in red meaning 'exclude' the rows having zeroes
    in qty1 column)
    qty2 = 0.00 (here '=' symbol is in red meaning 'exclude' the rows having zeroes
    in qty2 column)
    Once the user presses the enter button of this popup window, the filter criteria is applied and the whole report is becoming empty. Because in the above example all the three rows are having the zeroes in qty1 or qty2 columns. So logically the filter criteria applied was qty1 = 0.00 OR qty2 = 0.00
    The expected output after applying the filter was just one row like below because both qty1 and qty2 are having zeroes. Logically the filter criteria applied should have been qty1 = 0.00 AND qty2 = 0.00
    Matnr qty1 qty2
    ABCD 0.00 0.00
    cheers,
    Hema.

  • Display one or more rows for a particular column in alv grid display

    Hi,
    My requirement in the report is to display users for a particular workitem id.If a workitem is in the inbox of one or more users(approvers) i have to display all the user names in one field in alv grid output (output-approver id).There are other fields which display details of the workitem also.
    Is there a way to populate multiple rows for a single column or creating one more internal table for users in the alv output table.
    Please suggest.
    regards,
    Sravanthi Chilal

    ALV only can show flat internal table data.
    you should set a sort on the field which you want to show only once.
    Then on the output of the ALV, the field with the same value will show only once.

  • Problem with download link for a BLOB Column in a "Classic report"

    I am having a problem where I cannot make a download link for a blob column function in a "classic" (non-interactive) report. I went through the tutorial on this topic and it was great help it working out the minor bugs, but I get a 404 error (apex_util.get_BLOB not found). For testing purposes I went ahead and created a an identical report on the same page that is an "Interactive report" and it works like a charm. Same query, same BLOB formatting Mask, pulling data from the same table. So, it really doesn't seem like an issue with the grants, since both reports should be executing as the same user.
    I know it sounds like the obvious answer is to just go with the interactive report and my problem is solved, but the rest of this site uses classic reports, and I don't need the sort features of an interactive report, and the slightly different style of the the report really stands out even if I turn off all the bells and whistles. I don't want to change the css to make them look identical, I just want a regular report to work.

    I eventually found another post: APEX_UTIL.GET_BLOB was not found on this server
    In this post there is the suggestion of putting "dbms_lob.getlength("var")" after the date field in your select. So I changed my query to have it at the end, and now my format mask (DOWNLOAD:table_name:ATTACHED_FILE:FILE_ID::FILE_MIME_TYPE:FILE_NAME:::attachment:Download) works like a charm, in a classic report.

  • Mapping Problem with 2 ALV Tables after sorting

    Hi,
    I have a context node INCIDENTS with a sub-node SUB_INCIDENTS.
    The sub-node is filled via a Supply Function.
    Both nodes are displayed in separate ALV Grids on the same view, which works pretty well.
    The only problem I face is when I try to sort one of the ALVs, then I get an error "The node specified in mapping ( SUB_INCIDENTS) could not be found ".
    I have no clue how to solve that, already tried to fill the sub-node with the ALV standard function "ON_STD_FUNCTION_AFTE", no effect.
    Does anybody can imagine what might be the reason?
    Best regards, Steffen
    Edited by: Steffen Weber on Aug 27, 2008 2:55 PM

    In general, having two ALVs for parent and then a sub node is not supported.  Here is a section from the online help that describes what happens when a sort occurs on the parent node in ALV:
    Important Exception: Sorting
    Here ALV has to use the entire dataset so that the data records can be arranged in the new order. For this purpose, the ALV component temporarily takes control of the internal data table and invalidates the corresponding context node of your application during this time. This ensures that the application cannot access the context node while the ALV component is editing the internal data table.
    Once the internal data table has been resorted, ALV rebuilds the context node, releases it again for the application, and displays the data accordingly.
    This ensures that the internal data table is never copied. This is important because large volumes of data would considerably impact performance and memory space.
    When you are planning your application, note the following side-effects of this mechanism:
    ●      When the context node is invalidated, information about current selections, and in particular the lead selection, is lost.
    ●      If your application has created subnodes for the context node, (master-detail scenario), these subnodes are lost as soon as the ALV component invalidates the context node. If the application then tries to access the subnodes, a runtime error occurs.
    Because of the invalidation that is described here, the subnode leadselection is lost and is invalidated as well. This leads to the error you are encountering.

  • Problem with ALV filter functionality when filtered for multiple values

    Hi,
    I am facing a problem with ALV filter functionality.
    I have displayed an ALV with some columns col_A, col_B and col_C
    col_A---- col_B -
    col_C
    1----
    a -
    abc
    2----
    b -
    pqr
    3----
    c -
    lmn
    4----
    d -
    xyz
    5----
    f -
    stu
    From the settings link I am applying filter on column col_C and selected multiple values say 'pqr', 'xyz' and 'lmn'.
    Now the ALV is showing rows only for last selection i.e . results are fetched only for value 'lmn'.
    i.e. after applying the filter the ALV table looks as below:
    col_A---- col_B -
    col_C
    3----
    c -
    lmn
    But ideally it should be:
    col_A---- col_B -
    col_C
    2----
    b -
    pqr
    3----
    c -
    lmn
    4----
    d -
    xyz
    I could not find any OSS note related to this issue.
    Please help me resolve this issue.
    Thanks,
    Feroz

    Hi,
    I am facing a problem with ALV filter functionality.
    I have displayed an ALV with some columns col_A, col_B and col_C
    col_A---- col_B -
    col_C
    1----
    a -
    abc
    2----
    b -
    pqr
    3----
    c -
    lmn
    4----
    d -
    xyz
    5----
    f -
    stu
    From the settings link I am applying filter on column col_C and selected multiple values say 'pqr', 'xyz' and 'lmn'.
    Now the ALV is showing rows only for last selection i.e . results are fetched only for value 'lmn'.
    i.e. after applying the filter the ALV table looks as below:
    col_A---- col_B -
    col_C
    3----
    c -
    lmn
    But ideally it should be:
    col_A---- col_B -
    col_C
    2----
    b -
    pqr
    3----
    c -
    lmn
    4----
    d -
    xyz
    I could not find any OSS note related to this issue.
    Please help me resolve this issue.
    Thanks,
    Feroz

  • 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

  • Hi how to apply Chronological sort for a month column?

    Hi All,
    I am struck with how to apply Chronological sort for a month column that contains values like January, February, March, April, May, June.... December. If we apply normal sorting then we can arrange the column values either in ascending order or descending order. But i want the column values to be in this format like jan, feb, mar,apr....dec. Is it possible???
    If this is possible then pls tell me the way in a step wise manner for my better understanding..
    Thanks in Advance
    Thenmozhi

    Hi Deva,
    I tried with the below formula :
    CASE WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='January' THEN 1 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='February' THEN 2 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='March' THEN 3 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='April' THEN 4 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='May' THEN 5 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='June' THEN 6 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='July' THEN 7 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='August' THEN 8 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='September' THEN 9 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='October' THEN 10 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='November' THEN 11 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='December' THEN 12 ELSE '' END
    But it is showing the error like this:
    Error Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 17001] Oracle Error code: 604, message: ORA-00604: error occurred at recursive SQL level 1 ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at line 8 ORA-00932: inconsistent datatypes: expected NUMBER got CHAR at OCI call OCIStmtExecute. [nQSError: 17010] SQL statement preparation failed. (HY000)
    What it is problem? Please help me...
    Thanks

  • ALV Not Fix a Column for specific SAP GUI

    Hello Team.
    we have a little problem when We try Fix a Column.
    We create an ALV report, for user with the SAP GUI 7.20
    ls_dispo-FIX_COLUMN   = 'X'.
    Some user has the Patch Level 4 and the fix column work Fine.
    Other has the Patch Level 7, and when the user move the scroll bar, the fixed column not work.
    I think Some Difference in parameter configuration in SAP GUI is the problem,
    Can you help me.
    Best Regards

    Hi David
    I am not sure this might be a solution if you have mentioned all the parameters programatically but you can try if this works
    You can compare the Options between the users GUI
    Goto ->Customize Local Layout ( Alt + F12 ) on your Logon Screen-> Options
    and check if there is any change between these two Patch Levels.
    Thanks
    Dev

  • Mix AVG and Total for the same column in ALV grid

    Hi,
    We are using CL_GUI_ALV_GRID=>SET_TABLE_FOR_FIRST_DISPLAY, and I'd like to know if the following situation is possible.
    Let's say we have a column which contains a number of hours, and we set it up to subtotal by period, but as an average rather than a total (DO_SUM = "C"). This is not a problem so far.
    The problem is that we'd like for the "Grand Total" at the bottom of the ALV grid to total all of the subtotal averages, instead of calculating an average.
    Ex:
    Period            Hours
    2010/01           6.0
    2010/02           7.0
    2010/03           2.0
                    5.0  (This is an average... 6.0 + 7.0 + 2.0 / 3)
    2011/01          12.0
    2011/02           5.0
    2011/03           4.0
                    7.0  (This is an average... 12.0 + 5.0 + 4.0 / 3)
                12.0 (We want this to be a total of 5.0 + 7.0)
    So we want the "grand total" line to be 12.0 which is the sum, but it currently comes out as an average.
    Therefore we're looking to average at the sub total level, but we want a total of the subtotal levels at the grand total level for the same column.
    Thanks,
    Denis

    Refer to the suggestion given by Naimesh here Can we modify a sub-total in ALV making use of function GET_GLOBALS_FROM_SLVC_FULLSCR and the method GET_SUBTOTALS. You can see the parameter ep_collect01 refered in case of subtotals. Can you please check ep_collect00 for grand total in your case.
    As said about EP_COLLECT00,here goes a classic example Modify grand total in ALV GRID
    BR
    Keshav
    Edited by: Keshav.T on Sep 21, 2011 9:39 AM

  • How to get ALV Display with First column alone in sort

    How to get ALV Display with First column alone in sort

    HI,
    You can build Internal Table and send this to the parameter "IT_SORT".
    eg:
    "the sorting Internal Table structure is as whown below.
    DATA:  t_sort_info type slis_t_sortinfo_alv.
    "Build the Sort Internal Table
      t_sort_info-fieldname = 'CARRID'.
      t_sort_info-subtot = 'X'.
      append t_sort_info.
      t_sort_info-fieldname = 'FLDATE'.
      t_sort_info-subtot = 'X'.
      append t_sort_info.
    Then pass this "IT_SORT_INFO" table to the Function module "Reuse_alv_*". (Note send the body of the Internal table only like "<b>IT_SORT = IT_SORT_INFO[]</b>".
    Here i am making ALV output sorted on CARRID & FLDATE.
    You can specify only the First Column name for sorting.
    Regards,
    Manju
    Message was edited by:
            MANJUNATHA KS

  • Iphone 4S updated to iOS 5.0.1 last nite no longer visible in iTunes for wireless sync.  check box is viewable as checked when connected via usb. anyone else having this problem and been able to sort? Thanks.

    Hi all.  Update my iphone 4S via usb last night.  Since then the iphone is not visible in itunes for wireless syncing.  The sync wirelessly box is checked and is viewable as checked when phone connected via usb.  Anyone else have this problem and been able to sort?  Thanks.  Doug

    Hi all.  Update my iphone 4S via usb last night.  Since then the iphone is not visible in itunes for wireless syncing.  The sync wirelessly box is checked and is viewable as checked when phone connected via usb.  Anyone else have this problem and been able to sort?  Thanks.  Doug

Maybe you are looking for

  • My ipod will not be recognized by Itunes

    I keep trying to put my ipod on my computer and it will not go in as a drive. The computer recognizes it as "Connor's Ipod (K:)," but Itunes will not allow it and gives me an error message sending me to this screen: http://support.apple.com/kb/TS1363

  • Accessing DefaultValues for parameters with dynamic values

    We have a custom user interface we place in front of all Crystal Reports (to maintain look&feel) that reads the parameters from the report and dynamically generates controls for user input.  The only time this doesn't work is for parameters that have

  • IChat preferences not being saved?

    Hey everyone, Everytime I launch iChat I have to go through the initial setup process as if I've never run the app before. It really just amounts to entering my name and then clicking return a few times, but still - its annoying. I'm runing version 3

  • SQL query -- self-join question?

    SQL> l 1* select originator,destination,oaddress,daddress from (select * from activity where rownum<=3) SQL> / 10099 10004 16196344392 16199375530 10064 10002 18454644069 18456563415 10065 10006 18302650166 16416609306 looking at the above query, i a

  • Abt web.show_document

    hi,. i am trying to call the builtin in forms 10g web.Show_document('javascript:alert("hello world")','_blank'); but its not working!!!! can anybody help!!!!!! thanX in advance chandra