Technical Articles
Enhance BP selection ALV view
This blog post is part of Business Partner blog series. See the previous 2 blogs related to BP-handling topics:
1. How to synchronize KNVK for other relationship types than ‘Contact Person’
2. How to create a BP Role with Company and Sales/ Purchasing view
Standard view of BP search result
When you find a Business Partner using BP-based transaction you are getting a simple view which shows you basic partner data:
Business Partner basic search result
It lacks of customer, vendor, full address information and any other that you may want to see.
You can of course open the BP selected and check one by one such information or build a custom report (as there are no complex business partners reports in standard SAP).
However, you can also enahnce the standard view without any modification and include any additional information you want.
Add new field to BP search result
The display of search result is based on structure BUS_RESULT_TC:
Standard fields available in search result
Proceed with following to enhance the list:
1. Append structure to BUS_RESULT_TC
New append creation
Add new fields – I suggest to keep the same field names as in SAP standard – in such way during upgrade you can easily identify if SAP has included the same field as you. In such case you could eliminate your enhancement – the same data would be already provided by SAP Standard.
In the append add fields that are of your interest – in the example street, customer, vendor, BP Type and country are added:
Additional fields to display
Activate the append and proceed to data filling.
2. Implement filling of new field
The fields in ALV are populated in class CL_BUPA_DIALOG_SEARCHER in methods GET_TABLE_LINES and GET_HEADER_INFORMATION.
Both use the method READ_DESCRIPTION and READ_EXT_DESCRIPTION where all data for a line being processed is available – they are defined as local class of the global class.
Create implicit enhancement at the end of these 2 methods:
Enhancement at the end of READ_DESCRIPTION
Add code to populate your new fields (hint: here is just a simple example – you can put it into a separate class):
*----------------------------------------------------------------------*
* SAP Blog: How to populate additional fields in BP Result *
*----------------------------------------------------------------------*
SELECT SINGLE but000~bpkind, adrc~COUNTRY, adrc~street FROM adrc
JOIN but020 ON but020~addrnumber = adrc~addrnumber
JOIN but000 ON but020~partner = but000~partner
WHERE but000~partner_guid = @iv_partner_guid
AND adrc~nation = @space
INTO CORRESPONDING FIELDS OF @es_tabline.
SELECT SINGLE customer INTO @es_tabline-kunnr FROM cvi_cust_link WHERE partner_guid = @iv_partner_guid.
IF sy-subrc <> 0.
CLEAR es_tabline-kunnr.
ENDIF.
SELECT SINGLE vendor INTO @es_tabline-lifnr FROM cvi_vend_link WHERE partner_guid = @iv_partner_guid.
IF sy-subrc <> 0.
CLEAR es_tabline-lifnr.
ENDIF.
You may wonder why you have to clear the es_tabline-lifnr and kunnr fields, when selection is empty – the reason for that is that SAP copies the value from previous search.
3.Refresh ALV buffen
To see new fields ALV buffer needs to be refreshed using report BALVBUFDEL.
See the result in BP search
After doing all abovementioned steps just go to BP transaction and open the search option and search for some business partners. The new fields are automatically displayed:
New fields in BP search result
Here you go – you can see your new fields in BP display.
Marek TurczyĆski