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

BAPI_MATERIAL_SAVEDATA / Purchase view

Former Member
0 Likes
10,606

Hello Gurus i'm once again in need of your help,

So i'm using the bapi  BAPI_MATERIAL_SAVEDATA to update materials via batch input ("txt file uploaded with a template")

i managed to get most of the views i need and populate and the fields i need, the catch is when i go to the tcode MM03 to see the material updated

the purchase view is missing, so i passed the value 'X' to the Headdata i.e. (" headdata-purchase_view = 'X'.") but when i do so

i get the error message E M3 019 as sen in the image

i'm already passing values to the structure  taxclassificationss, but the value dissapears in the error message, if i pass another random value

it's shown in the error message. i get the right values to the structure with this code and pass it to the bapi:

*****************************

CALL FUNCTION 'STEUERTAB_IDENTIFY'

           EXPORTING

             vkorg       = gwa_plantilla-org_ventas

             bukrs_vkorg = gwa_plantilla-org_ventas

             vtweg       = gwa_plantilla-canal_dist

           TABLES

             steuertab   = lt_steuertab.

         LOOP AT lt_steuertab INTO ls_steuertab.

           MOVE ls_steuertab-aland TO taxclassifications-depcountry.

           MOVE ls_steuertab-tatyp TO taxclassifications-tax_type_1.

           MOVE '1' TO taxclassifications-taxclass_1.

           MOVE gwa_plantilla-id_imp_mat to taxclassifications-tax_ind.

           APPEND taxclassifications.

         ENDLOOP.

*****************************

I get this error when i execute my code with the passed the value 'X' to the Headdata i.e. (" headdata-purchase_view = 'X'.")

is there another structure i'm missing to pass the taxes?, please help.


Best Regards.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
9,396

Hi

The fm STEUERTAB_IDENTIFY returns sales tax, not purchase tax: try to check the table  TMKM1

Max

Hello Gurus i'm once again in need of your help,

So i'm using the bapi  BAPI_MATERIAL_SAVEDATA to update materials via batch input ("txt file uploaded with a template")

i managed to get most of the views i need and populate and the fields i need, the catch is when i go to the tcode MM03 to see the material updated

the purchase view is missing, so i passed the value 'X' to the Headdata i.e. (" headdata-purchase_view = 'X'.") but when i do so

i get the error message E M3 019 as sen in the image

i'm already passing values to the structure  taxclassificationss, but the value dissapears in the error message, if i pass another random value

it's shown in the error message. i get the right values to the structure with this code and pass it to the bapi:

*****************************

CALL FUNCTION 'STEUERTAB_IDENTIFY'

           EXPORTING

             vkorg       = gwa_plantilla-org_ventas

             bukrs_vkorg = gwa_plantilla-org_ventas

             vtweg       = gwa_plantilla-canal_dist

           TABLES

             steuertab   = lt_steuertab.

         LOOP AT lt_steuertab INTO ls_steuertab.

           MOVE ls_steuertab-aland TO taxclassifications-depcountry.

           MOVE ls_steuertab-tatyp TO taxclassifications-tax_type_1.

           MOVE '1' TO taxclassifications-taxclass_1.

           MOVE gwa_plantilla-id_imp_mat to taxclassifications-tax_ind.

           APPEND taxclassifications.

         ENDLOOP.

*****************************

I get this error when i execute my code with the passed the value 'X' to the Headdata i.e. (" headdata-purchase_view = 'X'.")

is there another structure i'm missing to pass the taxes?, please help.


Best Regards.

22 REPLIES 22
Read only

Former Member
0 Likes
9,397

Hi

The fm STEUERTAB_IDENTIFY returns sales tax, not purchase tax: try to check the table  TMKM1

Max

Read only

0 Likes
9,396

Thanks for your reply it seems that the table is empty with this function wich could explain the error, how do i fill this to pass the values to the taxclassification table in the bapi?

Read only

0 Likes
9,380

Hi

It depends which taxes you need to upload: Sales or Purchase?

It seems your system doesn't manage the taxes for purchase, if it's so, you should upload the taxes with sales view.

Anyway you should check in which view you can see the taxes, you can run MM03 for an old material code.

Read only

0 Likes
9,380

I need to upload both of them, with my previous function i upload the tax data for the sales wich i already did.

