Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
Andi_M
Product and Topic Expert
Product and Topic Expert
1,792
Sometimes it is needed to have a custom specific field check at standard fields or custom fields.

In this blog I will describe a way to check field values after input

Introduction


The purpose of this blog is to create a custom Function Module with a simple check logic as example. This Function Module will be assigned to BDT setup.

Target audience: Functional Experts

Version: SAP S/4HANA On Premise 1610 and higher

At this example I will implement a field check on a free text field to limit possible entries.

If you start transaction BP you can see field "Express Station" at customer level.


Target is to limit possible field values to entries starting with "E". If a value is entered which doesn't start with "E" a error message should appear.

Screen Analysis


If you want to use standard functionality you can enter your custom field field check at view level only. Therefor you need to determine the corresponding BDT-view by using BDT Analyzer.

How to use BDT Analyzer please have a look at my blog post

SAP S/4HANA Business Partner BDT Analyzer usage

BDT View


Field "Express Station" is assigned to BDT view CVIC93. You can access BDT view directly via BDT Analyzer or with transaction BUS3.


Standard field check is implemented at Function Module CVIC_BUPA_PAI_CVIC93. To implement an additional check you can use "Further Checks" assignment.

Create check Function Module


With this example I've created Function Module Z_CVIC_BUPA_PAI_CVIC93
FUNCTION z_cvic_bupa_pai_cvic93.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"----------------------------------------------------------------------
DATA: lt_kna1 TYPE TABLE OF kna1,
ls_kna1 LIKE LINE OF lt_kna1,
table_name_kna1 TYPE fsbp_table_name VALUE 'KNA1',
false TYPE boole-boole VALUE ' '.

CHECK cvi_bdt_adapter=>is_direct_input_active( ) = false.

* get kna1 data
cvi_bdt_adapter=>get_current_bp_data(
EXPORTING
i_table_name = table_name_kna1
IMPORTING
e_data_table = lt_kna1[]
).

READ TABLE lt_kna1 INTO ls_kna1 INDEX 1.

IF ls_kna1-bahne(1) NE 'E' AND NOT ls_kna1-bahne IS INITIAL.

CALL FUNCTION 'BUS_MESSAGE_STORE'
EXPORTING
arbgb = 'ZCVI'
msgty = 'E'
txtnr = '001'
tbfld_strg = 'GS_KNA1-BAHNE'
repeat_show = '1'
sicht = 'CVIC93'.

ENDIF.

ENDFUNCTION.

To process error message you have to create your own Message Class or use an existing one. At this Message Class create your own message which shall be called in case of error.

Assign Check Function Module to BDT view


Access BDT view CVIC93 with transaction or via BDT Analyzer.

Navigate to "Further Checks" and add your Function Module.



Test at BP transaction


Run BP transaction and navigate to screen "Customer: General Data" and enter any value which doesn't start with "E".


After pressing <ENTER> system checks field value additionally with custom check and gives back an error message. Cursor is placed at the field "Express Station".
3 Comments