Skip to Content

Summary

The document provides one of a solution to generate tax lines while posting FI documents via IDOC or BAPI ACC_DOCUMENT. SAP standard provides a provision using the BAdi exit to enable the tax calculation in the receiving system however it didn’t generate the GL tax lines in the FI posting to be used later for actual debit ( VAT amounts) to the tax GLs.

The scenario

While posting an FI document either from different SAP system or from Legacy system sometimes there are requirements to allow the tax processing to happen in the receiving SAP system. The processing of the tax in the receiving system can easily be activated by enabling the tax calculation, i.e. setting flag xmwst = ‘X’ via BAdI ACC_DOCUMENT. However here i am describing a solution for more complex situation whereby we want the tax lines to be added as part of posted FI document, which will otherwise happen if the document is posted via FB01 (provided tax processing is set in such a way). When we post FI document via FB01, the tax lines are generated and added as part of separate line items in  FI document. However, even though all the system settings are same, this doesn’t happen with the BAPI or IDOC (which eventually calls the BAPI) processing, reason being the way both are processed.  Solution here describes a way to achieve the same with BAPI/IDOC. The solution is valid for SAP ECC 6.0 onwards.

BAdI ACC_DOCUMENT

BAdI can be used to activate the tax calculation flag; this will enable the system to calculate the tax and will be a prerequisite for our solution, as we want the tax lines to be at least in runtime memory for being picked up by us.

Include LFACIF4O

An enhancement point provided in this includes which is called after the tax calculation can be used to append additional tax lines likewise done via transaction code FB01.

ENHANCEMENT-POINT DOCUMENT_TAX_BSET_03 SPOTS ES_SAPLFACI.

The processing routine calls Function module ‘ FI_TAX_CALCULATION_CHECK’ before actually reaching the enhancement point, the call to function module fills up the global parameter ‘XDBSEG’, which got the structure for amending the lines of BSEG. This implies a dynamic call to SAPLTAX2 be used to get the filled values for table ‘XDBSEG’ like,

ASSIGN (‘(SAPLTAX2)XDBSEG[]’) to <FS_XDBSEG>

Where,<FS_XDBSEG> is a local field-symbol.

With this you got tax lines as calculated by the tax routine. With this data we can start adjusting the BSEG lines to reflect the tax accounting on line items.

You can copy the code lines as used in standard routine to add tax lines subroutine “steuer_netto_setzen” include “MF05ATAX_STEUER_NETTO_SETZEN” Also add tax item to t_bseg, you can refer to the code as in subroutine OIA_UPE_VAT_LINE

Final lines of code: See attachment Main CodeLines.txt

To report this post you need to login first.

26 Comments