the problem is when i want to fill the purchase view / "tax ind. f. material" field with the letter "A",

wich is filled i suppose with the function you passed(?) but retrieves empty fields, i also checked

table TMKM1 wich was empty with the country needed i filled it with the needed values but still no good results in the function  STEUMMTAB_IDENTIFY it still just gets the country code

Read only

0 Likes
9,380

Hi

I think you don't need to use a particular fm to upload the taxes data, probably you can transfer the MM classification and country (of your plant) only :


CALL FUNCTION 'STEUERTAB_IDENTIFY'

           EXPORTING

             vkorg       = gwa_plantilla-org_ventas

             bukrs_vkorg = gwa_plantilla-org_ventas

             vtweg       = gwa_plantilla-canal_dist

           TABLES

             steuertab   = lt_steuertab.

         LOOP AT lt_steuertab INTO ls_steuertab.

           MOVE ls_steuertab-aland TO taxclassifications-depcountry.

           MOVE ls_steuertab-tatyp TO taxclassifications-tax_type_1.

           MOVE '1' TO taxclassifications-taxclass_1.

           MOVE gwa_plantilla-id_imp_mat to taxclassifications-tax_ind.

           APPEND taxclassifications.

         ENDLOOP.

MOVE: T001W-LAND1               to taxclassifications-depcountry.,

MOVE gwa_plantilla-id_imp_mat to taxclassifications-tax_ind.

APPEND taxclassifications.

Max

Read only

0 Likes
9,380

i guess not, but even so i get the same message "E M3 019" how do i manage the taxes for purchase?, or how do i pass the tax values for sale to purchase?, in which structure or table or field do i fill my requiered field?("which is shown empty in the error"), i was trying  the taxclassifications table where i can pass 'A' as a  "tax_ind" but it seems it does not work.


Thanks for your time.

Read only

JL23
Active Contributor
0 Likes
9,380

Create one material manually using the data from your template.

Then check how the record(s) appears in table MLAN

And this value is what you have to get over via the taxclassifications, basically nothing more than DEPCOUNTRY and TAX_IND fields in case of purchasing.

Read only

0 Likes
9,380

Hi

The purchase taxes are not managed in my system, so that error message is right for me, but I've tried to run the BAPI in order to upload it.

Of course I've that error, but now I can check where that error is raised:

it's raised by fm MLAN_TAXIM, so you can try to set a break-point and check which values are checked here.

Anyway I can see that fm check the values transfered to BAPI parameter TAXCLASSIFICATIONS:

TAXCLASSIFICATIONS-DEPCOUNTRY and  TAXCLASSIFICATIONS-TAX_IND

Read only

0 Likes
9,380

It seems the value for the tax_ind("material in yellow color field") in MLAN is empty for the material i need wich i guess gives that error(?)

but i pass that value to the taxclassifications-tax_ind isn't the BAPI supposed to update that value?

Read only

JL23
Active Contributor
0 Likes
9,380

the BAPI does not update it replaces it if you have no error message.

in case you have already data in MLAN then you need to fetch the data from there and enhance it with the new data and insert it into the taxclassification table

Read only

0 Likes
9,373

i get no error when i comment the " headdata-purchase_view = 'X'." in my code but even so i can't get to modify that value, i passed the data to taxclassifications as seen in the image:

with this the code executes properly but i can't see the purchase view in mm03("which i was asking in the first place") and the field is not modified in the table MLAN neither.

Thanks for your time.

Read only

0 Likes
9,373

i know im fetching those values in the table with no results.

thanks for your time.

Read only

JL23
Active Contributor
0 Likes
9,373

all what you provided so far is information about taxclassification, you have not shown anything from your purchasing data view at all. We do not know if you entered somewhere the plant code, if you have any values for other fields in that screen...

Read only

0 Likes
9,373

But can you update purchase tax manually by MM02?

Read only

0 Likes
9,373

this code works properly as i said early but it does not mdify those fields please help me correcting

