1,简介
Search Help Exit是对标准F4功能进行的扩充,是一个出口function,
2,创建exit function
ZTEST_F4_EXIT拷贝自系统标准function F4IF_SHLP_EXIT_EXAMPLE.
SE37
输入输出参数含义:
Changing:
SHLP 搜索帮助描述
CALLCONTROL 具有搜索帮助出口的 F4 处理控制结构
Tables:
SHLP_TAB 替代基本搜索帮助的清单
RECORD_TAB 搜索帮助的结果表
3,代码
通常,代码是在CALLCONTROL-STEP = 'DISP'后加的,
例子:针对某人只显示特定工厂下的物料,代码在DISP后,工厂代码通过偏移量+长度定位
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 |
DATA:lwa_tmp LIKE LINE OF record_tab, lt_tmp LIKE STANDARD TABLE OF record_tab. * EXIT immediately, if you do not want to handle this step IF callcontrol-step <> 'SELONE' AND callcontrol-step <> 'SELECT' AND " AND SO ON callcontrol-step <> 'DISP'. EXIT. ENDIF. *"---------------------------------------------------------------------- * STEP SELONE (Select one of the elementary searchhelps) *"---------------------------------------------------------------------- * This step is only called for collective searchhelps. It may be used * to reduce the amount of elementary searchhelps given in SHLP_TAB. * The compound searchhelp is given in SHLP. * If you do not change CALLCONTROL-STEP, the next step is the * dialog, to select one of the elementary searchhelps. * If you want to skip this dialog, you have to return the selected * elementary searchhelp in SHLP and to change CALLCONTROL-STEP to * either to 'PRESEL' or to 'SELECT'. IF callcontrol-step = 'SELONE'. * PERFORM SELONE ......... EXIT. ENDIF. *"---------------------------------------------------------------------- * STEP PRESEL (Enter selection conditions) *"---------------------------------------------------------------------- * This step allows you, to influence the selection conditions either * before they are displayed or in order to skip the dialog completely. * If you want to skip the dialog, you should change CALLCONTROL-STEP * to 'SELECT'. * Normaly only SHLP-SELOPT should be changed in this step. IF callcontrol-step = 'PRESEL'. * PERFORM PRESEL .......... EXIT. ENDIF. *"---------------------------------------------------------------------- * STEP SELECT (Select values) *"---------------------------------------------------------------------- * This step may be used to overtake the data selection completely. * To skip the standard seletion, you should return 'DISP' as following * step in CALLCONTROL-STEP. * Normally RECORD_TAB should be filled after this step. * Standard function module F4UT_RESULTS_MAP may be very helpfull in this * step. IF callcontrol-step = 'SELECT'. * PERFORM STEP_SELECT TABLES RECORD_TAB SHLP_TAB * CHANGING SHLP CALLCONTROL RC. * IF RC = 0. * CALLCONTROL-STEP = 'DISP'. * ELSE. * CALLCONTROL-STEP = 'EXIT'. * ENDIF. EXIT. "Don't process STEP DISP additionally in this call. ENDIF. *"---------------------------------------------------------------------- * STEP DISP (Display values) *"---------------------------------------------------------------------- * This step is called, before the selected data is displayed. * You can e.g. modify or reduce the data in RECORD_TAB * according to the users authority. * If you want to get the standard display dialog afterwards, you * should not change CALLCONTROL-STEP. * If you want to overtake the dialog on you own, you must return * the following values in CALLCONTROL-STEP: * - "RETURN" if one line was selected. The selected line must be * the only record left in RECORD_TAB. The corresponding fields of * this line are entered into the screen. * - "EXIT" if the values request should be aborted * - "PRESEL" if you want to return to the selection dialog * Standard function modules F4UT_PARAMETER_VALUE_GET and * F4UT_PARAMETER_RESULTS_PUT may be very helpfull in this step. IF callcontrol-step = 'DISP'. * PERFORM AUTHORITY_CHECK TABLES RECORD_TAB SHLP_TAB * CHANGING SHLP CALLCONTROL. IF sy-uname = 'XXXX'. LOOP AT record_tab INTO lwa_tmp WHERE string+21(4) = '3100'. APPEND lwa_tmp TO lt_tmp. ENDLOOP. record_tab[] = lt_tmp[]. ENDIF. EXIT. ENDIF. |
4,测试
效果如下,只显示3100的物料
以上,
发表评论