Application Development 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: 

Regarding MATERIAL_MAINTAIN_DARK function module

Former Member
0 Kudos
618

Hi All,

For updating material master I am using function module 'MATERIAL_MAINTAIN_DARK', it is working fine for modify the values, however it is not working for remove the values.

Suppose for a material currently weight unit is 'KG', if I modify this value as'LB', it is working fine, but if I try to remove the value 'KG', it is not removing, and old value is existing. It is not only for weight unit field, for any field it is applicable. Even quantity values also if I modify it is accepting but I remove the value, it is not working fine. Please let me know the solution.

Thanks & Regards

Naveen Kumar

1 ACCEPTED SOLUTION

Former Member
0 Kudos
148

Hi Naveen,

I would try to pass your field namesin the AMFIELDRES table parameter.

& check tha D_IND field in your _UEB tables.

As an option - try to post MATMAS01 IDOC, I believe MATERIAL_MAINTAIN_DARK is used in this FM, if it removes values - check how SAP calls this FM.

8 REPLIES 8

Former Member
0 Kudos
149

Hi Naveen,

I would try to pass your field namesin the AMFIELDRES table parameter.

& check tha D_IND field in your _UEB tables.

As an option - try to post MATMAS01 IDOC, I believe MATERIAL_MAINTAIN_DARK is used in this FM, if it removes values - check how SAP calls this FM.

0 Kudos
148

Hi Siarhei Mahulenka,

You have to pass the values to AMARA_UEB,AMARC_UEB,AMARD_UEB etc not in AMFIELDRES. Mine is a report using ALV, please let me know the solution.

THanks & Regards

Naveen kumar

0 Kudos
148

HI Siarhei,

Please let me know how to pass structure AMFIELDRES in the FM. Suppose I want to pass loading group(LADGR), gross weight (BRGEW) and GEWEI blank values in the FM. How to write the code for these three fields.

Thanks & Regards

Naveen Kumar

0 Kudos
148

I believe you have to put space in the field-value in _UEB table and you have to add this field to

Example with one of our fields :

i_marc_ueb-zhksh = space.

i_marc_ueb-zhval = space.

z_mfieldres-tranc = help_tranc.

z_mfieldres-d_ind = counter-d_ind.

z_mfieldres-fname = 'MARC-ZHKSH'. "ZHKSH can be blanked out

append z_mfieldres to t_mfieldres. " to blankout fileds <<<<<<<<<

... then when FM maintain_dark is called t_mfieldres is passed to amfieldres.

tables

...

amfieldres = t_mfieldres

0 Kudos
148

Hi Siarhei,

Thanks for your quick response. I required one more clarification, for structure t_mfieldres, you pass help_tranc, counter-d_ind and whatever required empty fields. Suppose in my requirement I have to pass empty fields in i_mara, i_marc and i_mard. So for all shall I have to pass one structue and one more thing what the value is stored in help_tranc and counter-d_ind.

In my case I have to pass approximately one empty field in each structrure like mara, marc, mard, mbew. Please let me know the code how to pass these.

THanks & Regards

Naveen Kumar

0 Kudos
148

Hi Naveen,

to clarify :

when you add new records to marc_ueb and some fields have blank values and marc is supposed to be updated with htose blank values, you need to add several records to t_mfieldres internal table for each field which should accept blank value. help_tranc & counter-d_ind are the same as passed in _UEB table.

SAP uses the following logic in maintain_dark FM

if the field in _UEB table has initial value - SAP checks if this field exists in

"mfieldres" table, if it does - the field should be updated with blank value, if it does not exist in this internal table - the field retains previous value.

in your case, when you add records to marc_ueb, mara_ueb, mard_ueb, mbew_ueb - add corresponding records with your field names to mfieldres table.

You can check FM IDOC_INPUT_MATAMS01 for the example on how to call MAINTAIN_DARK FM. In particular :

form e1marcm_nodata_find tables t_m structure mfieldres

using i_d structure e1marcm

