Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Field MATNR has been transferred inconsistently or is blank

Hi,

i am using BAPI_MATERIAL_SAVEDATA to create material master. program is successfully creating materials for single record (one material) and multiple records(one material with multiple plants). only when program is going create new material in the same file data then BAPI returns message 'Field MATNR has been transferred inconsistently or is blank'.

example file format.

Material Industry Sector Material Type Plant Stor_Loc

BC000x6 C ZRAW 195 1000

BC000x6 C ZRAW 370 1000

BC000x6 C ZRAW 1399 1000

BC000x6 C ZRAW 1510 1000

BC000x1 C ZRAW 195 1000

BC000x1 C ZRAW 370 1000

BC000x1 C ZRAW 1399 1000

BC000x1 C ZRAW 1510 1000

BC000x2 C ZRAW 195 1000

BC000x2 C ZRAW 370 1000

BC000x2 C ZRAW 1399 1000

BC000x2 C ZRAW 1510 1000

BC000x3 C ZRAW 195 1000

BC000x3 C ZRAW 370 1000

BC000x3 C ZRAW 1399 1000

BC000x3 C ZRAW 1510 1000

BC000x4 C ZRAW 195 1000

BC000x4 C ZRAW 370 1000

BC000x4 C ZRAW 1399 1000

BC000x4 C ZRAW 1510 1000

BC000x5 C ZRAW 195 1000

BC000x5 C ZRAW 370 1000

BC000x5 C ZRAW 1399 1000

BC000x5 C ZRAW 1510 1000

in the above file data, BC000x6 is successful for all plants and rest all errored out with message "Field MATNR has been transferred inconsistently or is blank".

Then i changed the order of data in file like

BC000x1 C ZRAW 195 1000

BC000x1 C ZRAW 370 1000

BC000x1 C ZRAW 1399 1000

BC000x1 C ZRAW 1510 1000

BC000x2 C ZRAW 195 1000

BC000x2 C ZRAW 370 1000

BC000x2 C ZRAW 1399 1000

BC000x2 C ZRAW 1510 1000

BC000x3 C ZRAW 195 1000

BC000x3 C ZRAW 370 1000

BC000x3 C ZRAW 1399 1000

BC000x3 C ZRAW 1510 1000

BC000x4 C ZRAW 195 1000

BC000x4 C ZRAW 370 1000

BC000x4 C ZRAW 1399 1000

BC000x4 C ZRAW 1510 1000

BC000x5 C ZRAW 195 1000

BC000x5 C ZRAW 370 1000

BC000x5 C ZRAW 1399 1000

BC000x5 C ZRAW 1510 1000

BC000x6 C ZRAW 195 1000

BC000x6 C ZRAW 370 1000

BC000x6 C ZRAW 1399 1000

BC000x6 C ZRAW 1510 1000

then BC000x1 is successful. rest all errored out.

Here is the code in place.

Please let me know where i am doing wrong.

DATA: ls_error TYPE t_error,

ls_input TYPE t_input,

ls_materialdescription TYPE bapi_makt,

ls_materiallongtext TYPE bapi_mltx,

lv_count TYPE i.

CLEAR: gs_input_data,

gs_headdata,

gs_clientdata,

gs_plantdata,

gs_valuationdata,

gs_storagelocationdata,

gs_clientdatax,

gs_plantdatax,

gs_valuationdatax,

gs_storagelocationdatax,

gt_materialdescription,

gs_return,

rt_input.

SELECT * INTO TABLE gt_ind_sec FROM t137.

SELECT * INTO TABLE gt_mat_type FROM t134.

SELECT * INTO TABLE gt_stor_loc FROM t001l.

SELECT * INTO TABLE gt_mat_grp FROM t023.

SELECT * INTO TABLE gt_mrp_type FROM t438a.

SELECT * INTO TABLE gt_avl_check FROM tmvf.

SELECT * INTO TABLE gt_val_class FROM t025.

SELECT * INTO TABLE gt_temp_cond FROM t143.

REFRESH: gt_materialdescription, rt_input.

LOOP AT rt_input_data INTO gs_input_data.

PERFORM sub_convert_input CHANGING gs_input_data-link-matnr.

PERFORM sub_convert_input CHANGING gs_input_data-link-werks.

PERFORM sub_convert_input CHANGING gs_input_data-link-mstae.

PERFORM sub_convert_input CHANGING gs_input_data-link-tempb.

PERFORM validate_input_data USING gs_input_data

CHANGING rt_error.

      • Header data

gs_headdata-material = gs_input_data-link-matnr.

gs_headdata-ind_sector = gc_catering.

gs_headdata-matl_type = gs_input_data-link-mtart.

gs_headdata-basic_view = 'X'.

gs_headdata-purchase_view = 'X'.

gs_headdata-mrp_view = 'X'.

gs_headdata-storage_view = 'X'.

gs_headdata-account_view = 'X'.

gs_headdata-cost_view = 'X'.

      • Client data update to MARA table

gs_clientdata-matl_group = gs_input_data-link-matkl.

gs_clientdata-old_mat_no = gs_input_data-link-bismt.

gs_clientdata-base_uom = gs_input_data-link-meins. "'EA'.

gs_clientdata-pur_status = gs_input_data-link-mstae.

