Skip to Content
0
Former Member
Jan 17, 2012 at 11:03 PM

Re: Material master creation using BAPI_MATERIAL_SAVEDATA

74 Views

Hi,

I am creating Material Master record using BAPI_MATERIAL_SAVEDATA. I am getting all material details from BAPI_MATERIAL_GET_ALL and then passing them to variables of BAPI_MATERIAL_SAVEDATA.

I can create successfully material, but Sales Views are not created, always display the message , Material not found in Storage location X of plant Y.

I am using loop because, I am having multiple storage locations for combination of plant, sales organization and

distribution channel.

LOOP AT it_mvke .

CALL FUNCTION 'BAPI_MATERIAL_GET_ALL'

EXPORTING

material = p_matnr1

comp_code = it_t001k-bukrs

val_area = it_mbew-bwkey

val_type = it_mbew-bwtar

plant = p_werks

salesorg = it_mvke-vkorg

distr_chan = it_mvke-vtweg

IMPORTING

clientdata = it_client

plantdata = it_plant

storagelocationdata = it_storage

valuationdata = it_valuation

salesdata = it_sales

TABLES

taxclassifications = it_tax_class

return = it_return.

it_header-material = lv_matnr.

it_header-matl_type = it_mara-mtart.

it_header-ind_sector = it_mara-mbrsh.

it_header-sales_view = 'X'.

MOVE-CORRESPONDING it_sales TO it_sales1.

MOVE-CORRESPONDING it_sales1 TO it_sales1x.

  • BEGIN OF I_D01K966423 Add Code

MOVE-CORRESPONDING it_client TO it_client1.

MOVE-CORRESPONDING it_client1 TO it_client1x.

it_client1-old_mat_no = lv_matnr1.

it_client1-pur_status = 'M2'.

it_client1-sal_status = 'Z1'.

it_client1-svalidfrom = sy-datum.

  • END OF I_D0K966423 Add Code

MOVE-CORRESPONDING it_plant TO it_plant1.

MOVE-CORRESPONDING it_plant1 TO it_plant1x.

  • Tax classification for Sales view

LOOP AT it_tax_class.

MOVE-CORRESPONDING it_tax_class TO it_tax_class1.

APPEND it_tax_class1.

CLEAR : it_tax_class, it_tax_class1.

ENDLOOP.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = it_header

clientdata = it_client1

clientdatax = it_client1x

plantdata = it_plant1

plantdatax = it_plant1x

salesdata = it_sales1

salesdatax = it_sales1x

IMPORTING

return = it_return2

TABLES

taxclassifications = it_tax_class1[] " For Sales View

returnmessages = returnmsg2.

ENDLOOP.