Skip to Content

Introduction & Scope:

This document explains the details of Accounting document posting with the TAX line break up based on TAX code maintained as per configuration in ECC system.This approach can be applied for Any FI document posting via BAPI(Accounting document post) or Inbound Interface(IDOC) commonly used for FI posting. This document does not include line by line Code(which may vary as per requirement),creation of Custom Class,creation of explicit enhancement etc.

1.1.  Requirement Summery:

We have SAP Customer Activity Repository(CAR) system in use for a typical IS-Retail landscape. This is a separate box other than central ERP (ECC) which collects,cleanses and centralizes all customer related data in real time for analysis. CAR box  is configured to send WPUFIB IDOC to SAP ECC6 system for Inventory sync and valuation update. This IDOC carries details of FI transaction that took place in the store-tills.

  • Now,based on FI configuration settings at ECC box,upon successful posting of WPUFIB Idoc,there should be one Accounting document posted which must have a separate line item for tax calculated on the total amount based on tax code.
  • Also there can be a cancellation at till level,which will be carried via WPUFIB and need to post a reverse FI document having opposite posting key with a reverse tax line generated separately.

However,in current standard SAP solution,this additional line item is not showing on FI document.

1.2.  System behavior Analysis:

  • While posting a FI document either from different SAP system or legacy system via IDOC we noticed that it is not generating any extra tax line.
  • Now we tried to post via F-02 t-code and it generated 3 lines on FI doc( one debit entry,one credit entry,one tax calculation entry).
  • Now we implemented BADI ACC_DOCUMENT setting flag xmwst = ‘X’.

We re-do the testing –>Triggered Inbound IDOC from CAR to ECC, This time FI document generated but with no tax line,however tax line posted in BSET table as a separate entry,though the calculation was wrong as opposed to F-02 posted Accounting doc.

1.3.  Google search:

We did read lot of post and one post suggesting the same problem with a solution but no code help or reverse posting feature.Few suggested calling FB01 or F-02 t-code from exit using BDC or use substitution logic somewhere-(Looked to me a clumsy solution) we checked SAP notes,where SAP has suggested to calculate tax amount manually within our own program and then we have to pass the values to accounting interface.

Where to pass and how to pass was still ambiguous….

1.4.  Analysis on Accounting interface:

Further research on accounting interface and SAP design revealed during ABAP debugging, TWO main FMs are called while inbound IDOC processing happens -namely (1)ac_document_create & (2)ac_document_post.

FM1)-> Calls FI_DOCUMENT_PROJECT which has XBSET table inside a subroutine.

FM2)-> Calls FI_DOCUMENT_POST which also deals with XBSET table.

1.5.  Actual Solution Adopted :

Go inside Fm FI_DOCUMENT_PROJECT at line 59..( Based on ABAP7.4 -EHP7 ),it may vary in other software version.

Go inside the PERFORM as shown below.

Then go inside PERFORM DOCUMENT_TAX_BSET.

There is one explicit enhancement point provisioned by SAP (Tips: This is very important,to create explicit enhancement for this solution,if you create implicit enhancement,which is also present,then code trigger point will not work to the desired effect->we faced this situation during implementation)

ENHANCEMENT-POINT DOCUMENT_TAX_BSET_03 SPOTS ES_SAPLFACI.

Used call stack reference to restrict the enhancement for only WPUFIB IDOC processing as per below details.

Message Type –> ‘(SAPLWPUE)G_MESSAGE_TYPE’ -> This is used for filtering.
IDoc Type –> ‘(SAPLWPUE)G_DOCUMENT_TYPE’ -> This is used for filtering.

Then created a helper class as below with following methods doing each task for preparation of Accounting line items with tax calculation.

  • We introduced one TVARVC switch to restrict this enhancement based on specific Company code,the sequence of tasks are listed below.

1.6.  Technical Design overview:

* 1)Get the tax corresponding to company code.
LO_FI->GET_TAX_DATA(
IMPORTING
EV_SUBRC = DATA(LV_SUBRC)
CHANGING
CT_XBKPF = XBKPF[]
CT_XBSEG = XBSEG[]

* 2)Set the TAX amount in local & Document currency.
READ TABLE XDBSEG ASSIGNING FIELD-SYMBOL(<LS_XDBSEG_S>) INDEX 1.
IF SY-SUBRC = 0.
<LS_XDBSEG_S>-WMWST = LO_FI->MS_ITXDAT-FWSTE.
<LS_XDBSEG_S>-MWSTS = LO_FI->MS_ITXDAT-HWSTE.
ENDIF.

IF LO_FI->MS_ITXDAT-FWSTE IS INITIAL AND
LO_FI->MS_ITXDAT-HWSTE IS INITIAL.
* 3)This is the case where we consider this as Reverse Posting FI document
* Stop here for cheking
SORT XBSEG[] BY BSCHL DESCENDING.” Reverse the accounting posting

* 4)Setup Flag for reverse posting Tax line generation
LO_FI->GV_REVERSE_TAX_INDICATOR = abap_true.
* 5)Start the tax break up.
LO_FI->SET_TO_ENABLE_TAX_LINE(
CHANGING
CT_XBKPF = XBKPF[]
CT_XBSEG = XBSEG[]
CT_XDBSEG = XDBSEG[] ).
ENDIF.
ENDIF.
* 6)Set the DEBIT Line item excluding the TAX amount.
lo_fi->SET_DEBIT_DATA(
EXPORTING
IT_XDBSEG = XDBSEG[]
CHANGING
CT_XBSEG = XBSEG[]
CS_BSEG = BSEG ).
* 7)Set the Tax data line item.
lo_fi->SET_TAX_LINE(
EXPORTING
it_xbset = XBSET[]
CHANGING
CT_XBSEZ = XBSEZ[]
CT_XBSEG = XBSEG[] ).
* 8)Adjust XBSEG values as per required.
lo_fi->FORMAT_OUTPUT(
CHANGING
CT_XBSEG = XBSEG[] ).
*9) Destroy the instance of the static attribute
lo_fi->SET_REVERSE_TAX_FORMAT(
CHANGING
CT_XBSEG = XBSEg[] ).
endif.
ENDIF.
ENDIF.

1.7.  Functional Unit Test:

Finally when Inbound WPUFIB idoc is posted into ECC- Check the outcome as below.

This is forward posting scenario,reverse posting screenshot not given ,but this also worked fine using this solution approach.

 

Regards,

Avik

 

 

 

 

 

 

 

 

 

 

 

To report this post you need to login first.

3 Comments

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

  1. Avik Mazumder Post author

    Thanks for the comments. I am new to SCN and it will take some time for me to write more blogs.

    Moreover,I do not consider myself well versed on MM subject.It is my interest area,however I have worked on many cases,which I might try to convert to blog if I find it useful and unique in practical terms .

    Regards,

    Avik

    (0) 

Leave a Reply