Search The SAP Consultant

Tuesday, October 09, 2018

My solution to attach 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 should be attached to each accounting document separately. But typically the security of a given user would be restricted by company code.

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 who comes across with the same requirement can implement it.

This solution can be copied and pasted in any system without any modification (Including S4Hana).

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.

Wednesday, September 27, 2017

New reporting possibilities for finance in S4Hana using analysis for office

In this post I would like to show how a typical finance report such as an equity roll forward report for US GAAP reporting can be designed using the capabilities of S4Hana. My intention here is to show the various tools used to generate this kind of finance or non finance reports from a S4Hana system so functional consultants who want to broaden their knowledge on these tools can make use this post as a guidance for further research and learning. The tools used to define this report have been highlighted for easy reference.

Step 1

In this case, the consolidation transaction types in SAP has been used to track the horizontal development of the equity GL accounts. Additional validation and substitution rules are used to tag transaction types on postings. Please note that this is not something new to S4Hana but the existing solution from ECC is enhanced by the real time reporting capabilities on S4Hana using analysis for office excel. Consolidation transaction types are configured using the following menu path.

Financial Accounting (New)  à Consolidation Preparation (New) à Transaction Types à Maintain Transaction Types for Consolidation



Step 2

This step and proceeding steps have been made possible by the OLAP capabilities and integrated analytics of S4Hana. An analytical view ZROLLFORWARD has been created using the Hana modeler perspective of Hana Studio by combining the table ACDOCA and consolidation transaction table T856 with an inner join so only the records with transaction types populated in ACDOCA are pulled into the view.




Step 3


A virtual info provider ZEQTYRF is created using Data Warehouse Workbench (RSA1) to fetch data from the analytical view ZROLLFORWARD created in the previous step. The fields from the analytical view are mapped to the info objects so that the virtual info provider will fetch the data from underlying Hana view.



Step 4

Once the virtual provider is created, Required BW query for the report can be written using BEx Query Designer or the BW modeling perspective of Hana Studio. Query "Rollforward schedule" is created for this post.







Step 5


Query created in the previous step will then be called in the Analysis for office.
Excel worksheet containing the report can then be saved on the application server or on a corporate network drive or on the local PC.



Executing the report

Users will now be able to execute the report by simply opening the excel workbook from either the application server or a corporate network drive or from their own local computer.





I hope this post act as a guide to learn the required tools that will help to generate attractive real time reports for business users which was traditionally considered a weak point in the SAP transactional system. 

Thursday, July 20, 2017

Interactive profitability analysis report using analysis for office

In this post I would like to give an idea about how to write an interactive profitability analysis report using analysis for office and virtual InfoProvider for COPA in S4Hana Finance. Virtual InfoProviders are BW InfoProviders that sit on top of S4Hana tables and obtain the actual data in real time. In this case, the COPA data from universal ledger is directly obtained by the virtual InfoProvider thus eliminates the need to extract and send the data to a BW system like it was done in previous versions of SAP.

As the first step, we need to activate the virtual InfoProvider for COPA using the following configuration menu.

Controlling  à Profitability Analysis  à Information System  à Generation: Virtual InfoProvider


Once the InfoProvider is generated, we can write a BEx query for our COPA report based on the InfoProvider generated using the previous step.


Now the above query will be called using the analysis for office for an interactive profitability analysis report using the favorite tool of finance teams  "The Excel".
                                            It has to be noted that the data on this report is fetched on a real time basis from the transactional system unlike the traditional BW reporting that typically has a time lag due to the ETL process.


The same query can also be called using the analysis for office for PowerPoint to have real time profitability analysis content on presentations.



Hope the information above helps you to further explore the new reporting possibilities with S4Hana.



Wednesday, May 17, 2017

Real time overhead calculation

In this post I would like to talk about the enhancement that's delivered by SAP with regards to the overhead calculation process in SAP. Prior to S4Hana world, finance teams used to run the overhead calculation as a month end process for cost centers, internal orders or production orders. In the manufacturing world, this is a critical process before executing the work in progress, variance and settlement processes during month and year ends. Most finance team members would agree that anything that we take out from the list of items to be done during period end processing is always appreciated.

SAP has introduced the new real time overhead calculation process as part of S4Hana 1610 that calculates and posts the overhead absorption as and when the postings are made to the relevant cost objects. for example if we have a material overhead based on raw material consumption on a production order, as soon the raw materials are issues to the production order, the overhead will also be absorbed and posted to the order and the credit object.

In this post I'm not going to cover the configurations related to costing sheets since there is no changes to this set up because of the real time overhead calculation. Following steps are needed to activate the functionality.

Step 1

As the first step we need to activate the functionality per  controlling area. I'm showing the SPRO menu path under internal orders but the same configuration menu can be found under cost centers and production orders.

Internal Orders  à Actual Postings  à Overhead Rates à Maintain Real-Time Overhead Calculation  à Activate Realtime Overhead Calculation


Step 2

Next step is to activate the business transactions that trigger the real time overhead calculation.

Internal Orders  à Actual Postings  à Overhead Rates  à Maintain Real-Time Overhead Calculation  à Activate Overheads for Controlling Area and Business Transaction
There are five business transactions that can trigger this new functionality and we can selectively activate the required ones. For example if we want an overhead to be calculated based on raw material consumption on the production order then the business transaction COIN should be activated, if we want an overhead to be posted based on activity allocation on the production order or a cost center then business transaction RKL needs to be activated. Following are the available business transactions.
COIN  - CO Through-postings from FI
KAMV  - Manual cost allocation
RKL - Actual activity allocation
RKU1 - Repost costs
RKU2 - Repost revenue

With these settings, the new functionality is turned on for the controlling area. We need to note that the traditional month end process of calculating the overheads is still available if an organization wants to use it instead of real time calculation.
Lets see how this works using a costing sheet assigned to a cost center. An overhead costing sheet was created to absorb 5% overhead based on the expenses posted to the assigned cost center.

A journal entry is posted to the cost center against the expense account that was defined as the base for overhead calculation.

When the above document was posted, a separate document was posted for the calculated overhead amount.