You must be Logged on to comment or reply to a post.

  1. Jeroen Scheffer

    Hi Hemendra,

    We implemented above coding…. We experience one issue, which is document splitting doesnt work for generated tax lines. In GL view the tax lines are added up with the original line item, rather than being split according profit centers (we use only prctr for splitting criteria). When we post the document manually (as a copy of the one being posted through IDoc), the tax lines are being split, so i suppose its no configuration issue…

    Do you have any idea how to solve this?

    Regards,

    Jeroen

    (0) 
    1. Hemendra Singh Manral Post author

      HI Jeroen,

      Can you show with e.g., the lines not splitted on GL View, or show some screens, so that i can get some clear view of your issue. In our case it has worked well.

      Regards, Hemendra

      (0) 
        1. Rajiv Kurra

          Hi Hemendra,

          I added code successfully after  line :

          ENHANCEMENT-POINT DOCUMENT_TAX_BSET_03 SPOTS ES_SAPLFACI.

          But in the debug I found XDBSEG table not assigning ,

          ASSIGN (‘(SAPLTAX2)XDBSEG[]’) to <fs_XDBSEG>.

          IF <fs_XDBSEG> IS ASSIGNED.
               XDBSEG[] = <fs_XDBSEG>.
             ENDIF.

          do I need to set any flag .I already set sending XMWST =’X’ fro my Input, do I still need to implement BADI

          (0) 
          1. Hemendra Singh Manral Post author

            Hi Rajiv,

            Can you check how the tax processing is set, it should be set to post seperate line item. Try positng a direct document, and check if that generates a seperate line item or not?

            Regards, Hemendra

            (0) 
  2. Venkateswara Rao Pendyala

    Hello Hemendra,

    I got same type requirement, that through manual posting tax line item is  getting created but through IDOC it’s not happening… can we use your solution what u proposed…?

    For this do we have to implement the BADI_ACC_DOCUMENT and we no need implement our logic…? and if so in which methos we have to opt… or directly with out implementing…. can we add our logic in enhancement..?

    Please suggest asap

    Regards,

    Venkat

    (0) 
    1. Hemendra Singh Manral Post author

      Yes, definetly you can use the solution. to make the solution work you need to follow the instructions and implement the badi and enhancements spot.

      Regards, Hemendra

      (0) 
      1. Venkateswara Rao Pendyala

        Thanks Hemendra,

        Which method do we have to use to activate tax calculation flag in BADI..?

        In the attached code, we have called perform statements at the last loop, so where we have to implement the form blocks for this two performs check_posting_key and  oia_store_tax_line… if i write these in the same enhancement it’s showing error.. .. 🙁

        Can i have your contact no please… facing some issues while implementing…

        Regards,

        Venkat

        (0) 
  3. Santiago Moreno Díez

    Hi Hemendra,

    It seemed too good to be true.

    But I found a problem, as these new tax lines generated don´t pass through the substitutions neither the validations, there may be some inconsistencies in the FI Doc generated.

    I don´t understand why SAP doesn´t offer a valid solution to use this BAPI as FB01 tcode.

    Regards,

    (0) 
    1. Chris Park

      I just want to echo Santi’s comments – this solution, whilst very effective if all the data and config is 100% correct, can result in inconsistent FI docs being generated so should be used with caution.

      (0) 
  4. Saurabh Patni

    Hi Hemendra,

    Thanks for the wonderful informative document.

    Can you please help me with one thing, actual when we are uploading the file, for the tax line that get generated separately are getting posted but when we are using a tax code that setoff the value against the expense line item (NVV account type) and a separate line item is not created for the same, we are getting error “FI/CO interface: Balance in transaction currency” and amount is equal to calculated tax amount.

    Thanks in advance.

    Regards,

    Saurabh

    (0) 
  5. Gaurab Banerji

    Hi Hemendra,

    I found a problem with the usage of this technique to create additional vat lines. When this development is in place, there is an additional line item with DMBTR value equal to the last line of the existing line items. this means, if the earlier Debit amount and Credit amount (S and H) were equal, now they are not. As such, the function module POST_DOCUMENT fails with the error A808. Since H and S amounts are unequal. I encountered this error message when using MRRL transaction. Please let me know if you know how to overcome this error message.

    (0) 
  6. Abhishek chanders

    Hi Hemendra,

    I have tried using the above technique, i have implemented the badi and written the code in the given enhancement point but the include LFACIF4O does not trigger. I have put a breakpoint in it and tried with the bapi and FB60, FB70 and even FB01, but the include does not trigger anywhere. So can you please suggest me if i need to do anything else before using the include.

    Thank you,

    (0) 
    1. Hemendra Singh Manral Post author

      Hi Abhishek,

      The solution applies to BAPI/IDOC Postings and the exit will be triggering for such cases.

      Have you implemented the BAdI ACC_DOCUMENT, which is a start point for exit to be picked up.

      Regards, Hemendra

      (0) 
  7. amol korde

    Hello Hemendra,

    Could you please share sample code as attachment file (Main CodeLines.txt) is not accessible.

    Thanks in advance for your help, which would be highly appreciable.

    Thanks again,

    Amol

     

    (0) 

Leave a Reply