ALV report summary)

Source: Internet
Author: User

Post transferred from

Http://www.cnblogs.com/VerySky/articles/2700894.html

 

There are two ways to create ALV: 1> using function module, 2> oops ABAP
The two creation methods have corresponding applicability and intersection. For details, refer:

You can see that you need to create ALV list/Hierachical list. function module can be used in fullscreen grid and is backward compatible.
When creating ALV grid or tree control, we must use the OO creation method. This method is also applicable before 6.4. However, when using oo alv wrapper to control, it applies to Versions later than 6.4.
There is still a big change between NW was and R3 4.6. The whole platform has extended many things, such as the large-scale use of web services and OO, and it is said that the implementation of SOA strategy is adopted,

I. fm

When Using FM to implement Alv, it is very important to correspond to fullscreen Alv, type-pool: slis, which defines many parameter types in FM.
1. ALV is a display method, which involves defining data selection conditions, data acquisition, data presentation, event processing, and other steps.
1> when defining selection conditions, you can use selection screen to define conditions. You can define a value (parameters) or a range (selection-options), which is convenient, if there are dynamic conditions in the program, you can consider using ranges, and a small trick is to use () to dynamically Execute SQL. A simple example is as follows.
Select * into itab from sflightwhere (wheretab) wheretab is a row-based inner table. each row of this table is a selection condition string.
This kind of dynamic statement should be avoided as much as possible, because it can determine the statement to be executed at runtime, and it can avoid syntax check during compilation.
Note: This usage can be seen in SAP standard programs, such as FM: sd_partner_read.
Select * from (object) into Table l_vbpa where vbeln = f_vbeln. It dynamic the selected data table.
2> data selection
This generally has the greatest impact on program performance, with focus on accessing database tables and operations on internal tables.
3> data presentation
Field catalog: it is an internal table that corresponds to the technical information or additional information of the display options in each column, such as the definition of hotspot. This column is not displayed.
Layout Structure: Layout for grid. You can define some grid configurations, such as the total options,
4> event handling
Double-click events, hot spot processing, top-of-page, end-of-list, and so on.
2. Related FM.
Reuse_alv_variant_default_get
Reuse_alv_variant_f4
Reuse_alv_variant_existence
Reuse_alv_events_get: internal table containing the event name and Event Processing Form name
Reuse_alv_commentary_write
Reuse_alv_fieldcatalog_merge: generate a field catalog Based on the transparent table, structure, and view in the ABAP dictionary.
Reuse_alv_list_display: displays the result in the form of list
Reuse_alv_grid_display: Display Results in Grid Format

Reuse_alv_popup_to_select
The line mark is the most frequently used.
3. Field catalog
1> it describes the fields in the output table and defines the output attributes of the fields.
For example:
Col_posThe column number of a field in the table,
FieldnameOutput field name. If this field is curr (currency field), Quan (Quantity Field) needs to specify the corresponding cuky and Unit fields. settings,CfieldnamectabnameAndQfieldnameqtabname

No_out
This column is hidden and not output, but you can change layout to display this column.
HotspotSet all cells in this column as hotspots and click to trigger the corresponding function.
Do_sumSum of this column
No_zeroOnly meaningful values are output, and null values are not output.
Edit_maskFormat fields like write.
JustR l adjust alignment Mode
Adjust the text of the output column header: The text can change as you adjust the width of the column. The text is defined in the corresponding data element. to customize the text, you can specify the following fields:
Seltext_l(Long field label)
Seltext_m(Medium field label)
Seltext_s(Short field label)
Reptext_ddic(Header) analogous to the data element main Header
Ddictxt(Specify text): You can specify with values 'l', 'M', and 's', directly specify long text, medium, short text, after this field is specified, it will be fixed and will not change with the user's Width Adjustment.
2> How to Build
A. Create an internal table of the slis_t_field_alv type manually. Set the row item type to slis_field_alv and add the corresponding attributes of each field to the internal table.
Clear x_fieldcat.
X_FIELDCAT-COL_POS = 12.
X_FIELDCAT-FIELDNAME = 'dmbtr '.
X_FIELDCAT-TABNAME = 'I _ tab '.
X_FIELDCAT-SELTEXT_M = 'local curr '.
X_FIELDCAT-OUTPUTLEN = 12.
X_FIELDCAT-INTTYPE = 'P '.
X_FIELDCAT-JUST = 'R '.
X_FIELDCAT-DO_SUM = 'x '.
Append x_fieldcat to I _fieldcat.
B. Semi-automatic
Call FM: reuse_field_catalog_merge to input the transparent table, view, and structure names in ddic, and output the table in field catalog.
Call function 'reuse _ alv_fieldcatalog_merge'
Exporting
* I _program_name =
* I _internal_tabname =
I _structure_name = c_alv_structure_name
* I _client_never_display = 'X'
* I _inclname =
* I _bypassing_buffer =
* I _buffer_active =
Changing
Ct_fieldcat = gt_fieldcat []
Exceptions
Inconsistent_interface = 1
Program_error = 2
Others = 3

To adjust attributes such as header and hotspot, You can loop through the table in field catalog and modify its corresponding attributes. For example:
Loop at gt_fieldcat assigning <l_fcat>.
Case <l_fcat>-fieldname.
When 'flname '.
"Modify attributes.
Endcase.
Endloop.

