Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
gellper
Participant
2,123
When you are implementing SAP Ariba Commerce Automation or Digital Supplier Network, one of the most requested functionalities when is the sending of tax indicators and additional charges/discounts within the purchase order to the Ariba
Business Network, why? because in this way the supplier can view these components and migrate them to the PO Flip Invoice and avoid some errors on the reconciliation process.

I will explain in this blog, how to implement both functionalities, from the ABAP side, from the Cloud Integration Gateway side (mappings), and from Ariba Network side (rules).

Tax information on purchase order


In some countries, sending the tax indicator is mandatory, taking this into account, several modifications must be made to be able to include them in the purchase order, and then the supplier can migrate them to the PO Flip Invoice.


Tax code in line item


 


Tax code detail


 

ABAP Development


The first thing to know is that the IDOC used to send the information from SAP ERP/S4 to Ariba Business Network, is the ARBCIG_ORDERS, which contains the E1EDP04 segment used to fill in the tax code information.

This segment, like the others, can be extended/modified from the User Exit EXIT_SAPLEINM_002 within the include ZXM06U02. This segment is a child of E1EDP01 segment, so as a first step, you must validate that within the User Exit when is processing the E1EDP01 segment.

 IF int_edidd-segnam = 'E1EDP01'.


Inside this "IF", you must loop the item table, filtering by the item that are being processed at this time.

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

*&---------------------------------------------------------------------*
*&  START - SECTION E1EDP04 FOR TAX CODES
*&---------------------------------------------------------------------*
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.

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 = 'S' AND kschl =  <fs_komvtab>-kschl.
SELECT SINGLE text1
FROM T007S
INTO ls_e1edp04-ktext
WHERE spras = 'S'
AND   MWSKZ =  is_taxcom-mwskz.
CONDENSE:ls_e1edp04-mwskz, ls_e1edp04-msatz, ls_e1edp04-mwsbt, ls_e1edp04-txjcd NO-GAPS.
idoc_data-segnam = 'E1EDP04'.
idoc_data-sdata = ls_e1edp04.
APPEND idoc_data TO int_edidd[].
CLEAR : ls_e1edp04,idoc_data.
ENDLOOP.

*&---------------------------------------------------------------------*
*&  END - SECTION E1EDP04 FOR TAX CODES
*&---------------------------------------------------------------------*


 

As a result, you will se the segment full filled with tax information in IDOC:


IDOC segment


 

CIG Mapping (now called MGSN)


 

Now we need to do the corresponding mapping in Managed Gateway Spend & Network, from the E1EDP04 segment to the corresponding fields of the cXML as we can see in the next picture.


cXML after mapping


To achieve this mapping, we need to follow the next steps:

  1. Make a line between KTEXT field of E1EDP04 segment to the <Description> field inside <TaxDetail>, inside <Tax>, inside <ItemOut> from cXML.

  2. Add a constant value to field @xml:lang inside <Description> with the languaje that will be used, for example: en-US, or es-ES.

  3. This mapping must be configures as a position variable, in order to map correctly item by item and not concatenate several values into one single item, in order to ensure this we will mark the line and with right click will choose the next option.After this, we go up and select the ItemOut line.Finally, we select again the line and with right click we select the option Add Source Condition.And we select from the left side, the E1EDP01 segment.


 

Charges, Surcharges or Discount on purchase order


In some cases the purchase order contain different prices conditions such as additional cost or discounts, its important to reflect this conditions on Ariba Business Network for the supplier consideration.


Price Condition information in Ariba Business Network


In this way you can reflect all the price conditions you want from the ERP side, for example discounts by quantity, shipments costs, pre negotiated discounts and so on.


Price Conditions in SAP ERP


 

ABAP Development


In this case, we need to modify the same IDOC ARBCIG_ORDERS, but different segment, now we need to modity the E1EDP05 segment.

For this, we will use the same user Exit used for the tax information, EXIT_SAPLEINM_002 from INCLUDE ZXM06U02, this segment is also child of E1EDP01 segment, so we can put the code inside the same "IF" condition:

 IF int_edidd-segnam = 'E1EDP01'.


The code is at item level, so also we can put the code inside the LOOP used for tax information:

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

 

Now, we will use the next code to fill the segment with the price conditions used in the purchase order.

*&---------------------------------------------------------------------*
*&  START - SECTION E1EDP05 FOR PRICE COND
*&---------------------------------------------------------------------*

