In part 1 SAP ABAP Creating a Material using a BAPI Part 1 we have seen how to get the next Material Number. In this Part we will see the parameters that need to be passed for creating the actual Material. For simplicity let us keep the number of parameters to minimum. We will just pass the mandatory fields as per the system that I am using. Please note that you need to pass the Material Number Obtained in the previous Part. Also make sure that you run the following BAPIs in the Order shown below.
To create a Material in SAP using a BAPI you need to use the following 2 BAPIs
_______________________________________________
Pass the Material Number obtained
from the above BAPI to the following BAPI
_______________________________________________
_______________________________________________
Parameters: p_matype like BAPIMATDOA-MATL_TYPE,
p_indsr like BAPIMATDOA-IND_SECTOR,
p_reqnum like BAPIMATALL-REQ_NUMBERS.
Data: d_ret like BAPIRETURN1,
d_ret2 like BAPIRET2.
Data: int_matnum type BAPIMATINR occurs 0 with header line,
int_matdesc type BAPI_MAKT occurs 0 with header line.
Data: st_headdata like BAPIMATHEAD,
st_clientdata like BAPI_MARA,
st_clientx like BAPI_MARAX.
CALL FUNCTION 'BAPI_MATERIAL_GETINTNUMBER'
EXPORTING
MATERIAL_TYPE = p_matype
INDUSTRY_SECTOR = p_indsr
REQUIRED_NUMBERS = p_reqnum
IMPORTING
RETURN = d_ret
TABLES
MATERIAL_NUMBER = int_matnum.
if sy-subrc = 0.
endif.
loop at int_matnum.
st_headdata-MATERIAL = int_matnum-MATERIAL.
endloop.
int_matdesc-langu ='E'.
int_matdesc-langu_iso = 'E'.
int_matdesc-matl_desc = 'Material 1'.
append int_matdesc.
clear int_matdesc.
st_headdata-ind_sector = 'C'.
st_headdata-matl_type = 'HAWA'.
st_clientdata-MATL_GROUP = '001'.
st_clientdata-BASE_UOM = 'BT'.
st_clientdata-BASE_UOM_ISO = 'BT'.
st_clientx-MATL_GROUP ='X'.
st_clientx-BASE_UOM = 'X'.
st_clientx-BASE_UOM_ISO = 'X'.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
HEADDATA = st_headdata
CLIENTDATA = st_clientdata
CLIENTDATAX = st_clientx
* PLANTDATA =
* PLANTDATAX =
* FORECASTPARAMETERS =
* FORECASTPARAMETERSX =
* PLANNINGDATA =
* PLANNINGDATAX =
* STORAGELOCATIONDATA =
* STORAGELOCATIONDATAX =
* VALUATIONDATA =
* VALUATIONDATAX =
* WAREHOUSENUMBERDATA =
* WAREHOUSENUMBERDATAX =
* SALESDATA =
* SALESDATAX =
* STORAGETYPEDATA =
* STORAGETYPEDATAX =
* FLAG_ONLINE = ' '
* FLAG_CAD_CALL = ' '
* NO_DEQUEUE = ' '
IMPORTING
RETURN = d_ret2
TABLES
MATERIALDESCRIPTION = int_matdesc
* UNITSOFMEASURE =
* UNITSOFMEASUREX =
* INTERNATIONALARTNOS =
* MATERIALLONGTEXT =
* TAXCLASSIFICATIONS =
* RETURNMESSAGES =
* PRTDATA =
* PRTDATAX =
* EXTENSIONIN =
* EXTENSIONINX =
.
If sy-subrc = 0.
Endif.
No comments:
Post a Comment