1、ALV文挡ALV (ABAP LIST VIEWER)Sap provides a set of ALV (ABAP LIST VIEWER) function modules, which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report
2、 contains columns extending more than 255 characters in length. In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting
3、and arranging the columns from a report output. The report output can contain upto 90 columns in the display with the wide array of display options.The commonly used ALV functions used for this purpose are;1. REUSE_ALV_VARIANT_DEFAULT_GET2. REUSE_ALV_VARIANT_F43. REUSE_ALV_VARIANT_EXISTENCE4. REUSE_
4、ALV_EVENTS_GET5. REUSE_ALV_COMMENTARY_WRITE6. REUSE_ALV_FIELDCATALOG_MERGE7. REUSE_ALV_LIST_DISPLAY8. REUSE_ALV_GRID_DISPLAY9. REUSE_ALV_POPUP_TO_SELECTThe different steps used for getting the above function modules into use are :Step 1 DATA DECLARATIONSap standard type pools: SLIS , KKBLO .Sap stan
5、dard tables types taken from the type pools are: SLIS_LAYOUT_ALV , SLIS_T_FIELDCAT_ALV,SLIS_T_LISTHEADER,SLIS_T_EVENT,SLIS_SELFIELD.Internal tables to used in the program declared based on the above table typesDATA: I_LAYOUT TYPE SLIS_LAYOUT_ALV, I_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV, I_HEADING TYPE S
6、LIS_T_LISTHEADER, I_EVENTS TYPE SLIS_T_EVENT.TYPES: KKBLO_SELFIELD TYPE SLIS_SELFIELD.Step 2 (Optional) SELECTING THE VARIANTS FOR INITIAL LIST DISPLAY (DEFAULT VARIANT)The variants in the list display can be both user-specific and general. The user can programmatically set the initial (default) var
7、iant for list display. The default variant can be found using the function module REUSE_ALV_VARIANT_DEFAULT_GET.Sample code: CALL FUNCTION REUSE_ALV_VARIANT_DEFAULT_GET EXPORTING i_save = variant save condition ( A=all, U = user-specific ) CHANGING cs_variant = internal table containing the program
8、name (and the default variant-optional ) EXCEPTIONS not_found = 2.The user can also choose from the list of existing variants using the function module REUSE_ALV_VARIANT_F4.Step 3 DEFININING OUTPUT CHARACTERISTICS: PREPARING DISPLAY FIELDS CATALOGA field catalog is prepared using the internal table
9、(I_FIELDCAT) of type SLIS_T_FIELDCAT_ALV. Field catalog containing descriptions of the list output fields (usually a subset of the internal output table fields).A field catalog is required for every ALV list output to add desired functionality (i.e. Key, Hotspot, Specific headings, Justify, Col. pos
10、ition etc) to certain fields of the output. If not mentioned specifically, then the defaults are taken. The possible values and defaults are listed below.The field catalog for the output table is built-up in the callers coding. The build-up can be completely or partially automated by calling the REU
11、SE_ALV_FIELDCATALOG_MERGE module.The minimal field catalog is documented below. This can be done in a routine using a local variable. The user can use the other optional parameters to assign output attributes to different fields in the output, which differ from the default.A field catalog need not b
12、e built-up and passed explicitly only under the following conditions:1. The internal table to be output has the same structure as a Data Dictionary structure which is referred to in the internal table declaration using LIKE or INCLUDE STRUCTURE. In this case the attributes of the different fields is
13、 taken directly from the table and the attributes (key fields, length, texts etc) need to state explicitly.2. all fields in this structure are to be output3. The structure name is passed to ALV in the parameter I_STRUCTURE_NAME of the function module REUSE_ALV_LIST_DISPLAY.All the values entered in
14、the catalog is specific to the particular field whose name is entered in the fieldname FIELDNAME of the fieldcat structure. The name of the table is also entered in the corr. Fieldname TABNAME of the structure.The different possible attributes are: Row_pos (row position): Only relevant if the list o
15、utput is to be multi-line (two or three lines) by default. So, this attribute can be used maintain certain level of alignment in the output. Value set: 0, 1 3 Col_pos (column position): This parameter is relevant when the fields in the output are to be different from the sequence of the fields in th
16、e internal table used for display. The parameter specifies the relative column position of the field in the list output. The column order can be changed interactively by the user. If this parameter is initial for all field catalog entries, columns appear in the internal table field sequence.Value se
17、t: 0, 1 60 Fieldname (field name): This is the name of the internal table field for which the parameters are passed in the catalog.Value set: internal output table field name (required parameter) Tabname (internal output table): Name of the internal output table that contains the field FIELDCAT-FIEL
18、DNAME above. Value set: SPACE, internal output table name. Ref_fieldname (reference field name): Name of the Data Dictionary field referred to. This parameter is only used when the internal output table field described by the current field catalog entry has a reference to the Data Dictionary (not a
19、program field), and the field name in the internal output table is different from the name of the field in the Data Dictionary. If the field names are identical, naming the Data Dictionary structure or table in the FIELDCAT-REF_TABNAME parameter is sufficient. Value set: SPACE, Data Dictionary field
20、 name. Ref_tabname (reference table/structure field name): Structure or table name of the referred Data Dictionary field. This parameter is only used when the internal output table field described by the current field catalog entry has a Data Dictionary reference (not a program field).Value set: SPA
21、CE, name of a Data Dictionary structure or table Link to currency unit Cfieldname (currency unit field name): This is used for currency fields that have a reference to any unit field. This is only relevant for amount columns with associated unit. This parameter contains the Name of the internal outp
22、ut table field containing the currency unit associated with the amount field FIELDCAT-FIELDNAME. The field in FIELDCAT-CFIELDNAME must have its own field catalog entry.Value set: SPACE, output table field name Ctabname (internal currency unit field output table): Name of the internal output table co
23、ntaining the FIELDCAT-CFIELDNAME field.Value set: SPACE, output table field name. Link to measurement unit Qfieldname (measurement unit field name): Only relevant for quantity columns with unit link. Name of the internal output table field containing the measurement unit associated with the quantity
24、 field FIELDCAT-FIELDNAME. The field in FIELDCAT-QFIELDNAME must have its own field catalog entry. Value set: SPACE, output table field name. Qtabname (internal measurement unit field output table): Name of the internal output table containing the FIELDCAT-QFIELDNAME field. Value set: SPACE, output
25、table field name. Outputlen (column width): This parameter is used if the desired output length for a field is desired to be different from the internal output table field. For fields with a Data Dictionary link this parameter can be left initial. For fields without a Data Dictionary link (program f
26、ield) the parameter must be given the value of the desired field list output length (column width).Initial = column width is the output length of the referred Data Dictionary field (domain).N = column width is n characters. Value set: 0 (initial), n. Key (key column): By default, the system makes so
27、me fields in the output as key fields, provided the fields are key fields in their referencing table. Using this parameter, fields other than key fields of the referencing table can be made key field. This parameter is most important if the output needs to contain some field which are not scrollable
28、 or cannot be hidden. If the internal output table contains fields that are key fields from different tables, then all those fields in the report output becomes unscrollable and cannot be hidden. So, the fields in the output internal table should not be referenced from tables in which they are key f
29、ields. Instead, they should be referenced to the tables in which they are not key fields, incase they are not desired as key field in the output.X = key field (key field output in color) and Key fields can not be interactively hidden. Parameter FIELDCAT-NO_OUT must be left initial. Value set: SPACE,
30、 X. Key_sel (hideable key column): This parameter is only relevant for the fields which are made key fields using FIELDCAT-KEY = X. Using this parameter the Key field can be hidden interactively.The key column sequence cannot be changed interactively by the user. The output is controlled by the FIEL
31、DCAT-NO_OUT parameter analogously to non-key fields.Value set: SPACE, X. No_out (field in field list): This parameter is used to remove certain fields from the output during initial display. The user can however interactively choose the field for output from the field list in the display variant. X
32、= field is not displayed in the current list. Value set: SPACE, X. Tech (technical field): This parameter is used to make certain field display only in the field catalog. The fields with this parameter set cannot be output in the list nor can they be displayed interactively from the catalog. X = technical field. Value set: SPACE, X. Emphasize (highlight columns in color): As name suggests, this field parameter is used to highlight certai
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1