下面介绍一个小程序,能翻译message中的文本,不用通过SE91.
程序选择画面:
通过此程序翻译的内容需要手工通过tcode slxt手动包到传输请求(TR)中-->参照使用SLXT传输翻译文本
完整代码:
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 |
REPORT z_copy_msg. * Thanks a lot for Dylan's effort! DATA: lit_t100_s TYPE TABLE OF t100, lit_t100_t TYPE TABLE OF t100, lit_t100_u TYPE TABLE OF t100, lit_t002 TYPE TABLE OF t002, lwa_t002 TYPE t002, lwa_t100 TYPE t100. DATA: l_object TYPE doku_obj, lit_lines TYPE TABLE OF tline, lwa_head TYPE thead. TABLES: t002. SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002 . PARAMETERS: p_rb1 RADIOBUTTON GROUP gp1, p_rb2 RADIOBUTTON GROUP gp1. SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 . PARAMETERS: p_text TYPE natxt. SELECTION-SCREEN END OF BLOCK b1. SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE text-004 . PARAMETERS: p_arbgb2 TYPE arbgb. PARAMETERS: p_msgnr2 TYPE msgnr. PARAMETERS: p_langu TYPE spras. SELECTION-SCREEN END OF BLOCK b4. SELECTION-SCREEN END OF BLOCK b2. SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003 . PARAMETERS: p_arbgb TYPE arbgb OBLIGATORY. PARAMETERS: p_msgnr TYPE msgnr OBLIGATORY. SELECT-OPTIONS: s_lang FOR sy-langu. PARAMETERS: p_long AS CHECKBOX. SELECTION-SCREEN END OF BLOCK b3. START-OF-SELECTION. IF p_rb1 = abap_true. IF p_text IS INITIAL. RETURN. ENDIF. ENDIF. IF p_rb2 = abap_true. IF p_langu IS INITIAL. RETURN. ENDIF. ENDIF. * Get Language SELECT * FROM t002 INTO TABLE lit_t002 WHERE spras IN s_lang. IF sy-subrc <> 0. RETURN. ENDIF. SORT lit_t002 BY spras. * Get Target Short Message SELECT * FROM t100 INTO TABLE lit_t100_t WHERE msgnr = p_msgnr AND arbgb = p_arbgb. * Get Source Short Message IF p_rb2 = abap_true. SELECT * FROM t100 INTO TABLE lit_t100_s WHERE msgnr = p_msgnr2 AND arbgb = p_arbgb2. IF sy-subrc <> 0. RETURN. ENDIF. SORT lit_t100_s BY sprsl. READ TABLE lit_t100_s INTO lwa_t100 WITH KEY sprsl = p_langu BINARY SEARCH. IF sy-subrc <> 0. RETURN. ENDIF. DATA(l_text) = lwa_t100-text. ENDIF. * Copy Short Message LOOP AT lit_t002 INTO lwa_t002. READ TABLE lit_t100_t INTO lwa_t100 WITH KEY sprsl = lwa_t002-spras BINARY SEARCH. IF sy-subrc <> 0. lwa_t100-msgnr = p_msgnr. lwa_t100-arbgb = p_arbgb. lwa_t100-sprsl = lwa_t002-spras. ENDIF. lwa_t100-text = COND #( WHEN l_text IS NOT INITIAL THEN l_text ELSE p_text ). APPEND lwa_t100 TO lit_t100_u. ENDLOOP. MODIFY t100 FROM TABLE lit_t100_u. COMMIT WORK. * Copy Message Long text IF p_rb2 = abap_true AND p_long = abap_true. l_object = p_arbgb2 && p_msgnr2. SELECT * FROM dokhl UP TO 1 ROWS INTO @DATA(lwa_dokhl) WHERE id = 'NA' AND object = @l_object AND langu = @p_langu. ENDSELECT. IF sy-subrc <> 0. RETURN. ENDIF. CALL FUNCTION 'DOCU_READ' EXPORTING id = 'NA' langu = p_langu object = l_object typ = lwa_dokhl-typ version = lwa_dokhl-dokversion IMPORTING head = lwa_head TABLES line = lit_lines. IF lit_lines IS INITIAL. RETURN. ENDIF. l_object = p_arbgb && p_msgnr. LOOP AT lit_t002 INTO lwa_t002. lwa_head-tdspras = lwa_t002-spras. lwa_head-tdname = l_object. CALL FUNCTION 'DOCU_UPDATE' EXPORTING head = lwa_head state = lwa_dokhl-dokstate typ = lwa_dokhl-typ version = lwa_dokhl-dokversion TABLES line = lit_lines. ENDLOOP. ENDIF. |
其他翻译小工具-->选择画面文本(selection texts)翻译小工具
以上。
发表评论