1 REPORT y4_b4_test40. 2 TYPE-POOLS:vrm. 3 4 DATA: name TYPE vrm_id. 5 DATA:num TYPE i. "内表判断字段长度的变量 6 7 TYPES: BEGIN OF wa , 8 key(40), 9 text(80) TYPE c, 10 END OF wa. 11 12 DATA:gt LIKE t179t OCCURS 0 WITH HEADER LINE. 13 DATA:wa1 TYPE TABLE OF wa WITH HEADER LINE. "111 14 DATA:wa2 TYPE TABLE OF wa WITH HEADER LINE . "111222 15 DATA:wa3 TYPE TABLE OF wa WITH HEADER LINE. "111222333 16 17 DATA:itab LIKE t179t OCCURS 0 WITH HEADER LINE. 18 19 DATA: ps_t(15) TYPE c. 20 21 SELECTION-SCREEN BEGIN OF BLOCK t1 WITH FRAME TITLE title1. 22 23 SELECTION-SCREEN BEGIN OF LINE. 24 25 SELECTION-SCREEN COMMENT 1(31) TEXT-003. 26 27 PARAMETERS: pl1 LIKE ps_t AS LISTBOX VISIBLE LENGTH 15 USER-COMMAND p1 ."一级类 28 29 SELECTION-SCREEN END OF LINE. 30 31 SELECTION-SCREEN SKIP 1. 32 33 SELECTION-SCREEN BEGIN OF LINE. 34 35 SELECTION-SCREEN COMMENT 1(31) TEXT-004. 36 37 PARAMETERS: pl2 LIKE ps_t AS LISTBOX VISIBLE LENGTH 15 USER-COMMAND p2."二级类 38 39 SELECTION-SCREEN END OF LINE. 40 41 SELECTION-SCREEN SKIP 1. 42 43 SELECTION-SCREEN BEGIN OF LINE. 44 45 SELECTION-SCREEN COMMENT 1(31) TEXT-005. 46 47 PARAMETERS: pl3 LIKE ps_t AS LISTBOX VISIBLE LENGTH 15."三级类 48 49 SELECTION-SCREEN END OF LINE. 50 51 SELECTION-SCREEN SKIP 1. 52 53 SELECTION-SCREEN END OF BLOCK t1. 54 55 INITIALIZATION. 56 57 gt-vtext = '1'. 58 gt-prodh = 'YI111'. 59 APPEND gt . 60 gt-vtext = '1'. 61 gt-prodh = 'YI222'. 62 APPEND gt . 63 gt-vtext = '1'. 64 gt-prodh = 'YI11145678'. 65 APPEND gt . 66 gt-vtext = '1'. 67 gt-prodh = 'YI11198765'. 68 APPEND gt . 69 gt-vtext = '1'. 70 gt-prodh = 'YI11112345'. 71 APPEND gt . 72 gt-vtext = '1'. 73 gt-prodh = 'YI11156789'. 74 APPEND gt . 75 gt-vtext = '1'. 76 gt-prodh = 'YI1114567812345678'. 77 APPEND gt . 78 gt-vtext = '1'. 79 gt-prodh = 'YI1114567887654321'. 80 APPEND gt . 81 gt-vtext = '1'. 82 gt-prodh = 'YI1115678123456789'. 83 APPEND gt . 84 gt-vtext = '1'. 85 gt-prodh = 'YI1115678987654321'. 86 APPEND gt . 87 88 AT SELECTION-SCREEN OUTPUT. 89 90 CLEAR:wa1,wa1[]. 91 92 name = 'PL1'. 93 94 LOOP AT gt. 95 96 num = strlen( gt-prodh ). 97 98 IF num = 5. 99 100 wa1-text = gt-vtext. 101 102 wa1-key = gt-prodh. 103 104 APPEND: wa1. 105 106 ENDIF. 107 108 CLEAR: gt,num,wa1. 109 110 ENDLOOP. 111 112 CALL FUNCTION 'VRM_SET_VALUES' 113 EXPORTING 114 id = name 115 values = wa1[]. 116 117 AT SELECTION-SCREEN. 118 119 CASE sy-ucomm. 120 121 WHEN 'P1'. 122 123 CLEAR: pl2,pl3. "清空2、3级下拉空默认值,当用户在选择屏幕上重新选择时需要清除 124 125 CLEAR:wa2,wa2[]. "清空2级下拉内表对应的值,当用户在选择屏幕上重新选择时需要清除 126 127 CLEAR num. 128 129 LOOP AT gt . 130 131 num = strlen( gt-prodh ). 132 133 IF num = 10 AND gt-prodh+0(5) = pl1. 134 135 wa2-text = gt-vtext. 136 137 wa2-key = gt-prodh. 138 139 APPEND: wa2. 140 141 ENDIF. 142 143 CLEAR:gt,num,wa2. 144 145 ENDLOOP. 146 147 CALL FUNCTION 'VRM_SET_VALUES' 148 EXPORTING 149 id = 'PL2' 150 values = wa2[]. 151 152 CLEAR pl2. 153 154 WHEN 'P2'. 155 156 CLEAR pl3. "清空3级下拉空默认值,当用户在选择屏幕上重新选择时需要清除 157 158 CLEAR:wa3,wa3[]. "清空3级下拉内表对应的值,当用户在选择屏幕上重新选择时需要清除 159 160 CLEAR num. 161 162 LOOP AT gt . 163 164 num = strlen( gt-prodh ). 165 166 IF num = 18 AND gt-prodh+0(10) = pl2. 167 168 wa3-text = gt-vtext. 169 170 wa3-key = gt-prodh. 171 172 APPEND: wa3. 173 174 ENDIF. 175 176 CLEAR:gt,num,wa3. 177 178 ENDLOOP. 179 180 CALL FUNCTION 'VRM_SET_VALUES' 181 EXPORTING 182 id = 'PL3' 183 values = wa3[]. 184 185 CLEAR pl3. 186 187 ENDCASE.标签:gt,SCREEN,prodh,ABAP,SELECTION,vtext,动态,下拉框,APPEND From: https://www.cnblogs.com/TigerMan/p/16733223.html