Hi Liyana,
please have a look at OSS Note 736873 about MATERIAL_SAVE_CONFIGURATION function module.
Here follows an example of the FM usage, based on your code and using some of my sandbox system peculiarities and hardcoded values (configurable material, plant, characteristics, characteristic values, etc. to be adapted at your case), just to give it a try.
Startng point is a newly created material, without any reference yet to plant-specific configuration (MRP3 field is empty).
Image may be NSFW.
Clik here to view.
REPORT zflatest.
DATA: lt_e1cucfg TYPESTANDARDTABLEOF e1cucfg WITHHEADERLINE,
lt_e1cuins TYPESTANDARDTABLEOF e1cuins WITHHEADERLINE,
lt_e1cuval TYPESTANDARDTABLEOF e1cuval WITHHEADERLINE,
lt_e1cucom TYPESTANDARDTABLEOF e1cucom,
gt_returnmessages TYPESTANDARDTABLEOF bapi_matreturn2.
DATA: gv_matnr TYPE matnr.
lt_e1cucfg-POSEX = '4000'.
lt_e1cucfg-CONFIG_ID = '000001'.
lt_e1cucfg-ROOT_ID = '00000001'.
lt_e1cucfg-COMPLETE = 'T'.
lt_e1cucfg-CONSISTENT = 'T'.
APPEND lt_e1cucfg.
lt_e1cuins-INST_ID = '00000001'.
lt_e1cuins-OBJ_TYPE = 'MARA'.
lt_e1cuins-CLASS_TYPE = '300'.
lt_e1cuins-OBJ_KEY = 'C_GLTP'.
lt_e1cuins-QUANTITY = '1000'.
lt_e1cuins-QUANTITY_UNIT = 'KG'.
lt_e1cuins-COMPLETE = 'T'.
lt_e1cuins-CONSISTENT = 'T'.
lt_e1cuins-OBJECT_GUID = 'C_GLTP'.
APPEND lt_e1cuins.
gv_matnr = '000000000004002322'.
*----- Characteristic values management
lt_e1cuval-inst_id = '00000001'.
lt_e1cuval-valcode = '1'.
lt_e1cuval-charc = 'SHOT_PEENING_Y_N'.
lt_e1cuval-value = 'N'.
APPEND lt_e1cuval.
lt_e1cuval-charc = 'BENDING_Y_N'.
lt_e1cuval-value = 'N'.
APPEND lt_e1cuval.
lt_e1cuval-charc = 'LENGTH_MIN_DISCRIMINATING_MM'.
lt_e1cuval-value = '5000'.
APPEND lt_e1cuval.
lt_e1cuval-charc = 'LENGTH_MAX_DISCRIMINATING_MM'.
lt_e1cuval-value = '7000'.
APPEND lt_e1cuval.
*-----------Plant-specific configuration-----------------------------------------
*---Save the configuration for each plant-----------------------------------
CALLFUNCTION'MATERIAL_SAVE_CONFIGURATION'
EXPORTING
material = gv_matnr
plant = '4000' "iv_plant
conf_matl_plant = 'C_GLTP'
TABLES
e1cucfg_w = lt_e1cucfg
e1cuins_w = lt_e1cuins
e1cuval_w = lt_e1cuval
e1cucom_w = lt_e1cucom
returnmessages = gt_returnmessages.
CALLFUNCTION'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
After running the code, here the messages from the function module:
Image may be NSFW.
Clik here to view.
And here the configuration with updated values:
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
In case the material has already been configured and there is a need to change the configuration, then the code shall read the configuration structures first, with the CUXM_GET_CONFIGURATION function module (see OSS Note above).
I hope this could be of some help.
Thanks and bye,
Flavio