Custom field extension FBL1N & FBL3N & FBL5N – BTE Approach
One of the most used SAP GUI financial report for checking reconciliation is FBL1N, FBL3N and FBL5N. These reports display each accounting item with document status and item clearing status along with almost all the accounting document fields. User can select specific report to perform analysis, FBL1N for Account Payable, FBL3N for GL item and FBL5N for Account Receivable.
Most common requirement I get working with SAP customers are that they want to add custom fields to these reports. I worked with adding custom fields that either come from financial accounting data source or from sales and distribution data source, or can be from completely custom defined Z tables.
Luckily, FBL1N, FBL3N and FBL5N all shares the same layout structure, so adding custom fields into one report will reflect to the other reports as well. After extending the base structure, we must implement logic to map the value to the custom field extended in the base structure.
Make sure to check the same solution with different technic approach using BAdI at Custom field extension FBL1N & FBL3N & FBL5N – BAdI Approach – SAP Extensibility 101.
The Setup
This blog will demonstrate step-by-step how to add custom fields to FBL1N, FBL3N and FBL5N by using Business Transaction Events(BTE). We will setup a sample requirement, where we needed to display profit center text on the reports.
1. Create Function Module for BTE
Go to transaction code FIBF and go to Environment -> Info System(P/S). Execute the report with default parameters.
Find Business Transaction Event 0000165(LINE ITEM DISPLAY: Add to data per line), select it and click Documentation button.
You can see when this event is triggered and how to implement this event. Copy the function module in the documentation.
Go to SE80 and create a function group. Then copy the function module in the document ‘SAMPLE_INTERFACE_00001650’ and create your own function module.
You will see there is no code implemented. We will implement the logic in the later steps. For now, activate your function group and function module.
2. Add custom product in BTE
Go to transaction code FIBF and go to Settings -> Products->….of a customer. Add a new entry like below and make sure to check Active button. Save and attach the change to a transport request.
Next, go back to the home screen of FIBF and go to Settings -> P/S Modules->….of a customer. Add new entry and set the custom function module created in the previous step. Save.
2. Extend RFPOS and RFPOSX
Go to SE11 and display structure RFPOS and RFPOSX. Create custom Append Structure and click on create button.
Enter description ‘Custom fields for FBL1N FBL3N FBL5N’ and define field ‘ZZ1_KTEXT’ using data element ‘KTEXT’. Save and activate. If there is warning regarding enhancement category, we can ignore for now. If you want to suppress this warning, you must define enhancement category by Extra tab->Enhancement Category-> Select ‘Cannot be enhanced’.
3. Extend RFPOSXEXT
Now we have added custom field to structure, we will extend another structure RFPOSXEXT. RFPOSXEXT is the actual structure used in the reports and it is generated structure based on RFPOSX. To trigger the regeneration, go to SE38 and execute program RFPOSXEXTEND. A pop up will appear to ask us if we are sure to extend RFPOSXEXT so click yes. You will get a complete message if it’s succesfull.
Go to SE11 and check structure RFPOSXEXT if the custom field is added automatically. The field does not necessarily get added in the bottom.
Now go to FBL1N, FBL3N, or FBL5N and Change layout too see all the hidden fields. You should be able to see our custom field ‘Name’ on the right side. Click on the arrow button to add it to the left side.
Now you should be able to see it as report column. However, there is no value displayed. This is because we haven’t mapped any value to this field yet. We will do this in the next step.
4. Map value to custom field
Go to SE80 and let’s add logic to our custom function module. To get profit center text, implement below code(or implement your logic of your choice). Save and activate.
FUNCTION YINTERFACE_00001650.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_POSTAB) LIKE RFPOS STRUCTURE RFPOS
*" EXPORTING
*" VALUE(E_POSTAB) LIKE RFPOS STRUCTURE RFPOS
*"----------------------------------------------------------------------
*-------------- Initialize Output by using the following line ----------
E_POSTAB = I_POSTAB.
SELECT SINGLE KTEXT
FROM CEPCT
WHERE PRCTR = @E_POSTAB-PRCTR
AND SPRAS = @SY-LANGU
AND KOKRS = '1000'
AND DATBI >= @SY-DATUM
INTO @E_POSTAB-ZZ1_KTEXT.
ENDFUNCTION.