Skip to Content
Technical Articles
Author's profile photo Lokanatha Malepati

How to add taxes to the Purchase Order sent to Ariba Network

One of the more common requirements when it comes to what to include on the Purchase Order sent to Supplier Network is taxes.

Customer in some countries have a legal obligation to add a tax on the PO line item.

Having that, the next step is to force the vendor to include the same on the PO flipped invoice.

 

To Populate PO taxes in IDOC ARBCIG_ORDERS segment E1EDP04 to Ariba system

We can populate taxes To Ariba using User Exit – EXIT_SAPLEINM_002 INCLUDE ZXM06U02.

IF int_edidd-segnam = 'E1EDP01'.

DATA:idoc_data  TYPE edidd,

ls_e1edp04 TYPE e1edp04,

it_komvtab TYPE STANDARD TABLE OF komv,

is_taxcom  TYPE taxcom,

es_lfa1    TYPE lfa1.


IF xekko-bsart NE 'ZSER'. “ For Po type Not Equal to Services

LOOP AT xekpo INTO DATA(is_ekpodata) WHERE ebelp = int_edidd-sdata+0(5).

is_taxcom-bukrs =  xekko-bukrs.

is_taxcom-budat =  xekko-aedat.

is_taxcom-bldat = xekko-aedat.

is_taxcom-waers  = xekko-waers.

is_taxcom-hwaer   = xekko-waers.

is_taxcom-kposn   = is_ekpodata-ebelp.

is_taxcom-mwskz   = is_ekpodata-mwskz.

*IS_TAXCOM-KOART  = 'H'.

is_taxcom-shkzg  = 'H'.

IF xekko-bstyp EQ 'F'.

is_taxcom-wrbtr = is_ekpodata-netwr.

ELSE.

is_taxcom-wrbtr = is_ekpodata-zwert.

ENDIF.

is_taxcom-xmwst   = 'X'."is_ekpodata-xmwst."

is_taxcom-lifnr   = xekko-lifnr.

is_taxcom-ekorg   = xekko-ekorg.

is_taxcom-llief = xekko-llief.

is_taxcom-bwtar = xekpo-bwtar.

is_taxcom-txjcd = is_ekpodata-txjcd.

is_taxcom-matnr   = is_ekpodata-matnr.

is_taxcom-werks   = is_ekpodata-werks.

is_taxcom-matkl   = is_ekpodata-matkl.

is_taxcom-meins   = is_ekpodata-meins.

is_taxcom-mglme   = is_ekpodata-menge.

is_taxcom-mtart   = is_ekpodata-mtart.

is_taxcom-land1  = xekko-lands.

is_taxcom-ebeln   = is_ekpodata-ebeln.

is_taxcom-ebelp   = is_ekpodata-ebelp.

IF xekko-bstyp EQ 'F'.

is_taxcom-mglme = is_ekpodata-menge.

ELSE.

IF xekko-bstyp EQ 'K' AND is_ekpodata-abmng GT 0.

is_taxcom-mglme = is_ekpodata-abmng.

ELSE.

is_taxcom-mglme = is_ekpodata-ktmng.

ENDIF.

ENDIF.

IF is_taxcom-mglme EQ 0.

is_taxcom-mglme = 1000.

ENDIF.

*To Get Tax Calculation for PO

DATA: lv_gst_rele               TYPE char1,

lo_gst_service_purchasing TYPE REF TO j_1icl_gst_service_purchasing,

lo_copypo                 TYPE REF TO if_ex_me_cin_mm06efko,

ls_ekpo                   TYPE ekpo,

ls_ekko                   TYPE ekko.

CLEAR:lv_gst_rele,lo_gst_service_purchasing,lo_copypo,ls_ekpo,ls_ekko.

CALL FUNCTION 'J_1BSA_COMPONENT_ACTIVE'

EXPORTING

bukrs                = xekko-bukrs

component            = xekko-lands   "'IN'.

EXCEPTIONS

component_not_active = 1

OTHERS               = 2.

IF sy-subrc = 0.

DATA is_t005 TYPE t005.

CALL FUNCTION 'SAP_TO_ISO_COUNTRY_CODE'

EXPORTING

sap_code    = xekko-lands

IMPORTING

iso_code    = is_t005-intca

EXCEPTIONS

not_found   = 1

no_iso_code = 2

OTHERS      = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*      CALL METHOD cl_exithandler=>get_instance
*        CHANGING
*          instance = me_copypo.
*
*      CALL METHOD me_copypo->me_cin_copy_po_data
*        EXPORTING
*          flt_val = t005-intca
*          y_ekpo  = ekpo.
ls_ekpo = is_ekpodata.
ls_ekko = xekko.
CALL METHOD cl_exithandler=>get_instance
EXPORTING
exit_name              = 'ME_CIN_MM06EFKO'
null_instance_accepted = 'X'
CHANGING
instance               = lo_copypo.