4. Field Layout
Note that the property get_selinfos is useful for the input is_sel_hide of reuse_alv_grid_display, but is no longer supported in was 7.0.
5. Events
The events triggered by ALV can be obtained by FM: reuse_alv_events_get. An internal table is output, the type is slis_t_event, And the row item is slis_alv_event. It contains two fields, one event name, the other is the form name for event processing.
Call function 'reuse _ alv_events_get'
Exporting
I _list_type = 0
Importing
Et_events = I _events.
Common events include:
List header processing:Slis_ev_top_of_page type slis_formname value 'top _ of_page '.
Double-click and click:Slis_ev_user_command type slis_formname value 'user _ command'
Subtotal text: slis_ev_subtotal_text type slis_formnamevalue 'subtotal _ text '.


Reference https://www.sdn.sap.com/irj/scn/wiki? Path =/display/snippets/display % 252 bsubtotal % 252 btext % 252bin % 252 balv % 252 bgrid
Https://www.sdn.sap.com/irj/scn/thread? Threadid = 1033110 & tstart = 0
Note: This event can be triggered only when the field_catalog attribute no_out of the field corresponding to subtotal is changed to X.
6. General requirements during development:
Generally, the INPUT attribute of reuse_alv_grid_display is involved.
1> ALV variant save
Is_default
Is_save
Is_variant
2> subtotal, sorting
The it_sort attribute defines which fields are sorted and can specify other fields that can be summarized by this field subtotal.
-SPOs: Sort Sequence
-Fieldname: internal output table field name
-Tabname: only relevant for hierarchical-sequential lists. Name of the internal output table.
-Up: 'X' = sort in ascending order
-Down: 'X' = sort in descending order
-Subtot: 'X' = subtotal at group value change
-Group: '*' = new page at group value change, 'ul '= underline at group value change

3> ALV head and footer
A. You can use the top_of_page event trigger method:
A. Call function 'reuse _ alv_commentary_write 'outputs an internal table: slis_t_listheader. The output format is fixed, which is not conducive to alignment and setting the I _logo output image.
B. grid mode: easy to control layout.
Data: lr_content type ref to cl_salv_form_element.
Data: lr_grid type ref to cl_salv_form_layout_grid, "Top grid definition

Lr_flow type ref to cl_salv_form_layout_flow, "flow for top Grid

L_text (500) Type C. "showed in top of list

* Create a grid
Create object lr_grid.
* Create a cell
Lr_flow = lr_grid-> create_flow (
Row = 1 "Row
Column = 1). "column

* Write a blank column
Write (20) ''." can be output directly.

Plr_flow = plr_grid-> create_flow (
Row = 1
Column = 2 ).

* Create text in Cell
Lr_flow-> create_text (text = pl_text). "customize the text in the cell.
Cl_salv_form_content => set (lr_content ).
B. Set the I _callback_html_top_of_page attribute to trigger
Form f_html_top_of_page using pr_document type ref to cl_dd_document.
HTML text, links, and images can be added.
Call method pr_document-> add_text (text = 'picture ').

Call method pr_document-> add_gap (width = 10 ).

Call method pr_document-> add_picture (picture_id = 'enjoysap _ logo ').

4> click a column to go to another tranaction. You need to set the column field to hotspot, and then process the function code in user_command :"& IC1"

The it_events attribute is used to input an slis_t_event type internal table. Set the corresponding processing form, such as handle_user_command.
Form handle_user_command using p_ucomm like sy-ucomm
Ps_selfield type slis_selfield.

Ii. Oops
1. creates an ALV Grid Control for the image. It is a component in the control framework. You can also use cl_salv_table, cl_salv_hierseq_table, and cl_salv_tree. and so on. the latter is created in the form of list or grid. It is recommended by SAP and is supported by Versions later than NW 2004.

The Grid Control on the full screen has a corresponding function module: reuse_alv_grid_display_lvc.
Oops provides more powerful functions, such as the maximum and minimum values. Currently, components in SAP have been rewritten in the OO mode, and compiling in the OO mode is the future development direction.

Related Classes:
Cl_gui_alv_grid: ALV grid control class, Alv list Viewer
Cl_gui_custom_container: container for custom controls in the screen area
Structure/table type in ddic
Lvc_t_fcat: Field catalog for list viewer control, table Type
Lvc_s_fcat: Field catalog fro ALV control, Structure
Lvc_t_lout: ALV control: Layout Structure

2. steps:
1>. Define a custom control area on screen
2> Generate a cl_gui_custom_container class instance and input the custom area name in the constructor parameters.
3> Generate a cl_gui_alv_grid instance and set the container reference generated above in the parameters of the constructor.
4> call the set_table_for_first_display method of the grid instance to set the internal table to be displayed. In addition, you can enter a global structure name, that is, the line type corresponding to the table in ALV to be displayed, or a table in field catalog.

Note that when the cl_gui_alv_grid instance is generated, the constructor parameter I _parent is required, but if you want to extend the functions of ALV, such as adding a button to the toolbar, when changing the cell attributes of ALV, such as color and style, In the event processor, the I _appl_events must be assigned X.

Some parameters of set_table_for_first_display:
Defines variant-related parameters: is_variant, is_save, I _default
Hide unnecessary functions: it_toolbar_excluding. The related function code is a constant starting with mc_fc.
Define the sorting table it_sort
Column header: colddictxt coltext reptext scrtext_l scrtext_m scrtext_s selddictxt

Refresh_table_display is used to refresh ALV in PbO without generating a new Alv.

3. The field catalog can be manually generated, or you can call FM lvc_fieldcatalog_merge to generate a field catalog table, and then modify attributes cyclically as needed.

If both the I _structure_name ''it _ fieldcatalog 'parameters are input, I _structure_name has a priority.

When you use the it_sort parameter of the set_table_for_first_display method, the same column values are vertically merged during sorting. If you want to cancel merging all columns, you can change no_merging in layout, to change the merge of a single column, you can change the no_merging of the corresponding field catalog.

 

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.