Alv-subtotals texts

hi all,
    i need to display the short texts of the field at the subtotals.for instance,for an order i need to sum up currency and i need to dispaly its short description at the subtotal column..for this i'm using layout-subtotals_text..
and i'm sending the field to this alv field..
Thanks in Advance.

HI venkata
for this you need to do using handlers
in local classs , you need a event for sub total text,
and set the handler for it, then sub total text will come.
FORM method_subtotal_text USING es_subtottxt_info TYPE lvc_s_stxt
ep_subtot_line TYPE REF TO data
e_event_data TYPE REF TO
cl_alv_event_data.
DATA ls_sflight LIKE sflight.
FIELD-SYMBOLS: <fs1> STRUCTURE sflight DEFAULT ls_sflight,
<fs2>.
IF es_subtottxt_info-criteria = 'PLANETYPE'.
ASSIGN ep_subtot_line->* TO <fs1>.
ASSIGN e_event_data->m_data->* TO <fs2>.
CONCATENATE es_subtottxt_info-keyword ': '
<fs1>-planetype INTO <fs2>.
ENDIF.
regards
kishore

Similar Messages

  • ALV  SUBTOTALS TEXTS: how can we use 'slis_subtot_text' structure

    hi
    in SLIS type pool
    there is a structure
    <b>slis_subtot_text</b>
    i think this for custom subtotal texts
    other that standard
    but how do we use it
    where is this structure to be given as parameter

    Hi Srikant,
    You can use the subtotal text in ALV.
    Before using the subtotal,. you have to sort the List using the field for which total has to be calculated.
    DATA: lt_sort       TYPE slis_t_sortinfo_alv.
      DATA: lw_sort       TYPE slis_sortinfo_alv.
      CONSTANTS:
            lc_value_x                   TYPE  ebstyp                VALUE 'X'.
      v_repid = sy-repid.
      lw_sort-fieldname = fieldname.
      lw_sort-up = lc_value_x.
      lw_sort-subtot = lc_value_x.
    lw_sort-stext  = 'Subttotal'.
      APPEND lw_sort TO lt_sort.
    *call function to display the report
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program      = v_repid
          i_callback_top_of_page  = 'TOP_OF_PAGE'
          it_fieldcat             = ut_fieldcattab
          it_sort                 = lt_sort
        TABLES
          t_outtab                = ct_output_values_tab
        EXCEPTIONS
          program_error           = 1
          OTHERS                  = 2.
    Regards,
    Yogesh

  • Subtotals text in ALV

    Hi All,
         I want subtotals text in ALV GRID. For this iam seeing a standard program 'BCALV_TEST_FULLSCREEN'.Iam giving subtotal text on selection screen,but its not displayed in output.How to view the text.
    When i executed another program BCALV_TEST_LIST, iam able to get the subtotal text in output, what ever i give the text on the selction screen.
    Regards,
    Kiran I

    Hi,
    Chk out this:
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    gd_layout-totals_only        = 'X'.
    gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                            "click(press f2)
    gd_layout-zebra             = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    Best Regards,
    Anjali

  • ALV Subtotals

    Hi ABAP Gurus,
    I have a problem with ALV subtotals and don't now how to solve it using ALV. I might have to go back to Classical reports if I cannot solve it. Here is the Problem :
    The tables BSET stores the Taxes info for the accounting documents. Each line is for the tax jurisdiction levels and tax jurisdiction code. The base amount on all the lines is same say 100.00 and let us assume 6 lines. When the subtotals are done for the jurisdiction levels the subtotal for the base amount is 100.00 ( only one line per level ) and this is what is expected. But for tax jurisdiction code the total comes to 600.00 Which is what is expected from ALV totals . But since 100.00 is the base amount for tax report purposes this should be the subtotal. That is the subtotal should be 100 for the jurisdiction codes not 600.00.
    I tried varous stuff but couldn't get desired results? Any solution is highly appreciated.
    Thanks,
    Nanda

    REPORT ysalesorder_alv_subtotals.
    Type Pools
    TYPE-POOLS:slis.
    Tables
    TABLES: vbak, "Sales Document: Header Data
    vbap. "Sales Document: Item Data
    Global Structures
    DATA:gt_fieldcat TYPE slis_t_fieldcat_alv,
    wa_fieldcat TYPE slis_fieldcat_alv,
    gt_sortcat TYPE slis_t_sortinfo_alv,
    wa_sortcat LIKE LINE OF gt_sortcat.
    Internal Table
    DATA: BEGIN OF gt_salesorder OCCURS 0,
    vbeln LIKE vbak-vbeln, " Sales Document Number
    posnr LIKE vbap-posnr, " Sales Doc Item
    netwr LIKE vbap-netwr, " Net Value
    END OF gt_salesorder.
    SELECT OPTIONS
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME
    TITLE text-001.
    SELECT-OPTIONS: s_vbeln FOR vbak-vbeln. " Sales Document
    Number.
    SELECTION-SCREEN END OF BLOCK b1.
    Initialization
    INITIALIZATION.
    PERFORM initialization.
    Start Of Selection
    START-OF-SELECTION.
    PERFORM field_catalog. "For Structure Creation
    PERFORM fetch_data. "Get the Data From DB Table
    PERFORM sorting USING gt_sortcat.
    End Of Selection
    END-OF-SELECTION.
    PERFORM display_data.
    *& Form initialization
    text
    --> p1 text
    <-- p2 text
    FORM initialization .
    s_vbeln-sign = 'I'.
    s_vbeln-option = 'BT'.
    s_vbeln-low = '4969'.
    s_vbeln-high = '5000'.
    APPEND s_vbeln.
    ENDFORM. " initialization
    *& Form field_catalog
    text
    --> p1 text
    <-- p2 text
    FORM field_catalog .
    REFRESH : gt_fieldcat.
    CLEAR : wa_fieldcat.
    wa_fieldcat-col_pos = '1'. "Column Position
    wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table
    wa_fieldcat-fieldname = 'VBELN'. "Field Name
    wa_fieldcat-key = 'X'. "Blue Color
    wa_fieldcat-seltext_m = 'Sales Doc No'. "Display Text In Screen
    APPEND wa_fieldcat TO gt_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-col_pos = '2'. "Column Position
    wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table Name
    wa_fieldcat-fieldname = 'POSNR'. "Field Name
    wa_fieldcat-seltext_m = 'Sales Doc Item'."Display Text In Screen
    APPEND wa_fieldcat TO gt_fieldcat.
    CLEAR wa_fieldcat.
    *SubTotal on the Field NETWR
    wa_fieldcat-col_pos = '3'. "Column Position
    wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table
    wa_fieldcat-fieldname = 'NETWR'. "Field Name
    wa_fieldcat-do_sum = 'X'. "Sum
    wa_fieldcat-seltext_m = 'Net Value'. "Display Text In Screen
    APPEND wa_fieldcat TO gt_fieldcat.
    CLEAR wa_fieldcat.
    ENDFORM. " field_catalog
    *& Form sorting
    text
    -->P_IT_SORTCAT text
    FORM sorting USING p_it_sortcat TYPE slis_t_sortinfo_alv.
    CLEAR wa_sortcat.
    wa_sortcat-fieldname = 'VBELN'.
    wa_sortcat-up ='X'.
    wa_sortcat-subtot = 'X'.
    APPEND wa_sortcat TO p_it_sortcat.
    ENDFORM. " sorting
    *& Form display_data
    text
    --> p1 text
    <-- p2 text
    FORM display_data .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER = ' '
    I_BUFFER_ACTIVE = ' '
    i_callback_program = sy-repid
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    I_CALLBACK_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_END_OF_LIST = ' '
    I_STRUCTURE_NAME =
    I_BACKGROUND_ID = ' '
    I_GRID_TITLE =
    I_GRID_SETTINGS =
    IS_LAYOUT =
    it_fieldcat = gt_fieldcat
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    it_sort = gt_sortcat
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS =
    IT_EVENT_EXIT =
    IS_PRINT =
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IT_ALV_GRAPHICS =
    IT_HYPERLINK =
    IT_ADD_FIELDCAT =
    IT_EXCEPT_QINFO =
    I_HTML_HEIGHT_TOP =
    I_HTML_HEIGHT_END =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    t_outtab = gt_salesorder
    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.
    ENDFORM. " display_data
    *& Form fetch_data
    text
    --> p1 text
    <-- p2 text
    FORM fetch_data .
    REFRESH : gt_salesorder.
    CLEAR : gt_salesorder.
    SELECT a~vbeln
    posnr
    b~netwr
    FROM vbak AS a
    INNER JOIN vbap AS b ON avbeln = bvbeln
    INTO TABLE gt_salesorder
    WHERE a~vbeln IN s_vbeln.
    ENDFORM. " fetch_data
    pls see this example and try u r program.i
    regards
    ravi

  • Subtotals text to be displayed on ALV

    How can a subtotals and totals text can be displayed on ALV.
    I have tried using <b>totals_text</b> and <b>subtotals_text</b> of <b>is_layout</b> of alv but its not working.
    so if any one knows this , please reply at earliest.

    Hi,
    i think you are using ALV Grid FM, in that case check the following event, you can do that.
    <b>FORM subtotal_text CHANGING p_ep_subtot_line_r    TYPE any
                    p_es_subtottxt_info_r TYPE slis_subtot_text."#EC CALLED</b>
      DATA: l_st_subtot_line LIKE LINE OF t_outtab_list.
      FIELD-SYMBOLS: <fs1> TYPE ANY,      "report structure
                    <fs_field> TYPE ANY. "field of structure
    * Retrieve the subtotal line
      ASSIGN p_ep_subtot_line_r TO <fs1>.
      IF sy-subrc NE 0.
        UNASSIGN <fs1>.
      ELSE.
    * retrieve field value for subtotal criteria
        ASSIGN COMPONENT p_es_subtottxt_info_r-criteria
        OF STRUCTURE <fs1> TO
        <fs_field>.
        IF sy-subrc <> 0.
          UNASSIGN <fs_field>.
        ELSE.
          l_st_subtot_line = p_ep_subtot_line_r.
          CASE p_es_subtottxt_info_r-criteria.
            WHEN 'GLOB'.
              IF l_st_subtot_line-glob_ct <> 0.
                l_st_subtot_line-variance
                  = l_st_subtot_line-variance / l_st_subtot_line-spart_ct.
              ENDIF.
              p_es_subtottxt_info_r-display_text_for_subtotal =
                     'Average at Highest Level'.
            WHEN 'SPART'.
              IF l_st_subtot_line-spart_ct <> 0.
                l_st_subtot_line-variance
                   = l_st_subtot_line-variance / l_st_subtot_line-spart_ct.
              ENDIF.
              CONCATENATE   'Average Level 4 @ Division ' <fs_field>
               INTO p_es_subtottxt_info_r-display_text_for_subtotal
              SEPARATED BY space.
            WHEN 'PRDHA1'.
              IF l_st_subtot_line-prdha1_ct <> 0.
                l_st_subtot_line-variance
                   = l_st_subtot_line-variance / l_st_subtot_line-spart_ct.
              ENDIF.
              CONCATENATE   'Average Level 3 @ Category ' <fs_field>
              INTO p_es_subtottxt_info_r-display_text_for_subtotal
              SEPARATED BY space.
            WHEN 'PRDHA2'.
              IF l_st_subtot_line-prdha2_ct <> 0.
                l_st_subtot_line-variance
                   = l_st_subtot_line-variance / l_st_subtot_line-spart_ct.
              ENDIF.
              CONCATENATE   'Average Level 2 @ Class ' <fs_field>
              INTO p_es_subtottxt_info_r-display_text_for_subtotal
              SEPARATED BY space.
            WHEN 'PRDHA3'.
              IF l_st_subtot_line-prdha3_ct <> 0.
                l_st_subtot_line-variance
                   = l_st_subtot_line-variance / l_st_subtot_line-spart_ct.
              ENDIF.
              CONCATENATE   'Average Level 1 @ Sub-Class ' <fs_field>
              INTO p_es_subtottxt_info_r-display_text_for_subtotal
              SEPARATED BY space.
          ENDCASE.
          p_ep_subtot_line_r = l_st_subtot_line.
        ENDIF.
      ENDIF.
    ENDFORM.                    "get_subtotal_txt
    Regards
    vijay

  • Subtotals text on ALV

    How Should I use EVENT SUBTOTALS_TEXT in an ALV.
          i_events-name = 'SUBTOTALS_TEXT'
          i_events-form = 'SUBTOTAL'.
       how this event can be <i><b>handled</b></i> in an ALV

    Hi,
    <b>FORM subtotal_text CHANGING p_ep_subtot_line_r    TYPE any
                    p_es_subtottxt_info_r TYPE slis_subtot_text."#EC CALLED</b>
      DATA: l_st_subtot_line LIKE LINE OF t_outtab_list.
      FIELD-SYMBOLS: <fs1> TYPE ANY,      "report structure
                    <fs_field> TYPE ANY. "field of structure
    * Retrieve the subtotal line
      ASSIGN p_ep_subtot_line_r TO <fs1>.
      IF sy-subrc NE 0.
        UNASSIGN <fs1>.
      ELSE.
    * retrieve field value for subtotal criteria
        ASSIGN COMPONENT p_es_subtottxt_info_r-criteria
        OF STRUCTURE <fs1> TO
        <fs_field>.
        IF sy-subrc <> 0.
          UNASSIGN <fs_field>.
        ELSE.
          l_st_subtot_line = p_ep_subtot_line_r.
          CASE p_es_subtottxt_info_r-criteria.
            WHEN 'GLOB'.
              IF l_st_subtot_line-glob_ct <> 0.
                l_st_subtot_line-variance
                  = l_st_subtot_line-variance / l_st_subtot_line-spart_ct.
              ENDIF.
              p_es_subtottxt_info_r-display_text_for_subtotal =
                     'Average at Highest Level'.
            WHEN 'SPART'.
              IF l_st_subtot_line-spart_ct <> 0.
                l_st_subtot_line-variance
                   = l_st_subtot_line-variance / l_st_subtot_line-spart_ct.
              ENDIF.
              CONCATENATE   'Average Level 4 @ Division ' <fs_field>
               INTO p_es_subtottxt_info_r-display_text_for_subtotal
              SEPARATED BY space.
            WHEN 'PRDHA1'.
              IF l_st_subtot_line-prdha1_ct <> 0.
                l_st_subtot_line-variance
                   = l_st_subtot_line-variance / l_st_subtot_line-spart_ct.
              ENDIF.
              CONCATENATE   'Average Level 3 @ Category ' <fs_field>
              INTO p_es_subtottxt_info_r-display_text_for_subtotal
              SEPARATED BY space.
            WHEN 'PRDHA2'.
              IF l_st_subtot_line-prdha2_ct <> 0.
                l_st_subtot_line-variance
                   = l_st_subtot_line-variance / l_st_subtot_line-spart_ct.
              ENDIF.
              CONCATENATE   'Average Level 2 @ Class ' <fs_field>
              INTO p_es_subtottxt_info_r-display_text_for_subtotal
              SEPARATED BY space.
            WHEN 'PRDHA3'.
              IF l_st_subtot_line-prdha3_ct <> 0.
                l_st_subtot_line-variance
                   = l_st_subtot_line-variance / l_st_subtot_line-spart_ct.
              ENDIF.
              CONCATENATE   'Average Level 1 @ Sub-Class ' <fs_field>
              INTO p_es_subtottxt_info_r-display_text_for_subtotal
              SEPARATED BY space.
          ENDCASE.
          p_ep_subtot_line_r = l_st_subtot_line.
        ENDIF.
      ENDIF.
    ENDFORM.                    "get_subtotal_txt
    Regards
    vijay

  • ALV - Subtotals with different waers

    Hello!
    I have a hierarquical ALV sorted by LIFNR and payments with the WRBTR and WAERS columns.
    WAERS can be 'ARS' 'USD' etc. for the same LIFNR.
    I want to display subtotals of WRBTR field for each LIFNR by WAERS.
    Can anyone help me please?
    Thanks,
    Liliana.

    Hi Liliana,
    Plz check this code .
    report  zxx_alvexer4    message-id zz        .
    *& TABLES DECLARATION                                                  *
    tables: vbak, vbap.
    *& TYPE POOLS DECLARATION                                              *
    type-pools: slis.
                          DATA DECLARATIONS                             *
    data: v_flag type c.                        "Flag to display the header
    data: v_repid type sy-repid.
    *& INTERNAL TABLE DECLARATION                                          *
    data: begin of it_vbak occurs 0,
           vbeln like vbak-vbeln,
           audat like vbak-audat,
           auart like vbak-auart,
           netwr like vbak-netwr,
           expand(1),
          end of it_vbak.
    data: begin of it_vbap occurs 0,
           vbeln like vbap-vbeln,
           posnr like vbap-posnr,
           matnr like vbap-matnr,
           pstyv like vbap-pstyv,
           charg like vbap-charg,
         end of it_vbap.
    data: it_fldcat type slis_t_fieldcat_alv,
          it_fldcat1 type slis_t_fieldcat_alv,
    *events
          it_events type slis_t_event with header line,
          v_call type c,
          x_user type  slis_exit_by_user,
          it_variant like  disvariant occurs 0 with header line,
          x_keyinfo type slis_keyinfo_alv,
    *layout
          x_layout type slis_layout_alv,
    *sort
          it_sort type slis_t_sortinfo_alv,
          wa_sort like line of it_sort,
          x_cat type slis_fieldcat_alv,
          v_tabix like sy-tabix.
          Selection screen Declaration
    *--BLOCK1
    selection-screen begin of block b1 with frame title text-001.
    select-options: s_vbeln for vbak-vbeln,
                    s_auart for vbak-auart.
    selection-screen end of block b1.
    AT SELECTION-SCREEN                                                 *
    *- Validations
    at selection-screen.
      perform validate_screen.
                  START OF SELECTION                                    *
    start-of-selection.
    *- To get data from VBAK
      perform get_data.
    *to get data from VBAP
      perform get_data_vbap.
      perform prepare_alv.
                  END OF SELECTION                                    *
    end-of-selection.
      perform display_report.
    *&      Form  VALIDATE_SCREEN
          text
    -->  p1        text
    <--  p2        text
    form validate_screen .
      data: lv_vbeln like vbak-vbeln,
            lv_auart like vbak-auart.
      if not s_vbeln[] is initial.
        select vbeln
               into lv_vbeln
               from vbak
               where vbeln in s_vbeln.
        endselect.
        if sy-subrc <> 0.
          message e000 with 'INVALID SALES DOC'(002).
        endif.
      endif.
      if not s_auart[] is initial.
        select auart
               into lv_auart
               from vbak
               where auart in s_auart.
        endselect.
        if sy-subrc <> 0.
          message e000 with 'INVALID SALES DOC TYPE'(003).
        endif.
      endif.
    endform.                    " VALIDATE_SCREEN
    *&      Form  GET_DATA
          text
    -->  p1        text
    <--  p2        text
    form get_data .
      select vbeln
             audat
             auart
             netwr
             from vbak
             into table it_vbak
             where vbeln in s_vbeln
             and auart in s_auart.
      if sy-subrc = 0.
        sort it_vbak by vbeln.
      endif.
    endform.                    " GET_DATA
    *&      Form  GET_DATA_VBAP
          text
    -->  p1        text
    <--  p2        text
    form get_data_vbap .
      select vbeln
             posnr
             matnr
             pstyv
             charg
             into table it_vbap
             from vbap
             for all entries in it_vbak
             where vbeln = it_vbak-vbeln.
      if sy-subrc = 0.
        sort it_vbap by vbeln posnr.
      endif.
    endform.                    " GET_DATA_VBAP
    *&      Form  prepare_alv
          text
    -->  p1        text
    <--  p2        text
    form prepare_alv .
    Prepare field catalog .
      perform prepare_catalog.
    Modify catalog
      perform change_attr_of_catalog.
    Modify Layout
      perform modify_layout.
    Sort Catalog
      perform sort_catalog.
    endform.                    " prepare_alv
    *&      Form  prepare_catalog
          text
    -->  p1        text
    <--  p2        text
    form prepare_catalog .
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
        exporting
          i_program_name         = sy-repid
          i_internal_tabname     = 'IT_VBAK'
          i_inclname             = sy-repid
        changing
          ct_fieldcat            = it_fldcat1[]
        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.
      append lines of it_fldcat1 to it_fldcat.
      clear: it_fldcat1[].
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
        exporting
          i_program_name         = sy-repid
          i_internal_tabname     = 'IT_VBAP'
          i_inclname             = sy-repid
        changing
          ct_fieldcat            = it_fldcat1[]
        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.
      append lines of it_fldcat1 to it_fldcat.
    endform.                    " prepare_catalog
    *&      Form  change_attr_of_catalog
          text
    -->  p1        text
    <--  p2        text
    form change_attr_of_catalog .
      loop at it_fldcat into x_cat.
        v_tabix = sy-tabix.
        case x_cat-fieldname.
          when  'EXPAND'.
            if x_cat-tabname = 'IT_VBAK'.
              x_cat-no_out = 'X'.
            endif.
         when  'VBELN'.
           if x_cat-tabname = 'IT_VBAK'.
             x_cat-no_out = 'X'.
           endif.
          when  'VBELN'.
            if x_cat-tabname = 'IT_VBAK'.
              x_cat-col_pos   = '1'.
              x_cat-seltext_m = 'SALES DOC'.
              x_cat-seltext_l = 'SALES DOC'.
              x_cat-seltext_s = 'SALES DOC'.
              x_cat-outputlen = '10'.
            endif.
          when  'AUDAT'.
            if x_cat-tabname = 'IT_VBAK'.
              x_cat-col_pos   = '2'.
              x_cat-seltext_m = 'DOC DATE'.
              x_cat-seltext_l = 'DOC DATE'.
              x_cat-seltext_s = 'DOC DATE'.
              x_cat-outputlen = '8'.
            endif.
          when  'AUART'.
            if x_cat-tabname = 'IT_VBAK'.
              x_cat-col_pos   = '3'.
              x_cat-seltext_m = 'ORDER REASON'.
              x_cat-seltext_l = 'ORDER REASON'.
              x_cat-seltext_s = 'ORDER REASON'.
              x_cat-outputlen = '5'.
            endif.
          when  'NETWR'.
            if x_cat-tabname = 'IT_VBAK'.
              x_cat-col_pos   = '4'.
              x_cat-seltext_m = 'NET PRICE'.
              x_cat-seltext_l = 'NET PRICE'.
              x_cat-seltext_s = 'NET PRICE'.
              x_cat-outputlen = '15'.
            endif.
        endcase.
        modify it_fldcat from x_cat.
        clear x_cat.
      endloop.
    endform.                    " change_attr_of_catalog
    *&      Form  modify_layout
          text
    -->  p1        text
    <--  p2        text
    form modify_layout .
      x_layout-default_item = 'X'.
      x_layout-zebra = 'X'.
      x_layout-expand_fieldname = 'EXPAND'.
    endform.                    " modify_layout
    *&      Form  sort_catalog
          text
    -->  p1        text
    <--  p2        text
    form sort_catalog .
      clear wa_sort.
      wa_sort-spos = '01'.
      wa_sort-fieldname = 'VBELN' .
      wa_sort-tabname   = 'IT_VBAP'.
      wa_sort-up        = 'X'.
      append wa_sort to it_sort.
      clear  wa_sort.
      wa_sort-spos = '02'.
      wa_sort-fieldname = 'POSNR' .
      wa_sort-tabname   = 'IT_VBAP'.
      wa_sort-up        = 'X'.
      append wa_sort to it_sort.
    endform.                    " sort_catalog
    *&      Form  DISPLAY_REPORT
          text
    -->  p1        text
    <--  p2        text
    form display_report .
      it_variant-report = sy-repid.
      sort it_vbak by vbeln.
      sort it_vbap by vbeln posnr.
      call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
        exporting
          i_callback_program      = sy-repid
          is_layout               = x_layout
          it_fieldcat             = it_fldcat[]
          it_sort                 = it_sort
          is_variant              = it_variant
          it_events               = it_events[]
          i_tabname_header        = 'IT_VBAK'
          i_tabname_item          = 'IT_VBAP'
          is_keyinfo              = x_keyinfo
        importing
          e_exit_caused_by_caller = v_call
          es_exit_caused_by_user  = x_user
        tables
          t_outtab_header         = it_vbak
          t_outtab_item           = it_vbap
        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.
    endform.                    " DISPLAY_REPORT
    Regards,
    Laxmi
    Message was edited by: Laxmi

  • ALV Subtotals calculation - Urgent

    Hi All,
      How can I caliculate subtotals in ALV ?
      How to increase column size in alv?
    Regards

    Hi,
    Refer this code
    *&      Form  sub_display_data
          text
    FORM sub_display_data .
    *--To sort the output through material number
      DATA : lwa_sort TYPE slis_sortinfo_alv.
      DATA : lit_sort TYPE slis_t_sortinfo_alv.
    *--Pass the values to the table
      lwa_sort-fieldname = 'PERNR'.             "Field name in o/p inttable
      lwa_sort-tabname   = 'it_final2'.         "Output Internal table
      lwa_sort-spos      = '1'.                 "Sort  sequence
      lwa_sort-up        = 'X'.                 "Sort in ascending order
      lwa_sort-down      = ' '.                 "Sort in descending order
      lwa_sort-subtot    = 'X'.                 "Subtotal
      APPEND lwa_sort TO lit_sort.
    *--Pass the values to the table
      lwa_sort-fieldname = 'WORKDATE'.          "Field name in o/p inttable
      lwa_sort-tabname   = 'it_final2'.         "Output Internal table
      lwa_sort-spos      = '2'.                 "Sort  sequence
      lwa_sort-up        = 'X'.                 "Sort in ascending order
      lwa_sort-down      = ' '.                 "Sort in descending order
      lwa_sort-subtot    = ' '.                 "Subtotal
      APPEND lwa_sort TO lit_sort.
    *--Pass the values to the table
      lwa_sort-fieldname = 'WEKLY'.             "Field name in o/p inttable
      lwa_sort-tabname   = 'it_final2'.         "Output Internal table
      lwa_sort-spos      = '3'.                 "Sort  sequence
      lwa_sort-up        = 'X'.                 "Sort in ascending order
      lwa_sort-down      = ' '.                 "Sort in descending order
      lwa_sort-subtot    = ' '.                 "Subtotal
      APPEND lwa_sort TO lit_sort.
      wa_layout-colwidth_optimize = 'X'.       to increase collumn length
      IF NOT it_final2[] IS INITIAL.
    *--Call the function module to display the ALV report
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            is_layout          = wa_layout
            i_callback_program = v_repid
            it_fieldcat        = it_fieldcat1[]
            i_default          = c_chk
            i_save             = c_save
            it_sort            = lit_sort
          TABLES
            t_outtab           = it_final2
          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.
    *--Message No data found
        MESSAGE i888 WITH text-017.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM.                    " sub_display_data
    Regards,
    Prashant

  • ALV Subtotals Description

    Hi,
    Can you please tell how to write subtotal text in ALV Report.
    770016     MTNL Gas     770018143     KGST     7/24/2005     DG     -157.77
    770016     MTNL Gas     770018203     KGST     7/24/2005     DG     -1,354.75
    770016     MTNL Gas     770018219     KGST     7/24/2005     DG     -499.26
    770016     MTNL Gas     770018220     KGST     7/17/2005     DG     -609.34
    770016     MTNL Gas     770018253     KGST     7/24/2005     DG     -332.84
    770016     MTNL Gas     770018257     KGST     7/24/2005     DG     -630.05
    770016     MTNL Gas     770018299     KGST     7/31/2005     DG     -158.01
    770016     A/R Open Balances                     (3,742.02)
    770016     Unapplied Customer Credits     3,742.02                 
    Please let me know how to write description <b>A/R Open</b> <b>Balances(Debit)</b> and <b>Unapplied Customer</b> <b>Credits(Credit)</b> for the subtotals in ALV.
    Thanks in advance.
    Regards,
    Baba.

    hi
    try this out this may help u.............
    populate Table IT_SORT with the sort criteria for the different fields.
    sorting and subtotaling are specified by the caller in the internal table I_SORT.
    call this function and mention the fields.

  • Subtotals text

    Hi gurus,
    I'm displaying a list using Hierarchial ALV's. I'm displaying subtotals for field AMOUNT.
    Now I have 2 issues.
    1) while displaying subtotals exactly after the list, and exactly before the subtotal is displayed, one extra line is getting added and displayed in the output.
    Could anyone let me know how to remove this unnecessary  line.
    2) Also how to display certain text  exactly beside  the SUBTOTAL.
    Thanks
    Natasha SS

    Hi,
    Please visit the links:
    1. http://wiki.sdn.sap.com/wiki/display/Snippets/DisplaysubtotaltextinALV+grid
    2. http://help.sap.com/saphelp_bw/helpdata/en/ee/c8e056d52611d2b468006094192fe3/content.htm
    3. Passing the Total/Subtotal Text in ALV
    These links gives you the idea about the subtotal_text.
    May this info helps you.
    Regards.
    Deepak Sharma

  • Hierarchical alv subtotals

    HI,
    i am trying to print the subtotals in hierarchical sequential alv.
    i have written some code.but in that it is not showing the subtotals by default.for subtotals i am selecting a column in header and pressing the subtotals button.then only it is showing subtotals.
    how can i show the subtotals by default(without selecting any column and subtotals button)
    regards,
    Hi

    Please help me on this issue: i want grand total on end of every column for example field 'metric-safety'
    'metric-avtual'. very urgent. thanks in advance
    TYPE-POOLS : slis.
    Tables : Marc,                      " Plant Data for Material
             Mbew,                      " Material Valuation
             Ekpo,                      " Purchasing Document Item
             Eord,                      " Purchasing Source List
            Zpmt.                      " Purchasing Metric Table
    --Internal Tables Declaration--
    Data : Begin of metric occurs 0,
           matnr like marc-matnr,        " Material number
           werks like marc-werks,        " Plant
           minbe like marc-minbe,        " Recoder Point
           eisbe like marc-eisbe,        " Safety Stock
           stprs like mbew-stprs,        " Standard Price
           lifnr like eord-lifnr,        " Vendor
           menge like ekpo-menge,        " PO Quantity
           scalc type p decimals 2,
           safety(20) type c,
           tcalc type p decimals 2,
           Target(20) type c,
           acalc type p decimals 2,
           actual(20) type c,
           ecalc type p decimals 2,
           excess(20) type c,
           ucalc type p decimals 2,
           usafety(20) type c,
    *******Custom table
           inscr like zpmt-inscr,        " Inventory Score
           stkot like zpmt-stkot,        " Stock Out
           impct like zpmt-impct,        " Impact
           nafta like zpmt-nafta,        " %nafta
           stscr like zpmt-stscr,        " Stock Out Score
           end of metric.
    Data : final like metric occurs 0 with header line.
    DATA: fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
    **Data : Begin of output occurs 0,
          lifnr like eord-lifnr,        " Vendor
          eisbe like marc-eisbe,        " Safety Stock
          minbe like marc-minbe,        " Re-order Point
          stprs like mbew-stprs,        " Standard Price
          sstock(13) type c,            " Value of Safety Stock
          Actual(13) type c,            " Actual
          Excess(13) type c,            " Excess Inv
          underSs(13) type c,           " Under Safety Stock
          end of output.
    --Data type  Declaration--
    Data : a type c value '$'.
    Data : safety(20) type c,
            target(20) type c,
            actual(20) type c,
            excess(20) type c,
            usafety(20) type c,
            repid like sy-repid.
    data : i_pos type i.
    --Selection Screen--
    selection-screen : begin of block b1 with frame Title tname.
    Select-options:    Mat for marc-matnr,  " Material Number Selection
                       Plt for marc-werks,  " Plant Selection
                       Vdr for eord-lifnr.  " Vendor Selection
    selection-screen : end of block b1.
    --Initialization--
    initialization.
    tname = 'Purchasing Metric Report'.
    --At Selection-Screen--
    At selection-screen.
    IF mat = ' ' and  Plt = ' ' and Vdr = ' '.
    message e000.
    *elseif mat <> metric-matnr.
    *message e001.
    *elseif plt <> metric-werks.
    *message e002.
    *elseif vdr <> metric-lifnr.
    *message e003.
    endif.
    --Start-of-Selection--
    Start-of-selection.
    *******For Data Retrival
           Perform Data_retrival.
    *******For Calculation
            Perform Calculation.
    *******For Building Fieldcatalog
            Perform Build_fieldcatalog.
    *******Alv Display
            Perform Alv_display.
    *&      Form  Get_Data
          text
    FORM Data_retrival .
    SELECT a~matnr
           a~werks
           a~eisbe
           a~minbe
           b~matnr
           b~stprs
           c~matnr
           c~lifnr
           d~matnr
           d~menge
                  into corresponding fields of table metric from
                  (  ( ( marc as a inner join mbew as b on bmatnr = amatnr )
                         inner join eord as c on cmatnr = amatnr )
                         inner join ekpo as d on dmatnr = amatnr )
                         where amatnr in mat and awerks in plt and c~lifnr in vdr.
                         if sy-subrc = 0.
                            sort metric by matnr.
                            endif.
    ENDFORM.                    " Get_Data
    *&      Form  Calculation
          text
    FORM Calculation .
    loop at metric.
    ******calculation for safety stock ( safety stock * standard price )
    metric-scalc = metric-eisbe * metric-stprs.
    move metric-scalc to safety.
    condense safety.
    concatenate a safety into metric-safety.
    ******calculation for target ( safety stock + standard price )
    metric-tcalc = ( metric-eisbe * metric-stprs ) + metric-stprs.
    move metric-tcalc to target.
    condense target.
    concatenate a target into metric-target.
    ******calculation for Actual ( Po quantity  * standard price )
    metric-acalc = metric-menge * metric-stprs.
    move metric-acalc to actual.
    condense actual.
    concatenate a actual into metric-actual.
    ******calculation for Excess Inv ( Actual - Target )
    metric-ecalc = ( metric-menge * metric-stprs ) - ( ( metric-eisbe * metric-stprs ) + metric-stprs ).
    move metric-ecalc to excess.
    condense excess.
    concatenate a excess into metric-excess.
    ******calculation for Under Safety Stock ( actual < safety stock. then actual + safety stock (Else) zero )
       if actual < safety.
    metric-menge * metric-stprs <   metric-eisbe * metric-stprs.
        metric-ucalc =  ( metric-menge * metric-stprs ) + ( metric-eisbe * metric-stprs ).
        else.
        metric-ucalc = 0.
        endif.
    move metric-ucalc to usafety.
    condense usafety.
    concatenate a usafety into metric-usafety.
    collect metric into final.
    endloop.
    ENDFORM.                    " Calculation
    *--End-for-Selection--
    *end-of-selection.
    *loop at final.
    *write : / final-lifnr, final-safety, final-target, final-actual, final-excess, final-usafety.
    *endloop.
    *&      Form  Build_fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    FORM Build_fieldcatalog .
      fcat-fieldname   = 'LIFNR'.
      fcat-seltext_m   = 'Vendor'.
    fcat-col_pos     = i_pos.
      fcat-outputlen   = 10.
      fcat-emphasize   = 'X'.
      fcat-key = 'X'.
    fcat-do_sum = 'X'.
    fcat-edit = 'X'.
      append fcat to fcat.
      clear  fcat.
    i_pos = i_pos + 1.
      fcat-fieldname   = 'SAFETY'.
      fcat-seltext_m   = 'Safety Stock'.
      fcat-col_pos     = 2.
      fcat-outputlen   = 10.
      fcat-emphasize   = 'X'.
      fcat-do_sum = 'X'.
    fieldcatalog-key         = 'X'.
      append fcat to fcat.
      clear  fcat.
        fcat-fieldname   = 'ACTUAL'.
      fcat-seltext_m   = 'Actual'.
      fcat-col_pos     = 3.
      fcat-outputlen   = 10.
      fcat-emphasize   = 'X'.
      fcat-do_sum = 'X'.
    fieldcatalog-key         = 'X'.
      append fcat to fcat.
      clear  fcat.
        fcat-fieldname   = 'TARGET'.
      fcat-seltext_m   = 'Target'.
      fcat-col_pos     = 4.
      fcat-outputlen   = 10.
      fcat-emphasize   = 'X'.
    fieldcatalog-key         = 'X'.
      append fcat to fcat.
      clear  fcat.
        fcat-fieldname   = 'EXCESS'.
      fcat-seltext_m   = 'Excess Inv'.
      fcat-col_pos     = 5.
      fcat-outputlen   = 10.
      fcat-emphasize   = 'X'.
    fieldcatalog-key         = 'X'.
      append fcat to fcat.
      clear  fcat.
      fcat-fieldname   = 'USAFETY'.
      fcat-seltext_m   = 'Under Safety Stock'.
      fcat-col_pos     = 6.
      fcat-outputlen   = 20.
      fcat-emphasize   = 'X'.
    fieldcatalog-key         = 'X'.
      append fcat to fcat.
      clear  fcat.
      fcat-fieldname   = 'INSCR'.
      fcat-seltext_m   = 'Iventory Score'.
      fcat-col_pos     = 7.
      fcat-outputlen   = 20.
      fcat-emphasize   = 'X'.
    fieldcatalog-key         = 'X'.
      append fcat to fcat.
      clear  fcat.
      fcat-fieldname   = 'STKOT'.
      fcat-seltext_m   = 'Stock Out'.
      fcat-col_pos     = 6.
      fcat-outputlen   = 20.
      fcat-emphasize   = 'X'.
    fieldcatalog-key         = 'X'.
      append fcat to fcat.
      clear  fcat.
      fcat-fieldname   = 'IMPCT'.
      fcat-seltext_m   = 'Impact'.
      fcat-col_pos     = 6.
      fcat-outputlen   = 20.
      fcat-emphasize   = 'X'.
    fieldcatalog-key         = 'X'.
      append fcat to fcat.
      clear  fcat.
      fcat-fieldname   = 'NAFTA'.
      fcat-seltext_m   = '%Nafta'.
      fcat-col_pos     = 6.
      fcat-outputlen   = 20.
      fcat-emphasize   = 'X'.
    fieldcatalog-key         = 'X'.
      append fcat to fcat.
      clear  fcat.
      fcat-fieldname   = 'STSCR'.
      fcat-seltext_m   = 'Safety Out Score'.
      fcat-col_pos     = 6.
      fcat-outputlen   = 20.
      fcat-emphasize   = 'X'.
    fieldcatalog-key         = 'X'.
      append fcat to fcat.
      clear  fcat.
    ENDFORM.                    " Build_fieldcatalog
    *&      Form  Alv_display
          text
    -->  p1        text
    <--  p2        text
    FORM Alv_display .
    repid = sy-repid.
    *CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
      I_CALLBACK_PROGRAM             = repid
      I_CALLBACK_PF_STATUS_SET       = ' '
      I_CALLBACK_USER_COMMAND        = ' '
      I_STRUCTURE_NAME               =
      IS_LAYOUT                      =
      IT_FIELDCAT                    = fcat[]
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
      IT_EVENTS                      =
      IT_EVENT_EXIT                  =
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_SCREEN_START_COLUMN          = 0
      I_SCREEN_START_LINE            = 0
      I_SCREEN_END_COLUMN            = 0
      I_SCREEN_END_LINE              = 0
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
    TABLES
       T_OUTTAB                       = 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.
    repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = repid
               i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
               i_callback_user_command = 'USER_COMMAND'
               i_grid_title           = outtext
               is_layout               = gd_layout
                it_fieldcat             = fcat[]
               it_special_groups       = gd_tabgroup
               it_events               = gt_events
               is_print                = gd_prntparams
               i_save                  = 'X'
               is_variant              = z_template
           tables
                t_outtab                = 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.
    regards
    sat

  • Downloads from ALV GRID-Text conversion to dates in EXCEL

    When downloading table displays of data from ALV-GRID for excel spreadsheet, we end of with files that have a header and various line ifnromation.  IF we manually clear up the display, then we can have the individicual column headers used and force them to text but if we just call the file up as an EXCEL spreadsheet, some part numbers such 12-3465 appear in Excel as Dec-65.
    The following is an example of the record (but it is word wrapped within this display limit).  In actuality, the verbage enclosed with the <b> represent the start of the  lines that have actual display data running out about 90 characters.
    Suggestions on how to make the download immediately correct in Excel direct from SAP ALV-GRID without cleaning out the heading lines and manually forcing the affected columns to TEXT format?
    thanks
    <b>03/02/2007</b>                                                                    Dynamic List Display                                                                                1
    <b>Materials-Inforecord Details Report</b>
    <b>Purchasing Org: ILMO</b>
                        <b>Report Run Date:03/02/2007</b>                    <b>Report Time:14:31:16</b>
         <b>Plnt     Mat Grp     Vendor     Name 1     Material     Material</b> description     Vendor Cat     Mfr     MPN     PC     Item Chg.     OUn      Eq to     BUn     Net price     Per     OPUn     Inforecord     PGr     Mv Avg        per     ValCl
         <b>0042     04     106070     BURROWS COMPANY</b>     184110     Glv Exam Ltx Non Ster     02-5001     TILLOTSON     02-5001               CA     2,000     EA        93.40      1     CA     5300006999     999     93.40     2,000     6438

    there are different options to export to excel which all behave differently, if you go for the menu ->export it differs from the export button from the alv buttonbar.
    try the different export to excel options perhaps there is one that behaves the way you want
    kind regards
    arthur de smidt

  • In ALV: Subtotals for every month, not for every day, possible?

    Hello,
    in my Alv-Grid I have a date column, which I want to use to generate subtotals. But I don't want to have a subtotal for every date, but for every month. Is there a method to accomplish this with subtotals? Thanks.
    Regards, Lars.

    Hi Stembergg,
    1. Its not possible with only date field.
    2. However, if you have one EXTRA FIELD
       which contains the Month
       only then it is possible.
      ( You may hide this extra field if   u don't
      won't to display. But anyhow, u need to
      modify your logic and the internal table
       and accordingly populate the extra field)
    3. There is contraint in alv
        that we cannot use any function for any column value
        for any claculation/grouping purpose.
    Hope it helps.
    Regards,
    Amit M.
    Message was edited by: Amit Mittal

  • Alv subtotals  and grand total for a field

    Hi friends,
    I Have an internal table ITAB1
    in that i have a senario as below.
    In my GRID display iam getting values in the layou as follows
    BUKRS =  1000
    LIFNR      MATNR     STCST
    100          abc            500,00
    100          pqr             400,00
    100          xyz            200,00
                        sub total
    200         pto              700,00
    200         vbr              900,00
                        sub total
    BUKRS =  2000
    LIFNR      MATNR     STCST
    150          abc            500,00
    150          pqr             400,00
    150          xyz            200,00
                        sub total
    260         pto              700,00
    260         vbr              900,00
                        sub total
              GRAND TOTAL = 
    Now my requirement is at the end of every vendor  i need sub total for STCST field.
    and at the end of every company code i need GRAND TOTAL for STCST field.
    Its alv grid display.
    how can i do that.
    Regards,
    Priyanka.

    Check this sample code may it will help u:
    *& Report  Z_ALV_SUBTOTAL
    REPORT z_alv_subtotal.
    *& Table declaration
    TABLES: ekko.
    *& Type pool declaration
    TYPE-POOLS: slis. " Type pool for ALV
    *& Selection screen
    SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.
    *& Type declaration
    * Type declaration for internal table to store EKPO data
    TYPES: BEGIN OF x_data,
           ebeln  TYPE char30,  " Document no.
           ebelp  TYPE ebelp,   " Item no
           matnr  TYPE matnr,   " Material no
           matnr1 TYPE matnr,   " Material no
           werks  TYPE werks_d, " Plant
           werks1 TYPE werks_d, " Plant
           ntgew  TYPE entge,   " Net weight
           gewe   TYPE egewe,   " Unit of weight                          
           END OF x_data.
    *& Internal table declaration
    DATA:
    * Internal table to store EKPO data
      i_ekpo TYPE STANDARD TABLE OF x_data INITIAL SIZE 0,
    * Internal table for storing field catalog information
      i_fieldcat TYPE slis_t_fieldcat_alv,
    * Internal table for Top of Page info. in ALV Display
      i_alv_top_of_page TYPE slis_t_listheader,
    * Internal table for ALV Display events
      i_events TYPE slis_t_event,
    * Internal table for storing ALV sort information
      i_sort TYPE  slis_t_sortinfo_alv,
      i_event TYPE slis_t_event.
    *& Work area declaration
    DATA:
      wa_ekko TYPE x_data,
      wa_layout     TYPE slis_layout_alv,
      wa_events         TYPE slis_alv_event,
      wa_sort TYPE slis_sortinfo_alv.
    *& Constant declaration
    CONSTANTS:
       c_header   TYPE char1
                  VALUE 'H',                    "Header in ALV
       c_item     TYPE char1
                  VALUE 'S'.
    *& Start-of-selection event
    START-OF-SELECTION.
    * Select data from ekpo
      SELECT ebeln " Doc no
             ebelp " Item
             matnr " Material*
             matnr " Material*
             werks " Plant*
             werks " Plant*
             ntgew " Quantity
             gewei " Unit
             FROM ekpo
             INTO TABLE i_ekpo
             WHERE ebeln IN s_ebeln
             AND ntgew NE '0.00'.
      IF sy-subrc = 0.
        SORT i_ekpo BY ebeln ebelp matnr .
      ENDIF.
    * To build the Page header
      PERFORM sub_build_header.
    * To prepare field catalog
      PERFORM sub_field_catalog.
    * Perform to populate the layout structure
      PERFORM sub_populate_layout.
    * Perform to populate the sort table.
      PERFORM sub_populate_sort.
    * Perform to populate ALV event
      PERFORM sub_get_event.
    END-OF-SELECTION.
    * Perform to display ALV report
      PERFORM sub_alv_report_display.
    *&      Form  sub_build_header
    *       To build the header
    *       No Parameter
    FORM sub_build_header .
    * Local data declaration
      DATA: l_system     TYPE char10 ,          "System id
            l_r_line     TYPE slis_listheader,  "Hold list header
            l_date       TYPE char10,           "Date
            l_time       TYPE char10,           "Time
            l_success_records TYPE i,           "No of success records
            l_title(300) TYPE c.                " Title
    * Title  Display
      l_r_line-typ = c_header.               " header
      l_title = 'Test report'(001).
      l_r_line-info = l_title.
      APPEND l_r_line TO i_alv_top_of_page.
      CLEAR l_r_line.
    * Run date Display
      CLEAR l_date.
      l_r_line-typ  = c_item.                " Item
      WRITE: sy-datum  TO l_date MM/DD/YYYY.
      l_r_line-key = 'Run Date :'(002).
      l_r_line-info = l_date.
      APPEND l_r_line TO i_alv_top_of_page.
      CLEAR: l_r_line,
             l_date.
    ENDFORM.                    " sub_build_header
    *&      Form  sub_field_catalog
    *       Build Field Catalog
    *       No Parameter
    FORM sub_field_catalog .
    *  Build Field Catalog
      PERFORM sub_fill_alv_field_catalog USING:
         '01' '01' 'EBELN' 'I_EKPO' 'L'
         'Doc No'(003) ' ' ' ' ' ' ' ',
         '01' '02' 'EBELP' 'I_EKPO' 'L'
         'Item No'(004) 'X' 'X' ' ' ' ',
         '01' '03' 'MATNR' 'I_EKPO' 'L'
         'Material No'(005) 'X' 'X' ' ' ' ',
         '01' '03' 'MATNR1' 'I_EKPO' 'L'
         'Material No'(005) ' ' ' ' ' ' ' ',
         '01' '04' 'WERKS' 'I_EKPO' 'L'
         'Plant'(006) 'X' 'X' ' ' ' ',
         '01' '04' 'WERKS1' 'I_EKPO' 'L'
         'Plant'(006) ' ' ' ' ' ' ' ',
         '01' '05' 'NTGEW' 'I_EKPO' 'R'
         'Net Weight'(007) ' ' ' ' 'GEWE' 'I_EKPO'.
    ENDFORM.                    " sub_field_catalog
    *&     Form  sub_fill_alv_field_catalog
    *&     For building Field Catalog
    *&     p_rowpos   Row position
    *&     p_colpos   Col position
    *&     p_fldnam   Fldname
    *&     p_tabnam   Tabname
    *&     p_justif   Justification
    *&     p_seltext  Seltext
    *&     p_out      no out
    *&     p_tech     Technical field
    *&     p_qfield   Quantity field
    *&     p_qtab     Quantity table
    FORM sub_fill_alv_field_catalog  USING  p_rowpos    TYPE sycurow
                                            p_colpos    TYPE sycucol
                                            p_fldnam    TYPE fieldname
                                            p_tabnam    TYPE tabname
                                            p_justif    TYPE char1
                                            p_seltext   TYPE dd03p-scrtext_l
                                            p_out       TYPE char1
                                            p_tech      TYPE char1
                                            p_qfield    TYPE slis_fieldname
                                            p_qtab      TYPE slis_tabname.
    * Local declaration for field catalog
      DATA: wa_lfl_fcat    TYPE  slis_fieldcat_alv.
      wa_lfl_fcat-row_pos        =  p_rowpos.     "Row
      wa_lfl_fcat-col_pos        =  p_colpos.     "Column
      wa_lfl_fcat-fieldname      =  p_fldnam.     "Field Name
      wa_lfl_fcat-tabname        =  p_tabnam.     "Internal Table Name
      wa_lfl_fcat-just           =  p_justif.     "Screen Justified
      wa_lfl_fcat-seltext_l      =  p_seltext.    "Field Text
      wa_lfl_fcat-no_out         =  p_out.        "No output
      wa_lfl_fcat-tech           =  p_tech.       "Technical field
      wa_lfl_fcat-qfieldname     =  p_qfield.     "Quantity unit
      wa_lfl_fcat-qtabname       =  p_qtab .      "Quantity table
      IF p_fldnam = 'NTGEW'.
        wa_lfl_fcat-do_sum  = 'X'.
      ENDIF.
      APPEND wa_lfl_fcat TO i_fieldcat.
      CLEAR wa_lfl_fcat.
    ENDFORM.                    " sub_fill_alv_field_catalog
    *&      Form  sub_populate_layout
    *       Populate ALV layout
    *       No Parameter
    FORM sub_populate_layout .
      CLEAR wa_layout.
      wa_layout-colwidth_optimize = 'X'." Optimization of Col width
    ENDFORM.                    " sub_populate_layout
    *&      Form  sub_populate_sort
    *       Populate ALV sort table
    *       No Parameter
    FORM sub_populate_sort .
    * Sort on material
      wa_sort-spos = '01' .
      wa_sort-fieldname = 'MATNR'.
      wa_sort-tabname = 'I_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.
    * Sort on plant
      wa_sort-spos = '02'.
      wa_sort-fieldname = 'WERKS'.
      wa_sort-tabname = 'I_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.
    ENDFORM.                    " sub_populate_sort
    *&      Form  sub_get_event
    *       Get ALV grid event and pass the form name to subtotal_text
    *       event
    *       No Parameter
    FORM sub_get_event .
      CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE
    'SUBTOTAL_TEXT'.
      DATA: l_s_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 4
        IMPORTING
          et_events       = i_event
        EXCEPTIONS
          list_type_wrong = 0
          OTHERS          = 0.
    * Subtotal
      READ TABLE i_event  INTO l_s_event
                        WITH KEY name = slis_ev_subtotal_text.
      IF sy-subrc = 0.
        MOVE c_formname_subtotal_text TO l_s_event-form.
        MODIFY i_event FROM l_s_event INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " sub_get_event
    *&      Form  sub_alv_report_display
    *       For ALV Report Display
    *       No Parameter
    FORM sub_alv_report_display .
      DATA: l_repid TYPE syrepid .
      l_repid = sy-repid .
    * This function module for displaying the ALV report
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = l_repid
          i_callback_top_of_page   = 'SUB_ALV_TOP_OF_PAGE'
          is_layout                = wa_layout
          it_fieldcat              = i_fieldcat
          it_sort = i_sort
          it_events                = i_event
          i_default                = 'X'
          i_save                   = 'A'
        TABLES
          t_outtab                 = i_ekpo
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
    *    MESSAGE i000 WITH 'Error in ALV report display'(055).
      ENDIF.
    ENDFORM.                    " sub_alv_report_display
    *       FORM sub_alv_top_of_page
    *       Call ALV top of page
    *       No parameter
    FORM sub_alv_top_of_page.                                   "#EC CALLED
    * To write header for the ALV
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = i_alv_top_of_page.
    ENDFORM.                    "alv_top_of_page
    *&      Form  subtotal_text
    *       Build subtotal text
    *       P_total  Total
    *       p_subtot_text Subtotal text info
    FORM subtotal_text CHANGING
                   p_total TYPE any
                   p_subtot_text TYPE slis_subtot_text.
    * Material level sub total
      IF p_subtot_text-criteria = 'MATNR'.
        p_subtot_text-display_text_for_subtotal
        = 'Material level total'(009).
      ENDIF.
    * Plant level sub total
      IF p_subtot_text-criteria = 'WERKS'.
        p_subtot_text-display_text_for_subtotal = 'Plant level total'(010).
      ENDIF.
    ENDFORM.                    "subtotal_text
    Edited by: Joyjit Ghosh on Aug 21, 2008 5:25 PM

  • Alv-field text-80 characters needed.

    Hi experts,
    in my alv report, field text is coming like below.
    Emp (excl. apprentices & temp. emp on si----upto this only it is coming.
    i need like this.
    Emp (excl. apprentices & temp. emp on site) - Beginning of year   
    how to get like this  -
    i need the complete text....
    i am writing like this
    gs_fieldcat-fieldname = 'E_BEG_YEAR'
      gs_fieldcat-tabname   = 'GT_FINAL_HCT'.
      gs_fieldcat-outputlen = '70'.
      gs_fieldcat-seltext_l = text-006.
      gs_fieldcat-do_sum    = 'X'.
      APPEND gs_fieldcat TO gt_fieldcat.
      CLEAR gs_fieldcat.
    can u give any modification for this.suggest me........................................

    Hi,
    First check the internal table i.e. the field that is holding the value of text. Check whether its length is sufficient or not.
    Second declare the layout for e.g.
    w_layout TYPE slis_layout_alv.
    and do.
    w_layout -colwidth_optimize = 'X'.
    and pass the layout to the alv function module .
    I hope this will help you.
    Help children of U.N World Food Program by rewarding them and encourage others to answer your queries

Maybe you are looking for

  • White Macbook (Mid 2006) Trackpad problem

    I have a white Macbook from Mid 2006 and it has been functioning fine all these years. However just yesterday, it developed a trackpad problem. I am still able to move the cursor but nothing happens when I click the trackpad button. I then bought an

  • SQL Developer Data Modeler: Logical model, unable to create arc

    I have a logical model in SQL Developer Data Modeler. Entity A has two 'incoming' foreign key relations to entities B and C. Both releations have the same optionality and cardinality. I want to place both relations in an arc. I see the buttons in my

  • View in external browser keeps opening new tabs

    Recently, in a failed effort to address the new version's inability to close successfully, I reset Firefox. I seem to have lost another valuable setting, and I can't remember how to recreate it. I use a peculiar, old html editor. When I ask it to "Vi

  • Assign/Map X509 certificate to the SAP User

    Hello Everybody, I am accessing SAP R/3 Function module from the outside(JAVA Application) using JCO connections. I got sucess doing this using Basic authentication. I have passed fix username and password to connect to the SAP R/3 from my JAVA progr

  • How to authorize music under a dead AOL account

    Having a problem. Just bought a new Mac and copied all my iTunes music to the new one, including ones I had purchased over the years since the iTunes store got started. Problem is, I used to buy music under an AOL account, which I have since cancelle