CLEAR komp.
CLEAR tkomv.
CLEAR tkomvd.
*- fill structure KOMK (Pricing Communications-Header) ----------------*
IF komk-knumv NE xekko-knumv.
CLEAR komk.
komk-mandt = xekko-mandt.
IF xekko-kalsm NE space.
komk-kalsm = xekko-kalsm.
ELSE.
komk-kalsm = 'RM0000'.
ENDIF.
komk-kappl = 'M'.
komk-waerk = xekko-waers.
komk-knumv = xekko-knumv.
komk-bukrs = xekko-bukrs.
ENDIF.

*  komp-kposn = posnr.
komp-kposn = is_ekpodata-ebelp.

SELECT *
FROM konv
INTO TABLE tkomv
WHERE knumv = xekko-knumv.

*- determine item conditions ------------------------------------------*
CALL FUNCTION 'RV_PRICE_PRINT_ITEM'
EXPORTING
comm_head_i = komk
comm_item_i = komp
language    = xekko-spras
IMPORTING
comm_head_e = komk
comm_item_e = komp
TABLES
tkomv       = tkomv
tkomvd      = tkomvd.

LOOP AT tkomvd.

IF tkomvd-kinak EQ ' ' AND
tkomvd-kwert NE '0'.
CLEAR ykoein_iso.
CLEAR idoc_data_5.
CLEAR ls_e1edp05.
idoc_data_5-segnam = 'E1EDP05'.
*- Surcharge or discount indicator ------------------------------------*
IF tkomvd-kwert LT 0.
tmp_kwert = ( -1 ) * tkomvd-kwert.
ls_e1edp05-alckz = '-'.
ELSE.
tmp_kwert = tkomvd-kwert.
ls_e1edp05-alckz = '+'.
ENDIF.

IF cur_factor IS INITIAL.
CALL FUNCTION 'CURRENCY_CONVERTING_FACTOR'
EXPORTING
currency          = tkomvd-koein
IMPORTING
factor            = cur_factor
EXCEPTIONS
too_many_decimals = 1.
IF sy-subrc NE 0.
*              MESSAGE e855 WITH xekko-waers
*              RAISING error_message_received.
ENDIF.
ENDIF.

*- Condition type (coded) ---------------------------------------------*
ls_e1edp05-kschl = tkomvd-kschl.
ls_e1edp05-kotxt = tkomvd-vtext.

*- Fixed surcharge/discount on total gross ----------------------------*
ls_e1edp05-betrg = tmp_kwert * cur_factor.
CONDENSE ls_e1edp05-betrg.
IF tkomvd-koein EQ '%'.
tkomvd-kbetr = tkomvd-kbetr / 10.
ls_e1edp05-kperc = tkomvd-kbetr.
CONDENSE ls_e1edp05-kperc.
ls_e1edp05-mwskz = tkomvd-mwskz.
ELSE.
* compute converting factor, if condition currency <> document currency
IF xekko-waers EQ tkomvd-koein.
h_cond_cur_factor = cur_factor.
ELSE.
IF cond_curcy_save NE tkomvd-koein.
CALL FUNCTION 'CURRENCY_CONVERTING_FACTOR'
EXPORTING
currency          = tkomvd-koein
IMPORTING
factor            = cond_cur_factor
EXCEPTIONS
too_many_decimals = 1.
IF sy-subrc NE 0.
*              MESSAGE e855 WITH xekko-waers
*              RAISING error_message_received.
ENDIF.
cond_curcy_save = tkomvd-koein.
ENDIF.
h_cond_cur_factor = cond_cur_factor.
ENDIF.
ls_e1edp05-krate = tkomvd-kbetr * h_cond_cur_factor.
CONDENSE ls_e1edp05-krate.
*- pricing rate -------------------------------------------------------*
IF NOT tkomvd-kpein IS INITIAL.
ls_e1edp05-uprbs = tkomvd-kpein.
ENDIF.
IF NOT tkomvd-kmein IS INITIAL.
CALL FUNCTION 'UNIT_OF_MEASURE_SAP_TO_ISO'
EXPORTING
sap_code    = tkomvd-kmein
IMPORTING
iso_code    = ls_e1edp05-meaun
EXCEPTIONS
not_found   = 1
no_iso_code = 2
OTHERS      = 3.
IF sy-subrc <> 0.
MESSAGE ID 'VG' TYPE 'E' NUMBER '500'
WITH tkomvd-kmein is_ekpodata-ebelp 'KMEIN'
RAISING error_message_received.
ENDIF.
ENDIF.
ls_e1edp05-mwskz = tkomvd-mwskz.