some mistakes it may have as you say.

         CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

           EXPORTING

             input  = gwa_plantilla-material

           IMPORTING

             output = gwa_plantilla-material.

         CALL FUNCTION 'BAPI_MATERIAL_GET_ALL'

           EXPORTING

             material = gwa_plantilla-material

             plant    = gwa_plantilla-centro

             stge_loc = gwa_plantilla-almacen

           TABLES

             return   = return.

         "Headdata

         headdata-material = gwa_plantilla-material.

         headdata-ind_sector = gwa_plantilla-ramo.

         headdata-matl_type = gwa_plantilla-t_material.

         "headdata-basic_view    = 'X'.

         "headdata-sales_view    = 'X'.

         "headdata-purchase_view = 'X'.

         "headdata-mrp_view      = 'X'.

         "headdata-storage_view  = 'X'.

         "headdata-account_view  = 'X'.

         "headdata-cost_view = 'X'.

         "Clientdata

         clientdata-matl_group = '.'.

         clientdata-pur_valkey = ' '.

         clientdata-base_uom = 'UND'.

         clientdata-trans_grp = gwa_plantilla-gr_transp.

         clientdata-stor_conds = gwa_plantilla-cond_almacenaje.

         clientdata-pur_valkey = 'X'.

         clientdata-base_uom = 'X'.

         clientdata-matl_group = 'X'.

         clientdatax-trans_grp = 'X'.

         clientdatax-stor_conds = 'X'.

         "Plantdata

         plantdata-plant = gwa_plantilla-centro.

         plantdata-availcheck = gwa_plantilla-verif_disp.

         plantdata-loadinggrp = gwa_plantilla-gr_carga.

         CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

           EXPORTING

             input  = gwa_plantilla-centro_bnf

           IMPORTING

             output = gwa_plantilla-centro_bnf.

         plantdata-profit_ctr = gwa_plantilla-centro_bnf.

         plantdata-pur_group = gwa_plantilla-gr_compras.

         plantdata-comm_code = gwa_plantilla-n_mci_n_cod_imp.

         plantdata-mrp_type = gwa_plantilla-crt_plan_nec.

         plantdata-mrp_group = gwa_plantilla-gr_plan_nec.

         plantdata-reorder_pt = gwa_plantilla-pto_pedido.

         plantdata-mrp_ctrler = gwa_plantilla-planif_nec.

         plantdata-lotsizekey = gwa_plantilla-tm_lote_planif_nec.

         plantdata-max_stock = gwa_plantilla-stock_max.

         plantdata-spproctype = gwa_plantilla-aprov_esp.

         plantdata-plnd_delry = gwa_plantilla-plz_ent_prev.

         plantdata-sm_key = gwa_plantilla-cl_horizonte.

         plantdata-safety_stk = gwa_plantilla-stock_seg.

         plantdata-plan_strgp = gwa_plantilla-gr_est_planif.

         plantdatax-plant = gwa_plantilla-centro.

         plantdatax-availcheck = 'X'.

         plantdatax-loadinggrp = 'X'.

         plantdatax-profit_ctr = 'X'.

         plantdatax-pur_group = 'X'.

         plantdatax-comm_code = 'X'.

         plantdatax-mrp_type = 'X'.

         plantdatax-mrp_group = 'X'.

         plantdatax-reorder_pt = 'X'.

         plantdatax-mrp_ctrler = 'X'.

         plantdatax-lotsizekey = 'X'.

         plantdatax-max_stock = 'X'.

         plantdatax-spproctype = 'X'.

         plantdatax-plnd_delry = 'X'.

         plantdatax-sm_key = 'X'.

         plantdatax-safety_stk = 'X'.

         plantdatax-plan_strgp = 'X'.

         "Forecastparameters

         forecastparameters-plant = gwa_plantilla-centro.

         forecastparametersx-plant = gwa_plantilla-centro.

         "Planningdata

         planningdata-plant = gwa_plantilla-centro.

         planningdatax-plant = gwa_plantilla-centro.

         "Storagelocationdata

         storagelocationdata-plant = gwa_plantilla-centro.

         storagelocationdata-stge_loc = gwa_plantilla-almacen.

         storagelocationdata-stge_bin = gwa_plantilla-ubicacion.

         storagelocationdatax-plant = storagelocationdata-plant.

         storagelocationdatax-stge_loc = storagelocationdata-stge_loc.

         storagelocationdatax-stge_bin = 'X'.

         "Salesdata

         salesdata-sales_org = gwa_plantilla-org_ventas.

         salesdata-distr_chan = gwa_plantilla-canal_dist.

         salesdata-matl_stats = gwa_plantilla-gr_estad.

         salesdata-acct_assgt = gwa_plantilla-gr_imp_mat.

         salesdatax-sales_org = gwa_plantilla-org_ventas.

         salesdatax-distr_chan = gwa_plantilla-canal_dist.

         salesdatax-matl_stats = 'X'.

         salesdatax-acct_assgt = 'X'.

         "Valuationdata

         SELECT SINGLE bwkey

              INTO valuationdata-val_area

              FROM t001w

              WHERE werks = gwa_plantilla-centro.

         valuationdata-val_class = gwa_plantilla-cat_valoracion.

         valuationdata-price_ctrl = gwa_plantilla-cont_precios.

         valuationdatax-val_area = valuationdata-val_area.

         valuationdatax-val_class = 'X'.

         valuationdatax-price_ctrl = 'X'.

         "Tablas BAPI 'BAPI_MATERIAL_SAVEDATA'

         "Taxclassifications

         DATA: lt_steuertab TYPE TABLE OF mg03steuer,

               ls_steuertab TYPE mg03steuer.

         CALL FUNCTION 'STEUERTAB_IDENTIFY'

           EXPORTING

