Search The SAP Consultant

Tuesday, October 09, 2018

My solution to attached supporting documents to cross company documents

Recently a requirement was brought up by my client where they wanted to attach supporting documents to cross company journal entries and wanted the documents to be attached to all the accounting documents posted as part of the given cross company entry. In standard SAP, the attachments needed to be attached to each accounting document separately. Typically I would have advised them to not to duplicate the attachments and ask the users to be provided with appropriate security access so view the supporting documents from the leading company code on the inter-company posting but this was not an option since it was a very unique situation where the company codes involved belonged to different shareholder ownership and had very strict security controls. Manual attachment of documents were not preferred due to the number of entities involved in a average posting.

As a first step, I was looking around in SAP service market place to see whether do we have any standard solutions to cater to this requirement and ended up with no luck. Ultimately I have given the following solution. I'm updating my blog with the solution so anyone come across the same requirement can implement it.

This solution can be copied and pasted in any system without any modification.

Step 1- Implicit enhancement point.

As a first step, we need to create an Implicit enhancement point in function module SGOS_OBJECT_ADD_TO_HISTORY


Step 2 - Copy the following code and paste it in the enhancement created above.

if not SYST-TITLE 'Service: Attachment list'.
  if SYST-TCODE 'FB02' or  SYST-TCODE 'FB03'.

TablesBKPF,
        BVOR,
        SRGBTBREL.

DATAls_source TYPE sibflporb,      " Source
      ls_target TYPE sibflporb.      " Target
DATAlt_services TYPE tgos_sels.    " Services table typ
DATAls_service TYPE sgos_sels.     " Services structure type
DATAZBELNR type BKPF-BELNR,
      ZBUKRS type BKPF-BUKRS,
      ZBUKRS2 type BKPF-BUKRS,
      ZGJAHR type BKPF-GJAHR.
DATAIT_BKPF type BKPF.
DATAZINSTID TYPE SRGBTBREL-INSTID_A.
DATABEGIN OF it_bvor OCCURS 0,
      BELNR type bvor-BELNR,
      BUKRS type bvor-BUKRS,
      GJAHR type bvor-GJAHR,
END OF it_bvor.

FIELD-SYMBOLS:  <BVOR>     LIKE it_bvor.


  ls_service-sign   'I'.
  ls_service-option 'EQ'.
  ls_service-low    'PCATTA_CREA'.
  APPEND ls_service TO lt_services.

ZBUKRS bc_object-instid+0(4).
ZBELNR bc_object-instid+4(10).
ZGJAHR bc_object-instid+14(4).



  ls_source-instid bc_object-instid.
  ls_source-typeid 'BKPF'.
  ls_source-catid  'BO'.


select single from BKPF into IT_BKPF where BELNR ZBELNR and BUKRS ZBUKRS and GJAHR ZGJAHR and BVORG <> ''.

if sy-subrc 0.
ZBUKRS2 IT_BKPF-BVORG+10(4).
if ZBUKRS2 ZBUKRS.
select from BVOR APPENDING CORRESPONDING FIELDS OF TABLE it_bvor where BVORG IT_BKPF-BVORG.


Loop at it_bvor assigning <bvor>.

if <bvor>-BELNR <> ZBELNR.
CONCATENATE <BVOR>-BUKRS <BVOR>-BELNR <BVOR>-GJAHR into ZINSTID.

  ls_target-instid ZINSTID.
  ls_target-typeid 'BKPF'.
  ls_target-catid   'BO'.

cl_gos_service_tools=>copy_linked_objects(
      is_source            ls_source
      is_target            ls_target
      it_service_selection lt_services
         ).
commit work.
endif.
endloop.
endif.
endif.

endif.
endif.


Now, this is how the solution works.

Step 1 - Attach a document to the leading or header company code of the posting.


This attachment will automatically be attached to all the other company codes in the given cross company journal entry.



