`

Customize subtotal text and grandtotal text in ALV

    博客分类:
  • ABAP
阅读更多
REPORT  zalv_test.

TABLES: ekko.

TYPE-POOLS:slis.

TYPES: BEGIN OF x_data,
  ebeln TYPE char30,
  ebelp TYPE ebelp,
  matnr TYPE matnr,
  matnr1 TYPE matnr,
  ntgew TYPE entge,[img][/img]
END OF x_data.

TYPES: BEGIN OF x_data_tot,
  const(15),
  ebeln TYPE char30,
  ebelp TYPE ebelp,
  matnr TYPE matnr,
  matnr1 TYPE matnr,
  ntgew TYPE entge,
END OF x_data_tot.

DATA: i_ekpo TYPE STANDARD TABLE OF x_data INITIAL SIZE 0,
      i_ekpo_tot TYPE STANDARD TABLE OF x_data_tot INITIAL SIZE 0,
      i_fieldcat TYPE slis_t_fieldcat_alv,
      i_alv_top_of_page TYPE slis_t_listheader,
      i_events TYPE slis_t_event,
      i_sort TYPE slis_t_sortinfo_alv,
      i_event TYPE slis_t_event.

DATA:wa_ekko TYPE x_data,
      wa_ekko_tot TYPE x_data_tot,
      wa_layout TYPE slis_layout_alv,
      wa_events TYPE slis_alv_event,
      wa_sort TYPE slis_sortinfo_alv.

CONSTANTS:c_header TYPE char1 VALUE 'H',
          c_item TYPE char1 VALUE 'S'.

START-OF-SELECTION.
  SELECT ebeln ebelp matnr matnr ntgew FROM ekpo INTO TABLE i_ekpo UP TO 10 ROWS.
  LOOP AT i_ekpo INTO wa_ekko.
    MOVE-CORRESPONDING wa_ekko TO wa_ekko_tot.
    wa_ekko_tot-ntgew = sy-tabix.
    wa_ekko_tot-const = 'Grand Total'.
    APPEND wa_ekko_tot TO i_ekpo_tot.
  ENDLOOP.
  IF sy-subrc EQ 0.
    SORT i_ekpo_tot BY ebeln ebelp matnr.
  ENDIF.

  PERFORM sub_field_catalog.
  PERFORM sub_populate_layout.
  PERFORM sub_populate_sort.
  PERFORM sub_get_event.

END-OF-SELECTION.
  PERFORM sub_alv_report_display.

*&---------------------------------------------------------------------*
*&      Form  sub_field_catalog
*&---------------------------------------------------------------------*
FORM sub_field_catalog.
  PERFORM sub_fill_alv_field_catalog USING:
        '01' '01' 'CONST' 'I_EKPO_TOT' 'L'
        ' '(005) 'X' 'X' ' ' ' ',
        '01' '01' 'EBELN' 'I_EKPO_TOT' 'L'
        'Doc No'(003) ' ' ' ' ' ' ' ',
        '01' '02' 'EBELP' 'I_EKPO_TOT' 'L'
        'Item No'(004) ' ' ' ' ' ' ' ',
        '01' '03' 'MATNR' 'I_EKPO_TOT' 'L'
        'Material No'(005) 'X' 'X' ' ' ' ',
        '01' '03' 'MATNR1' 'I_EKPO_TOT' 'L'
        'Material No'(005) ' ' ' ' ' ' ' ',
        '01' '04' 'NTGEW' 'I_EKPO_TOT' 'R'
        'Net Weight'(007) ' ' ' ' ' ' ' '.
ENDFORM.                    "sub_field_catalog

*&---------------------------------------------------------------------*
*&      Form  sub_fill_alv_field_catalog
*&---------------------------------------------------------------------*
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.
  DATA: wa_lfl_fcat TYPE slis_fieldcat_alv.

  wa_lfl_fcat-row_pos = p_rowpos.
  wa_lfl_fcat-col_pos = p_colpos.
  wa_lfl_fcat-fieldname = p_fldnam.
  wa_lfl_fcat-tabname = p_tabnam.
  wa_lfl_fcat-just  = p_justif.
  wa_lfl_fcat-seltext_l = p_seltext.
  wa_lfl_fcat-no_out = p_out.
  wa_lfl_fcat-tech = p_tech.
  wa_lfl_fcat-qfieldname  = p_qfield.
  wa_lfl_fcat-qtabname  = p_qtab.

  IF p_fldnam EQ '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
*&---------------------------------------------------------------------*
FORM sub_populate_layout.
  CLEAR wa_layout.
  wa_layout-colwidth_optimize = 'X'.
  wa_layout-no_totalline = 'X'.
ENDFORM.                    "sub_populate_layout

*&---------------------------------------------------------------------*
*&      Form  sub_populate_sort
*&---------------------------------------------------------------------*
FORM sub_populate_sort.
  wa_sort-spos = '01'.
  wa_sort-fieldname = 'CONST'.
  wa_sort-tabname = 'I_EKPO_TOT'.
  wa_sort-up  = 'X'.
  wa_sort-subtot = 'X'.
  APPEND wa_sort TO i_sort.
  CLEAR wa_sort.

  wa_sort-spos = '02'.
  wa_sort-fieldname = 'MATNR'.
  wa_sort-tabname = 'I_EKPO_TOT'.
  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
*&---------------------------------------------------------------------*
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.

  READ TABLE i_event INTO l_s_event WITH KEY name = slis_ev_subtotal_text.
  IF sy-subrc EQ 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
*&---------------------------------------------------------------------*
FORM sub_alv_report_display.
  DATA:l_repid TYPE syrepid.

  l_repid = sy-repid.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = l_repid
      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_tot
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.
ENDFORM.                    "sub_alv_report_display

*&---------------------------------------------------------------------*
*&      Form  subtotal_text
*&---------------------------------------------------------------------*
*      -->P_TOTAL        text
*      -->P_SUBTOT_TEXT  text
*----------------------------------------------------------------------*
FORM subtotal_text CHANGING
          p_total TYPE any
          p_subtot_text TYPE slis_subtot_text.
  IF p_subtot_text-criteria = 'MATNR'.
    p_subtot_text-display_text_for_subtotal =
      'Material level total'.
  ENDIF.
ENDFORM.                    "subtotal_text
  • 大小: 15.3 KB
0
0
分享到:
评论

相关推荐

    Shell.Programming.in.Unix.Linux.and.OS.X.4th.Ed

    Following the methodology of the original text, the book focuses on the POSIX standard shell, and teaches you how to develop programs in this useful programming environment, taking full advantage of ...

    WordPress Complete_ set up, customize, and market your blog

    WordPress Complete_ set up, customize, and market your blog.pdf

    Graphics and GUIs with matlab 2, third edition

    3.4.3 Creating Supporting Text and Legends 3.4.4 Text Placement 3.4.5 Special Text Character Formats 3.4.6 Using Subplot to Create Multiple Axes 3.5 SPECIALIZED 2-D PLOTTING 3.5.1 Bar Graphs 3.5.2 ...

    Softgroup.Net.Advanced Panel v2.0.3191 [vs.net]

    Softgroup .Net Advanced Panel enhance the user interface of your applications with ability to customize background gradient effects, border and corners aspects, display image with text and many other ...

    Graphics and GUIs with matlab 3, third edition

    3.4.3 Creating Supporting Text and Legends 3.4.4 Text Placement 3.4.5 Special Text Character Formats 3.4.6 Using Subplot to Create Multiple Axes 3.5 SPECIALIZED 2-D PLOTTING 3.5.1 Bar Graphs 3.5.2 ...

    Adobe InDesign CS3 - Scripting Guide JavaScript (pag 145) (ENG)

    •Work with text and type in an InDesign document, including finding and changing text. •Create dialog boxes and other user-interface items. •Customize and add menus and create menu actions. •...

    Packt.MVVM.Survival.Guide.for.Enterprise.Architectures.in.Silverlight.And.WPF

    Eliminate unnecessary code by taking advantage of the MVVM pattern in Silverlight and WPF using this book and eBook - less code, fewer bugs Build an enterprise application using Silverlight and WPF,...

    Linux and Unix Shell Programming

    With more and more systems being run under UNIX and Linux, the ability to program and customize the shell quickly and reliably to get the best out of any individual system is becoming a more and more ...

    Excel.2013.Working.with.Data.Ranges.and.Tables

    In Lesson 1 you learn how to organize columns and rows of data into a range so that you can effectively sort, filter, subtotal, and outline the data. Then you learn how to protect the data from ...

    UE(官方下载)

    In this tutorial, we'll cover some of the basics of Unicode-encoded text and Unicode files, and how to view and manipulate it in UltraEdit. Search and delete lines found UEStudio and UltraEdit provide...

    Clean Architecture A Craftsman's Guide to Software Structure and Design

    In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the ...

    Deploy Customize Jar file in Oracle EBS R12

    Deploy Customize Jar file in Oracle EBS R12.pdf

    Pro WF Windows Workflow in .NET 3.5

    This book also includes detailed coverage of how to customize your workflows and access them in a variety of ways and situations so you can maximize the advantages of this technology. What you'll ...

    EmEditor中文版

    In the Marker List tab, you can change the marker colors, change the marker text, and delete unnecessary markers. The auto marker is a new feature to automatically select text that is the same as ...

    Customize UI in a LabVIEW application

    Customize UI in a LabVIEW application介绍了在LabVIEW中构建有效用户界面的提示和技巧。在LabVIEW中进行编码的一个主要好处是提供了内置的控制和指标库。由于LabVIEW在设计时充分考虑了工程师和科学家,因此该库...

    Customize Rules 使用 myrules

    Customize Rules 使用附件中的 myrules 中的内容覆盖 Customize 的内容然后保存

    Akka.in.Action.2016.9.pdf

    Akka in Action shows you how to build message-oriented systems with Akka. This comprehensive, hands-on tutorial introduces each concept with a working example. You’ll start with the big picture of ...

    Beginning Game Development with Python and Pygame

    Like music and movies, video games are rapidly becoming an integral part of our lives.... such as support for multiple platforms, and granting users the ability to extend and customize your games.

    Enviro - Sky and Weather.7z

    These will bring you sky to life and offer plenty options to customize. Clouds performance is optimized by using techs like temporal reprojection and LOD system. In addition there are also fast flat ...

Global site tag (gtag.js) - Google Analytics