2007 Nov 21 8:13 AM
2007 Nov 21 8:20 AM
If you'll use the ALV you have to add TYPE-POOLS : SLIS. command at the beginning of your code.
Consider these :
slis_t_fieldcat_alv is containing "_t_"
It means that it is an internal table and slis_fieldcat_alv is header line of that.
Here is a practical example for alv grid :
Just think that you have an internal table named 'ITAB' to show.
Step1 : First add these lines to your code :
TYPE-POOLS : SLIS.
DATA ALV_PROG_NAME LIKE SY-REPID.
ALV_PROG_NAME = SY-REPID.
DATA : ALV_ITAB_NAME(30),
L_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
ALV_ITAB_NAME = 'ITAB'. "!!Write here the name of your internal table
Step 2 : Add these two function :
The first function is filling the fieldcat L_FIELDCAT that you described, second is showing it on the screen.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = ALV_PROG_NAME
I_INTERNAL_TABNAME = ALV_ITAB_NAME
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = ALV_PROG_NAME
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = L_FIELDCAT
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.
2007 Nov 21 8:34 AM
Hi Jamnun,
SLIS is a type pool where all the pre defined structures and tables are present. These structures contain various options like top of page,hotspot,colour,header,title etc to mention a few.
standard type pools: SLIS .
Sap standard tables types taken from the type pools are: SLIS_LAYOUT_ALV ,
SLIS_T_FIELDCAT_ALV,
SLIS_T_LISTHEADER,
SLIS_T_EVENT,
SLIS_SELFIELD.
A field catalog is prepared using the internal table (I_FIELDCAT) of type SLIS_T_FIELDCAT_ALV.
A field catalog need not be 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 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 output
3. 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 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 output 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 the 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 set: 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-FIELDNAME 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 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 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: SPACE, 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 output 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 containing 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 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 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 field) 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 some 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 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 fields. 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, '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 FIELDCAT-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' = 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 certain field with chosen colors.
Value set: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off ,'1'=on).
'X' = column is colored with the default column highlight color.
'Cxyz' = column is colored with a coded color:
- C: Color (coding must begin with C)
- X: color number
- Y: bold
- Z: inverse
Hotspot (column as hotspot): This parameter is used to make certain field appear as hotspot i.e. a hand is displayed if the cursor is positioned on the field value. Single click on such fields cause the PICK OR F2 events to happen.
Value set: SPACE, 'X'.
'X' = column cells are output as hotspots.
Fix_column (fix column): This parameter is used to fix certain columns in the output. All columns to be fixed must have this flag, starting from the left. If a column without this flag is output, only the columns to the left of this column are fixed. The user can change the column fixing interactively.
Value set: SPACE, 'X'.
'X' = column fixed (does not scroll horizontally).
Do_sum (sum over column): the user can also call this function interactively.
Value set: SPACE, 'X'.
'X' = a sum is calculated over this internal output table field.
No_sum (sums forbidden): No sum can be calculated over this field, although the data type of the field would allow summing.
Value set: SPACE, 'X'.
Icon: The parameter displays certain column contents as icons. The internal output table column contents must be valid icon strings.
Value set: SPACE, 'X'.
'X' = column contents to be output as an icon.
Symbol: The internal output table column must be a valid symbol character.
Value set: SPACE, 'X'
'X' = column contents are to be output as a symbol.
Just (justification): This parameter is used for alignment of the contents of the output table. This is only relevant for CHAR or NUMC fields in the output internal table. The justification of the column header always follows the justification of the columns. Independent justification of the column header is not possible.
Value set: SPACE, 'R', 'L', and C.
' ' = Default justification for this data type
'R' = right-justified output
'L' = left-justified output
'C' = centered output.
Lzero (leading zeros): By default ALV outputs NUMC fields right-justified without leading zeros. Using this parameter only the NUMC fields can be displayed with leading zeroes.
Value set: SPACE, 'X'.
'X' = output with leading zeros.
No_sign (no +/- sign): This parameter is used to suppress the signs of the output fields. It is only relevant for the value fields.
Value set: SPACE, 'X'.
'X' = value output without +/ sign.
No_zero (suppress zeros): Only relevant for value fields.
Value set: SPACE, 'X'.
'X' = suppress zeros.
Edit_mask (field formatting): To apply the report output formatting options same as in the WRITE statement in report writing.
Value set: SPACE, template.
2. Slis_ev_reprep_sel_modify TYPE slis_formname VALUE 'REPREP_SEL_MODIFY'.
RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to be put in the global item output table (T_OUTTAB_SLAVE). The Callback is only called if ALV has no items for a header that is to be expanded.
RFLG_ALL is passed with 'X' if the user shows all items. The application must ensure that entries are not repeated in the item table.
RS_SELFIELD is initial in this case.
3. Slis_ev_caller_exit_at_start TYPE slis_formname VALUE 'CALLER_EXIT'.
Is called at the beginning of the function module to make special settings. It is not usually used.
4. Slis_ev_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
As this is a frequently-used Callback event, the form routine can also be passed directly in the interface by passing the user command in the IMPORTING parameter I_CALLBACK_USER_COMMAND.
5. Slis_ev_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
Equivalent to the list processing TOP-OF-PAGE event.
6. Slis_ev_top_of_coverpage TYPE slis_formname VALUE 'TOP_OF_COVERPAGE'.
The selection information and list status are output together (if they exist) on a separate page by default
7. Slis_ev_end_of_coverpage TYPE slis_formname VALUE 'END_OF_COVERPAGE'.
Analogously to TOP_OF_COVERPAGE the user can add other information
to the information output by ALV (selection information, list status) at this event.
8. Slis_ev_foreign_top_of_page TYPE slis_formname VALUE FOREIGN_TOP_OF_PAGE'.
The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. This is still the case if the caller, e.g. by a user action, processes a branch list which was not formatted by ALV (e.g. a popup with additional information about the list record selected and displayed by ALV).
In this case, top-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event top-of-page still occurs in ALV. When ALV notices a top-of-page which was not caused by an ALV output, the form routine in FOREIGN_TOP_OF_PAGE is called.
9. Slis_ev_foreign_end_of_page TYPE slis_formname VALUE 'FOREIGN_END_OF_PAGE'.
The event end-of-page is always processed in ALV and only passed to the caller via callback. This is still the case, e.g. when the caller processes a details list which was not formatted by ALV (e.g. a popup with further information about selected list records which were displayed by ALV).
In this case, end-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event end-of-page still occurs in ALV. When ALV notices an end-of-page that was not caused by an ALV output, the form routine in FOREIGN_END_OF_PAGE is called.
10. Slis_ev_pf_status_set TYPE slis_formname VALUE 'PF_STATUS_SET'.
If a user list status is to be set, it must be done in the form routine assigned to this event. The ALV function codes, which must not be active, are in the Parameter RT_EXTAB. This table must be passed with the SET PF-STATUS command (with inactive user function codes as well, if necessary).
The STANDARD status of the function group SALV should be used as a template for a user-specific status. As this is a frequently used Callback event, its form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_PF_STATUS_SET.
11. Slis_ev_list_modify TYPE slis_formname VALUE 'LIST_MODIFY'.
LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME
R_INDEX LIKE SY-TABIX
R_INDEX_ITEM LIKE SY-TABIX
R_INDEX_SUM LIKE SY-TABIX.
12. Slis_ev_top_of_list TYPE slis_formname VALUE 'TOP_OF_LIST'.
Information output at the start of the list
13. Slis_ev_end_of_page TYPE slis_formname VALUE 'END_OF_PAGE'.
Information output at the end of a page. This is only called for printing.
14. Slis_ev_end_of_list TYPE slis_formname VALUE 'END_OF_LIST'.
Information output at the end of the list
15. Slis_ev_after_line_output TYPE slis_formname VALUE 'AFTER_LINE_OUTPUT'.
Output information after each output line. Should only be used in justified cases because it costs a lot of performance.
16. Slis_ev_before_line_output TYPE slis_formname VALUE 'BEFORE_LINE_OUTPUT'.
Output information before each output line. Should only be used in justified cases because it costs a lot of performance.
17. Slis_ev_subtotal_text TYPE slis_formname VALUE 'SUBTOTAL_TEXT'.
This event table (I_EVENTS) is now checked with the desired constants. If the desired constant is found, then the corresponding field for the FORM NAME is populated with the name of the routine containing the corresponding event.
REWARD POINTS, IF USEFUL.
Regards,
Nitin.
2007 Nov 21 8:54 AM
Hi Jamnun,
1) <u><b>Field catalog : </b></u> In the case of simple list's remember we had to use list headers etc for displaying the headings right. But in ALV it is much more simpler , they provide some function modules and parameters through which we can handle things like the formatting of fields , its label , field length , whether it should be a combo box etc. For these things we use the field catalog.
2) <u><b>Type pools :</b></u> as you might know in the transaction se11 we create it and so it will global to all programs too. Type pool as it's name indicates its a pool or collection of different structures by which i mean declaration of one or more structures can be done at one place and all these structures can be reused on different programs by just using the statement type-pool 'type pool name'.
So 'slis' is a standard type-pool used for alv.Most of the structures needed for alv are declared in this type-pool.
Hope u understood.
Regards,
Simy Abraham.
Message was edited by:
Simi Abraham