p_tranc p_d_ind.

data: i_m like mfieldres.

i_m-tranc = p_tranc. <<< same values as you pass to _UEB table

i_m-d_ind = p_d_ind.

if i_d-werks = c_nodata. <<< if the value of the field should not be changed

clear i_d-werks.

else.

marc-werks = i_d-werks.

if marc-werks is initial. <<<< your case, when the field should be initialized.

i_m-fname = 'MARC-WERKS'.

append i_m to t_m.

endif.

endif.

0 Kudos
148

Hi Siarhei,

With your data I have checked, however its working for few fields only. Like I have to remove values for 'Length', 'Width', 'Height', 'Picking Area' , 'ABC Indicator', 'Storage Bin' etc.

With the code its working fine for 'Length', 'Width' and 'Height' only, but its not working for 'Picking Area' , 'ABC Indicator', 'Storage Bin' etc.

Code is like below:

ITAB_MARA-MATNR = USER_PROFDC_F-MATNR.

ITAB_MARA-ERSDA = USER_PROFDC_F-ERSDA.

ITAB_MARA-BRGEW = USER_PROFDC_F-BRGEW.

ITAB_MARA-BEHVO = USER_PROFDC_F-BEHVO.

IF USER_PROFDC_F-LAENG NE ' '.

ITAB_MARA-LAENG = USER_PROFDC_F-LAENG.

ENDIF.

IF USER_PROFDC_F-BREIT NE ' '.

ITAB_MARA-BREIT = USER_PROFDC_F-BREIT.

ENDIF.

IF USER_PROFDC_F-HOEHE NE ' '.

ITAB_MARA-HOEHE = USER_PROFDC_F-HOEHE.

ENDIF.

ITAB_MARA-MEABM = USER_PROFDC_F-MEABM.

ITAB_MARA-PRDHA = USER_PROFDC_F-PRDHA.

ITAB_MARA-GEWEI = USER_PROFDC_F-GEWEI.

ITAB_MARA-TRANC = '1'.

ITAB_MARA-D_IND = '1'.

ITAB_MARA-TCODE = 'MM02'.

APPEND ITAB_MARA.

CLEAR ITAB_MARA.

ITAB_MARC-MATNR = USER_PROFDC_F-MATNR.

ITAB_MARC-WERKS = USER_PROFDC_F-WERKS.

IF USER_PROFDC_F-MAABC NE ' '.

ITAB_MARC-MAABC = USER_PROFDC_F-MAABC.

ENDIF.

ITAB_MARC-LADGR = USER_PROFDC_F-LADGR.

ITAB_MARD-TRANC = '2'.

ITAB_MARD-D_IND = '2'.

APPEND ITAB_MARC.

CLEAR ITAB_MARC.

ITAB_MARD-MATNR = USER_PROFDC_F-MATNR.

ITAB_MARD-WERKS = USER_PROFDC_F-WERKS.

ITAB_MARD-LGORT = USER_PROFDC_F-LGORT.

ITAB_MARD-LGPBE = USER_PROFDC_F-LGPBE.

IF USER_PROFDC_F-LWMKB NE ' '.

ITAB_MARD-LWMKB = USER_PROFDC_F-LWMKB.

ENDIF.

ITAB_MARD-TRANC = '3'.

ITAB_MARD-D_IND = '3'.

APPEND ITAB_MARD.

CLEAR ITAB_MARD.

LOOP AT INT_T001W.

ITAB_MVKE-MATNR = USER_PROFDC_F-MATNR.

ITAB_MVKE-VKORG = INT_T001W-VKORG. "'1101'. "USER_PROFDC_F-WERKS.

ITAB_MVKE-VTWEG = INT_T001W-VTWEG. "'10'. "USER_PROFDC_F-MAABC.

APPEND ITAB_MVKE.

CLEAR ITAB_MVKE.

ENDLOOP.

ITAB_MAKT-MATNR = USER_PROFDC_F-MATNR.

ITAB_MAKT-MAKTX = USER_PROFDC_F-MAKTX.

