Over View
Described how to make a basic ALV. The flow is data acquisition-> edit-> ALV setting-> display.
With just this, you can create a simple ALV.
A function module can be used for each setting, so it is possible to display according to the requirements just by setting the parameters.
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
REPORT ytest. TYPE-POOLS:slis. ************************************************************************ * Internal Table ************************************************************************ DATA: gi_sflight TYPE TABLE OF sflight. *** ALV *** DATA: gi_fieldcat TYPE slis_t_fieldcat_alv. ************************************************************************ * Structure ************************************************************************ FIELD-SYMBOLS: <fs_sflight> LIKE LINE OF gi_sflight. *** ALV *** DATA: gw_layout TYPE slis_layout_alv. DATA: gw_variant TYPE disvariant. DATA: gw_fieldcat TYPE slis_fieldcat_alv. ************************************************************************ * Variable ************************************************************************ DATA: v_carrid TYPE sflight-carrid, v_fldate TYPE sflight-fldate. ************************************************************************ * Screen ************************************************************************ SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-t01. SELECT-OPTIONS s_carrid FOR v_carrid OBLIGATORY. SELECT-OPTIONS s_fldate FOR v_fldate. SELECTION-SCREEN END OF BLOCK b01. ************************************************************************ * Initial Process ************************************************************************ INITIALIZATION. CLEAR: gi_sflight. ************************************************************************ * Main Process ************************************************************************ START-OF-SELECTION. PERFORM get_data. PERFORM edit_data. PERFORM set_variant. PERFORM set_layout. PERFORM get_fieldcatalog. PERFORM output_alv. ************************************************************************ * GET_DATA ************************************************************************ FORM get_data. SELECT * INTO TABLE gi_sflight FROM sflight WHERE carrid IN s_carrid AND fldate IN s_fldate. ENDFORM. ************************************************************************ * EDIT_DATA ************************************************************************ FORM edit_data. LOOP AT gi_sflight ASSIGNING <fs_sflight>. ****** If you need edit to internal table, please write here ****** ENDLOOP. ENDFORM. ************************************************************************ * SET_VARIANT ************************************************************************ FORM set_variant. gw_variant-report = sy-cprog. ** IT_VARIANT-HANDLE = ** IT_VARIANT-LOG_GROUP = gw_variant-username = sy-uname. ** IT_VARIANT-VARIANT = ** IT_VARIANT-TEXT = ** IT_VARIANT-DEPENDVARS = ENDFORM. ************************************************************************ * SET_LAYOUT ************************************************************************ FORM set_layout. gw_layout-zebra = 'X'. gw_layout-colwidth_optimize = 'X'. gw_layout-window_titlebar = sy-title. ** GW_LAYOUT-no_colhead = ** GW_LAYOUT-no_hotspot = ** GW_LAYOUT-no_vline = ** GW_LAYOUT-no_hline = ** GW_LAYOUT-cell_merge = ** GW_LAYOUT-edit = ** GW_LAYOUT-edit_mode = ** GW_LAYOUT-numc_sum = ** GW_LAYOUT-no_input = ** GW_LAYOUT-f2code = ** GW_LAYOUT-reprep = ** GW_LAYOUT-no_keyfix = ** GW_LAYOUT-expand_all = ** GW_LAYOUT-no_author = ** GW_LAYOUT-def_status = ** GW_LAYOUT-item_text = ** GW_LAYOUT-countfname = ** GW_LAYOUT-colwidth_optimize = ** GW_LAYOUT-no_min_linesize = ** GW_LAYOUT-min_linesize = ** GW_LAYOUT-max_linesize = ** GW_LAYOUT-window_titlebar = ** GW_LAYOUT-no_uline_hs = ** GW_LAYOUT-lights_fieldname = ** GW_LAYOUT-lights_tabname = ** GW_LAYOUT-lights_rollname = ** GW_LAYOUT-lights_condense = ** GW_LAYOUT-no_sumchoice = ** GW_LAYOUT-no_totalline = ** GW_LAYOUT-no_subchoice = ** GW_LAYOUT-no_subtotals = ** GW_LAYOUT-no_unit_splitting = ** GW_LAYOUT-totals_before_items = ** GW_LAYOUT-totals_only = ** GW_LAYOUT-totals_text = ** GW_LAYOUT-subtotals_text = ** GW_LAYOUT-box_fieldname = ** GW_LAYOUT-box_tabname = ** GW_LAYOUT-box_rollname = ** GW_LAYOUT-expand_fieldname = ** GW_LAYOUT-hotspot_fieldname = ** GW_LAYOUT-confirmation_prompt = ** GW_LAYOUT-key_hotspot = ** GW_LAYOUT-flexible_key = ** GW_LAYOUT-group_buttons = ** GW_LAYOUT-get_selinfos = ** GW_LAYOUT-group_change_edit = ** GW_LAYOUT-no_scrolling = ** GW_LAYOUT-detail_popup = ** GW_LAYOUT-detail_initial_lines = ** GW_LAYOUT-detail_titlebar = ** GW_LAYOUT-header_text = ** GW_LAYOUT-default_item = ** GW_LAYOUT-info_fieldname = ** GW_LAYOUT-coltab_fieldname = ** GW_LAYOUT-list_append = ** GW_LAYOUT-xifunckey = ** GW_LAYOUT-xidirect = ** GW_LAYOUT-dtc_layout = ENDFORM. ************************************************************************ * GET_FIELDCATALOG ************************************************************************ FORM get_fieldcatalog. CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING i_program_name = sy-repid * i_internal_tabname = I_STRUCTURE_NAME = 'SFLIGHT' * I_CLIENT_NEVER_DISPLAY = 'X' * I_INCLNAME = * I_BYPASSING_BUFFER = * I_BUFFER_ACTIVE = CHANGING ct_fieldcat = gi_fieldcat * EXCEPTIONS * INCONSISTENT_INTERFACE = 1 * PROGRAM_ERROR = 2 * OTHERS = 3 . IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. ENDFORM. ************************************************************************ * OUTPUT_ALV ************************************************************************ FORM output_alv. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = sy-repid is_layout = gw_layout it_fieldcat = gi_fieldcat is_variant = gw_variant TABLES t_outtab = gi_sflight * EXCEPTIONS * PROGRAM_ERROR = 1 * OTHERS = 2 . IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. ENDFORM. |
See here for how to define Data
See here for getting multiple records
Recent Comments