cancel
Showing results for 
Search instead for 
Did you mean: 

Create/change inspec type in QM view thru BAPI_MATERIAL_SAVEDATA

former_member491305
Active Contributor
0 Kudos
599

Hi,

I need to create/change inspection type in Quality Management view for each Material in MM02. Can any one tell me how to do this through BAPI_MATERIAL_SAVEDATA for each material.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Go through the following Code

tables: mara, "General Material Data

makt, "Material Descriptions

mbew, "Material Valuation

marc. "Plant Data for Material

data : begin of it_reqdata occurs 0,

recid(1), " Record ID

plant(4), " Plant

project(30) , " Project

drawing(30), " Drawing

plnrgrp(4), " Planner Group

material(18), " Material

qty(7), " Quantity

unit(3), " Unit

ordstdt(10), " Delivery Date

req(3), " Requisner

end of it_reqdata.

  • Internal Table to hold data for extending the material to plant

data: begin of it_matdata occurs 100,

werks(4), "Plant

mtart(4), "Material type

matnr(18), "Material number

matkl(9) , "Material group

mbrsh(1), "Industry sector

meins(3), "Base unit of measure

gewei(3), "Weight Unit

spart(2), "Division

ekgrp(3), "Purchasing group

vprsv(1), "Price control indicator

stprs(12), "Standard price

peinh(3), "Price unit

spras(2), "Language key

maktx(40), "Material description

end of it_matdata.

  • Internal Table to hold material text when extending material to plant

data: begin of it_desc occurs 100.

include structure bapi_makt.

data: end of it_desc.

  • Internal tables for processing in 'BAPI_MATERIAL_SAVEDATA'

data: it_bapi_head like bapimathead,

it_bapi_mara1 like bapi_mara, "Client Data

it_bapi_marax like bapi_marax,

it_bapi_marc1 like bapi_marc, "Plant View

it_bapi_marcx like bapi_marcx,

it_bapi_mbew1 like bapi_mbew, "Accounting View

it_bapi_mbewx like bapi_mbewx,

it_bapi_return like bapiret2.

  • Check whether the material exists for the plant

loop at it_reqdata.

select single matnr

from marc into mara-matnr

where matnr = it_reqdata-material

and werks = it_reqdata-plant.

if sy-subrc <> 0.

  • If not extend the material into plant

perform extend_material.

endif.

endloop.

&----


*& Form extend_material

&----


  • To extend material

----


form extend_material .

  • Select material related data for extending

perform select_mat_data.

  • Move material related data to the tables for BAPI

perform move_mat_data.

  • Extend the material to plant using BAPI

perform extend_with_bapi.

endform. " extend_material

&----


*& Form select_mat_data

&----


  • Select material related data when extending material to plant

----


form select_mat_data .

  • select * from marc

  • where lvorm eq ' '

  • and werks = it_reqdata-plant

  • and matnr = it_reqdata-material.

clear mara.

select single *

from mara

where matnr = it_reqdata-material.

clear mbew.

select single *

from mbew

where matnr = it_reqdata-material

and bwkey = it_reqdata-plant.

clear makt.

select single *

from makt

where spras = 'EN'

and matnr = it_reqdata-material.

it_matdata-werks = marc-werks. "Plant

it_matdata-mtart = mara-mtart. "Material type

it_matdata-matnr = mara-matnr. "Material number

it_matdata-matkl = mara-matkl. "Material group

it_matdata-mbrsh = mara-mbrsh. "Industry sector

it_matdata-meins = mara-meins. "Base unit of measure

it_matdata-gewei = mara-gewei. "Weight Unit

it_matdata-spart = mara-spart. "Division

it_matdata-ekgrp = marc-ekgrp. "Purchasing group

it_matdata-vprsv = mbew-vprsv. "Price control indicator

it_matdata-stprs = mbew-stprs. "Standard price

it_matdata-peinh = mbew-peinh. "Price unit

it_matdata-spras = makt-spras. "Language key

it_matdata-maktx = makt-maktx. "Material description

append it_matdata.

clear it_matdata.

  • endselect.

endform. " select_mat_data

&----


*& Form move_mat_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form move_mat_data .

  • Header

it_bapi_head-material = it_matdata-matnr.

it_bapi_head-ind_sector = it_matdata-mbrsh.

it_bapi_head-matl_type = it_matdata-mtart.

it_bapi_head-basic_view = 'X'.

it_bapi_head-purchase_view = 'X'.

it_bapi_head-account_view = 'X'.

  • Material Description

refresh it_desc.

it_desc-langu = it_matdata-spras.

it_desc-matl_desc = it_matdata-maktx.

append it_desc.

  • Client Data - Basic

it_bapi_mara1-matl_group = it_matdata-matkl.

it_bapi_mara1-base_uom = it_matdata-meins.

it_bapi_mara1-unit_of_wt = it_matdata-gewei.

it_bapi_mara1-division = it_matdata-spart.

it_bapi_marax-matl_group = 'X'.

it_bapi_marax-base_uom = 'X'.

it_bapi_marax-unit_of_wt = 'X'.

it_bapi_marax-division = 'X'.

  • Plant - Purchasing

it_bapi_marc1-plant = it_matdata-werks.

it_bapi_marc1-pur_group = it_matdata-ekgrp.

it_bapi_marcx-plant = it_matdata-werks.

it_bapi_marcx-pur_group = 'X'.

  • Accounting

it_bapi_mbew1-val_area = it_matdata-werks.

it_bapi_mbew1-price_ctrl = it_matdata-vprsv.

it_bapi_mbew1-std_price = it_matdata-stprs.

it_bapi_mbew1-price_unit = it_matdata-peinh.

it_bapi_mbewx-val_area = it_matdata-werks.

it_bapi_mbewx-price_ctrl = 'X'.

it_bapi_mbewx-std_price = 'X'.

it_bapi_mbewx-price_unit = 'X'.

endform. " move_mat_data

&----


*& Form extend_with_bapi

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form extend_with_bapi .

call function 'BAPI_MATERIAL_SAVEDATA'

exporting

headdata = it_bapi_head

clientdata = it_bapi_mara1

clientdatax = it_bapi_marax

plantdata = it_bapi_marc1

plantdatax = it_bapi_marcx

valuationdata = it_bapi_mbew1

valuationdatax = it_bapi_mbewx

importing

return = it_bapi_return

tables

materialdescription = it_desc.

  • If error

if it_bapi_return-type = 'E'.

write:/ 'error'.

endif.

endform. " extend_with_bapi

Regards

Sreeni

Answers (1)

Answers (1)

former_member491305
Active Contributor
0 Kudos

Hi Sreeni,

I've tried BAPI_MATINSPCTRL_SAVEREPLICA to modify inspection type in QM view instead of BAPI_MATERIAL_SAVEDATA .It's working well.

Thank you Sreeni.

Former Member
0 Kudos

Hi

Can we use the BAPI ' BAPI_MATINSPCTRL_SAVEREPLICA ' to create inspection in QM view.

Can you please give me the input parameters.

I am getting the following error

E QA 080 The quality score procedure does not exist for inspection type 0800

W QS 024 Check the data for sample calculation for inspection type 0800

Because if data is not available in QMAT table it's giving this error.

Regards

Uma