ALV Data Summary, double-click to pop up detailed data

Source: Internet
Author: User

* & operator *
* & function: reuse_alv_fieldcatalog_merge * & ALV summation
* & and function: use reuse_alv_grid_display together * & classic example
* & as a method to set fieldcatlog of ALV.
* & similar to dxdbgrid in Delphi. Calculate the sum of classes,
* & sum the total number of classes.
* & test the classification of a column in ALV Program .
* & lt; br> data: Begin of it1 occurs 5,
matnr like Mara-matnr,
psmng like afpo-psmng,
end of it1.

Type-pools: slis.
Data: l_events type slis_t_event,
Gt_list_top_of_page type slis_t_listheader,
Gs_layout type slis_layout_alv,
Fieldcat type slis_t_fieldcat_alv with header line,
Eventcat type slis_t_event with header line,
It_sort type slis_t_sortinfo_alv with header line,
PRG like sy-repid.

Data: l_variant type table of disvariant with header line,

Start-of-selection.
Clear it1.
It1-matnr = 'A '.
It1-psmng = 10.
Append it1.
Clear it1.

It1-matnr = 'A '.
It1-psmng = 20.
Append it1.
Clear it1.

It1-matnr = 'bb '.
It1-psmng = 30.
Append it1.
Clear it1.

It1-matnr = 'bb '.
It1-psmng = 40.
Append it1.
Clear it1.

It1-matnr = 'bb '.
It1-psmng = 50.
Append it1.
Clear it1.

It1-matnr = 'cc '.
It1-psmng = 80.
Append it1.

end-of-selection.
perform prepare_list_val.
perform display_val.
* & lt; br> * & form prepare_list_val
* & lt; br> * Text
* required *
form prepare_list_val.
PRG = sy-repid.
l_variant-report = sy-repid.
perform eventtab_build changing l_events.
perform comment_build changing gt_list_top_of_page.
perform set_layout.
endform. "prepare_list_val
* & Deployment *
* & form eventtab_build
* & Deployment *
* Text
* deployment *
form eventtab_build changing p_events type slis_t_event.

Endform. "eventtab_build
*---------------------------------------------------------------------*
* Form comment_build *
*---------------------------------------------------------------------*
* --> Gt_top_of_page *
*---------------------------------------------------------------------*
Form comment_build changing gt_top_of_page type slis_t_listheader.

Endform. "comment_build
*&---------------------------------------------------------------------*
* & Form set_layout
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
Form set_layout.
Gs_layout-zebra = 'x '.
Gs_layout-f2code = '& ETA '.
Gs_layout-detail_popup = 'x '.
Gs_layout-get_selinfos = 'x '.
Endform. "set_layout
*&---------------------------------------------------------------------*
* & Form display_val
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
Form display_val.
Perform get_fieldcat.
Perform get_eventcat.
Perform get_it_sort.
Perform start_list_val.
Endform. "display_val
*&---------------------------------------------------------------------*
* & Form get_fieldcat
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
Form get_fieldcat.

Call function 'reuse _ alv_fieldcatalog_merge'
Exporting
I _program_name = PRG
I _internal_tabname = 'it1'
I _inclname = PRG
Changing
Ct_fieldcat = fieldcat []
Exceptions
Inconsistent_interface = 1
Program_error = 2
Others = 3.
If sy-subrc <> 0.
Write: 'sy-subrc: ', Sy-subrc, 'reuse _ alv_fieldcatalog_merge '.
Endif.

Loop at fieldcat.
Case fieldcat-fieldname.
When 'matnr '.
Fieldcat-tabname = 'it1 '.
Fieldcat-Key = 'x'. "key column
Fieldcat-col_pos = 1. "position on screen
Fieldcat-hotspot = ''." Hotspot Column
Fieldcat-seltext_s = 'name '.
Fieldcat-ddictxt ='s '.
Fieldcat-outputlen = 18.
When 'psmng '.
Fieldcat-tabname = 'it1 '.
Fieldcat-Key = ''." key column
Fieldcat-col_pos = 2. "position on screen
Fieldcat-hotspot = ''." Hotspot Column
Fieldcat-seltext_s = 'money '.
Fieldcat-ddictxt ='s '.
Fieldcat-outputlen = 15.
Fieldcat-no_zero = 'x '.
Fieldcat-do_sum = 'x'. "sum upon display
Endcase.
Modify fieldcat.
Endloop.
Endform. "get_fieldcat
*&---------------------------------------------------------------------*
* & Form get_eventcat
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
Form get_eventcat.

Endform. "get_eventcat
*&---------------------------------------------------------------------*
* & Form get_it_sort
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
Form get_it_sort.

Clear it_sort.
It_sort-fieldname = 'matnr '.
It_sort-spos = 1.
It_sort-up = 'x '.
It_sort-subtot = 'x '.
Append it_sort.

* Clear it_sort.
* IT_SORT-FIELDNAME = 'aufnr '.
* IT_SORT-SPOS = 2.
* IT_SORT-UP = 'x '.
* IT_SORT-SUBTOT = ''.
* Append it_sort.

Endform. "get_it_sort
*&---------------------------------------------------------------------*
* & Form start_list_val
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
Form start_list_val.
Call function 'reuse _ alv_grid_display'
Exporting
I _callback_program = PRG
Is_layout = gs_layout
Is_variant = l_variant
It_fieldcat = fieldcat []
It_sort = it_sort []
I _save = 'A'
It_events = eventcat []
Tables
T_outtab = it1
Exceptions
Program_error = 1
Others = 2.

Endform. "start_list_val

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.