ALV StepByStep Tutorials

Embed Size (px)

Citation preview

  • 7/26/2019 ALV StepByStep Tutorials

    1/36

  • 7/26/2019 ALV StepByStep Tutorials

    2/36

  • 7/26/2019 ALV StepByStep Tutorials

    3/36

  • 7/26/2019 ALV StepByStep Tutorials

    4/36

  • 7/26/2019 ALV StepByStep Tutorials

    5/36

  • 7/26/2019 ALV StepByStep Tutorials

    6/36

  • 7/26/2019 ALV StepByStep Tutorials

    7/36

  • 7/26/2019 ALV StepByStep Tutorials

    8/36

  • 7/26/2019 ALV StepByStep Tutorials

    9/36

  • 7/26/2019 ALV StepByStep Tutorials

    10/36

  • 7/26/2019 ALV StepByStep Tutorials

    11/36

  • 7/26/2019 ALV StepByStep Tutorials

    12/36

  • 7/26/2019 ALV StepByStep Tutorials

    13/36

  • 7/26/2019 ALV StepByStep Tutorials

    14/36

    ALV DOCUMENTATION AND EXAMPLES1414 Rajago

    14 of 36

    Value set: SPACE, 'X'.If the calling program is a report with an ABAP/4 selection screen, setting thisparameter makes ALV read the selection screen again. If the selections are readsuccessfully, a pushbutton, via which the user can call a popup which lists the reportselections in a simple form, becomes active on the results list output by ALV.

    38.

    group_change_edit(1) TYPE c : Settings by user for new groupValue set: SPACE, 'X''X' = the user can enter a format option for each sort criterion in the sort/subtotalpopup, for the list format when this value changes (e.g. new page or underline).

    39.No_scrolling(1) TYPE c : Does not allow scrolling of the list to the right.Value set: SPACE, 'X'.

    40. Expand_all(1) TYPE c : Expand all positions

    Detailed screen

    40.

    Detail_popup(1) TYPE c : show detail in popup.Value set: SPACE, 'X'' ' = List record detail display in full-screen mode, with top-of-page.'X' = list record detail display in popup (without top-of-page).

    41. Detail_initial_lines(1) TYPE c : show also initial linesValue set: SPACE, 'X'' ' = Only fields whose contents are not initial are output in the detail view.'X' = initial field contents are also output in detail.

    41.detail_titlebar(30) type c : Titlebar for detail screenValue set: SPACE, string (max.30)

    ` ' = ' Detail: Display' is output as the title of the detail window.'String = the string passed is output as the title of the detail window.

    Display variants42. Header_text (20) TYPE c: Text for header button. Only relevant for hierarchical-sequential lists. You can toggle between display field and field list views viapushbuttons in the display variant definition popup for hierarchical-sequential lists.The views refer to the hierarchy level of the fields. This is technically a togglebetween the header table and item table fields.Value set: SPACE, CHAR (20)' ' = The header table field pushbutton text is 'Header' by default.CHAR (20) = header table field pushbutton text.

    43.item_text(20) TYPE c : Text for item button. Only relevant for hierarchical-

    sequential lists. You can toggle the view between the display fields and the field listvia pushbuttons in the display variant definition popup for hierarchical-sequentiallists. The views refer to the hierarchy level of the fields. This is technically a togglebetween the header table and item table fields.Value set: SPACE, CHAR (20)' ' = The pushbutton text for the item table fields is 'Item' by default.CHAR (20) = item table field pushbutton text.

    44.default_ item(1) TYPE c : Items as default. Only relevant for hierarchical-sequential lists.Value set: SPACE, 'X'

  • 7/26/2019 ALV StepByStep Tutorials

    15/36

    ALV DOCUMENTATION AND EXAMPLES1515 Rajago

    15 of 36

    ' ' = The header table fields are displayed by default in the display variant definitionpopup. The user can switch to the item table fields interactively.'X' = the item table fields are displayed by default in the display variant DefinitionPopup. The user can switch to the header table fields interactively.

    Colour45. Info_fieldname TYPE slis_fieldname: infofield for listoutput. A whole list recordcan be colored individually using a color code in a column of the internal output tablefor the record. Assign the name of the field containing the color code to thisparameter.Value set: SPACE, internal output table field nameThe internal output table field must be of type CHAR(3).The code must have the following syntax: 'Cxy':

    C = color (all codes must start with 'C')X = color number ('1'-'9')Y = bold ('0' = off, '1' = on)

    46. Coltab_fieldname TYPE slis_fieldname: Cells can be colored individually using acolor code which is contained in a column of the internal output table for the recordcontaining the cell. Assign the name of the field to this parameter.

    Others47. List_append(1) TYPE c : no call screen. It is only useful to output block-listswithout specifying the above modules if the number of list blocks exceeds, or mayexceed, the maximum number specified in the block module documentation. Theseoperations are not possible for user-defined block lists.

    Example code :

    I_LAYOUT-f2code = ws_fcode.I_LAYOUT-zebra = 'X'.I_LAYOUT-colwidth_optimize = 'X'.I_LAYOUT-no_keyfix = 'X'.I_LAYOUT-get_selinfos = 'X'.I_LAYOUT-no_hotspot = 'X'.I_LAYOUT-no_input = 'X'.I_LAYOUT-hotspot_fieldname = FIELDNAME.I_LAYOUT-no_input = X.I_LAYOUT-no_vline = `X.I_LAYOUT-no_colhead = .I_LAYOUT-lights_condense = ` `.I_LAYOUT-totals_text = ` `.

    I_LAYOUT-subtotals_text = ` `.I_LAYOUT-totals_only = ` `.I_LAYOUT-key_hotspot = X.I_LAYOUT-detail_popup = X.I_LAYOUT-group_change_edit = X.I_LAYOUT-GROUP_BUTTONS = X.

    Step 6

    This step is required to get the selection screen information in the report output.The prerequisite for this is to set the parameter LAYOUT-GET_SELINFOS of theIMPORTING structure.The parameters to be passed in the IS_SEL_HIDE table are:

  • 7/26/2019 ALV StepByStep Tutorials

    16/36

    ALV DOCUMENTATION AND EXAMPLES1616 Rajago

    16 of 36

    o mode: 'R' = only the entries passed in the internal table IS_SEL_HIDE-T_ENTRIES

    Are output in the pop up. Selection info, which the list tool read in theselection screen (when called by a report with a selection screen), isreplaced by the values passed.

    'S' = the selection info which the list tool read in the selection screen of thecalling report are modified by the entries in the table IS_SEL_HIDE-T_ENTRIES.

    o t_entries: Selection info table

    o t_entries-mode: 'A' = output the selection info for the current table record in the infopopup.

    'D' = do not output select option or SELNAME parameter selection infoin the popup.

    o t_entries-selname: (only used in t_entries-mode = 'D') : Name of the select option or

    parameter.

    The following table fields are only used in t_entries-mode = 'A'. They contain the selectioninformation to be added.

    t_entries-field: DDIC field name of the field for which selection information is to

    be output.

    t_entries-table: DDIC table names of t_entries-field.

    t_entries-stext: Field name in info popup.

    If t_entries-field and t_entries-table have been entered, this text is taken from

    DDIC.

    t_entries-valuf: Selection condition 'from' value (external format)

    t_entries-valut: Selection condition 'to' value (external format)

    t_entries-sign0: (I)nclusive (E)xclusive

    t_entries-option: All values of the select options Option field allowed.

    Step 6

    The Table IT_SORT is populated with the sort criteria for the different fields.The caller specifies the sorting and/or subtotaling of the basic list in the internal tableIT_SORT.

    This internal table has the following fields:

    o spos : Sort sequenceo fieldname : Internal output table field nameo tabname : Only relevant for hierarchical-sequential lists. Name of the internal output

    table.o up : 'X' = sort in ascending ordero down : 'X' = sort in descending ordero subtot : 'X' = subtotal at group value changeo group : '* ' = new page at group value change ,'UL' = underline at group value change

    Step 7

    The final step in the output of the report is the use of two ALV functions modules.1. REUSE_ALV_FIELDCATALOG_MERGE

  • 7/26/2019 ALV StepByStep Tutorials

    17/36

  • 7/26/2019 ALV StepByStep Tutorials

    18/36

    ALV DOCUMENTATION AND EXAMPLES1818 Rajago

    18 of 36

    *" VALUE(I_CALLBACK_USER_COMMAND) TYPE SLIS_FORMNAME*" DEFAULT SPACE*" VALUE(I_STRUCTURE_NAME) LIKE DD02L-TABNAME OPTIONAL*" VALUE(IS_LAYOUT) TYPE SLIS_LAYOUT_ALV OPTIONAL*" VALUE(IT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV OPTIONAL*" VALUE(IT_EXCLUDING) TYPE SLIS_T_EXTAB OPTIONAL*" VALUE(IT_SPECIAL_GROUPS) TYPE SLIS_T_SP_GROUP_ALV*" OPTIONAL*" VALUE(IT_SORT) TYPE SLIS_T_SORTINFO_ALV OPTIONAL*" VALUE(IT_FILTER) TYPE SLIS_T_FILTER_ALV OPTIONAL*" VALUE(IS_SEL_HIDE) TYPE SLIS_SEL_HIDE_ALV OPTIONAL*" VALUE(I_DEFAULT) DEFAULT 'X'" VALUE(I_SAVE) DEFAULT SPACE" VALUE(IS_VARIANT) LIKE DISVARIANT" STRUCTURE DISVARIANT DEFAULT SPACE" VALUE(IT_EVENTS) TYPE SLIS_T_EVENT OPTIONAL" VALUE(IT_EVENT_EXIT) TYPE SLIS_T_EVENT_EXIT OPTIONAL

    " VALUE(IS_PRINT) TYPE SLIS_PRINT_ALV OPTIONAL" VALUE(IS_REPREP_ID) TYPE SLIS_REPREP_ID OPTIONAL" VALUE(I_SCREEN_START_COLUMN) DEFAULT 0" VALUE(I_SCREEN_START_LINE) DEFAULT 0" VALUE(I_SCREEN_END_COLUMN) DEFAULT 0" VALUE(I_SCREEN_END_LINE) DEFAULT 0" EXPORTING" VALUE(E_EXIT_CAUSED_BY_CALLER)" VALUE(ES_EXIT_CAUSED_BY_USER) TYPE SLIS_EXIT_BY_USER" TABLES" T_OUTTAB" EXCEPTIONS

    " PROGRAM_ERROR

    Import parametersI_INTERFACE_CHECK: Interface consistency check log output.I_CALLBACK_PROGRAM: Name of the calling program

    I_CALLBACK_PF_STATUS_SET: Set EXIT routine to status.I_CALLBACK_USER_COMMAND: EXIT routine for command handling

    I_STRUCTURE_NAME: Internal output table structure nameIS_LAYOUT: List layout specificationsIT_FIELDCAT: Field catalog with field descriptions

    IT_EXCLUDING: Table of inactive function codes

    IT_SPECIAL_GROUPS: Grouping fields for column selectionIT_SORT: Sort criteria for first list displayIT_FILTER: Filter criteria for first list output

    IS_SEL_HIDE : Selection information modificationI_DEFAULT: Initial variant active/inactive logicI_SAVE: Variants can be saved

    IS_VARIANT : Variant informationIT_EVENTS: Table of events to perform

    IT_EVENT_EXIT : Standard fcode exit requests tableIS_PRINT: Print informationIS_REPREP_ID: Initialization keys for Re/Re interface

    I_SCREEN_START_COLUMN: Coordinates for list in dialog boxI_SCREEN_START_LINE: Coordinates for list in dialog box

    I_SCREEN_END_COLUMN: Coordinates for list in dialog box

  • 7/26/2019 ALV StepByStep Tutorials

    19/36

  • 7/26/2019 ALV StepByStep Tutorials

    20/36

  • 7/26/2019 ALV StepByStep Tutorials

    21/36

  • 7/26/2019 ALV StepByStep Tutorials

    22/36

    ALV DOCUMENTATION AND EXAMPLES2222 Rajago

    22 of 36

    USER CAN CHOOSE A PARTICULAR SET OF FIELD FROM THE OUTPUT AND CAN SAVE

    IT AS VARIANTS

  • 7/26/2019 ALV StepByStep Tutorials

    23/36

    ALV DOCUMENTATION AND EXAMPLES2323 Rajago

    23 of 36

    Using other function module 'REUSE_ALV_GRID_DISPLAY can help us get list output inthe form of a grid and also attach logos to the report output.

  • 7/26/2019 ALV StepByStep Tutorials

    24/36

    ALV DOCUMENTATION AND EXAMPLES2424 Rajago

    24 of 36

    Sample code

    1 Simple list output:

    REPORT Y_DEMO_ALV NO STANDARD PAGE HEADING.** Data to be displayed

    DATA: I_SFLIGHT TYPE TABLE OF SFLIGHT.

    *---------------------------------------------------------------------** SelectionSELECT * FROM SFLIGHT INTO TABLE I_SFLIGHT.

    * Call ABAP List Viewer (ALV)CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTINGI_STRUCTURE_NAME = 'SFLIGHT'

    TABLEST_OUTTAB = I_SFLIGHT.

    2.Simple grid output:

  • 7/26/2019 ALV StepByStep Tutorials

    25/36

    ALV DOCUMENTATION AND EXAMPLES2525 Rajago

    25 of 36

    REPORT Y_DEMO_ALV_1.** Data to be displayedDATA: I_SFLIGHT TYPE TABLE OF SFLIGHT.*---------------------------------------------------------------------*

    * SelectionSELECT * FROM SFLIGHT INTO TABLE I_SFLIGHT.

    * Call ABAP List Viewer (ALV)CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTINGI_STRUCTURE_NAME = 'SFLIGHT'

    TABLEST_OUTTAB = I_SFLIGHT.

    3. Demo for 'REUSE_ALV_POPUP_TO_SELECT'

    REPORT y_demo_alv_3.

    TYPE-POOLS: slis.

    DATA: BEGIN OF i_outtab OCCURS 0.INCLUDE STRUCTURE sflight.

    DATA: w_chk TYPE c. "For multiple selectionDATA: END OF i_outtab.

    * I_OUTTAB TYPE SFLIGHT OCCURS 0,

    DATA: i_private TYPE slis_data_caller_exit,i_selfield TYPE slis_selfield,W_exit(1) TYPE c.

    PARAMETERS: p_title TYPE sy-title.*START-OF-SELECTION.

    SELECT * FROM sflight INTO TABLE i_outtab.

    CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'EXPORTING

    i_title = p_titlei_selection = 'X'i_zebra = 'X'

    * I_SCREEN_START_COLUMN = 0* I_SCREEN_START_LINE = 0* I_SCREEN_END_COLUMN = 0* I_SCREEN_END_LINE = 0

    i_checkbox_fieldname = 'W_CHK'* I_LINEMARK_FIELDNAME =* I_SCROLL_TO_SEL_LINE = 'X'

    i_tabname = 'I_OUTTAB'i_structure_name = 'SFLIGHT'

  • 7/26/2019 ALV StepByStep Tutorials

    26/36

    ALV DOCUMENTATION AND EXAMPLES2626 Rajago

    26 of 36

    * IT_FIELDCAT =* IT_EXCLUDING =* I_CALLBACK_PROGRAM =* I_CALLBACK_USER_COMMAND =* IS_PRIVATE = I_PRIVATE

    IMPORTINGes_selfield = i_selfielde_exit = w_exit

    TABLESt_outtab = i_outtab

    EXCEPTIONSprogram_error = 1OTHERS = 2.

    IF sy-subrc 0.* MESSAGE i000(0k) WITH sy-subrc.ENDIF.

    *****the internal table is modified with a cross sign for marking the***rows selected

    LOOP AT i_outtab WHERE w_chk = 'X'.WRITE: / i_outtab-carrid, i_outtab-price.

    ENDLOOP.

    4. Demo for ALV output using field catalog and layout:

    REPORT y_demo_alv NO STANDARD PAGE HEADING.* ALV related data declaration

    TYPE-POOLS: slis.* DB-TableTABLES sflight.* IncludesINCLUDE .INCLUDE .*CONSTANTS:c_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.

    DATA: i_fieldcat TYPE slis_t_fieldcat_alv,i_layout TYPE slis_layout_alv,i_sp_group TYPE slis_t_sp_group_alv,i_events TYPE slis_t_event,i_print TYPE slis_print_alv,i_sort TYPE slis_t_sortinfo_alv.

    *internal table for data to be displayedDATA: BEGIN OF i_sflight OCCURS 0.

    INCLUDE STRUCTURE sflight.DATA: box,

    lights.DATA: END OF i_sflight.

    *DATA: w_repid LIKE sy-repid.

  • 7/26/2019 ALV StepByStep Tutorials

    27/36

    ALV DOCUMENTATION AND EXAMPLES2727 Rajago

    27 of 36

    DATA: i_list_top_of_page TYPE slis_t_listheader.* Report SelectionsSELECT-OPTIONS s_carrid FOR sflight-carrid.SELECT-OPTIONS s_connid FOR sflight-connid.SELECT-OPTIONS s_fldate FOR sflight-fldate.*SELECTION-SCREEN SKIP 1.* ParametersPARAMETERS: p_maxrow TYPE i DEFAULT 30."to limit the selectionSELECTION-SCREEN SKIP 1.

    * Variant for ALV displaySELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE text-000.PARAMETERS: p_varnt LIKE disvariant-variant.SELECTION-SCREEN END OF BLOCK 0.* Layout of the report displaySELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.PARAMETERS: p_zebra AS CHECKBOX DEFAULT ' ', "Striped pattern

    p_nocolh AS CHECKBOX DEFAULT ' ', "No column headingp_novlin AS CHECKBOX DEFAULT ' ', "No vertical linesp_colopt AS CHECKBOX DEFAULT ' ', "Optimizes col. wdp_keyhot AS CHECKBOX DEFAULT ' ', "Key fields hotp_noinpt AS CHECKBOX DEFAULT ' '. "No field for input

    SELECTION-SCREEN END OF BLOCK a.

    SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-002.PARAMETERS: p_lights AS CHECKBOX DEFAULT 'X',

    p_lightc AS CHECKBOX DEFAULT 'X'.SELECTION-SCREEN END OF BLOCK b.

    SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-003.PARAMETERS: p_totonl AS CHECKBOX DEFAULT ' ',

    p_totext(60),p_sttext(60).

    SELECTION-SCREEN END OF BLOCK c.

    SELECTION-SCREEN BEGIN OF BLOCK d WITH FRAME TITLE text-004.PARAMETERS: p_chkbox AS CHECKBOX DEFAULT 'X',

    p_detpop AS CHECKBOX DEFAULT 'X',p_groupb AS CHECKBOX DEFAULT ' ',p_groups AS CHECKBOX DEFAULT ' '.

    SELECTION-SCREEN END OF BLOCK d.

    SELECTION-SCREEN BEGIN OF BLOCK e WITH FRAME TITLE text-005.

    PARAMETERS: p_print AS CHECKBOX DEFAULT ' ',p_nosinf AS CHECKBOX DEFAULT ' ',p_nocove AS CHECKBOX DEFAULT ' ',p_nonewp AS CHECKBOX DEFAULT ' ',p_nolinf AS CHECKBOX DEFAULT ' ',p_reserv TYPE i.

    SELECTION-SCREEN END OF BLOCK e.

    DATA: w_boxnam TYPE slis_fieldname VALUE 'BOX',w_f2code LIKE sy-ucomm VALUE '&ETA',w_lignam TYPE slis_fieldname VALUE 'LIGHTS',w_save(1) TYPE c,

  • 7/26/2019 ALV StepByStep Tutorials

    28/36

  • 7/26/2019 ALV StepByStep Tutorials

    29/36

  • 7/26/2019 ALV StepByStep Tutorials

    30/36

    ALV DOCUMENTATION AND EXAMPLES3030 Rajago

    30 of 36

    program_error = 1OTHERS = 2.

    IF sy-subrc 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.ENDIF.

    * CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'* EXPORTING* i_callback_program = w_repid* i_structure_name = 'SFLIGHT'* is_layout = i_layout* it_fieldcat = i_fieldcat[]** IT_EXCLUDING =* it_special_groups = i_sp_group[]* it_sort = i_sort[]

    ** IT_FILTER =** IS_SEL_HIDE =** i_default = W_DEFAULT* i_save = w_save* is_variant = i_variant* it_events = i_events[]** IT_EVENT_EXIT =* is_print = i_print** I_SCREEN_START_COLUMN = 0** I_SCREEN_START_LINE = 0** I_SCREEN_END_COLUMN = 0** I_SCREEN_END_LINE = 0

    ** IMPORTING** E_EXIT_CAUSED_BY_CALLER =* TABLES* t_outtab = i_sflight.

    *---------------------------------------------------------------------** FORM FIELDCAT_INIT **---------------------------------------------------------------------** --> L_FIELDCAT **---------------------------------------------------------------------*FORM fieldcat_init USING l_fieldcat TYPE slis_t_fieldcat_alv.

    DATA: ls_fieldcat TYPE slis_fieldcat_alv.*

    CLEAR ls_fieldcat.ls_fieldcat-fieldname = 'SEATSOCC'.

    *The field is not displayed in the initial output, can be interactively* chosen for displayls_fieldcat-no_out = 'X'.

    *This field is assigned to a special group with tech. key 'A' and can be*displayed using the special group buttonsls_fieldcat-sp_group = 'A'.

    *The field cannot be summed irrespective of its data typels_fieldcat-no_sum = 'X'.APPEND ls_fieldcat TO l_fieldcat.

    *

  • 7/26/2019 ALV StepByStep Tutorials

    31/36

  • 7/26/2019 ALV StepByStep Tutorials

    32/36

    ALV DOCUMENTATION AND EXAMPLES3232 Rajago

    32 of 36

    EXPORTINGi_list_type = 0

    IMPORTINGet_events = l_events.

    READ TABLE l_events WITH KEY name = slis_ev_top_of_page INTO ls_event.

    IF sy-subrc = 0.MOVE c_formname_top_of_page TO ls_event-form.APPEND ls_event TO l_events.

    ENDIF.

    ENDFORM.

    *---------------------------------------------------------------------** FORM COMMENT_BUILD **---------------------------------------------------------------------*

    * --> L_TOP_OF_PAGE **---------------------------------------------------------------------*FORM comment_build USING l_top_of_page TYPE slis_t_listheader.

    DATA: ls_line TYPE slis_listheader.

    ***HeaderCLEAR ls_line.ls_line-typ = 'H'.

    * LS_LINE-KEY: not used for this typels_line-info = 'Heading list'.APPEND ls_line TO l_top_of_page.

    ***SelectionCLEAR ls_line.ls_line-typ = 'S'.ls_line-key = 'Key 1'.ls_line-info = 'Information'.APPEND ls_line TO l_top_of_page.ls_line-key = 'Key 2'.APPEND ls_line TO l_top_of_page.

    ***ActionCLEAR ls_line.

    ls_line-typ = 'A'.* LS_LINE-KEY: not used for this type

    Ls_line-info = 'Status list'.APPEND ls_line TO l_top_of_page.

    ENDFORM.

    *---------------------------------------------------------------------** FORM LAYOUT_BUILD **---------------------------------------------------------------------** LS_LAYOUT **---------------------------------------------------------------------*FORM layout_build USING ls_layout TYPE slis_layout_alv.

  • 7/26/2019 ALV StepByStep Tutorials

    33/36

  • 7/26/2019 ALV StepByStep Tutorials

    34/36

    ALV DOCUMENTATION AND EXAMPLES3434 Rajago

    34 of 36

    FORM selection.

    SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE i_sflightUP TO p_maxrow ROWS WHERE carrid IN s_carridAND connid IN s_connid AND fldate IN s_fldate.

    PERFORM data_add TABLES i_sflight.ENDFORM.

    *---------------------------------------------------------------------** FORM TOP_OF_PAGE **---------------------------------------------------------------------** ........ **---------------------------------------------------------------------*FORM top_of_page.*CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTINGi_logo = 'ENJOYSAP_LOGO'it_list_commentary = i_list_top_of_page.

    ENDFORM.

    *---------------------------------------------------------------------** FORM F4_FOR_VARIANT **---------------------------------------------------------------------*FORM f4_for_variant.*CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

    EXPORTINGis_variant = i_varianti_save = w_save

    * it_default_fieldcat =IMPORTING

    e_exit = w_exites_variant = i_variant1

    EXCEPTIONSnot_found = 2.

    IF sy-subrc = 2.MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ELSE.IF w_exit = space.

    p_varnt = i_variant1-variant.ENDIF.

    ENDIF.ENDFORM.

    *&---------------------------------------------------------------------**& Form PAI_OF_SELECTION_SCREEN*&---------------------------------------------------------------------** to check whether right variant is entered on the selection scr*----------------------------------------------------------------------*FORM pai_of_selection_screen.*

  • 7/26/2019 ALV StepByStep Tutorials

    35/36

    ALV DOCUMENTATION AND EXAMPLES3535 Rajago

    35 of 36

    IF NOT p_varnt IS INITIAL.MOVE i_variant TO i_variant1.MOVE p_varnt TO i_variant1-variant.

    CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'EXPORTING

    i_save = w_saveCHANGING

    cs_variant = i_variant1.

    i_variant = i_variant1.ELSE.PERFORM variant_init.

    ENDIF.

    ENDFORM. " PAI_OF_SELECTION_SCREEN

    *&---------------------------------------------------------------------**& Form VARIANT_INIT*----------------------------------------------------------------------*FORM variant_init.*CLEAR i_variant.i_variant-report = w_repid.

    ENDFORM. " VARIANT_INIT

    *---------------------------------------------------------------------** FORM PRINT_BUILD *

    *---------------------------------------------------------------------** ........ **---------------------------------------------------------------------*FORM print_build USING l_print TYPE slis_print_alv.*l_print-print = p_print.l_print-no_print_selinfos = p_nosinf.l_print-no_coverpage = p_nocove.l_print-no_new_page = p_nonewp.l_print-no_print_listinfos = p_nolinf.l_print-reserve_lines = p_reserv.l_print-print = p_print.

    ENDFORM.

    *---------------------------------------------------------------------** FORM T_SORT_BUILD **---------------------------------------------------------------------*FORM t_sort_build USING l_sort TYPE slis_t_sortinfo_alv.

    DATA: ls_sort TYPE slis_sortinfo_alv.

    ls_sort-fieldname = 'CARRID'.ls_sort-spos = 1.ls_sort-up = 'X'.ls_sort-subtot = 'X'.

  • 7/26/2019 ALV StepByStep Tutorials

    36/36

    ALV DOCUMENTATION AND EXAMPLES3636 Rajago

    APPEND ls_sort TO l_sort.

    ENDFORM.