ALV Template
在常规报表开发中,通常都会用到 ALV来显示数据,这里有一个ALV模板来整合相关的ALV操作,便于开发。
1.创建 Function Group:ZCA_ALV_PRINT_SELECTION
1)需要导入的参数有:
2)需要导出的参数有:
3)需要传递的Tables有:
2.创建Title:
3.复制Standard 的 GUI Status:
并在标准的菜单上,加入备用菜单 BUTTON1~BUTTON5.
4.定义全局变量 (存放在:LZCA_ALV_PRINT_SELECTIONTOP)
1 FUNCTION-POOL zca_alv_print_selection. "MESSAGE-ID .. 2 TABLES: 3 rsvar, 4 dfies, 5 trdir. 6 7 TYPE-POOLS: 8 rsds , 9 syldb, 10 sydb0. 11 12 TYPE-POOLS: 13 icon, 14 sym, 15 slis. 16 17 *** Types definition 18 TYPES: 19 BEGIN OF ty_psel, 20 kind TYPE flag, 21 slnam TYPE char8, 22 text TYPE char255, 23 sign TYPE tvarv_sign, 24 option TYPE tvarv_opti, 25 low TYPE tvarv_val, 26 high TYPE tvarv_val, 27 END OF ty_psel. 28 29 CONSTANTS: 30 cn_$cross TYPE flag VALUE 'X', 31 cn_$null_dt TYPE char10 VALUE '00.00.0000', 32 cn_$alv_hd TYPE i VALUE '25', 33 cn_types TYPE c VALUE 'S', 34 cn_typed TYPE c VALUE 'D', 35 cn_entry(4) TYPE c VALUE '?...', 36 cn_dtype_d(4) TYPE c VALUE 'DATE', 37 cn_dtype_n(4) TYPE c VALUE 'NUMC', 38 cn_type_s(4) TYPE c VALUE 'STRG', 39 cn_part(4) TYPE c VALUE 'SSCR', 40 cn_finance(3) TYPE c VALUE 'ZFI', 41 cn_porcument(3) TYPE c VALUE 'ZMM'. 42 43 *** Variable, internal table and work area definition 44 DATA: 45 gv_number TYPE i, 46 gv_decimal TYPE tfmbbwhr2, 47 datum TYPE datum, 48 gv_date TYPE char10, 49 gv_char TYPE vtext_bf, "text45, 50 gv_header_lines TYPE i, 51 gv_show_bt6 TYPE flag, 52 gt_header TYPE slis_t_listheader, 53 gt_prn_header TYPE slis_t_listheader, 54 gw_line TYPE slis_listheader, 55 gv_time TYPE char5, 56 gv_wa_line TYPE text60, 57 gv_text TYPE text60, 58 gw_button1 TYPE smp_dyntxt, 59 gw_button2 TYPE smp_dyntxt, 60 gw_button3 TYPE smp_dyntxt, 61 gw_button4 TYPE smp_dyntxt, 62 gw_button5 TYPE smp_dyntxt, 63 gw_button6 TYPE smp_dyntxt, 64 gt_extab TYPE slis_t_extab , "OCCURS 0 WITH HEADER LINE, 65 gt_temp_sel TYPE ty_psel OCCURS 0 WITH HEADER LINE, 66 gt_temp_sel_dyn TYPE ty_psel OCCURS 0 WITH HEADER LINE, 67 gt_sel_tab TYPE rsparams OCCURS 0 WITH HEADER LINE, 68 gt_pg_txtpool TYPE textpool OCCURS 0 WITH HEADER LINE, 69 gt_l_selctab TYPE rsscr OCCURS 0 WITH HEADER LINE, 70 gt_t_dfies TYPE dfies OCCURS 0 WITH HEADER LINE. 71 72 DATA : 73 gv_databeg TYPE begda, 74 gv_dataend TYPE endda. 75 76 77 * Macros 78 DEFINE format_date. 79 * &1 - low 80 * &2 - high 81 * &3 - flag to get data selection period 82 if not &3 is initial. 83 gv_databeg = &1. 84 gv_dataend = &2. 85 endif. 86 datum = &1. 87 call 'DATE_CONV_INT_TO_EXT' id 'DATINT' field datum 88 id 'DATEXT' field &1. 89 datum = &2. 90 call 'DATE_CONV_INT_TO_EXT' id 'DATINT' field datum 91 id 'DATEXT' field &2. 92 END-OF-DEFINITION. 93 94 DEFINE add_itab. 95 * &1 - t_sel / t_sel_dyn / t_data 96 append &1. 97 clear &1. 98 END-OF-DEFINITION. 99 100 101 DEFINE header. 102 * &1 - line 103 * &2 - clear field 104 append &1 to gt_header. 105 case &2. 106 when 'I'. "info 107 clear &1-info. 108 when 'K'. "key 109 clear: &1-key, 110 &1-info. 111 endcase. 112 END-OF-DEFINITION.
5.创建Subroutine,改变标准菜单的显示
1 *&---------------------------------------------------------------------* 2 *& Include LZCA_ALV_PRINT_SELECTIONF02 3 *&---------------------------------------------------------------------* 4 *&---------------------------------------------------------------------* 5 *& Form FRM_GET_SELSCREEN_ICON 6 * Change Standard SAP displayed to map PM2S requirements 7 *&---------------------------------------------------------------------* 8 FORM frm_get_selscreen_icon USING pr_sign LIKE rsparams-sign 9 pr_option LIKE rsparams-option 10 CHANGING p_icon TYPE char40. 11 CASE pr_sign. 12 WHEN 'I'. 13 CASE pr_option. 14 WHEN 'EQ'. 15 MOVE '' TO p_icon. 16 WHEN 'NE'. 17 MOVE 'Not' TO p_icon. 18 WHEN 'GT'. 19 MOVE '>' TO p_icon. 20 WHEN 'LT'. 21 MOVE '<' TO p_icon. 22 WHEN 'GE'. 23 MOVE '>=' TO p_icon. 24 WHEN 'LE'. 25 MOVE '<=' TO p_icon. 26 WHEN 'BT'. 27 MOVE '' TO p_icon. 28 WHEN 'NB'. 29 MOVE 'Not' TO p_icon. 30 WHEN 'CP'. 31 MOVE '' TO p_icon. 32 WHEN 'NP'. 33 MOVE 'Not' TO p_icon. 34 ENDCASE. 35 36 *****exclusive (RED) 37 WHEN 'E'. 38 CASE pr_option. 39 WHEN 'EQ'. 40 MOVE 'Not' TO p_icon. 41 WHEN 'NE'. 42 MOVE '' TO p_icon. 43 WHEN 'GT'. 44 MOVE text-s33 TO p_icon. 45 WHEN 'LT'. 46 MOVE text-s32 TO p_icon. 47 WHEN 'GE'. 48 MOVE text-s30 TO p_icon. 49 WHEN 'LE'. 50 MOVE text-s29 TO p_icon. 51 WHEN 'BT'. 52 MOVE text-s31 TO p_icon. 53 WHEN 'NB'. 54 * Not exclude these range means include these 55 MOVE '' TO p_icon. 56 WHEN 'CP'. 57 MOVE text-s31 TO p_icon. 58 WHEN 'NP'. 59 MOVE '' TO p_icon. 60 ENDCASE. 61 ENDCASE. 62 ENDFORM. "FRM_GET_SELSCREEN_ICON
6.定义相关操作的Subroutine:
1 *&---------------------------------------------------------------------* 2 *& Include LZCA_ALV_PRINT_SELECTIONF03 3 *&---------------------------------------------------------------------* 4 *&---------------------------------------------------------------------* 5 *& Form fRM_append_seltab 6 *&---------------------------------------------------------------------* 7 * text 8 *----------------------------------------------------------------------* 9 * --> p1 text 10 * <-- p2 text 11 *----------------------------------------------------------------------* 12 FORM frm_append_seltab TABLES pr_temp_sel 13 STRUCTURE gt_temp_sel. 14 DATA: lv_icon(40) TYPE c, 15 lv_len TYPE i, 16 lv_lines TYPE i, 17 lv_start TYPE i. 18 DATA: lt_temp_header TYPE slis_t_listheader. 19 CONSTANTS: lc_dis TYPE i VALUE 3. 20 21 22 lv_lines = LINES( pr_temp_sel ). 23 IF lv_lines > 15 AND sy-batch = 'X'. 24 **** No of lines to be printed in top-of-page are too many for 25 ****background mode. 26 *** Write horizontally 27 lt_temp_header[] = gt_header[]. 28 * SORT pr_temp_sel BY text sign option. 29 LOOP AT pr_temp_sel. 30 AT NEW text. 31 gw_line-key = pr_temp_sel-text. 32 CONCATENATE gw_line-key ':' INTO gw_line-key. 33 ENDAT. 34 CASE pr_temp_sel-option. 35 WHEN 'EQ'. 36 IF pr_temp_sel-slnam EQ 'ZVSCREEN'. "Don't change 'EQ' to 'to' 37 CONCATENATE pr_temp_sel-low 'EQ' pr_temp_sel-high 38 INTO gv_text SEPARATED BY space. 39 ELSE. 40 IF NOT pr_temp_sel-high IS INITIAL. 41 CONCATENATE pr_temp_sel-low 'to' pr_temp_sel-high 42 INTO gv_text SEPARATED BY space. 43 ELSE. 44 gv_text = pr_temp_sel-low. 45 ENDIF. 46 ENDIF. 47 WHEN space. 48 IF pr_temp_sel-kind = 'S'. 49 CONTINUE. 50 * text = 'Nothing specified'. 51 ELSEIF pr_temp_sel-kind = 'P'. 52 gv_text = pr_temp_sel-low. 53 IF NOT pr_temp_sel-high IS INITIAL. 54 CONCATENATE pr_temp_sel-low pr_temp_sel-high 55 INTO gv_text SEPARATED BY space. 56 ENDIF. 57 ENDIF. 58 WHEN OTHERS. 59 IF NOT pr_temp_sel-low IS INITIAL AND 60 NOT pr_temp_sel-high IS INITIAL. 61 IF pr_temp_sel-option EQ 'BT'. 62 CONCATENATE pr_temp_sel-low 'to' pr_temp_sel-high 63 INTO gv_text SEPARATED BY space. 64 ELSE. 65 CONCATENATE pr_temp_sel-low 66 pr_temp_sel-option 67 pr_temp_sel-high 68 INTO gv_text SEPARATED BY space. 69 ENDIF. 70 ELSEIF NOT pr_temp_sel-low IS INITIAL AND 71 pr_temp_sel-high IS INITIAL. 72 gv_text = pr_temp_sel-low. 73 ELSEIF pr_temp_sel-low IS INITIAL AND 74 NOT pr_temp_sel-high IS INITIAL. 75 gv_text = pr_temp_sel-high. 76 ENDIF. 77 ENDCASE. 78 CONDENSE gv_text. 79 lv_len = STRLEN( gv_text ). 80 IF lv_start IS INITIAL. 81 gw_line-info+7 = gv_text. 82 lv_start = 7 + lv_len + lc_dis. 83 ELSE. 84 lv_lines = lv_start + lv_len. 85 IF lv_lines < 60. 86 gw_line-info+lv_start = gv_text. 87 lv_start = lv_start + lv_len + lc_dis. 88 ELSE. 89 PERFORM frm_get_selscreen_icon USING pr_temp_sel-sign 90 pr_temp_sel-option 91 CHANGING lv_icon. 92 93 gw_line-info+0(6) = lv_icon. 94 * line-info+7 = text. 95 header gw_line 'K'. 96 gw_line-info+7 = gv_text. 97 lv_start = 7 + lv_len + lc_dis. 98 CLEAR gv_text. 99 CONTINUE. 100 ENDIF. 101 ENDIF. 102 AT END OF option. 103 * CHECK NOT text IS INITIAL. 104 PERFORM frm_get_selscreen_icon USING pr_temp_sel-sign 105 pr_temp_sel-option 106 CHANGING lv_icon. 107 108 gw_line-info+0(6) = lv_icon. 109 * line-info+ = text. 110 header gw_line 'K'. 111 CLEAR lv_start. 112 ENDAT. 113 CLEAR gv_text. 114 ENDLOOP. 115 116 lv_lines = LINES( gt_header ). 117 IF lv_lines > 25. 118 gt_header[] = lt_temp_header[]. 119 * line-info+0(6) = l_icon. 120 * line-info+ = text. 121 gw_line-key = text-t02. 122 gw_line-info = text-t01. 123 header gw_line 'K'. 124 * CONCATENATE line-key ':' INTO line-key. 125 126 ENDIF. 127 128 ELSE. 129 * SORT pr_temp_sel BY text. 130 LOOP AT pr_temp_sel. 131 AT NEW text. 132 gw_line-key = pr_temp_sel-text. 133 CONCATENATE gw_line-key ':' INTO gw_line-key. 134 ENDAT. 135 CASE pr_temp_sel-option. 136 WHEN 'EQ'. 137 IF pr_temp_sel-slnam EQ 'ZVSCREEN'. "Don't change 'EQ' to 'to' 138 CONCATENATE pr_temp_sel-low 'EQ' pr_temp_sel-high 139 INTO gv_text SEPARATED BY space. 140 ELSE. 141 IF NOT pr_temp_sel-high IS INITIAL. 142 CONCATENATE pr_temp_sel-low 'to' pr_temp_sel-high 143 INTO gv_text SEPARATED BY space. 144 ELSE. 145 gv_text = pr_temp_sel-low. 146 ENDIF. 147 ENDIF. 148 WHEN space. 149 IF pr_temp_sel-kind = 'S'. 150 CONTINUE. 151 * text = 'Nothing specified'. 152 ELSEIF pr_temp_sel-kind = 'P'. 153 gv_text = pr_temp_sel-low. 154 IF NOT pr_temp_sel-high IS INITIAL. 155 CONCATENATE pr_temp_sel-low pr_temp_sel-high 156 INTO gv_text SEPARATED BY space. 157 ENDIF. 158 ENDIF. 159 WHEN OTHERS. 160 IF NOT pr_temp_sel-low IS INITIAL 161 AND NOT pr_temp_sel-high IS INITIAL. 162 IF pr_temp_sel-option EQ 'BT'. 163 CONCATENATE pr_temp_sel-low 'to' pr_temp_sel-high 164 INTO gv_text SEPARATED BY space. 165 ELSE. 166 CONCATENATE pr_temp_sel-low 167 pr_temp_sel-option 168 pr_temp_sel-high 169 INTO gv_text SEPARATED BY space. 170 ENDIF. 171 ELSEIF NOT pr_temp_sel-low IS INITIAL AND 172 pr_temp_sel-high IS INITIAL. 173 gv_text = pr_temp_sel-low. 174 ELSEIF pr_temp_sel-low IS INITIAL AND 175 NOT pr_temp_sel-high IS INITIAL. 176 gv_text = pr_temp_sel-high. 177 ENDIF. 178 ENDCASE. 179 CONDENSE gv_text. 180 * CHECK NOT text IS INITIAL. 181 PERFORM frm_get_selscreen_icon USING pr_temp_sel-sign 182 pr_temp_sel-option 183 CHANGING lv_icon. 184 gw_line-info = lv_icon. 185 gw_line-info+7 = gv_text. 186 header gw_line 'K'. 187 CLEAR gv_text. 188 ENDLOOP. 189 ENDIF. 190 ENDFORM. " frm_append_seltab 191 192 *&--------------------------------------------------------------------* 193 *& Form frm_prepare_header 194 *&--------------------------------------------------------------------* 195 FORM frm_prepare_header TABLES pr_t_header_add 196 pr_t_sel 197 pr_t_sel_dyn 198 pr_t_header 199 USING pr_title TYPE sytitle 200 pr_repid TYPE repid 201 pr_tfill TYPE char8 202 pr_logo TYPE char30 203 pr_alv_header TYPE flag 204 value(pv_dont_show_initial) TYPE char1 205 value(pv_no_conf) TYPE xfeld. 206 207 DATA: lt_sscr TYPE TABLE OF rsscr, 208 lw_sscr TYPE rsscr. 209 DATA: lv_found TYPE c, 210 lo_dref TYPE REF TO data. 211 FIELD-SYMBOLS: <fs> TYPE ANY. 212 213 LOAD REPORT pr_repid PART cn_part INTO lt_sscr. "SSCR 214 215 CLEAR: gw_line, 216 gt_header[]. 217 218 ** Header 219 gw_line-typ = 'H'. 220 gw_line-info = pr_title. 221 header gw_line 'I'. 222 * 223 * Selection values 224 CLEAR gw_line. 225 gw_line-typ = 'S'. 226 227 * deparment name 228 gw_line-key = text-s34. 229 gv_wa_line = text-s35. 230 gw_line-info = gv_wa_line. 231 header gw_line 'K'. 232 233 * system name 234 gw_line-key = text-s36. 235 gv_wa_line = text-s37. 236 gw_line-info = gv_wa_line. 237 header gw_line 'K'. 238 239 * (ERP) System 240 gw_line-key = text-s38. 241 CASE pr_repid+0(3). 242 WHEN cn_finance. "'ZFI'. 243 gv_wa_line = text-s39. 244 WHEN cn_porcument ."'ZMM'. 245 gv_wa_line = text-s40. 246 WHEN OTHERS. 247 gv_wa_line = text-s41. 248 ENDCASE. 249 gw_line-info = gv_wa_line. 250 header gw_line 'K'. 251 252 * execute time 253 WRITE: sy-datum TO gv_date . 254 gw_line-key = text-s03. 255 gv_wa_line = gv_date. 256 gw_line-info = gv_wa_line. 257 header gw_line 'K'. 258 259 * person who execute the program 260 gw_line-key = text-s04. 261 gv_wa_line = sy-uname. 262 gw_line-info = gv_wa_line. 263 header gw_line 'K'. 264 265 266 IF NOT gt_temp_sel_dyn[] IS INITIAL. 267 gw_line-key = '.'. 268 header gw_line 'I'. 269 gw_line-key = text-s06. 270 CLEAR gw_line-info. 271 header gw_line 'K'. 272 * print_seltab gt_temp_sel_dyn. 273 PERFORM frm_append_seltab TABLES gt_temp_sel_dyn. "USING lt_sscr. 274 ENDIF. 275 276 * Remove the initial parameter values 277 IF NOT pv_dont_show_initial IS INITIAL. 278 *** Delete select-options with blank values. 279 DELETE gt_temp_sel WHERE kind = 'S' AND 280 sign IS INITIAL AND 281 option IS INITIAL. 282 *** Delete parameters with blank values 283 LOOP AT gt_temp_sel WHERE kind = 'P' 284 AND low CO '0 '. 285 *** Get the data type 286 READ TABLE lt_sscr WITH KEY name = gt_temp_sel-slnam 287 INTO lw_sscr. 288 *** STRING cannot be assigned dynamically. Check explicitly. 289 IF lw_sscr-dtyp = cn_type_s . ""'STRG'. 290 IF gt_temp_sel-low IS INITIAL. 291 DELETE gt_temp_sel. 292 ENDIF. 293 CONTINUE. 294 ENDIF. 295 CREATE DATA lo_dref TYPE (lw_sscr-type). 296 ASSIGN lo_dref->* TO <fs>. 297 MOVE gt_temp_sel-low TO <fs> . 298 * ASSIGN p_sel-low TO <fs> CASTING TYPE (p_sscr-type). 299 IF <fs> IS INITIAL. 300 DELETE gt_temp_sel. 301 ENDIF. 302 UNASSIGN <fs>. 303 ENDLOOP. 304 ENDIF. 305 gw_line-typ = 'S'. 306 gw_line-key = text-s01. 307 gw_line-info = space. 308 header gw_line 'K'. 309 PERFORM frm_append_seltab TABLES gt_temp_sel. 310 311 * Additional Header 312 IF NOT pr_t_header_add[] IS INITIAL. 313 gt_temp_sel[] = pr_t_header_add[]. 314 * print_seltab gt_temp_sel. 315 PERFORM frm_append_seltab TABLES gt_temp_sel. 316 ENDIF. 317 * 318 IF pr_alv_header IS INITIAL. 319 pr_t_sel[] = gt_temp_sel[]. 320 pr_t_sel_dyn[] = gt_temp_sel_dyn[]. 321 pr_t_header[] = gt_header[]. 322 EXIT. 323 ENDIF. 324 * 325 CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' 326 EXPORTING 327 i_logo = pr_logo 328 it_list_commentary = gt_header. 329 330 DESCRIBE TABLE gt_header LINES gv_header_lines. 331 332 ENDFORM. "frm_prepare_header 333 334 *&--------------------------------------------------------------------* 335 *& Form pf_status 336 *&--------------------------------------------------------------------* 337 FORM frm_pf_status USING pv_button1 STRUCTURE smp_dyntxt 338 pv_button2 STRUCTURE smp_dyntxt 339 pv_button3 STRUCTURE smp_dyntxt 340 pv_button4 STRUCTURE smp_dyntxt 341 pv_button5 STRUCTURE smp_dyntxt 342 pr_extab TYPE slis_t_extab 343 pr_title TYPE sytitle . "EC * 344 345 gt_extab = pr_extab. 346 * Activate / De-activate Button 1 347 IF pv_button1 IS INITIAL. 348 APPEND 'BUTTON1' TO gt_extab. 349 ELSE. 350 gw_button1 = pv_button1. 351 DELETE gt_extab WHERE fcode EQ 'BUTTON1'. 352 ENDIF. 353 * Activate / De-activate Button 2 354 IF pv_button2 IS INITIAL. 355 APPEND 'BUTTON2' TO gt_extab. 356 ELSE. 357 gw_button2 = pv_button2. 358 DELETE gt_extab WHERE fcode EQ 'BUTTON2'. 359 ENDIF. 360 * Activate / De-activate Button 3 361 IF pv_button3 IS INITIAL. 362 APPEND 'BUTTON3' TO gt_extab. 363 ELSE. 364 gw_button3 = pv_button3. 365 DELETE gt_extab WHERE fcode EQ 'BUTTON3'. 366 ENDIF. 367 * Activate / De-activate Button 4 368 IF pv_button4 IS INITIAL. 369 APPEND 'BUTTON4' TO gt_extab. 370 ELSE. 371 gw_button4 = pv_button4. 372 DELETE gt_extab WHERE fcode EQ 'BUTTON4'. 373 ENDIF. 374 * Activate / De-activate Button 5 375 IF pv_button5 IS INITIAL. 376 APPEND 'BUTTON5' TO gt_extab. 377 ELSE. 378 gw_button5 = pv_button5. 379 DELETE gt_extab WHERE fcode EQ 'BUTTON5'. 380 ENDIF. 381 382 * Activate / De-activate Button 6 if ALV header exceeds 25 lines 383 IF gv_header_lines LT cn_$alv_hd. 384 APPEND 'BUTTON6' TO gt_extab. 385 ELSE. 386 gv_show_bt6 = cn_$cross. 387 gw_button6-icon_id = '@7B@'. 388 gw_button6-icon_text = text-s20. 389 gw_button6-quickinfo = text-s20. 390 DELETE gt_extab WHERE fcode EQ 'BUTTON6'. 391 ENDIF. 392 393 * Force show Button6 to display selection parameters 394 IF gv_show_bt6 IS INITIAL. 395 APPEND 'BUTTON6' TO gt_extab. 396 ELSE. 397 gw_button6-icon_id = '@7B@'. 398 gw_button6-icon_text = 399 gw_button6-quickinfo = text-s20. 400 DELETE gt_extab WHERE fcode EQ 'BUTTON6'. 401 ENDIF. 402 403 SET PF-STATUS 'STANDARD' EXCLUDING gt_extab. 404 SET TITLEBAR 'TITLE' WITH pr_title . 405 406 407 ENDFORM. "PF_STATUS 408 409 *&---------------------------------------------------------------------* 410 *& Form frm_format_val 411 *&---------------------------------------------------------------------* 412 * Format values 413 *----------------------------------------------------------------------* 414 FORM frm_format_val USING pr_temp_sel TYPE ty_psel 415 pr_dtyp TYPE char4. 416 417 CASE pr_dtyp. 418 WHEN 'NUMC' OR 'INT1'. 419 IF NOT pr_temp_sel-low IS INITIAL. 420 pr_temp_sel-low = gv_char = gv_number = pr_temp_sel-low. 421 IF NOT gv_number IS INITIAL. 422 CONDENSE pr_temp_sel-low. 423 ENDIF. 424 ENDIF. 425 IF NOT pr_temp_sel-high IS INITIAL. 426 gv_char = gv_number = pr_temp_sel-high. 427 IF NOT gv_number IS INITIAL. 428 pr_temp_sel-high = gv_char. 429 CONDENSE pr_temp_sel-high. 430 ELSE. 431 CLEAR pr_temp_sel-high. 432 ENDIF. 433 ENDIF. 434 * Initialize lower range to zero if higher range is entered 435 IF pr_temp_sel-low EQ 0 AND 436 pr_temp_sel-high IS INITIAL. 437 CLEAR pr_temp_sel-low. 438 ENDIF. 439 WHEN 'DEC'. 440 * MOVE pr_temp_sel-low TO <fs> . 441 IF NOT pr_temp_sel-low IS INITIAL. " AND 442 * NOT pr_temp_sel-low = '0.00'. 443 gv_decimal = pr_temp_sel-low. 444 IF NOT gv_decimal IS INITIAL. 445 CONDENSE pr_temp_sel-low. 446 ENDIF. 447 ENDIF. 448 * MOVE pr_temp_sel-high TO <fs> . 449 * IF NOT <fs> IS INITIAL. 450 IF NOT pr_temp_sel-high IS INITIAL. " AND 451 * NOT pr_temp_sel-high = '0.00'. 452 gv_decimal = pr_temp_sel-high. 453 IF NOT gv_decimal IS INITIAL. 454 CONDENSE pr_temp_sel-high. 455 ELSE. 456 CLEAR pr_temp_sel-high. 457 ENDIF. 458 ENDIF. 459 WHEN 'DATE'. 460 IF NOT pr_temp_sel-low IS INITIAL. 461 datum = pr_temp_sel-low. 462 WRITE datum TO gv_date DD/MM/YYYY. 463 pr_temp_sel-low = gv_date. 464 ENDIF. 465 IF NOT pr_temp_sel-high IS INITIAL. 466 datum = pr_temp_sel-high. 467 IF NOT datum IS INITIAL. 468 WRITE datum TO gv_date DD/MM/YYYY. 469 pr_temp_sel-high = gv_date. 470 ELSE. 471 CLEAR pr_temp_sel-high. 472 ENDIF. 473 ENDIF. 474 * Initialize lower range to zero if higher range is entered 475 IF pr_temp_sel-low EQ cn_$null_dt AND 476 pr_temp_sel-high IS INITIAL. 477 CLEAR: pr_temp_sel-option, 478 pr_temp_sel-low. 479 ENDIF. 480 ENDCASE. 481 482 ENDFORM. " frm_format_val
7.完整的Function Module 内容:
1 FUNCTION ZCA_ALV_PRINT_SELECTION. 2 *"---------------------------------------------------------------------- 3 *"*"Local Interface: 4 *" IMPORTING 5 *" REFERENCE(REPID) TYPE REPID 6 *" REFERENCE(TITLE) TYPE SYTITLE OPTIONAL 7 *" REFERENCE(TFILL) TYPE CHAR8 OPTIONAL 8 *" REFERENCE(LOGO) TYPE CHAR30 OPTIONAL 9 *" REFERENCE(ALV_HEADER) TYPE FLAG DEFAULT 'X' 10 *" REFERENCE(TIMER_DATA) TYPE FLAG OPTIONAL 11 *" REFERENCE(PRINT_FLAG) TYPE FLAG OPTIONAL 12 *" REFERENCE(PARAM_FLAG) TYPE FLAG OPTIONAL 13 *" REFERENCE(DONT_SHOW_INITIAL) TYPE CHAR1 DEFAULT 'X' 14 *" REFERENCE(NO_CONF) TYPE XFELD OPTIONAL 15 *" EXPORTING 16 *" REFERENCE(DATABEG) TYPE BEGDA 17 *" REFERENCE(DATAEND) TYPE ENDDA 18 *" TABLES 19 *" T_SEL OPTIONAL 20 *" T_SEL_DYN OPTIONAL 21 *" T_HEADER OPTIONAL 22 *" T_HEADER_ADD OPTIONAL 23 *"---------------------------------------------------------------------- 24 25 gv_show_bt6 = param_flag. 26 DATA : 27 lv_entry TYPE textpooltx. 28 DATA: 29 lw_l_selctab TYPE rsscr, 30 lv_low TYPE char10, 31 lv_high TYPE char10, 32 lv_date_low TYPE sy-datum, 33 lv_date_high TYPE sy-datum. 34 35 * For preview and re-visit options 36 IF NOT gt_temp_sel[] IS INITIAL. 37 DESCRIBE TABLE gt_header LINES gv_header_lines. 38 IF gv_header_lines GT cn_$alv_hd AND NOT print_flag IS INITIAL. 39 CLEAR gt_prn_header[]. 40 LOOP AT gt_header INTO gw_line FROM 1 TO cn_$alv_hd. 41 APPEND gw_line TO gt_prn_header. 42 ENDLOOP. 43 CLEAR gw_line. 44 gw_line-typ = cn_types. "s 45 gw_line-info = text-s24. 46 APPEND gw_line TO gt_prn_header. 47 CLEAR gw_line. 48 CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' 49 EXPORTING 50 i_logo = logo 51 it_list_commentary = gt_prn_header. 52 ELSE. 53 CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' 54 EXPORTING 55 i_logo = logo 56 it_list_commentary = gt_header. 57 ENDIF. 58 EXIT. 59 ENDIF. 60 61 * Selection Screen values 62 CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS' 63 EXPORTING 64 curr_report = repid 65 TABLES 66 selection_table = gt_sel_tab 67 EXCEPTIONS 68 OTHERS = 0. 69 70 ** Program Selections 71 LOAD REPORT repid PART cn_part INTO gt_l_selctab. "SSCR 72 READ TEXTPOOL repid INTO gt_pg_txtpool LANGUAGE sy-langu . 73 LOOP AT gt_l_selctab. 74 CLEAR:gt_pg_txtpool. 75 READ TABLE gt_pg_txtpool WITH KEY id = cn_types 76 key = gt_l_selctab-name. 77 IF sy-subrc = 0. 78 lv_entry = gt_pg_txtpool-entry. 79 LOOP AT gt_sel_tab WHERE selname EQ gt_pg_txtpool-key. 80 gt_pg_txtpool-entry = lv_entry. 81 gt_temp_sel-slnam = gt_pg_txtpool-key. 82 IF gt_pg_txtpool-entry(1) = cn_typed."'D'. 83 PERFORM get_dd_text(rsdbspdd) USING gt_l_selctab 84 CHANGING gt_temp_sel-text. 85 ELSE. 86 SHIFT gt_pg_txtpool-entry BY 8 PLACES. 87 IF gt_pg_txtpool-entry = cn_entry. "'?...'. 88 gt_temp_sel-text = gt_sel_tab-selname. 89 ELSE. 90 gt_temp_sel-text = gt_pg_txtpool-entry. 91 ENDIF. 92 ENDIF. 93 94 CLEAR: lv_low,lv_high,lv_date_low,lv_date_high. 95 CASE gt_l_selctab-dtyp . 96 97 WHEN cn_dtype_d. "'DATE'. 98 gt_temp_sel-kind = gt_sel_tab-kind. 99 gt_temp_sel-sign = gt_sel_tab-sign. 100 gt_temp_sel-option = gt_sel_tab-option. 101 lv_date_low = gt_sel_tab-low. 102 IF lv_date_low CO '0 '. 103 gt_temp_sel-low = gt_sel_tab-low. 104 ELSE. 105 WRITE lv_date_low TO lv_low. 106 gt_temp_sel-low = lv_low. 107 ENDIF. 108 109 lv_date_high = gt_sel_tab-high. 110 IF lv_date_high CO '0 '. 111 ELSE. 112 WRITE lv_date_high TO lv_high. 113 gt_temp_sel-high = lv_high. 114 ENDIF. 115 WHEN cn_dtype_n . "'NUMC'. 116 gt_temp_sel-kind = gt_sel_tab-kind. 117 gt_temp_sel-sign = gt_sel_tab-sign. 118 gt_temp_sel-option = gt_sel_tab-option. 119 gt_temp_sel-low = gt_sel_tab-low. 120 121 IF gt_sel_tab-high CO '0 '. 122 ELSE. 123 gt_temp_sel-high = gt_sel_tab-high. 124 ENDIF. 125 126 WHEN OTHERS. 127 gt_temp_sel-kind = gt_sel_tab-kind. 128 gt_temp_sel-sign = gt_sel_tab-sign. 129 gt_temp_sel-option = gt_sel_tab-option. 130 gt_temp_sel-low = gt_sel_tab-low. 131 gt_temp_sel-high = gt_sel_tab-high. 132 ENDCASE. 133 134 CONDENSE: gt_temp_sel-text, 135 gt_temp_sel-low, 136 gt_temp_sel-high. 137 add_itab gt_temp_sel. 138 ENDLOOP. 139 ENDIF. 140 CLEAR:gt_l_selctab. 141 ENDLOOP. 142 143 144 * Prepare ALV Header, if required 145 PERFORM frm_prepare_header TABLES t_header_add 146 t_sel 147 t_sel_dyn 148 t_header 149 USING title repid tfill 150 logo alv_header dont_show_initial 151 no_conf. 152 databeg = gv_databeg. 153 dataend = gv_dataend. 154 155 156 ENDFUNCTION.
8.创建Include程序,用于Report:
1 *&---------------------------------------------------------------------* 2 *& Include ZCA_ALVTMP_T01 3 *&---------------------------------------------------------------------* 4 * Descripion: Include to display selection screen data in 5 * ALV grid/list output report headers 6 * Note: Should have logical database assigned to the main program 7 *&---------------------------------------------------------------------* 8 * Modify Log History. 9 *----------------------------------------------------------------------* 10 * 11 *No. Modified by Date Description 12 *--- ----------- ---- ----------- 13 *M1 14 *----------------------------------------------------------------------* 15 TYPE-POOLS:slis. 16 17 TYPES: 18 BEGIN OF ty_s_psel, 19 kind TYPE flag, 20 slnam TYPE char8, 21 text TYPE char255, 22 sign TYPE tvarv_sign, 23 option TYPE tvarv_opti, 24 low TYPE tvarv_val, 25 high TYPE tvarv_val, 26 END OF ty_s_psel. 27 28 *** Constant definition 29 CONSTANTS: 30 cn_cross TYPE flag VALUE 'X', 31 cn_zero_dt TYPE datum VALUE '00000000', 32 cn_header TYPE char30 VALUE 'FRM_PAGE_HEADER', 33 cn_ucomm TYPE char30 VALUE 'FRM_USER_COMMAND', 34 cn_stat TYPE char30 VALUE 'FRM_PF_STATUS', 35 cn_zero TYPE i VALUE 0, 36 cn_asterisk TYPE c VALUE '*', 37 cn_dash TYPE c VALUE '-', 38 cn_s_y TYPE string VALUE 'SY', 39 cn_p_rint TYPE string VALUE 'PRIN', 40 cn_prev TYPE string VALUE '&RNT_PREV' , 41 cn_line_typ_s TYPE string VALUE 'S', 42 cn_dot TYPE string VALUE '.', 43 cn_quantity TYPE string VALUE 'Q', 44 cn_currency TYPE string VALUE 'C', 45 cn_didtxt_l TYPE string VALUE 'L', 46 cn_save_a TYPE string VALUE 'A', 47 cn_topofpage TYPE string VALUE 'TOP_OF_PAGE', 48 cn_fr_pg_hd TYPE string VALUE 'FRM_PAGE_HEADER', 49 cn_endoflist TYPE string VALUE 'END_OF_LIST', 50 cn_fr_pg_ft TYPE string VALUE 'FRM_PAGE_FOOTER', 51 52 53 ** ALV Table Begin Tag Name, 54 * All that use this include must follow the pattern. 55 cn_alv_tab_beg_tag(14) TYPE c VALUE '*$BEG_GT_PRINT', 56 cn_alv_tab_end_tag(14) TYPE c VALUE '*$END_GT_PRINT', 57 58 cn_r01 TYPE string VALUE '([A-Za-z0-9_]+-[A-Za-z0-9_]+)', "#EC * 59 cn_r02 TYPE string VALUE '([^ ]+)([ ]+)TYPE', "#EC * 60 cn_r03 TYPE string VALUE '("........\|)', "#EC * 61 cn_r04 TYPE string VALUE '(\|.+\|)', "#EC * 62 cn_r05 TYPE string VALUE '(\|([CQ]_[A-Za-z0-9_]+)")'. "#EC * 63 64 *** varibale definition 65 DATA: 66 gv_repid TYPE syrepid, 67 gv_repid_scr TYPE syrepid, 68 gv_tfill TYPE char8, 69 gv_title TYPE sytitle, 70 gv_alv_header TYPE flag VALUE 'X', 71 gv_param_flag TYPE flag, 72 gv_print_flag TYPE flag, 73 gv_logo TYPE char30, 74 gv_ucomm TYPE slis_formname, 75 gv_noconf TYPE xfeld, 76 gv_noinitial TYPE char1 VALUE 'X', 77 gv_post_check TYPE char1. 78 79 80 81 82 83 *** work area and internal table definition 84 DATA: 85 gw_layout TYPE slis_layout_alv, 86 gt_fieldcat TYPE slis_t_fieldcat_alv, 87 gw_fieldcat TYPE slis_fieldcat_alv, 88 gt_sort TYPE slis_t_sortinfo_alv, 89 gw_sort TYPE slis_sortinfo_alv, 90 gt_events TYPE slis_t_event, 91 gw_events TYPE slis_alv_event, 92 gt_header TYPE slis_t_listheader, 93 gt_header_add TYPE TABLE OF ty_s_psel, 94 gt_pf_exclude TYPE slis_t_extab, 95 gw_pf_exclude TYPE slis_extab, 96 gw_variant TYPE disvariant, 97 gt_add_fieldcat TYPE slis_t_add_fieldcat, 98 gw_add_fieldcat TYPE slis_add_fieldcat. 99 100 DATA: 101 gw_button1 TYPE smp_dyntxt, 102 gw_button2 TYPE smp_dyntxt, 103 gw_button3 TYPE smp_dyntxt, 104 gw_button4 TYPE smp_dyntxt, 105 gw_button5 TYPE smp_dyntxt, 106 gv_variant TYPE variant. 107 108 *** Work area and internal table define for LVC moduel 109 DATA: 110 gv_lvc_mode TYPE char1 VALUE space, " 'X' - enabled 111 gw_lvc_layout TYPE lvc_s_layo, 112 gt_lvc_fcat TYPE STANDARD TABLE OF lvc_s_fcat, 113 gt_sort_lvc TYPE STANDARD TABLE OF lvc_s_sort, 114 gw_lvc_fcat TYPE lvc_s_fcat, 115 gw_lvc_sort TYPE lvc_s_sort, 116 gt_event_exit TYPE slis_t_event_exit. 117 118 119 *&---------------------------------------------------------------------* 120 *& Form FRM_CLEAR_VARIABLE 121 *&---------------------------------------------------------------------* 122 * Clear variable 123 *----------------------------------------------------------------------* 124 FORM frm_clear_variable . 125 126 CLEAR: gv_repid, 127 gv_repid_scr, 128 gv_tfill, 129 gv_title, 130 gv_param_flag, 131 gv_print_flag, 132 gv_logo, 133 gv_ucomm, 134 gv_noconf , 135 gw_variant, 136 gw_lvc_layout, 137 gv_alv_header, 138 gv_noinitial. 139 REFRESH: gt_header_add, 140 gt_sort_lvc. 141 142 ENDFORM. " FRM_CLEAR_VARIABLE 143 144 *&---------------------------------------------------------------------* 145 *& Form FRM_PAGE_HEADER 146 *&---------------------------------------------------------------------* 147 FORM frm_page_header. "#EC * 148 DATA : lv_repid TYPE syrepid, 149 lv_title TYPE sytitle. 150 * Check Print out complete. If complete, clear ucomm 151 IF sy-msgid EQ cn_s_y AND sy-ucomm EQ cn_p_rint. 152 CLEAR sy-ucomm. 153 ENDIF. 154 IF sy-ucomm EQ cn_prev OR sy-ucomm EQ cn_p_rint. 155 gv_print_flag = cn_cross. 156 ELSE. 157 CLEAR gv_print_flag. 158 ENDIF. 159 *** If you want to call Selection screen of some other program, 160 *** fill REPID_SCR. 161 IF gv_repid_scr IS INITIAL. 162 lv_repid = gv_repid. 163 ELSE. 164 lv_repid = gv_repid_scr. 165 ENDIF. 166 167 *** set different title IN ALV header 168 IF gv_title IS NOT INITIAL. 169 lv_title = gv_title. 170 ELSE. 171 lv_title = sy-title. 172 ENDIF. 173 174 *** set print header 175 176 CALL FUNCTION 'ZCA_ALV_PRINT_SELECTION' 177 EXPORTING 178 repid = lv_repid 179 title = lv_title 180 tfill = gv_tfill 181 logo = gv_logo 182 alv_header = gv_alv_header 183 timer_data = space 184 print_flag = gv_print_flag 185 param_flag = gv_param_flag 186 no_conf = gv_noconf 187 dont_show_initial = gv_noinitial 188 TABLES 189 t_header = gt_header 190 t_header_add = gt_header_add. 191 192 ENDFORM. " FRM_PAGE_HEADER 193 194 *&--------------------------------------------------------------------* 195 *& Form frm_page_footer 196 *&--------------------------------------------------------------------* 197 FORM frm_page_footer. "#EC called 198 199 DATA: lt_footer TYPE slis_t_listheader, 200 lw_line TYPE slis_listheader. 201 202 lw_line-typ = cn_line_typ_s. 203 lw_line-key = cn_dot. 204 lw_line-info = cn_dot. 205 APPEND lw_line TO lt_footer. 206 207 CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' 208 EXPORTING 209 it_list_commentary = lt_footer 210 i_end_of_list_grid = cn_cross. 211 212 ENDFORM. "frm_page_footer 213 *&--------------------------------------------------------------------* 214 *& Form frm_event_build 215 *&--------------------------------------------------------------------* 216 FORM frm_event_build. "#EC CALLED 217 218 gw_events-name = cn_topofpage. "'TOP_OF_PAGE'. 219 gw_events-form = cn_fr_pg_hd. "'FRM_PAGE_HEADER'. 220 APPEND gw_events TO gt_events. 221 * 222 gw_events-name = cn_endoflist. "'END_OF_LIST'. 223 gw_events-form = cn_fr_pg_ft. "'FRM_PAGE_FOOTER'. 224 APPEND gw_events TO gt_events. 225 * 226 ENDFORM. "frm_event_build 227 *&--------------------------------------------------------------------* 228 *& Form frm_pf_status 229 *&--------------------------------------------------------------------* 230 FORM frm_pf_status USING pr_t_extab TYPE slis_t_extab. "#EC * 231 232 DATA: 233 lv_title TYPE sytitle. 234 235 *** exclud button 236 pr_t_extab = gt_pf_exclude. 237 238 *** set different title in title bar 239 IF gv_title IS NOT INITIAL. 240 lv_title = gv_title. 241 ELSE. 242 lv_title = sy-title. 243 ENDIF. 244 245 *** set PF-STATUS and TITLE BAR 246 PERFORM frm_pf_status IN PROGRAM saplzca_alv_print_selection IF FOUND 247 USING gw_button1 248 gw_button2 249 gw_button3 250 gw_button4 251 gw_button5 252 pr_t_extab 253 lv_title. 254 255 256 ENDFORM. "PF_STATUS 257 258 *&---------------------------------------------------------------------* 259 *& Form FRM_RETRIEVE_FIELDS 260 *&---------------------------------------------------------------------* 261 * Build Field Catalog 262 *----------------------------------------------------------------------* 263 * -->LC_ALV_TAB_NAME ALV Table Tag Name 264 *----------------------------------------------------------------------* 265 FORM frm_retrieve_fields USING pr_alv_tab_name TYPE string. 266 DATA: 267 * Match offset 268 lv_moff TYPE sy-tabix, 269 * Match Length 270 lv_mlen TYPE sy-tabix, 271 * Table definition start index 272 lv_alv_beg_tabix TYPE sy-tabix, 273 * Table definition end index 274 lv_alv_end_tabix TYPE sy-tabix. 275 *** For field catalog 276 DATA: 277 lt_source TYPE TABLE OF prk_source. 278 279 DATA: 280 lw_source TYPE prk_source. 281 282 READ REPORT sy-repid INTO lt_source. "#EC * 283 LOOP AT lt_source INTO lw_source WHERE LINE = cn_alv_tab_beg_tag OR 284 LINE = cn_alv_tab_end_tag. 285 IF lw_source-line = cn_alv_tab_beg_tag. 286 lv_alv_beg_tabix = sy-tabix. 287 ELSEIF lw_source-line = cn_alv_tab_end_tag. 288 lv_alv_end_tabix = sy-tabix. 289 ENDIF. 290 ENDLOOP. 291 292 lv_alv_beg_tabix = lv_alv_beg_tabix + 1. 293 lv_alv_end_tabix = lv_alv_end_tabix - 1. 294 295 REFRESH gt_fieldcat. 296 LOOP AT lt_source INTO lw_source FROM lv_alv_beg_tabix 297 TO lv_alv_end_tabix. 298 * Avoid Comment parsing 299 IF lw_source-line(1) NE cn_asterisk. 300 301 *********************************************************************** 302 * Change all before " to Upper Case 303 *********************************************************************** 304 FIND FIRST OCCURRENCE OF '"' IN lw_source-line 305 MATCH OFFSET lv_moff. 306 IF sy-subrc = 0. 307 TRANSLATE lw_source-line(lv_moff) TO UPPER CASE. 308 ENDIF. 309 310 CLEAR gw_fieldcat. 311 312 gw_fieldcat-qtabname = 313 gw_fieldcat-ctabname = 314 gw_fieldcat-tabname = pr_alv_tab_name. 315 316 *********************************************************************** 317 * Find 2 Words Connected by dash 318 *********************************************************************** 319 FIND REGEX cn_r01 IN lw_source-line 320 MATCH OFFSET lv_moff 321 MATCH LENGTH lv_mlen. 322 IF sy-subrc = cn_zero. 323 SPLIT lw_source-line+lv_moff(lv_mlen) AT cn_dash 324 INTO gw_fieldcat-ref_tabname 325 gw_fieldcat-ref_fieldname. 326 ENDIF. 327 *********************************************************************** 328 * Find field name before the word TYPE 329 *********************************************************************** 330 FIND REGEX cn_r02 IN lw_source-line 331 MATCH OFFSET lv_moff 332 MATCH LENGTH lv_mlen. 333 334 IF sy-subrc = cn_zero. 335 * Exclude the word 'TYPE' 4 characters 336 lv_mlen = lv_mlen - 4. 337 gw_fieldcat-fieldname = lw_source-line+lv_moff(lv_mlen). 338 CONDENSE gw_fieldcat-fieldname. 339 ENDIF. 340 *********************************************************************** 341 * Find 5 digit of single character fields 342 *********************************************************************** 343 FIND REGEX cn_r03 IN lw_source-line 344 MATCH OFFSET lv_moff 345 MATCH LENGTH lv_mlen. 346 347 IF sy-subrc = cn_zero. 348 * Exclude the " and | 349 lv_moff = lv_moff + 1. 350 gw_fieldcat-just = lw_source-line+lv_moff. 351 352 lv_moff = lv_moff + 1. 353 gw_fieldcat-no_zero = lw_source-line+lv_moff. 354 355 lv_moff = lv_moff + 1. 356 gw_fieldcat-edit = lw_source-line+lv_moff. 357 358 lv_moff = lv_moff + 1. 359 gw_fieldcat-do_sum = lw_source-line+lv_moff. 360 361 lv_moff = lv_moff + 1. 362 gw_fieldcat-no_out = lw_source-line+lv_moff. 363 364 lv_moff = lv_moff + 1. 365 gw_fieldcat-fix_column = 366 gw_fieldcat-key = lw_source-line+lv_moff. 367 368 lv_moff = lv_moff + 1. 369 gw_fieldcat-icon = lw_source-line+lv_moff. 370 371 lv_moff = lv_moff + 1. 372 gw_fieldcat-lowercase = lw_source-line+lv_moff. 373 374 ENDIF. 375 376 *********************************************************************** 377 * Find Description 378 *********************************************************************** 379 FIND REGEX cn_r04 IN lw_source-line 380 MATCH OFFSET lv_moff 381 MATCH LENGTH lv_mlen. 382 383 IF sy-subrc = cn_zero. 384 * Exclude the front | and | 385 lv_moff = lv_moff + 1. 386 lv_mlen = lv_mlen - 2. 387 388 gw_fieldcat-seltext_s = gw_fieldcat-seltext_m = 389 gw_fieldcat-seltext_l = gw_fieldcat-reptext_ddic = 390 lw_source-line+lv_moff(lv_mlen). 391 gw_fieldcat-ddictxt = cn_didtxt_l. " 'L' 392 CONDENSE: gw_fieldcat-seltext_m, gw_fieldcat-seltext_l, 393 gw_fieldcat-seltext_s. 394 ENDIF. 395 396 *********************************************************************** 397 * Find Quantity or Currency Reference 398 *********************************************************************** 399 FIND REGEX cn_r05 IN lw_source-line 400 MATCH OFFSET lv_moff 401 MATCH LENGTH lv_mlen. 402 403 IF sy-subrc = cn_zero. 404 * Exclude the | and " 405 lv_moff = lv_moff + 1. 406 lv_mlen = lv_mlen - 4. 407 408 IF lw_source-line+lv_moff(1) EQ cn_quantity. "'Q'. 409 lv_moff = lv_moff + 2. 410 gw_fieldcat-qfieldname = lw_source-line+lv_moff(lv_mlen). 411 ELSEIF lw_source-line+lv_moff(1) EQ cn_currency. "'C'. 412 lv_moff = lv_moff + 2. 413 gw_fieldcat-cfieldname = lw_source-line+lv_moff(lv_mlen). 414 ENDIF. 415 ENDIF. 416 417 ENDIF. 418 APPEND gw_fieldcat TO gt_fieldcat. 419 CLEAR: gw_fieldcat. 420 ENDLOOP. 421 422 *** Build LVC field catlog 423 IF gv_lvc_mode = cn_cross. 424 425 CLEAR gw_fieldcat. 426 LOOP AT gt_fieldcat INTO gw_fieldcat. 427 428 MOVE-CORRESPONDING gw_fieldcat TO gw_lvc_fcat. "#EC * 429 430 MOVE: 431 gw_fieldcat-seltext_l TO gw_lvc_fcat-seltext, 432 gw_fieldcat-seltext_l TO gw_lvc_fcat-coltext, 433 gw_fieldcat-ref_fieldname TO gw_lvc_fcat-ref_field, 434 gw_fieldcat-ref_tabname TO gw_lvc_fcat-ref_table 435 . 436 437 APPEND gw_lvc_fcat TO gt_lvc_fcat. 438 CLEAR: 439 gw_fieldcat,gw_lvc_fcat. 440 ENDLOOP. 441 442 ENDIF. 443 444 ENDFORM. " FRM_RETRIEVE_FIELDS "#EC * 445 *&---------------------------------------------------------------------* 446 *& Form frm_show_alv_rep 447 *&---------------------------------------------------------------------* 448 * Show ALV Report 449 *** T_DATA is the data 450 *** layout is the layout 451 *** field is the field catalog 452 *----------------------------------------------------------------------* 453 FORM frm_show_alv_rep TABLES pr_t_data. "#EC called 454 *COLL_TOP_P 455 DATA : lw_grid_set TYPE lvc_s_glay, 456 lv_save TYPE char1, 457 lv_header TYPE char30. 458 459 DESCRIBE TABLE pr_t_data LINES gv_tfill. 460 CHECK gv_tfill > 0. 461 462 gv_repid = sy-repid. 463 *** Variant 464 IF NOT gw_variant IS INITIAL. 465 lv_save = cn_save_a. " 'A'. 466 ELSE. 467 CLEAR: lv_save. 468 gw_variant-report = sy-repid. 469 ENDIF. 470 * grid_set-coll_top_p = '1'. 471 IF gv_ucomm IS INITIAL. 472 IF NOT gw_button1 IS INITIAL OR 473 NOT gw_button2 IS INITIAL OR 474 NOT gw_button3 IS INITIAL OR 475 NOT gw_button4 IS INITIAL OR 476 NOT gw_button5 IS INITIAL. 477 gv_ucomm = cn_ucomm. 478 ENDIF. 479 ENDIF. 480 481 IF gv_lvc_mode = cn_cross. " LVC mode 482 483 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' 484 EXPORTING 485 * I_INTERFACE_CHECK = ' ' 486 * I_BYPASSING_BUFFER = I_BYPASSING_BUFFER 487 * I_BUFFER_ACTIVE = I_BUFFER_ACTIVE 488 i_callback_program = gv_repid 489 i_callback_pf_status_set = cn_stat 490 i_callback_user_command = gv_ucomm 491 i_callback_top_of_page = cn_header 492 * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' 493 * I_CALLBACK_HTML_END_OF_LIST = ' ' 494 * I_STRUCTURE_NAME = I_STRUCTURE_NAME 495 * I_BACKGROUND_ID = ' ' 496 * I_GRID_TITLE = I_GRID_TITLE 497 * I_GRID_SETTINGS = I_GRID_SETTINGS 498 is_layout_lvc = gw_lvc_layout 499 it_fieldcat_lvc = gt_lvc_fcat 500 it_excluding = gt_pf_exclude 501 * IT_SPECIAL_GROUPS_LVC = IT_SPECIAL_GROUPS_LVC 502 it_sort_lvc = gt_sort_lvc 503 * IT_FILTER_LVC = IT_FILTER_LVC 504 * IT_HYPERLINK = IT_HYPERLINK 505 * IS_SEL_HIDE = IS_SEL_HIDE 506 * I_DEFAULT = 'X' 507 i_save = lv_save 508 is_variant = gw_variant 509 it_events = gt_events 510 it_event_exit = gt_event_exit 511 * IS_PRINT_LVC = IS_PRINT_LVC 512 * IS_REPREP_ID_LVC = IS_REPREP_ID_LVC 513 * I_SCREEN_START_COLUMN = 0 514 * I_SCREEN_START_LINE = 0 515 * I_SCREEN_END_COLUMN = 0 516 * I_SCREEN_END_LINE = 0 517 i_html_height_top = '91' 518 * I_HTML_HEIGHT_END = I_HTML_HEIGHT_END 519 * IT_ALV_GRAPHICS = IT_ALV_GRAPHICS 520 * IT_EXCEPT_QINFO_LVC = IT_EXCEPT_QINFO_LVC 521 * IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER 522 TABLES 523 t_outtab = pr_t_data 524 EXCEPTIONS 525 program_error = 1 526 OTHERS = 2. 527 528 IF sy-subrc = 0. 529 * Call function successful 530 ENDIF. 531 532 ELSE. 533 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' 534 EXPORTING 535 i_callback_program = gv_repid 536 * i_callback_top_of_page = cn_header "l_header 537 i_callback_user_command = gv_ucomm 538 i_callback_pf_status_set = cn_stat 539 it_events = gt_events 540 it_event_exit = gt_event_exit 541 * i_grid_settings = grid_set 542 is_layout = gw_layout 543 it_fieldcat = gt_fieldcat 544 it_sort = gt_sort 545 * i_default = l_default 546 is_variant = gw_variant 547 i_save = lv_save 548 it_excluding = gt_pf_exclude 549 * i_html_height_top = '91' 550 it_add_fieldcat = gt_add_fieldcat 551 TABLES 552 t_outtab = pr_t_data 553 EXCEPTIONS 554 OTHERS = 0. 555 556 ENDIF. 557 558 ENDFORM. "frm_show_alv_rep