Any supporting documents attached to non leading company codes will not be copied to other entities. Users also have to delete the attachment from the leading entity that initiated the cross company journal entry before deleting from the non leading entities since the business requirement was to make sure that the supporting documents attached by the initiating entity cannot be tampered by other entities.

Please feel free to copy and modify my code to suit your needs if it helps.

Wednesday, September 26, 2018

How to populate ACDOCP

In this post I would like to talk about a way to populate the table ACDOCP that was delivered with S4Hana version 1610. There were no major business functionalities delivered by SAP with regards to ACDOCP till version 1709 but looks like these anticipated functionalities will be delivered as part of 1809. I'm expecting that, one of the functionalities will be the plan allocation for profit centers based on actual. I will try to update my blog with these functionalities once I get hold of a 1809 system.

There are two main InfoProviders delivered by SAP for integrated business planning for finance. You can view them using the transaction code RSPLAN.


/ERP/SFIN_R01 is a real InfoProvider that was delivered originally. Since this is a real InfoProvider, the data is stored in the InfoProvider itself. A virtual info provider based on ACDOCA and a Multi provider were used to generate plan and actual data needed for planning functions.

/ERP/SFIN_V20 is delivered as part of version 1610 and is a virtual provider that sits on top the Hana table ACDOCP. We also have a virtual info provider for actuals based on ACDOCA and a Multi provider to facilitate the planning functions.

By default, all the queries used by analysis for office templates that are used to manage planning functionalities point to the real InfoProvider /ERP/SFIN_R01. We will be changing the the info provider to  /ERP/SFIN_V20 in these queries so the data can be updated in table ACDOCP.

Step 1 - Open the Analysis for office template and identify the query to be updated.


click on "Analysis" tab and select "Display" option from tool bar. Select "Information" tab on display pane as shown below. The query related to selected workbook can be found under the "Query Technical Name"


Step 2 - Update the query with the InfoProvider related to table ACDOCP

Open the query identified above using either the BW query designer or Hana studio. For the purpose of this post, I have used BW query designer. Once the query is opened, change the default value for characteristic InfoProvider to /ERP/SFIN_V20 from /ERP/SFIN_R01.





Step 3 - Load the plan data using the Analysis for office 

Now if we work on plan data using the analysis for office workbook that was modified in above steps, the plan data would be updated in table ACDOCP.



I didn't put a lot of technical details in this post to make sure that the finance functional consultants without a technical background can understand the mechanics behind updating ACDOCP.  Hope this post helps to understand ACDOCP update in 1709. I will try to make a post in future with the new planning functionalities delivered by 1809.

Thursday, March 15, 2018

Charging interest on overdue items from customers

On this post, I would like to share my experience with a request came from my current client regarding the solution in SAP to calculate and charge interest on customer overdue items. The business requirement was to charge interest on overdue items from selected customers with the rational that this would encourage the customers to pay the invoices on time.

The following configurations were done on a S4Hana 1709 system for the purpose of this post and the customer demo that I have done but the solution is similar on older versions of SAP except  that the customer master is created through business partner functionality in 1709.

Step 1 - Define Interest Calculation Types

In this step, we define the interest indicator that will be maintained on customer master data for the customers who are in the scope. Interest calculation type "P" indicates that the interest is calculated per customer open items.

Financial Accounting à Accounts Receivable and Accounts Payable  à Business Transactions  à Interest Calculation  à Interest Calculation Global Settings  à Define Interest Calculation Types


Step 2 - Prepare Item Interest Calculation

In this step, we define various parameters used in the interest calculation and posting. For example, the reference date to be used when the due date is determined for the interest calculation (Select "4" to use the payment baseline date), whether the calculated interest should be posted (Select "Post interest" tick box), the payment term to be used for the interest receivable and whether do we want to post the interest with reference to the original invoice (Select "Postings with invoice Ref").

Financial Accounting à Accounts Receivable and Accounts Payable  à Business Transactions  à Interest Calculation  à Interest Calculation Global Settings  à Prepare Item Interest Calculation


