Dear All,
I have created custom fields in 'General Plant Data / Storage 1' view of MM01 transaction & those fields are to be saved into MARC table. It is working fine & I am able to change also that field using transaction code MM02. But Problem is that I want to change that custom field of material master using transaction code MM17 , which is for mass Material Maintenance.
So to edit custom field of material master from MM17 following steps have been taken:
1. Created the Z-fields in MARC table. Added the created Z-fields in the field selection group using SPRO.
2. Z-segment ZE1MARCM is created, containing the Z-fields added in the MARC.
3. Extension YMATMAS03 is created.
4. Extension is attached to the Message type MATMAS, basic type - MATMAS03 using the t-code WE82.
5. I have implemented the BADi 'MG_MASS_NEWSEG' and
6. The enhancement MGV00001 (Exit - EXIT_SAPLMV02_002).
The logic written in the BADi implementation in the method ADD_NEW_SEGMENT is as follows:
* 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.
* E1MARCM
TYPES: BEGIN OF lty_e1marcm,
docnum TYPE edidc-docnum,
pointer TYPE sy-tabix.
INCLUDE TYPE e1marcm AS data.
TYPES: END OF lty_e1marcm.
TYPES: lty_e1marcm_tab TYPE STANDARD TABLE OF lty_e1marcm.
* presupposition: customer segment ZE1MARAM must be defined
TYPES: BEGIN OF lty_ze1marcm,
docnum TYPE edidc-docnum,
pointer TYPE sy-tabix.
INCLUDE TYPE ZE1MARCM AS data. "<<< INSERT LINE
* INCLUDE TYPE e1marcm AS data. "<<< DELETE LINE
TYPES: END OF lty_ze1marcm.
TYPES: lty_ze1marcm_tab TYPE STANDARD TABLE OF lty_ze1marcm.
************************************************************
* Begin Types declaration of IS-OIL specific IDOC segments *
************************************************************
* 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.
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,
we1marcm TYPE lty_e1marcm,
e1marcm TYPE lty_e1marcm,
lt_e1marcm TYPE lty_e1marcm_tab,
wze1marcm TYPE lty_ze1marcm, "customer specific
ze1marcm TYPE lty_ze1marcm, "customer specific
lt_ze1marcm TYPE lty_ze1marcm_tab. "customer specific
* 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: 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_e1marcm = t_e1marcm.
* customer specific MARC Appendfields in MM17 mass change
segname = 'ZE1MARCM' .
**
** ZSMARC
**
READ TABLE seldata INTO wa_tab
WITH KEY tabname-name = 'MARC' .
LOOP AT smarc INTO ls_smarc.
CLEAR: ze1marcm , docnum.
CLEAR newstat.
READ TABLE wa_tab-newsegments INTO wa_newseg INDEX sy-tabix.
IF NOT sy-subrc IS INITIAL. "old segment
DO.
sy-index = sy-index + 2.
ASSIGN COMPONENT sy-index OF
STRUCTURE ze1marcm TO <f1>.
IF sy-subrc NE 0. EXIT. ENDIF.
<f1> = '/'.
ENDDO.
*fill key fields
*fill data fields
LOOP AT wa_tab-fieldnames INTO fname.
CONCATENATE 'LS_S' wa_tab-tabname-name
'-' fname INTO t1.
ASSIGN (t1) TO <f1>.
IF NOT sy-subrc IS INITIAL.
CONTINUE.
ENDIF.
CONCATENATE segname '-' fname INTO t2.
ASSIGN (t2) TO <f2>.
IF NOT sy-subrc IS INITIAL.
CONTINUE.
ENDIF.
<f2> = <f1>.
ENDLOOP.
ELSE. "new segment, take all fields
MOVE-CORRESPONDING ls_smarc TO ze1marcm .
ENDIF.
*work our way up the hierachy, if there is one
CLEAR: found, findex.
*fill parent key fields
CLEAR e1maram.
e1maram-matnr = ls_smarc-matnr .
e1marcm-werks = ls_smarc-werks .
we1maram-matnr = ls_smarc-matnr .
we1marcm-werks = ls_smarc-werks .
MOVE '004' TO e1maram-msgfn .
* search the corresponding MARC segment
READ TABLE lt_e1maram WITH KEY matnr = e1maram-matnr
INTO we1maram TRANSPORTING docnum pointer matnr.
READ TABLE lt_e1marcm WITH KEY docnum = we1maram-docnum
werks = e1marcm-werks
INTO e1marcm.
CALL FUNCTION 'I_MASS_GET_INDEX'
EXPORTING
pointer = e1marcm-pointer
IMPORTING
tabix = findex.
findex = findex + 1.
docnum = e1marcm-docnum .
*end of hierarchy work
*collection of append statements
IF ze1marcm-docnum IS INITIAL.
ze1marcm-docnum = docnum.
ls_idoc_data-segnam = 'ZE1MARCM' .
ls_idoc_data-sdata = ze1marcm-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 = ze1marcm-pointer.
APPEND ze1marcm TO lt_ze1marcm.
ENDIF.
ENDLOOP.
When I try to change the z-fields along with the costing lot size (standard SAP field) using the transaction MM17, the costing lot size gets updated, however the z-fields added in MARC table does not get updated.
Am I missing something? Please suggest...
Regards
Vinit Joshi.