IF NOT lo_copypo IS INITIAL.

CALL METHOD lo_copypo->me_cin_copy_po_data

EXPORTING

flt_val = is_t005-intca

y_ekpo  = ls_ekpo.

ENDIF.

*** GST India ---------------------------------------------------------------*
***Check if Company Code Country is India

CALL FUNCTION 'J_1BSA_COMPONENT_ACTIVE'

EXPORTING

bukrs                = ls_ekko-bukrs

component            = 'IN'

EXCEPTIONS

component_not_active = 1

OTHERS               = 2.

IF sy-subrc EQ 0.

DATA:im_gst_rele TYPE char1.

CLEAR im_gst_rele.

CALL FUNCTION 'J_1IG_DATE_CHECK'

IMPORTING

ex_gst_rele = im_gst_rele.

IF im_gst_rele EQ 'X'.

*PASS EKKO and EKPO to pricing

CALL FUNCTION 'J_1IG_PASS_EKKO_EKPO'

EXPORTING

im_ekko = ls_ekko

im_ekpo = ls_ekpo.

*** Begin of note 2444868

*DATA lo_gst_service_purchasing TYPE REF TO j_1icl_gst_service_purchasing.

lo_gst_service_purchasing = j_1icl_gst_service_purchasing=>get_instance( ).

lo_gst_service_purchasing->extend_mm06efko_kond_taxes( ls_ekpo ).

*** End of note 2444868
ENDIF.

ENDIF.

ENDIF.

CALL FUNCTION 'CALCULATE_TAX_ITEM'
EXPORTING
anzahlung                 = 'X'
i_taxcom                  = is_taxcom
* IMPORTING
*         E_NAVFW                   =
*         E_TAXCOM                  =
*         E_XSTVR                   =
*         NAV_ANTEIL                =
TABLES
t_xkomv                   = it_komvtab
EXCEPTIONS
mwskz_not_defined         = 1
mwskz_not_found           = 2
mwskz_not_valid           = 3
steuerbetrag_falsch       = 4
country_not_found         = 5
txjcd_not_valid           = 6
amounts_too_large_for_tax = 7
OTHERS                    = 8.
IF sy-subrc <> 0.

* Implement suitable error handling here

ENDIF.
*To Populate tax data to Idoc Segment
LOOP AT it_komvtab ASSIGNING FIELD-SYMBOL(<fs_komvtab>) WHERE kschl NE 'BASB'.   
"KNTYP = D or KNTYP ne space

ls_e1edp04-mwskz = is_taxcom-mwskz.  "<fs_komvtab>-mwsk1.

IF <fs_komvtab>-kbetr IS NOT INITIAL.

ls_e1edp04-msatz = <fs_komvtab>-kbetr / 10.

ENDIF.

ls_e1edp04-mwsbt = <fs_komvtab>-kwert.

ls_e1edp04-txjcd = <fs_komvtab>-kschl.

SELECT SINGLE vtext FROM t685t INTO ls_e1edp04-ktext WHERE spras = 'E' AND kschl =  <fs_komvtab>-kschl.

CONDENSE:ls_e1edp04-mwskz, ls_e1edp04-msatz, ls_e1edp04-mwsbt, ls_e1edp04-txjcd, ls_e1edp04-ktext NO-GAPS.

idoc_data-segnam = 'E1EDP04'.

idoc_data-sdata = ls_e1edp04.

APPEND idoc_data TO int_edidd[].

CLEAR : ls_e1edp04,idoc_data.

ENDLOOP.

REFRESH:it_komvtab.CLEAR:is_taxcom.

ENDLOOP.

ELSE. "Logic To Calculate tax for Service POS

DATA(it_ekpoitem) = xekpo[].

DELETE  it_ekpoitem WHERE ebelp NE int_edidd-sdata+0(5).

SELECT * FROM esll INTO TABLE @DATA(it_esll1) FOR ALL ENTRIES IN @xekpo[]
WHERE packno = @xekpo-packno.

IF sy-subrc = 0.
SELECT * FROM esll INTO TABLE @DATA(it_esll2)  FOR ALL ENTRIES IN @it_esll1
WHERE packno = @it_esll1-sub_packno.

IF sy-subrc = 0.
*To GET TAXTARIFFCODE
SELECT * FROM asmd INTO TABLE @DATA(it_asmd) FOR ALL ENTRIES IN @it_esll2
WHERE asnum = @it_esll2-srvpos.
IF sy-subrc = 0.
READ TABLE  it_ekpoitem[] INTO DATA(is_werks) INDEX 1.

