In SAP ABAP you can create a Material using a BAPI. To do so you first need to get the Next Material Number. This can be obtained by using the following BAPI.
To create a Material in SAP using a BAPI you need to use the following 2 BAPIs
BAPI_MATERIAL_GETINTNUMBER
BAPI_MATERIAL_SAVEDATA
Let us now see the parameters that need to be passed to the BAPI BAPI_MATERIAL_GETINTNUMBER.
The Mandatory Parameters that need to be passed to the BAPI are as follows.
Material Type
Industry Sector
Required Numbers
Industry Sector
Required Numbers
Enter the desired values and generate the Next Material Number. Once you obtain the Material Number, you then need to pass this number to the following BAPI.
BAPI to create Material in SAP
BAPI_MATERIAL_SAVEDATA
REPORT ZEX_GETMATNUM .
Parameters: p_matype like BAPIMATDOA-MATL_TYPE,
p_indsr like BAPIMATDOA-IND_SECTOR,
p_reqnum like BAPIMATALL-REQ_NUMBERS.
Data: d_ret like BAPIRETURN1.
Data: int_matnum type BAPIMATINR occurs 0.
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.
Parameters: p_matype like BAPIMATDOA-MATL_TYPE,
p_indsr like BAPIMATDOA-IND_SECTOR,
p_reqnum like BAPIMATALL-REQ_NUMBERS.
Data: d_ret like BAPIRETURN1.
Data: int_matnum type BAPIMATINR occurs 0.
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.
I have used the following Parameters:
Material Type HAWA
Industry Sector C
Required Numbers 1
Industry Sector C
Required Numbers 1
See Also: SAP ABAP Creating a Material using a BAPI Part 2
____________________________________________________________________________________________________________________________________________________________________
No comments:
Post a Comment