*           KZRFB       = ' '

             vkorg       = gwa_plantilla-org_ventas

             bukrs_vkorg = gwa_plantilla-org_ventas

             vtweg       = gwa_plantilla-canal_dist

           TABLES

             steuertab   = lt_steuertab.

         LOOP AT lt_steuertab INTO ls_steuertab.

           MOVE ls_steuertab-aland TO taxclassifications-depcountry.

           MOVE ls_steuertab-tatyp TO taxclassifications-tax_type_1.

           MOVE '1' TO taxclassifications-taxclass_1.

           MOVE gwa_plantilla-id_imp_mat to taxclassifications-tax_ind.

           APPEND taxclassifications.

         ENDLOOP.

         CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

           EXPORTING

             headdata             = headdata

             clientdata           = clientdata

             clientdatax          = clientdatax

             plantdata            = plantdata

             plantdatax           = plantdatax

             forecastparameters   = forecastparameters

             forecastparametersx  = forecastparametersx

             planningdata         = planningdata

             planningdatax        = planningdatax

             storagelocationdata  = storagelocationdata

             storagelocationdatax = storagelocationdatax

             salesdata            = salesdata

             salesdatax           = salesdatax

             valuationdata        = valuationdata

             valuationdatax       = valuationdatax

           IMPORTING

             return               = return1

           TABLES

             taxclassifications   = taxclassifications

             returnmessages       = returnmessages.

         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

           IMPORTING

             return = return2.

Read only

0 Likes
9,373

yes but the requeriment it's supposed to be via txt file i upload with that data.

Read only

0 Likes
9,373

I know it but i wanted to be sure your customizing is ok

i've checked your error message again:

Tax category    is not defined for country EC

This is message M3 019 and it should show tax category too, in your case it's blank, so are you sure your're transfering it to the Bapi?

Read only

0 Likes
9,373

i checked debugging and the values are there

and then i pass the table to the bapi

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

           EXPORTING

             headdata             = headdata

             clientdata           = clientdata

             clientdatax          = clientdatax

             plantdata            = plantdata

             plantdatax           = plantdatax

             forecastparameters   = forecastparameters

             forecastparametersx  = forecastparametersx

             planningdata         = planningdata

             planningdatax        = planningdatax

             storagelocationdata  = storagelocationdata

             storagelocationdatax = storagelocationdatax

             salesdata            = salesdata

             salesdatax           = salesdatax

             valuationdata        = valuationdata

             valuationdatax       = valuationdatax

           IMPORTING

             return               = return1

           TABLES

             taxclassifications   = taxclassifications

             returnmessages       = returnmessages.


please refer to the other response for more info


thanks for your help.

Read only

JL23
Active Contributor
0 Likes
9,373

eventually a bug, check if implementing this note helps: 2287506 - BAPI_MATERIAL_SAVEDATA: Purchasing tax indicator for material is not transferred

Read only

0 Likes
9,373

I can't try your case in my system, I'm sorry

If you don't know where the error is raised, try to run the BAPI in debug and create a watchpoint for SY-MSGNO = 019

Read only

0 Likes
9,373

Thank you so much!, thanks to the note now i can get the value and the purchase view!

You sir are a saviour!

Read only

0 Likes
9,373

Thanks for your concern i solved my problem with the note 2287506!