Сначала расширяем необходимую таблицу (MARA, MARC…).
Идем в транзакцию MASSOBJ, Добавляем к типу объекта нужное поле.
Далее запускаем транзакцию omsr, добавляем к группе полей новое поле (затрагивает таблицу T130F).
Создаем сегмент ZE1MARA (WE31)
Создаем расширение для базисного типа MATMAS03. Добавляем сегмент Z1MARA (WE30)
Создаем привязку к типу сообщения (WE82)
Внедряем бади MG_MASS_NEWSEG, метод ADD_NEW_SEGMENT
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 |
METHOD IF_EX_MG_MASS_NEWSEG~ADD_NEW_SEGMENT . * local TYPES declaration TYPES: lty_idoc_data TYPE edidd. ****************************** * R/3 standard IDoc segments * ****************************** * E1MARAM TYPES: BEGIN OF lty_e1maram, docnum TYPE edidc-docnum, pointer TYPE sy-tabix. INCLUDE TYPE e1maram AS data. TYPES: END OF lty_e1maram. TYPES: lty_e1maram_tab TYPE STANDARD TABLE OF lty_e1maram. ************************************************************** * Begin Types declaration of customer specific IDoc segments * ************************************************************** * presupposition: customer segment ZE1MARAM must be defined TYPES: BEGIN OF lty_ze1maram, docnum TYPE edidc-docnum, pointer TYPE sy-tabix. INCLUDE TYPE ze1mara AS data. "<<< INSERT LINE * INCLUDE TYPE e1maram AS data. "<<< DELETE LINE TYPES: END OF lty_ze1maram. TYPES: lty_ze1maram_tab TYPE STANDARD TABLE OF lty_ze1maram. ************************************************************** * End Types declaration of customer specific IDoc segments * ************************************************************** ************************************************************ * Begin Types declaration of IS-OIL specific IDOC segments * ************************************************************ * E1OILMA TYPES: BEGIN OF lty_e1oilma, docnum TYPE edidc-docnum, pointer TYPE sy-tabix. * INCLUDE TYPE e1oilma AS data. "<<< INSERT LINE INCLUDE TYPE e1maram AS data. "<<< DELETE LINE TYPES: END OF lty_e1oilma. TYPES: lty_e1oilma_tab TYPE STANDARD TABLE OF lty_e1oilma. * E1OILMC TYPES: BEGIN OF lty_e1oilmc, docnum TYPE edidc-docnum, pointer TYPE sy-tabix. * INCLUDE TYPE e1oilmc AS data. "<<< INSERT LINE INCLUDE TYPE e1marcm AS data. "<<< DELETE LINE TYPES: END OF lty_e1oilmc. TYPES: lty_e1oilmc_tab TYPE STANDARD TABLE OF lty_e1oilmc. * E1OILMW TYPES: BEGIN OF lty_e1oilmw, docnum TYPE edidc-docnum, pointer TYPE sy-tabix. * INCLUDE TYPE e1oilmw AS data. "<<< INSERT LINE INCLUDE TYPE e1mbewm AS data. "<<< DELETE LINE TYPES: END OF lty_e1oilmw. TYPES: lty_e1oilmw_tab TYPE STANDARD TABLE OF lty_e1oilmw. ************************************************************ * End Types declaration of IS-OIL specific IDOC segments * ************************************************************ * local Field Symbols FIELD-SYMBOLS <f1> TYPE ANY. FIELD-SYMBOLS <f2> TYPE ANY. * local Data declarations DATA: t1(32), t2(32), findex LIKE sy-tabix. DATA: ls_smara LIKE LINE OF smara, ls_smarc LIKE LINE OF smarc, ls_smbew LIKE LINE OF smbew, ls_smard LIKE LINE OF smard, ls_smvke LIKE LINE OF smvke, ls_idoc_data TYPE lty_idoc_data, we1maram TYPE lty_e1maram, e1maram TYPE lty_e1maram, lt_e1maram TYPE lty_e1maram_tab, wze1maram TYPE lty_ze1maram, "customer specific ze1maram TYPE lty_ze1maram, "customer specific lt_ze1maram TYPE lty_ze1maram_tab, "customer specific we1oilma TYPE lty_e1oilma, "IS-OIL specific e1oilma TYPE lty_e1oilma, "IS-OIL specific lt_e1oilma TYPE lty_e1oilma_tab. "IS-OIL specific DATA: fname TYPE dcobjdef-name, fname2 TYPE fname, segname TYPE dcobjdef-name, wsegname TYPE dcobjdef-name, tabix TYPE sy-tabix, wa_tab TYPE mass_wa_tabdata, wa_newseg LIKE LINE OF wa_tab-newsegments, wa_msg TYPE mass_msg, docnum TYPE edidc-docnum, found, doccnt TYPE edidc-docnum VALUE 1, newstat TYPE mara-pstat, l_findex TYPE sy-tabix, l_findex2 TYPE sy-tabix. * copy the IDoc segment tables from BADI interface to local tables lt_e1maram = t_e1maram. ********************************************************** * Begin of providing customer specific IDoc segments * ********************************************************** * customer specific MARA Appendfields in MM17 mass change segname = 'ZE1MARA' . ** ** ZSMARA ** LOOP AT smara INTO ls_smara. "new segment, take all fields MOVE-CORRESPONDING ls_smara TO ze1maram . *work our way up the hierachy, if there is one CLEAR: found, findex. IF found IS INITIAL. *fill parent key fields CLEAR e1maram. e1maram-matnr = ls_smara-matnr . we1maram-matnr = ls_smara-matnr . MOVE '004' TO e1maram-msgfn . READ TABLE lt_e1maram WITH KEY matnr = e1maram-matnr INTO e1maram. IF sy-subrc EQ 0. "existing entry, check higher levels found = 'X'. CALL FUNCTION 'I_MASS_GET_INDEX' EXPORTING pointer = e1maram-pointer IMPORTING tabix = findex. findex = findex + 1. ENDIF. "sy-subrc eq 0 IF found = 'X'. docnum = e1maram-docnum . ELSE. "create an entry CLEAR e1maram-docnum . DO. sy-index = sy-index + 2. ASSIGN COMPONENT sy-index OF STRUCTURE e1maram TO <f1>. IF sy-subrc NE 0. EXIT. ENDIF. IF <f1> IS INITIAL. <f1> = '/'. ENDIF. ENDDO. MOVE-CORRESPONDING ls_smara TO e1maram . CALL FUNCTION 'MG_GETPSTAT' EXPORTING tabname = 'MARA' segment = smara newstat = newstat CHANGING data = e1maram-data. ENDIF. ENDIF. *end of hierarchy work *collection of append statements IF docnum IS INITIAL. docnum = doccnt. ADD 1 TO doccnt. ENDIF. * IF ze1maram-docnum IS INITIAL. ze1maram-docnum = docnum. ls_idoc_data-segnam = 'ZE1MARA' . ls_idoc_data-sdata = ze1maram-data . ls_idoc_data-docnum = docnum. IF findex IS INITIAL. findex = 1. ENDIF. INSERT ls_idoc_data INTO t_idoc_data INDEX findex. CALL FUNCTION 'I_MASS_SET_INDEX' EXPORTING tabix = findex IMPORTING pointer = ze1maram-pointer. APPEND ze1maram TO lt_ze1maram . * ENDIF. ENDLOOP. ENDMETHOD. |
идем в CMOD, создаем расширение ZMATMAS3 (MGV00001) ФМ EXIT_SAPLMV02_002
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
DATA ls_ze1mara TYPE ze1mara. IF f_cust_segment-segnam = 'ZE1MARA'. ls_ze1mara = f_cust_segment-sdata. IF ls_ze1mara-zfield= c_nodata. CLEAR ls_ze1mara-zfield. ENDIF. IF ls_ze1mara-zfield IS INITIAL. res_fields-feldname = 'MARA-ZFIELD'. APPEND res_fields. ENDIF. f_mara_ueb-zfield= ls_ze1mara-zfield. ENDIF. |
Процесс расширения более подробно.
Решение проблем:
Если после всех действий поля не обновляются, смотрим ноту.
Вкратце:
MARA_ARRAY_UPDATE – фм, в котором происходит обновление ракурса MARU.
Нужно добавить Z поля в промежуточные таблицы *_TMP.
Например, если расширяем MARA, то расширяем на соответствующие поля таблицу MARA_TMP