Friday 21 June 2019

Custom Data from FI-CA to RAR (Part I – Overview)

Introduction


The purpose of this two part blog is to describe a solution that allows custom values to be populated on the provider contract and then transferred to SAP Revenue Accounting.  The custom values can be populated using both the provider contract create transaction and the standard creation BAPI.  The standard provider contract transactions are enhanced using the Business Data Toolset (BDT).  Using event 8205, the custom values are transferred to Revenue Accounting as both main and condition items.

1. Solution


Figure 1 – Solution components and data flow.


Figure 1 shows the main components and the data flow of the solution.  The solution’s main objective is to allow an external system to save custom fields, on the provider contract, as condition items in Revenue Accounting.  These custom fields, and their target condition types are shown in Figure 2.

Figure 2 – Custom Fields

Description Field Name  Format  Target Condition Type 
Total Cost to Fulfill ZZCTF  CURR (13)  VPRS
Total Cost to Obtain  ZZCTO CURR (13) COAC 

1.1. Populating the Custom Fields with Functions

An external SAP system can call the “BAPI_CTRACBILLCONTRACT_CREATE” function module to create a provider contract.  This BAPI provides an extension table that can be used to pass values for custom fields, which have been added to the provider contract.  Figure 3 describes the key requirements of using this BAPI.

Figure 3 – Key requirements of using “BAPI_CTRACBILLCONTRACT_CREATE”

◈ Table EXTENSIONIN is used to populate custom fields. This table is filled by translating a structure to a series of character fields.
◈ The contract header, items, technical resource, and discount data all require BAPI change structures (aka ‘X’ tables).
◈ Contract Item ID requires a 16 Byte external GUID
◈ Contract Item Parent ID requires a 16 Byte external GUID

The key requirements of the standard BAPI may make it difficult to utilize from a non-SAP external system.  Therefore, this solution includes a function module that allows the BAPI to be easily called from such a system.  The name and key features of this new, custom, function module are shown is figure 4.

Figure 4 – Key features of function “Z_API_CTRACBILLCONTRACT_CREATE”

◈ Custom fields are passed in the contract line items. The function will extract the custom fields and translate them into the EXTENSTIONIN table
◈ The function module will dynamically fill the BAPI change structures (aka ‘X’ tables), for any populated fields in the contract header and items table.
◈ GUIDs will be generated for the contract item and contract item parent IDs.

1.2. Populating the Custom Fields with Transactions

Although an external system is the main focus, this solutions also allows the custom fields to be populated using the standard provider contract transactions and a custom report.  This allows for easier testing of the solution.  As shown in figure 5, the standard provider contract transactions have been enhanced to include the custom fields.

Figure 5 – Custom fields added to standard provider contract transactions FP_FT1, FP_FT2, & FP_FT3.



The transactions were enhanced using the Business Data Toolset (BDT), which allows subscreens to be added to an existing transaction with a combination of configuration, custom PAI and PBO function modules and a custom subscreen.  The development for these enhanced transactions is  contained within function group “ZVKK_BDT_PRC”, which will be explained in the part II of this blog post.

1.3. Report ZPRC_UPLOAD

Custom report “ZPRC_UPLOAD” allows provider contracts to be created via an Excel spreadsheet. For each contract in a spreadsheet, the custom report calls function “Z_API_CTRACBILLCONTRACT_CREATE”, which in turn calls function “BAPI_CTRACBILLCONTRACT_CREATE”, to create the provider contract.  The spreadsheet combines the header and item fields into one worksheet.  Numeric values are used to establish the relationship between the header, items, and parent items as shown in Figure 6.

Figure 6 – Relating contracts, contract items, and contract item parents in the Excel spreadsheet.


The custom values are columns on each line of the contract, as shown in Figure 7.

Figure 7 – The custom values in the Excel spreadsheet.


The format of the Excel spreadsheet is the same as the “ZBAPI_BILLCONTR_I_CREATE” structure, which is documented in part II.  You can download a sample spreadsheet from the following link: Worksheet in Transferring Custom Data from FI-CA to RAR.xlsx

 The selection screen and output of the test program, are shown in Figure 8. 

Figure 8 – Selection Screen and Output of the Test Report

RAI Main Items


RAI Condition Items


1.4 Event 8205

When provider contracts are created or changed, event 8205 is processed before the revenue accounting items are saved.   This event can be used to change the amount fields, adjust existing conditions, or add new conditons.  This solution adds code, in the configured event function “ZFKK_SAMPLE_8205”, to create a condition record for each of the custom fields.  A condition record, with type ‘VPRS’, is created for the “Total Cost to Fulfill” custom fields. A ‘COAC’ condition record is created for the “Total Cost to Obtain”.  To have access to the custom fields in Event 8205, the custom fields were appended to the revenue accounting – main item.  Figure 9 shows the custom values in revenue accounting, after the processing of event 8205.

Figure 9 – Outcome of event 8205

RAI Main Items


RAI Condition Items


2. Environment


This solution was provided on SAP ERP, with the following key components.

Figure 10 – Version levels of key components in SAP ERP

Component Release SP-Level  Description
SAP_BASIS  740  0020 SAP Basis Component
SAP_FIN   617  0017  SAP FIN
FI-CA  617  0017  FI-CA
FI-CAX  617  0011 FI-CA Extended 
REVREC  130  0007 SAP Revenue Recognition 

3. Key Transactions


The following transactions were used to build and test the solution.

Figure 11 – Key Transactions

Transaction Description
FP_VT1 Create Provider Contract
FP_VT2  Change Provider Contract 
FP_VT3  Display Provider Contract 
FQEVENT_8205  Display Event 8205 
SE11  ABAP Dictionary Maintenance 
SE37  ABAP Function Modules 
SE38  ABAP Editor 
SE43  Maintain Area Menu 
SE80  Object Navigator 

No comments:

Post a Comment