Step 3 - Define Reference Interest Rates

In this step, we define the reference interest rates against which the interest rate percentages will be maintained in later configuration steps.

Financial Accounting à Accounts Receivable and Accounts Payable  à Business Transactions  à Interest Calculation  à Interest Calculation  à Define Reference Interest Rates

Step 4 - Enter Interest Values

In this step, we maintain the interest rate percentage for the reference interest rates maintained in previous configuration step. Rate can be maintained with validity periods.

Financial Accounting  à Accounts Receivable and Accounts Payable  à Business Transactions  à Interest Calculation  à Interest Calculation  à Enter Interest Values

Step 5 - Define Time-Based Terms
In this step, various control parameters such as the amount from which the specific interest rate to be applied "Amount from") or any premium that needs to be applied above the standard interest rate in cases such as high overdue amounts ("Premium") will be configured against the interest indicator. And also select the term as "Debit interest: arrears interest calc".
Financial Accounting  à Accounts Receivable and Accounts Payable  à Business Transactions  à Interest Calculation  à Interest Calculation  à Define Time-Based Terms
Step 6 - A/R: Calculation of Interest on Arrears
GL Accounts are mapped against the account symbols on this step. AR reconciliation account is mapped against account symbol 1000 but the customer sub ledger account will be debited during interest posting.

Financial Accounting  à Accounts Receivable and Accounts Payable  à Business Transactions  à Interest Calculation  à Interest Posting  à A/R: Calculation of Interest on Arrears



Above steps complete the required configurations needed for the AR interest calculation function in SAP. The interest indicator configured above should be maintained on the business partner (Customer master on old versions of SAP) master data. This allows the company to pick and choose the customers who should be part of interest calculation. 


Once the interest indicator is maintain on master data, Transaction FINT will be used to calculate and post the interest for customer over due items.




Hope this post helps you to understand the interest calculation process in SAP for customer over due items. 


Wednesday, January 10, 2018

Journal entry upload in S4Hana using Fiori app.

One of the common requirements that we come across in projects is the requirement to upload journal entries using excel templates. We normally propose third party tools such as ZOption, Winshuttle or a custom development to satisfy this requirement. Each of these third party tools come with their own strengths and weaknesses and importantly license fees to use them. A custom development comes with the cost related to design, development and maintenance.

With S4Hana, SAP has given a standard solution to upload journal entries using Fiori apps. I'm going to talk about this standard solution in S4Hana on this post. There is no need for any customizations except the installation of the Fiori app to make use of this standard functionality.

Please click on the images to enlarge them.

Step 1

We need to install the app F2548 - Upload journal entries. 




Step 2

Once the app is installed launch it using the Fiori launch pad.




Step 3

Click on the "Download Template" link on the lower right corner of the app. This will give the option to download the journal entry template using Excel or CSV formats. I have selected the excel format for the purpose of this post. Save the template on the desired location.



Step 4

Once the template is downloaded, we can populate it with the required journal entry or entries. Following options are provided with the solution.

1. Data elements are validated when the entry is posted. This solution doesn't provide field drop downs on excel template for input fields like some third party tools such as ZOption do.

2. Multiple journal entries can be loaded by adding multiple header records on the same upload file.

3. Ledger specific postings can be loaded by populating the ledger group on header.




Step 5

Once the file is prepared, load it using the upload option available on the Fiori app. Selecting the file will load it into the staging area but the entry is not posted as part of this step.



Step 6

Click on "Post" option located on the bottom right corner of the app. System will display the accounting document numbers once posted.


Any data errors will be displayed using the posting log. Log can be seen by clicking on "Show Log" option located on bottom right corner of the app. We can fix the errors on upload template and reload it by updating the "Batch ID" field on the upload file with the "Batch ID" provided as part of the original load.






I hope this post is helpful to you guys. Please do let me know your feedback.