Saving data in the SO10 text or standard text and moving it to Quality and Production is a common requirement. To achieve this we have to perform 2 steps
Step – 1 Create the SO10 text
Step – 2 Capture it in a customizing transport request using the program RSTXTRAN.
Since capturing text in the transport is a manual process and sometimes missed by the developer, hence missed to move the updated or new text to further systems.
To overcome the above problem, we can do the Enhancement in the standard program so that it will ask for a transport request as soon as you create or change a SO10 text. This would start working similar to a report program except that it will be a Customizing request.
Program LSTXXFTE -> Sub routine TE_SAVE_TEXT
Source Code Snippet of the Implicit Enhancement which will go at the end of sub routine TE_SAVE_TEXT
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 |
ENHANCEMENT 1 ZIE_SO10TRSAVE. "active version DATA : lo_utlities TYPE REF TO zcl_utilities_so10, lw_input TYPE zsavetextinput, l_message TYPE string, l_trnsprt TYPE strkorr. CONSTANTS: c_comma(1) TYPE c VALUE ',', c_s(1) TYPE c VALUE 'S'. FIELD-SYMBOLS: <fs_any> TYPE any. "Get instance lo_utlities = zcl_utilities_so10=>factory( ). IF lo_utlities IS BOUND. "Fill input for request lw_input-tdname = tename. lw_input-tdid = teid. lw_input-tdspras = tespras. CALL METHOD lo_utlities->save_standradtext EXPORTING is_input = lw_input IMPORTING e_task = l_trnsprt. IF l_trnsprt IS NOT INITIAL. CONCATENATE 'Text' tename 'language' tespras 'saved in' l_trnsprt 'Transport' INTO l_message SEPARATED BY space. MESSAGE l_message TYPE c_s. ENDIF. ENDIF. ENDENHANCEMENT. |
Now create the class zcl_utilities_so10
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 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
CLASS zcl_utilities_so10 DEFINITION PUBLIC FINAL CREATE PRIVATE. PUBLIC SECTION. CLASS-METHODS factory RETURNING VALUE(rt_ref) TYPE REF TO zcl_utilities_so10. METHODS save_standradtext IMPORTING !is_input TYPE zsavetextinput RETURNING VALUE(lo_output) type ref TO sy-subrc. PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. CLASS zcl_utilities_so10 IMPLEMENTATION. METHOD factory. CREATE OBJECT rt_Ref. IF rt_ref IS BOUND. ENDIF. ENDMETHOD. METHOD save_standradtext. DATA: l_tr_order_zz TYPE e070-trkorr, l_tr_task_zz TYPE e070-trkorr, l_name TYPE e071-obj_name, l_answer(1) TYPE c, l_text1 TYPE string, l_text2 TYPE string, l_textkey_zz(110), l_len_zz TYPE i. DATA: lt_e071_zz TYPE TABLE OF e071, lt_e071k_zz TYPE TABLE OF e071k, lw_e071_zz TYPE e071, lw_e071k_zz TYPE e071k. FIELD-SYMBOLS: <fs_zz> TYPE any. "Clear the exporting variable CLEAR: e_task. "Prepare object Name CONCATENATE c_text is_input-tdname is_input-tdid is_input-tdspras INTO l_name SEPARATED BY c_comma. "Check if the TEXT is locked in any existing unreleased TR SELECT a~trkorr, b~strkorr, b~as4user, c~as4text FROM e071 AS a INNER JOIN e070 AS b ON a~trkorr EQ b~trkorr INNER JOIN e07t AS c ON a~trkorr EQ c~trkorr INTO TABLE @DATA(lt_temp) WHERE trstatus EQ @c_d AND obj_name EQ @l_name. IF sy-subrc EQ 0. "Check if the owner of Task in which the TEXT is locked is "current user READ TABLE lt_temp INTO DATA(lw_temp) WITH KEY as4user = sy-uname. IF sy-subrc EQ 0. lw_e071_zz-obj_name = l_name. lw_e071_zz-trkorr = lw_temp-trkorr. lw_e071_zz-as4pos = 0. lw_e071_zz-pgmid = c_r3tr. lw_e071_zz-object = c_text. APPEND lw_e071_zz TO lt_e071_zz. "Save the changes in the above found Task CALL FUNCTION 'TR_APPEND_TO_COMM_OBJS_KEYS' EXPORTING wi_trkorr = lw_temp-trkorr TABLES wt_e071 = lt_e071_zz wt_e071k = lt_e071k_zz EXCEPTIONS error_message = 99. IF sy-subrc = 0. e_task = lw_temp-strkorr. ENDIF. ELSE. "Current user in not the owner of the Task in which "this TEXT is saved READ TABLE lt_temp INTO DATA(lw_temp_1) INDEX 1. IF sy-subrc EQ 0. "Check if current user has any Task in the TR in which this "TEXT is saved SELECT a~trkorr, b~strkorr, b~as4user, c~as4text FROM e071 AS a INNER JOIN e070 AS b ON a~trkorr EQ b~trkorr INNER JOIN e07t AS c ON a~trkorr EQ c~trkorr INTO TABLE @DATA(lt_task) WHERE trfunction EQ @c_q AND trstatus EQ @c_d AND as4user EQ @sy-uname AND strkorr EQ @lw_temp_1-strkorr. IF sy-subrc EQ 0. "Current user has a Task in the TR, lets save the changes "in this Task READ TABLE lt_task INTO DATA(lw_task) INDEX 1. IF sy-subrc EQ 0. CONCATENATE TEXT-003 lw_task-trkorr INTO l_text1 SEPARATED BY space. CONCATENATE lw_task-as4user lw_task-as4text INTO l_text2 SEPARATED BY space. CALL FUNCTION 'POPUP_TO_DECIDE_INFO' EXPORTING textline1 = l_text1 textline2 = l_text2 titel = TEXT-002 IMPORTING answer = l_answer. IF l_answer EQ c_j. lw_e071_zz-obj_name = l_name. lw_e071_zz-trkorr = lw_task-trkorr. lw_e071_zz-as4pos = 0. lw_e071_zz-pgmid = c_r3tr. lw_e071_zz-object = c_text. APPEND lw_e071_zz TO lt_e071_zz. CALL FUNCTION 'TR_APPEND_TO_COMM_OBJS_KEYS' EXPORTING wi_trkorr = lw_task-trkorr TABLES wt_e071 = lt_e071_zz wt_e071k = lt_e071k_zz EXCEPTIONS error_message = 99. IF sy-subrc = 0. e_task = lw_temp_1-strkorr. ENDIF. ENDIF. ENDIF. ELSE. "Current user does not has any Task in the TR in which "this TEXT is saved CONCATENATE TEXT-001 lw_temp_1-strkorr INTO l_text1 SEPARATED BY space. CONCATENATE lw_temp_1-as4user lw_temp_1-as4text INTO l_text2 SEPARATED BY space. CALL FUNCTION 'POPUP_TO_DECIDE_INFO' EXPORTING textline1 = l_text1 textline2 = l_text2 titel = TEXT-002 IMPORTING answer = l_answer. IF l_answer EQ c_j. "Create new Task in the existing TR CALL FUNCTION 'TRINT_INSERT_NEW_COMM' EXPORTING wi_kurztext = lw_temp_1-as4text wi_trfunction = c_q iv_username = sy-uname wi_strkorr = lw_temp_1-strkorr IMPORTING we_trkorr = l_tr_task_zz EXCEPTIONS no_systemname = 1 no_systemtype = 2 no_authorization = 3 db_access_error = 4 file_access_error = 5 enqueue_error = 6 number_range_full = 7 invalid_input = 8 OTHERS = 9. IF sy-subrc EQ 0. lw_e071_zz-obj_name = l_name. lw_e071_zz-trkorr = l_tr_task_zz. lw_e071_zz-as4pos = 0. lw_e071_zz-pgmid = c_r3tr. lw_e071_zz-object = c_text. APPEND lw_e071_zz TO lt_e071_zz. "Save the changes in the above created Task CALL FUNCTION 'TR_APPEND_TO_COMM_OBJS_KEYS' EXPORTING wi_trkorr = l_tr_task_zz TABLES wt_e071 = lt_e071_zz wt_e071k = lt_e071k_zz EXCEPTIONS error_message = 99. IF sy-subrc = 0. e_task = lw_temp_1-strkorr. ENDIF. ENDIF. ENDIF. ENDIF. ENDIF. ENDIF. ELSE. CALL FUNCTION 'TR_ORDER_CHOICE_CORRECTION' EXPORTING iv_category = c_cust iv_cli_dep = c_x IMPORTING ev_order = l_tr_order_zz ev_task = l_tr_task_zz EXCEPTIONS no_correction_selected = 1. IF sy-subrc = 0. l_textkey_zz = c_trdata. REPLACE c_symbol WITH c_text INTO l_textkey_zz. REPLACE c_symbol WITH is_input-tdid INTO l_textkey_zz. REPLACE c_symbol WITH is_input-tdspras INTO l_textkey_zz. CONDENSE l_textkey_zz NO-GAPS. l_len_zz = strlen( is_input-tdname ). ASSIGN is_input-tdname(l_len_zz) TO <fs_zz>. REPLACE c_symbol1 WITH <fs_zz> INTO l_textkey_zz. lw_e071_zz-obj_name = l_textkey_zz. lw_e071_zz-trkorr = l_tr_task_zz. lw_e071_zz-as4pos = 0. lw_e071_zz-pgmid = c_r3tr. lw_e071_zz-object = c_text. APPEND lw_e071_zz TO lt_e071_zz. CALL FUNCTION 'TR_APPEND_TO_COMM_OBJS_KEYS' EXPORTING wi_trkorr = l_tr_task_zz TABLES wt_e071 = lt_e071_zz wt_e071k = lt_e071k_zz EXCEPTIONS error_message = 99. IF sy-subrc = 0. * GET REFERENCE OF sy-subrc INTO lo_output. e_task = l_tr_order_zz. ENDIF. ENDIF. ENDIF. ENDMETHOD. ENDCLASS. |
You have successfully completed this automation.