gs_clientdata-temp_conds = gs_input_data-link-tempb.

gs_clientdatax-matl_group = 'X'.

gs_clientdatax-old_mat_no = 'X'.

gs_clientdatax-base_uom = 'X'.

gs_clientdatax-pur_status = 'X'.

gs_clientdatax-temp_conds = 'X'.

      • Plant data update to MARC table

gs_plantdata-plant = gs_input_data-link-werks.

gs_plantdata-auto_p_ord = gs_input_data-link-kautb.

gs_plantdata-mrp_type = gs_input_data-link-dismm.

gs_plantdata-max_stock = gs_input_data-link-mabst.

gs_plantdata-proc_type = gs_input_data-link-beskz.

gs_plantdata-safety_stk = gs_input_data-link-eisbe.

gs_plantdata-min_safety_stk = gs_input_data-link-eislo.

gs_plantdata-availcheck = gs_input_data-link-mtvfp.

gs_plantdata-profit_ctr = gs_input_data-link-prctr.

gs_plantdatax-plant = gs_input_data-link-werks.

gs_plantdatax-auto_p_ord = 'X'.

gs_plantdatax-mrp_type = 'X'.

gs_plantdatax-max_stock = 'X'.

gs_plantdatax-proc_type = 'X'.

gs_plantdatax-safety_stk = 'X'.

gs_plantdatax-min_safety_stk = 'X'.

gs_plantdatax-availcheck = 'X'.

gs_plantdatax-profit_ctr = 'X'.

      • Accounting data update to MBEW table

gs_valuationdata-val_area = gs_input_data-link-werks.

gs_valuationdata-val_class = gs_input_data-link-bklas.

gs_valuationdata-price_ctrl = gs_input_data-link-vprsv.

gs_valuationdata-moving_pr = gs_input_data-link-verpr.

gs_valuationdata-price_unit = gs_input_data-link-peinh.

gs_valuationdatax-val_area = gs_input_data-link-werks.

gs_valuationdatax-val_class = 'X'.

gs_valuationdatax-price_ctrl = 'X'.

gs_valuationdatax-moving_pr = 'X'.

gs_valuationdatax-price_unit = 'X'.

      • Plant Storage locaiton update to MARD table

gs_storagelocationdata-plant = gs_input_data-link-werks.

gs_storagelocationdata-stge_loc = gs_input_data-link-lgort.

gs_storagelocationdata-stge_bin = gs_input_data-link-lgpbe.

gs_storagelocationdatax-plant = gs_input_data-link-werks.

gs_storagelocationdatax-stge_loc = gs_input_data-link-lgort.

gs_storagelocationdatax-stge_bin = 'X'.

      • Material text update to MAKT table

ls_materialdescription-langu = sy-langu.

ls_materialdescription-matl_desc = gs_input_data-link-maktx.

APPEND ls_materialdescription TO gt_materialdescription.

ls_materiallongtext-applobject = 'MATERIAL'.

ls_materiallongtext-text_name = gs_input_data-link-matnr.

ls_materiallongtext-text_id = 'BEST'.

ls_materiallongtext-langu = sy-langu.

MOVE gs_input_data-text TO ls_materiallongtext-text_line.

APPEND ls_materiallongtext TO gt_materiallongtext.

gs_unitsofmeasure-alt_unit = gs_input_data-link-meins.

gs_unitsofmeasure-alt_unit_iso = gs_input_data-link-meins.

APPEND gs_unitsofmeasure TO gt_unitsofmeasure.

gs_unitsofmeasure-alt_unit = gs_input_data-link-meins.

APPEND gs_unitsofmeasure TO gt_unitsofmeasure.

gs_unitsofmeasurex-alt_unit = gs_input_data-link-meins.

gs_unitsofmeasurex-alt_unit_iso = gs_input_data-link-meins.

APPEND gs_unitsofmeasurex TO gt_unitsofmeasurex.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = gs_headdata

clientdata = gs_clientdata

clientdatax = gs_clientdatax

plantdata = gs_plantdata

plantdatax = gs_plantdatax

storagelocationdata = gs_storagelocationdata

storagelocationdatax = gs_storagelocationdatax

valuationdata = gs_valuationdata

valuationdatax = gs_valuationdatax

IMPORTING

return = gs_return

TABLES

materialdescription = gt_materialdescription

unitsofmeasure = gt_unitsofmeasure

unitsofmeasurex = gt_unitsofmeasurex

materiallongtext = gt_materiallongtext.

IF sy-subrc EQ 0.

IF gs_return-type CA 'AEX'.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

MOVE-CORRESPONDING gs_input_data-link TO ls_error.

ls_error-message = gs_return-message.

APPEND ls_error TO rt_error.

ELSE.

IF NOT rv_commit IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

MOVE-CORRESPONDING gs_input_data-link TO ls_input.

APPEND ls_input TO rt_input.

ENDIF.

ENDIF.

CLEAR: gs_input_data,

gs_clientdata,

gs_plantdata,

gs_valuationdata,

gs_storagelocationdata,

gs_clientdatax,

gs_plantdatax,

gs_valuationdatax,

gs_storagelocationdatax,

gt_materialdescription,

gs_return.

REFRESH: gt_materialdescription.

ENDLOOP.

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question