Custom field extension FBL1N & FBL3N & FBL5N – BAdI 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 – BTE 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 Add-Ins(BAdI). We will setup a sample requirement, where we needed to display how long days it took to clear the financial document item(Clearing date – Posting date) and show it on the reports.
1. Extend RFPOSX
Go to SE11 and create data element for you custom fields. In our case, enter the description as that describes this is number of days it took to clear the FI item. Define type and lengths as char 5. Number of days should not exceed number with 5 digits. Save and activate the data element.
Go to SE11 and display structure RFPOSX. Create custom Append Structure and click on create button.
Enter description ‘Custom fields for FBL1N FBL3N FBL5N’ and define field ‘ZZ1_CLEAR_DAYS’ using the data element we created in previous step. Save and activate.
You will get a warning after activation, which is most likely about enhancement category not defined. This warning can be ignored for our exercise.
If you want to suppress this warning, you must define enhancement category by Extra tab->Enhancement Category-> Select ‘Cannot be enhanced’.
2. 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 ‘Days it took to clear FI doc item’ 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.
3. Map value to custom field
Go to SE18 and enter ‘FI_ITEMS_CH_DATA’ as BAdI and display. Go to Implementation tab->Create. Enter you BAdI implementation name and Create. Enter description and activate the BAdI implementation.
Now switch to Interface tab and double-click ‘CHANGE_ITEMS’ method.
You can add logic in this method to map the custom field we created. CT_ITEMS is the output of report data and in this internal table we are going to map the calculated number of days.
The code loop all the accounting doc item that has posting date and clearing date, meaning all the cleared document items. INside loop is where substraction is performed and in the end of the loop we are suppressing the leading zero to display the number of days without leading zero.
METHOD IF_EX_FI_ITEMS_CH_DATA~CHANGE_ITEMS.
DATA:LV_DAYS TYPE SY-DATUM.
LOOP AT CT_ITEMS ASSIGNING FIELD-SYMBOL(<LW_ITEMS>)
WHERE BUDAT IS NOT INITIAL
AND AUGDT IS NOT INITIAL.
LV_DAYS = <LW_ITEMS>-AUGDT - <LW_ITEMS>-BUDAT. "Clraring date - Posting date
<LW_ITEMS>-ZZ1_CLEAR_DAYS = LV_DAYS.
"Suppress leading zero
SHIFT <LW_ITEMS>-ZZ1_CLEAR_DAYS LEFT DELETING LEADING '0'.
ENDLOOP.
ENDMETHOD.
Activate the class method.
4. Check result in FBL1N, FBL3N, and FBL5N
Go to FBL1N, FBL3N, and FBL5N respectively and add ‘Clearing Date’, ‘Posting Date’, and our custom field ‘Days it took to clear FI doc item’. You will be able to see the days difference displayed in the custom field.