cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Update of tax classification using BAPI_MATERIAL_MAINTAINDATA_RT - only partly updated.

Hamren
Newcomer
0 Likes
353

Hi,

I have a program that uses BAPI_MATERIAL_MAINTAINDATA_RT to update tax classification.

The problem is that the tax class (MARA-TAKLV) is not updated in General tab in MM43,

Hamren_0-1740560047957.png

...but if pressing button "Tax Data" next to the field the value it is updated there for SE (Sweden) KSCHL = MWST:

Hamren_2-1740560176213.png

The tax code change is due to a switch from one merchandise category to another and the tax code should be changed to the same as reference article have on the merchandise category the article is moved to.

 

 

 

  CLEAR: as_tax, at_tax.

  "Read mara-taklv from reference article.
  DATA(lv_ref_art) = zcl_mdam_lsd_mara=>get_ref( iv_matkl = p_nmatkl ).
  DATA(lv_taklv) = zcl_mdam_lsd_mara=>get( lv_ref_art )-taklv.

  CLEAR as_headdata.
  " Function change.
  as_headdata-function   = '004'.
  " Article number
  as_headdata-material   = p_matnr.
  as_headdata-matl_type = 'ZLOC'.
  " Reference article number
  as_headdata-ref_matl = lv_ref_art.
  as_headdata-matl_group = p_nmatkl.
  as_headdata-basic_view = abap_true.
  "as_headdata-sales_view = abap_true.
  " Set no application log.
  as_headdata-no_appl_log = abap_true.

  IF lv_taklv IS NOT INITIAL.
    " Set change.
    as_tax-function   = '004'.
    as_tax-material   = p_matnr.
    as_tax-tax_ind    = lv_taklv.
    as_tax-depcountry_iso = 'SE'.
    as_tax-depcountry = 'SE'.
    as_tax-tax_type_1 = 'MWST'.
    as_tax-taxclass_1 = lv_taklv.
    APPEND as_tax TO at_tax.

    as_clientdata-material   = p_matnr.
    as_clientdatax-material  = p_matnr.
    " Set update flags.
    as_clientdata-function   = '004'.
    as_clientdatax-function  = '004'.
    " Set tax class.
    as_clientdata-tax_class  = lv_taklv.
    as_clientdatax-tax_class = abap_true.
    as_clientdata-countryori = 'SE'.
    as_clientdata-countryori_iso = 'SE'.
    as_clientdatax-countryori = abap_true.
    as_clientdatax-countryori_iso = abap_true.

    APPEND as_clientdata TO at_clientdata.
    APPEND as_clientdatax TO at_clientdatax.
  ENDIF.

    IF as_selected_node IS NOT INITIAL.
      as_plantdata-function    = zdom_msgfn_004.
      as_plantdatax-function   = zdom_msgfn_004.
      as_plantdata-material    = av_matnr.
      as_plantdatax-material   = av_matnr.
      as_plantdata-plant       = ac_ref_store.
      as_plantdatax-plant      = abap_true.
      as_plantdata-cc_ph_inv   = get_ref_abcin( ).
      as_plantdatax-cc_ph_inv   = abap_true.
      APPEND as_plantdata TO at_plantdata.
      APPEND as_plantdatax TO at_plantdatax.
    ENDIF.

  DATA: ls_return  TYPE bapireturn1,
        ls_return2 TYPE bapiret2.

  " Call FM to update

  CALL FUNCTION 'BAPI_MATERIAL_MAINTAINDATA_RT'
    EXPORTING
      headdata           = as_headdata
    IMPORTING
      return             = ls_return
    TABLES
      clientdata         = at_clientdata
      clientdatax        = at_clientdatax
      plantdata          = at_plantdata
      plantdatax         = at_plantdatax
      taxclassifications = at_tax.
*  " Set return.
  ls_return2 = ls_return.

  IF p_test = abap_false.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      IMPORTING
        return = ls_return2.
  ELSE.
    " Call rollback.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
      IMPORTING
        return = rs_return.
  ENDIF.

 

 

 

Can you please assist how to update the taxcode/tax classification fully?

 

 

Accepted Solutions (0)

Answers (0)