Skip to Content

Need help in using FM BAPI_MATERIAL_SAVEDATA

Gurus,

I need help in using the FM BAPI_MATERIAL_SAVEDATA. The FM is returning a message that says "The field MARA-MEINS/BAPI_MARA-BASE_UOM(_ISO) is defined as a required field; it does not contain an entry".

I have supplied the necessary details and yet the FM won't push through.

If possible, please post sample codes.

Below is my sample code:

===============================================

REPORT zmm_materialupload.

  • eject

$$******************************************************************************

$$ TYPES

$$******************************************************************************

  • eject

$$******************************************************************************

$$ INTERNAL TABLES (custom structure

$$******************************************************************************

  • eject

$$******************************************************************************

$$ RANGES

$$******************************************************************************

  • {

  • }

  • eject

$$******************************************************************************

$$ FIELD-SYMBOLS

$$******************************************************************************

  • {

  • }

  • eject

$$******************************************************************************

$$ PARAMETERS & SELECT-OPTIONS

$$******************************************************************************

  • {

SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE text-001.

*SELECT-OPTIONS: s_matnr FOR mara-matnr.

SELECT-OPTIONS: s_mtart FOR mara-mtart.

SELECT-OPTIONS: s_mbrsh FOR mara-mbrsh DEFAULT 'P'.

SELECT-OPTIONS: s_werks FOR marc-werks DEFAULT '1000' OBLIGATORY.

SELECT-OPTIONS: s_lgort FOR marc-lgpro DEFAULT 'OPSL' OBLIGATORY.

PARAMETERS: p_path LIKE rlgrap-filename DEFAULT 'C:\Documents and Settings\training_11\Desktop\Book4 (2ITEMS).txt' OBLIGATORY.

SELECTION-SCREEN END OF BLOCK 1.

  • }

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

field_name = 'P_FNAME'

IMPORTING

file_name = p_path.

  • eject

$$******************************************************************************

$$ START-OF-SELECTION

$$******************************************************************************

  • {

START-OF-SELECTION.

PERFORM check_input.

PERFORM get_file.

PERFORM filter_input.

  • PERFORM populate_tabs.

PERFORM bapi_mat.

  • }

  • eject

$$******************************************************************************

$$ FORMS

$$******************************************************************************

  • {

FORM bapi_mat.

LOOP AT it_tab INTO wa_tab.

CALL FUNCTION 'BAPI_MATERIAL_GETINTNUMBER'

EXPORTING

material_type = wa_tab-mtart

industry_sector = wa_tab-mbrsh

required_numbers = 1

TABLES

material_number = it_matnr.

ENDLOOP.

LOOP AT it_matnr INTO wa_matnr.

READ TABLE it_tab INTO wa_tab INDEX sy-tabix.

wa_tab-matnr = wa_matnr-material.

MODIFY it_tab FROM wa_tab INDEX sy-tabix.

ENDLOOP.

PERFORM populate_tabs.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = it_headdata

  • clientdata = it_clientdata

  • clientdatax = it_clientdatax

  • plantdata = it_plantdata

  • plantdatax = it_plantdatax

  • FORECASTPARAMETERS =

  • FORECASTPARAMETERSX =

  • PLANNINGDATA =

  • PLANNINGDATAX =

  • STORAGELOCATIONDATA =

  • STORAGELOCATIONDATAX =

  • valuationdata = it_valuationdata

  • valuationdatax = it_valuationdatax

  • WAREHOUSENUMBERDATA =

  • WAREHOUSENUMBERDATAX =

  • SALESDATA =

  • SALESDATAX =

  • STORAGETYPEDATA =

  • STORAGETYPEDATAX =

  • flag_online = ' '

  • flag_cad_call = ' '

  • NO_DEQUEUE = ' '

  • NO_ROLLBACK_WORK = ' '

IMPORTING

return = it_return

TABLES

materialdescription = it_materialdescription

unitsofmeasure = it_unitsofmeasure

unitsofmeasurex = it_unitsofmeasurex

internationalartnos = it_internationalartnos

materiallongtext = it_materiallongtext

taxclassifications = it_taxclassifications

returnmessages = it_returnmessages

  • PRTDATA =

  • PRTDATAX =

  • EXTENSIONIN =

  • EXTENSIONINX =

.

IF sy-subrc = 0.

ENDIF.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'

IMPORTING

return = it_return.

ENDFORM. "bapi_mat

&----


*& Form GET_FILE

&----


  • text

----


FORM get_file.

CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'

EXPORTING

text = 'Getting data from file...'.

MOVE: p_path TO gv_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = gv_file

filetype = 'ASC'

has_field_separator = 'X'

read_by_line = 'X'

TABLES

data_tab = it_tab

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDFORM. "GET_FILE

&----


*& Form check_input

&----


  • text

----


FORM check_input.

  • Material Type

IF s_mtart-low IS INITIAL AND s_mtart-high IS INITIAL.

  • s_mtart = 'IEQ'.

  • s_mtart-low = 'ABF'. "Waste

  • s_mtart-high = 'ZTRD'. "Stock Items

  • APPEND s_mtart.

ENDIF.

IF s_mtart-low IS NOT INITIAL AND s_mtart-high IS INITIAL.

MOVE: s_mtart-low TO s_mtart-high.

ENDIF.

  • Industry Sector

IF s_mbrsh-low IS INITIAL AND s_mbrsh-high IS INITIAL.

  • s_mbrsh = 'IEQ'.

*

  • SELECT mbrsh

  • FROM mara

  • INTO TABLE it_mbrsh.

  • s_mbrsh-low = wa_mbrsh-mbrsh.

*

  • LOOP AT it_mbrsh INTO wa_mbrsh.

  • s_mbrsh-high = wa_mbrsh-mbrsh.

  • ENDLOOP.

*

  • APPEND s_mbrsh.

ENDIF.

IF s_mbrsh-low IS NOT INITIAL AND s_mbrsh-high IS INITIAL.

MOVE: s_mbrsh-low TO s_mbrsh-high.

ENDIF.

  • Plant

IF s_werks-low IS INITIAL AND s_werks-high IS INITIAL.

s_werks = 'IEQ'.

s_werks-low = '1000'.

s_werks-high = '2000'.

ENDIF.

IF s_werks-low IS NOT INITIAL AND s_werks-high IS INITIAL.

MOVE: s_werks-low TO s_werks-high.

ENDIF.

  • Storage Location

IF s_lgort-low IS NOT INITIAL AND s_lgort-high IS INITIAL.

MOVE: s_lgort-low TO s_lgort-high.

ENDIF.

ENDFORM. "check_input

&----


*& Form Filter_input

&----


  • text

----


FORM filter_input.

SORT it_tab BY matnr mtart mbrsh werks lgort.

LOOP AT it_tab INTO wa_tab.

  • IF wa_tab-mtart NOT IN s_mtart.

  • DELETE it_tab WHERE mtart NOT IN s_mtart.

  • ENDIF.

*

  • IF wa_tab-mbrsh NOT IN s_mbrsh.

  • DELETE it_tab WHERE mbrsh NOT IN s_mbrsh.

  • ENDIF.

IF wa_tab-werks NOT IN s_werks.

DELETE it_tab WHERE werks NOT IN s_werks.

ENDIF.

IF wa_tab-lgort NOT IN s_lgort.

DELETE it_tab WHERE lgort NOT IN s_lgort.

ENDIF.

ENDLOOP.

ENDFORM. "Filter_input

&----


*& Form populate_tabs

&----


  • text

----


FORM populate_tabs.

LOOP AT it_tab INTO wa_tab.

MOVE: wa_tab-matnr TO wa_headdata-material,

wa_tab-mbrsh TO wa_headdata-ind_sector,

wa_tab-mtart TO wa_headdata-matl_type,

'X' TO wa_headdata-basic_view,

'X' TO wa_headdata-sales_view,

'X' TO wa_headdata-purchase_view,

'X' TO wa_headdata-mrp_view,

'X' TO wa_headdata-account_view.

  • wa_tab-matkl TO wa_clientdata-matl_group,

  • wa_tab-meins TO wa_clientdata-base_uom,

  • wa_tab-groes TO wa_clientdata-size_dim,

  • wa_tab-gewei TO wa_clientdata-unit_of_wt,

  • wa_tab-ntgew TO wa_clientdata-net_weight,

*

  • 'X' TO wa_clientdatax-matl_group,

  • 'X' TO wa_clientdatax-base_uom,

  • 'X' TO wa_clientdata-size_dim,

  • 'X' TO wa_clientdatax-unit_of_wt,

  • 'X' TO wa_clientdatax-net_weight,

*

  • wa_tab-werks TO wa_plantdata-plant,

  • wa_tab-ekgrp TO wa_plantdata-pur_group,

  • wa_tab-prctr TO wa_plantdata-profit_ctr,

*

  • wa_tab-werks TO wa_plantdatax-plant,

  • 'X' TO wa_plantdatax-pur_group,

  • 'X' TO wa_plantdatax-profit_ctr,

*

  • wa_tab-werks TO wa_valuationdata-val_area,

  • wa_tab-bklas TO wa_valuationdata-val_class,

  • wa_tab-peinh TO wa_valuationdata-price_unit,

  • wa_tab-verpr TO wa_valuationdata-moving_pr,

  • wa_tab-stprs TO wa_valuationdata-std_price,

  • wa_tab-xlifo TO wa_valuationdata-lifo_fifo,

*

  • wa_tab-werks TO wa_valuationdatax-val_area,

  • 'X' TO wa_valuationdatax-val_class,

  • 'X' TO wa_valuationdatax-price_unit,

  • 'X' TO wa_valuationdatax-moving_pr,

  • 'X' TO wa_valuationdatax-std_price,

  • 'X' TO wa_valuationdatax-lifo_fifo.

APPEND wa_headdata TO it_headdata.

  • APPEND wa_clientdata TO it_clientdata.

  • APPEND wa_plantdata TO it_plantdata.

  • APPEND wa_valuationdata TO it_valuationdata.

  • MODIFY it_tab FROM wa_tab TRANSPORTING matnr.

ENDLOOP.

ENDFORM. "populate_tabs

  • }

$$******************************************************************************

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 09:46 AM

    Hai.

    check the below example.

    REPORT z34332_bdc_create_material .

    data: la_headdata type BAPIMATHEAD,

    la_clientdata type BAPI_MARA,

    la_CLIENTDATAX type BAPI_MARAX,

    la_return type BAPIRET2.

    data: i_materialdescription type table of BAPI_MAKT,

    wa_materialdescription like line of i_materialdescription.

    la_headdata-MATERIAL = '000000000000000004'.

    la_headdata-IND_SECTOR = 'M'.

    la_headdata-MATL_TYPE = 'FERT'.

    la_clientdata-BASE_UOM = 'FT3'.

    la_CLIENTDATAX-BASE_UOM = 'X'.

    la_clientdata-MATL_GROUP = '01'.

    la_CLIENTDATAX-MATL_GROUP = 'X'.

    wa_materialdescription = 'TEST'.

    append wa_materialdescription to i_materialdescription.

    clear: wa_materialdescription.

    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

    EXPORTING

    headdata = la_headdata

    CLIENTDATA = la_clientdata

    CLIENTDATAX = la_CLIENTDATAX

    • PLANTDATA =

    • PLANTDATAX =

    • FORECASTPARAMETERS =

    • FORECASTPARAMETERSX =

    • PLANNINGDATA =

    • PLANNINGDATAX =

    • STORAGELOCATIONDATA =

    • STORAGELOCATIONDATAX =

    • VALUATIONDATA =

    • VALUATIONDATAX =

    • WAREHOUSENUMBERDATA =

    • WAREHOUSENUMBERDATAX =

    • SALESDATA =

    • SALESDATAX =

    • STORAGETYPEDATA =

    • STORAGETYPEDATAX =

    • FLAG_ONLINE = ' '

    • FLAG_CAD_CALL = ' '

    IMPORTING

    RETURN = la_return

    TABLES

    MATERIALDESCRIPTION = i_materialdescription

    • UNITSOFMEASURE =

    • UNITSOFMEASUREX =

    • INTERNATIONALARTNOS =

    • MATERIALLONGTEXT =

    • TAXCLASSIFICATIONS =

    • RETURNMESSAGES =

    • PRTDATA =

    • PRTDATAX =

    • EXTENSIONIN =

    • EXTENSIONINX =

    .

    write: la_return-TYPE, ',', la_return-MESSAGE.

    clear: la_headdata, la_return, la_clientdata, la_clientdatax.

    regards.

    sowjanya.b.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.