SELECT SINGLE * FROM t001w INTO @DATA(is_t001w) WHERE werks = @is_werks-werks.

CALL FUNCTION 'LFA1_READ_SINGLE'
EXPORTING
id_lifnr            = xekko-lifnr
*ID_CVP_BEHAVIOR     =
IMPORTING
es_lfa1             = es_lfa1
EXCEPTIONS
not_found           = 1
input_not_specified = 2
lifnr_blocked       = 3
OTHERS              = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

*Condition Table this will differ from Customer to Customer
SELECT * FROM A900 INTO TABLE @DATA(it_a900) FOR ALL ENTRIES IN @it_asmd
WHERE kappl = 'TX' AND lland = @is_t001w-land1 AND regio = @es_lfa1-regio AND  wkreg = @is_t001w-regio AND taxim = @it_asmd-taxim AND mwskz = @is_werks-mwskz AND steuc = @it_asmd-taxtariffcode.

IF sy-subrc = 0.
SELECT * FROM konp INTO TABLE @DATA(it_konp) FOR ALL ENTRIES IN @it_a900
WHERE knumh = @it_a900-knumh.

LOOP AT it_esll2 INTO DATA(is_esll2).

*TO GET TAXIM
READ TABLE it_asmd INTO DATA(is_amd) WITH KEY asnum = is_esll2-srvpos.
IF sy-subrc = 0.
LOOP AT it_a900 INTO DATA(is_a900) WHERE  steuc = is_esll2-taxtariffcode AND  
mwskz = is_werks-mwskz.
READ TABLE it_konp INTO DATA(is_konp) WITH KEY  knumh = is_a900-knumh.

IF sy-subrc = 0.
*w_netpr = (  ( is_esll2-netwr * ( is_konp-kbetr / 10  ) ) / 100 ).
ls_e1edp04-mwskz = is_werks-mwskz.

IF is_konp-kbetr IS NOT INITIAL.

ls_e1edp04-msatz = is_konp-kbetr / 10.

ENDIF.

ls_e1edp04-mwsbt = ( is_esll2-netwr * ls_e1edp04-msatz ) / 100.

ls_e1edp04-txjcd = is_konp-kschl.

SELECT SINGLE vtext FROM t685t INTO ls_e1edp04-ktext WHERE spras = 'E' AND 
kschl =  is_konp-kschl.

CONDENSE:ls_e1edp04-mwskz, ls_e1edp04-msatz, ls_e1edp04-mwsbt, ls_e1edp04-txjcd, ls_e1edp04-ktext NO-GAPS.

idoc_data-segnam = 'E1EDP04'.

idoc_data-sdata = ls_e1edp04.

APPEND idoc_data TO int_edidd[].

CLEAR : ls_e1edp04,idoc_data.

ENDIF.
ENDLOOP.

ENDIF.

ENDLOOP.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

MATERIAL PO

In SAP:

After implementation, this what you would see in an IDOC for material PO:

Which shows up in the user interface in the following fashion:

SERVICE PO

So a buyer, requester or a planner would see taxes in SAP:

IDOC of Service PO would look like that:

Which is represented in the UI:

Once Tax appears on the Purchase Order, to make it copied automatically to invoice business rule needs to enabled:

 

Conclusion

In General Most of the customers needs to populate PO tax details from S/4 to Ariba Network, So by following the above process you can be able to send PO tax details in IDOC segment which we can map it in Ariba Network.

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sean Thomson
      Sean Thomson

      Very helpful information, Lokanatha. Thank you!

      Author's profile photo Shruthi Nandihallyrangaiah
      Shruthi Nandihallyrangaiah

      Hi Lokanatha,

      Very informative, thank you.

      Could you please share your thoughts on whether it is possible to achieve this requirement (sending tax details from ECC/S4 to ariba)  using exporting parameters ITEM_SPECIFIC_EXTENSION
      ITEM_CUSTOM_EXTENSION available in proxy reponse PurchaseOrderAsyncImportPullRequest ?

      Thanks,

      Shruthi

      Author's profile photo Lokanatha Malepati
      Lokanatha Malepati
      Blog Post Author

      Hi Shruthi

      you can pass in extensions but the same extensions to be mapped to Ariba Tax display screen.

      Author's profile photo Daniel Rolando Silva
      Daniel Rolando Silva

      Hi Lokanatha,

       

      We managed to include taxes at material and service line items, but we have a doubt:
      Is it possible to include the taxes on Service POs at "child" level?:

      We need to include the taxes while creating Invoice, and so far when supplier creates invoice it doesn't copies the taxes:

      So, when invoice arrives at our ERP it doesn't include taxes:

      Do you have any recommendation on how to include them for Service POs?

       

      Thank you!
      Daniel Silva