Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Custom Field is not updating using MM17 ( Mass Material Maintenance )

former_member189779
Active Contributor
0 Kudos
5,174

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.

4 REPLIES 4
Read only

kiran_k8
Active Contributor
0 Kudos
2,635

Vinit,

In Debugging check if any Material related BAPI FM's are getting triggered.If yes,check if any related BAPI structures needs to be updated with the Z fields. ( Structures BAPI_MARC / BAPI_MARCX )

K.Kiran.

Read only

FilipSt
Explorer
0 Kudos
2,635

Hi,

It seems that there is too much coding

please check this step-by-step guide: http://stankowski.it/webpage/how2/A001.pdf

BR,

F

Read only

0 Kudos
2,635

Hi,

Sorry to dig up this old thread but I came across this requirement recently and I did some research to understand why in BAdI MG_MASS_NEWSEG, your step-by-step procedure (§3.9.2) would omit some code that exists in the example class (CL_EXM_IM_MG_MASS_NEWSEG).

It turns out the missing code changes the way MM17 handles the case when a change is done to a material while it is changed in MM17 (MM17 doesn't create an entry lock).

  • With the Step-by-step guide code, the mass change updates all the fields of MARA, MARC, etc.
  • With the example class, only the selected field of MM17 are updated (and the other field have a "/")

Let me illustrate it with the following use case:

  1. Call MM17 for material M
  2. Call MM02 for material M in another window
  3. in MM02, change value of field F1 and save
  4. in MM17, select field F2, change value and save mass change

Result:

  • With the Step-by-step guide code, field F1 is changed with the value it had at step 1 => Unexpected
  • With the example class, field F1 is unchanged => Expected
  • (in both cases, F2 is changed as expected)

PS : Some additionnal info on CL_EXM_IM_MG_MASS_NEWSEG : despite its name, variable segname has no relation to the name of the custom segment defined in iDoc extension. It just holds the name of the local structure that is used for field-symbol assignments.

Read only

roberto_forti
Contributor
0 Kudos
2,635

Hi, I should to enhance related structure regarding customized fields into the corresponding FM (BAPI).