*- Konditionseinheit --------------------------------------------------*
*- Rate unit ----------------------------------------------------------*
IF NOT tkomvd-koein IS INITIAL.
CALL FUNCTION 'CURRENCY_CODE_SAP_TO_ISO'
EXPORTING
sap_code  = tkomvd-koein
IMPORTING
iso_code  = ykoein_iso
EXCEPTIONS
not_found = 1
OTHERS    = 2.
IF sy-subrc <> 0.
MESSAGE ID 'VG' TYPE 'E' NUMBER '531'
WITH  tkomvd-koein  ekpo-ebelp 'KOEIN'
RAISING error_message_received.
ELSE.
ls_e1edp05-koein = ykoein_iso.
CONDENSE ls_e1edp05-koein.
ENDIF.
ENDIF.

ENDIF.

MOVE ls_e1edp05 TO idoc_data_5-sdata.
APPEND idoc_data_5 TO int_edidd[].

ENDIF.

ENDLOOP.

*&---------------------------------------------------------------------*
*&  END - SECTION E1EDP05 FOR PRICE COND
*&---------------------------------------------------------------------*


As a result, we will see the IDOC full filled with the price condition information.


Price Condition on IDOC


 

CIG Mapping (now called MGSN)


The first consideration is that we have two possible structures to fill in the cXML, and this depends on which price condition are we sending from SAP, for example, if we are sending a charge condition, we need to map it to the AdditionalCost structure, and if for the contrary we are sending discounts, we need to map it into AdditionalDeduction structure.


Charges and Discount structures on cXML


 

Considerations:

  • Each E1EDP01 segment corresponds to an <ItemOut> structure, and also to a <Modifications> structure.

  • Each E1EDP05 segment corresponds to an <Modification> structure.

  • Each <Modifications> structure can have inside many <Modification> segments as price conditions have the item.


In the next picture we can see more graphically the considerations previously mentioned. In the example, we have in the IDOC for the first item, 2 price conditions.


Final Mapping from IDOC to cXML


In order to achieve the correct mapping, we need to follow the next steps.

  1. The first step is to allow the <Modifications> structure in the cXML, because this structure is not enabled by standard, with righ click we select the option Create/Replace Node.

  2. The next step is very important, and it consist of relaying how many and which price conditions we are going to map, because for each one of them, we will have to carry out all the following steps, which will consist of duplicating the <Modification> structure depending on how many price conditions we have. For this example, we will only map the RA01 discount condition.

  3. Now we map the <KSCHL> field to <ModificationDetail name="RA01">.

    1. We configure the mapping as a position variable, for this we select the line mapping and add the position variable.

    2. Then we select the ItemOut structure on the right side.

    3. Now we select again the line mapping and add a source condition.

    4. And we select from the left side the E1EDP01 segment.

    5. Now we again add a new source condition.

    6. And we select a fixed value with the ID of the price condition that we are trying to map, in this case, RA01.NOTE: We need to follow this steps for all the fields that we will map for price conditions.



  4. We map the field <KOTXT> to <Description xml:lang="ES">% DESC.SOBRE BRUTO</Description>.Inside the <Description> structure, we will add a constant value for the languaje used, for example "en-US" or "es-ES".

    1. Here we need to follow the steps of 3.1 step.



  5. Now we map the <BETRG> field to <AdditionalDeduction><DeductionAmount><Money>.

    1. Here we need to follow the steps of 3.1 step.



  6. Now we map the <KOEIN> field to <AdditionalDeduction><DeductionAmount><Money>@currency field.

    1. Here we need to follow the steps of 3.1 step.



  7. Until here we have implemented all the mappings for one price condition, if you need to map more than one price condition, you will need to duplicate the <Modification> node into another one, and do all the mappings again for the new one.You will must taking in account that when you create a new node <Modification#2>, you will do the source condition filter according to the new price condition, replacing "RA01" for the new one.


Summary


As a final result, the supplier will see all the information related to tax indicator and price conditions.


 

If you like this post please don't forget to share and give me your comments, also if you want to know more about this topic you can follow the Managed Gateway for Spend Management and SAP Business Network environment Topic page (https://community.sap.com/topics/ariba-cloud-integration-gateway) or post and answer questions (https://answers.sap.com/tags/73554900100800000872), and read other posts on the topic (https://blogs.sap.com/tags/73554900100800000872/).

Many Thanks,

Angel.

 

 

 

 
3 Comments
Labels in this area