APPEND ITAB_MAKT.

CLEAR ITAB_MAKT.

IF USER_PROFDC_F-LAENG EQ ' '.

ITAB_RESET_FLDS-FNAME = 'MARA-LAENG'.

ITAB_RESET_FLDS-TRANC = '1'.

ITAB_RESET_FLDS-D_IND = '1'.

ENDIF.

IF USER_PROFDC_F-BREIT EQ ' '.

ITAB_RESET_FLDS-FNAME = 'MARA-BREIT'.

ITAB_RESET_FLDS-TRANC = '1'.

ITAB_RESET_FLDS-D_IND = '1'.

ENDIF.

IF USER_PROFDC_F-HOEHE EQ ' '.

ITAB_RESET_FLDS-FNAME = 'MARA-HOEHE'.

ITAB_RESET_FLDS-TRANC = '1'.

ITAB_RESET_FLDS-D_IND = '1'.

ENDIF.

IF USER_PROFDC_F-MAABC EQ ' '.

ITAB_RESET_FLDS-FNAME = 'MARC-MAABC'.

ITAB_RESET_FLDS-TRANC = '2'.

ITAB_RESET_FLDS-D_IND = '2'.

ENDIF.

IF USER_PROFDC_F-LWMKB EQ ' '.

ITAB_RESET_FLDS-FNAME = 'MARD-LWMKB'.

ITAB_RESET_FLDS-TRANC = '3'.

ITAB_RESET_FLDS-D_IND = '3'.

ENDIF.

APPEND ITAB_RESET_FLDS.

CLEAR ITAB_RESET_FLDS.

Please let me know the solution, however thanks for guiding me in correct track. My email id is naveenkumar@vmoksha.com, please send me your mail id.

Thanks & Regards

Naveen Kumar

0 Kudos
148

Naveen,

I hope you appended each new field as a separate records in ITAB_RESET_FLDS.

I mean you need to append new record for each new field.

IF USER_PROFDC_F-LAENG EQ ' '.

ITAB_RESET_FLDS-FNAME = 'MARA-LAENG'.

ITAB_RESET_FLDS-TRANC = '1'.

ITAB_RESET_FLDS-D_IND = '1'.

<b>APPEND ITAB_RESET_FLDS.

CLEAR ITAB_RESET_FLDS.</b>

ENDIF.

IF USER_PROFDC_F-BREIT EQ ' '.

ITAB_RESET_FLDS-FNAME = 'MARA-BREIT'.

ITAB_RESET_FLDS-TRANC = '1'.

ITAB_RESET_FLDS-D_IND = '1'.

<b>APPEND ITAB_RESET_FLDS.

CLEAR ITAB_RESET_FLDS. </b>

ENDIF.

IF USER_PROFDC_F-HOEHE EQ ' '.

ITAB_RESET_FLDS-FNAME = 'MARA-HOEHE'.

ITAB_RESET_FLDS-TRANC = '1'.

ITAB_RESET_FLDS-D_IND = '1'.

ENDIF.

IF USER_PROFDC_F-MAABC EQ ' '.

ITAB_RESET_FLDS-FNAME = 'MARC-MAABC'.

ITAB_RESET_FLDS-TRANC = '2'.

ITAB_RESET_FLDS-D_IND = '2'.

ENDIF.

IF USER_PROFDC_F-LWMKB EQ ' '.

ITAB_RESET_FLDS-FNAME = 'MARD-LWMKB'.

ITAB_RESET_FLDS-TRANC = '3'.

ITAB_RESET_FLDS-D_IND = '3'.

ENDIF.

Also looke like the following lines are wrong :

ITAB_MARC-LADGR = USER_PROFDC_F-LADGR.

ITAB_MARD-TRANC = '2'. <<<<< shouldn't it be ITAB_MARC-TRANC = '2'. ??

ITAB_MARD-D_IND = '2'. <<<<

APPEND ITAB_MARC.

CLEAR ITAB_MARC.