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

Create Material Master

Former Member
0 Likes
1,877

Hi guys

I want to describe my situation. I want to create a material master data with the bapi "bapi_master_savedata". I have found out that this is the right one. Now I went to Tcode "se37" and saw too many input possibilities. I inserted some values but an error says the value "matnr" is blank or something like that. I just want to insert some mandatory values, create a material and get back the response.

Import parameters

Headdata/MATERIAL=new_material

Headdata/IND_SECTOR=c

Headdata/MATL_TYPE=voll

Clientdata/MATL_GROUP=01

Clientdata/BASE_OUM=GAI

Tables

Materialdescription/MATL_DESC=neues_material_desc

My question to you is, which input values are mandatory and have to be given input at least??

Thanks for your help.

Go:khan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,745

Actually....All parameters are optional except for <b>HEADDATA</b> which is mandatory...You must fill the whole structure. It's based on table <b>BAPIMATHEAD</b>.

Greetings,

Blag.

10 REPLIES 10
Read only

Former Member
0 Likes
1,746

Actually....All parameters are optional except for <b>HEADDATA</b> which is mandatory...You must fill the whole structure. It's based on table <b>BAPIMATHEAD</b>.

Greetings,

Blag.

Read only

0 Likes
1,745

Hi Alvaro

Thanks for the quick reply. Ok this information is a first big hint for me.

I have inserted some values in the headdata fiels and executed it. It says: "170 The parameter KZ_PFR does not contain a valid value".

I can't find this parameter in the headdata?

Where can I find it quickly amid that amount of parameters??

Read only

0 Likes
1,745

Hi

I have successfully created a material master data, horray. Thanks you all.

I have one final question. Is there any response value that is thrown back ???

Read only

0 Likes
1,745

Well, its an external Number range assigned, then you get the material number back.

Regards,

Ravi

Note : Please reward the posts that helped you.

Read only

0 Likes
1,745

You will definitly want to check the messages.



    returnmessages             = returnm


There will be a success message in there that says that the material was created.

The message class is M3 and number is 800, the new material number will be in the MESSAGE_V1 field

Regards,

Rich Heilman

Read only

0 Likes
1,745

Hi Rich

There is a return of type BAPIRET2

and a returnmessages of type BAPI_MATRETURN2 (that you mentioned)

Ok I will check at least the fields in "returnmessages".

Where can I check the values from the response??

Maybe right away in tcode se37??

Read only

0 Likes
1,745

Gokhan,

If you executing the function in a stand alone mode, you will get it in SE37. If you are calling from a program, then the return values will come into the variable which is recieving the the values.

Regards,

Ravi

Read only

ferry_lianto
Active Contributor
0 Likes
1,745

Hi Gokhan,

You can take a look at import, export and tables parameters of the function module/BAPI. If the optional checkbox is not checked then it means mandatory field otherwise an option for you to populate or not.

Hope this will help.

Regards,

Ferry Lianto

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,745

It really depends on what fields you have marked as required in configuration. Here is a sample program that creates a FERT material with the bare minimum fields.



report zrich_0003 .

data: headdata type bapimathead.
data: clientdata type bapi_mara.
data: clientdatax type bapi_marax.
data: descdata type table of BAPI_MAKT with header line.
data: return type  bapiret2 .
data: returnm type table of bapi_matreturn2 with header line.
data: xmara type mara.


parameters: p_matnr type mara-matnr.


headdata-material        = p_matnr.
headdata-ind_sector      = 'M'.
headdata-matl_type       = 'FERT'.
headdata-basic_view = 'X'.


clientdata-BASE_UOM   = 'EA'.
clientdatax-BASE_UOM   = 'X'.
clientdata-old_mat_no = 'Old Material'.
clientdatax-old_mat_no = 'X'.
clientdata-division = '00'.
clientdatax-division = 'X'.

descdata-LANGU = sy-langu.
descdata-MATL_DESC = 'This is the description'.
append descdata.

call function 'BAPI_MATERIAL_SAVEDATA'
  exporting
    headdata                   = headdata
    clientdata                 = clientdata
    clientdatax                = clientdatax
*   PLANTDATA                  =
*   PLANTDATAX                 =
*   FORECASTPARAMETERS         =
*   FORECASTPARAMETERSX        =
*   PLANNINGDATA               =
*   PLANNINGDATAX              =
*   STORAGELOCATIONDATA        =
*   STORAGELOCATIONDATAX       =
*   VALUATIONDATA              =
*   VALUATIONDATAX             =
*   WAREHOUSENUMBERDATA        =
*   WAREHOUSENUMBERDATAX       =
*   SALESDATA                  =
*   SALESDATAX                 =
*   STORAGETYPEDATA            =
*   STORAGETYPEDATAX           =
 importing
   return                     = return
  tables
    MATERIALDESCRIPTION        = descdata
*   UNITSOFMEASURE             =
*   UNITSOFMEASUREX            =
*   INTERNATIONALARTNOS        =
*   MATERIALLONGTEXT           =
*   TAXCLASSIFICATIONS         =
    returnmessages             = returnm
*   PRTDATA                    =
*   PRTDATAX                   =
*   EXTENSIONIN                =
*   EXTENSIONINX               =
          .

check sy-subrc  = 0.



Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,745

Hi. I am having a problem with bapi_material_savedata. I am creating new material and we are using external numbering. I used bapi_material_getintnumber to get the next material number then use it when calling bapi bapi_material_savedata. However, after executing the savedata bapi an error occurs saying that the material number is not existing. my question is how will i'm going to use the number I got from bapimaterial_getintnumber.

Please help