Download as pdf or txt
Download as pdf or txt
You are on page 1of 108

SAP PRESS E-Bites

Mapping with BRFplus


Decision Tables and SAP® AIF

Michal Rohnka
Michal Rohnka

Mapping with
BRFplus Decision Tables
and SAP AIF ®

This E-Bite is protected by copyright. It contains a digital watermark, a signature that


indicates which person may use this copy. Full Legal Notes and Notes on Usage can be
found at the end of this publication.
Copy No. 456h-8rnq-iubx-yz3f
for personal use of
Fernando Andres
facgal@hotmail.com
SAP PRESS E-Bites
SAP PRESS E-Bites provide you with a high-quality response to your specific project need.
If you’re looking for detailed instructions on a specific task; or if you need to become
familiar with a small, but crucial sub-component of an SAP product; or if you want to
understand all the hype around product xyz: SAP PRESS E-Bites have you covered.
Authored by the top professionals in the SAP universe, E-Bites provide the excellence
you know from SAP PRESS, in a digestible electronic format, delivered (and consumed) in
a fraction of the time!

Dwayne DeSylvia, Jonathan Yagos


Introducing SAP Intelligent Robotic Process Automation
www.sap-press.com/4998 | $24.99 | 127 pages

Uwe Mayer
Predictive Accounting with SAP S/4HANA
www.sap-press.com/5000 | $24.99 | 91 pages

Muhammad Iqbal
SAP HANA Data Lifecycle Management: Dynamic Tiering and Data Aging
www.sap-press.com/5009 | $29.99 | 104 pages

The Author of this E-Bite


Michal Rohnka is a freelance SAP integration consultant with int4. He
is integration architect in long term, international projects. Michal's
focus is SAP AIF and SAP Process Orchestration integrations with
BRFplus to achieve flexible integration solutions.
What You’ll Learn
In this E-Bite, you’ll learn how BRFplus can function as a complex mapping
engine using decision tables and SAP AIF integration. Whether you’re a
developer, integration specialist, or just curious about BRFplus, this E-Bite
will have something for you. We’ll start by building our BRFplus foundation,
and then move directly into working with decision tables. After we explore
table creation, maintenance, settings, versioning, and more, we’ll move
onto advanced mapping. After we’ll look at SAP AIF integration, and then
wrap up with a discussion on error handling with SAP AIF.

1 BRFplus as a Mapping Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5


1.1 BRFplus as a Simple Rule Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2 BRFplus as an Advance Mapping Engine . . . . . . . . . . . . . . . . . . . . 7
2 Working with Decision Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1 Table Creation and Table Content Maintenance . . . . . . . . . . . . . 9
2.2 Table Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.3 Versioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.4 Texts and Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3 Advanced Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.1 Nested Calls in Decision Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.2 Reusability of Decision Tables with Function Call
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.3 Nested Call of a Table with Multiple Result Columns . . . . . . . . 62
4 Integration with SAP Application Interface Framework . . . . . . . . . . . . 74
4.1 BRFplus Call in Value Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
4.2 BRFplus Call in Structure Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . 77
4.3 BRFplus Call in Check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
5 Error Handling with SAP Application Interface Framework . . . . . . . . . 87
5.1 Standard SAP Application Interface Framework Behavior
for BRFplus Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 4


1 BRFplus as a Mapping Engine

5.2 Catching BRFplus Exceptions in SAP Application Interface


Framework Function Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
5.3 Passing Errors from BRFplus to SAP Application Interface
Framework without Raising Exceptions . . . . . . . . . . . . . . . . . . . . . 98
6 What’s Next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

1 BRFplus as a Mapping Engine


SAP’s Business Rule Framework plus (BRFplus) allows you to model rules,
use them in your developments, and maintain them in an intuitive way, via
an easy-to-use user interface that is fully comprehensive and allows you to
adjust to any business requirements. Although BRFplus is a well-known and
widely used SAP component, in most business applications its full potential
is not fully utilized. It’s used mostly to create simple rules.

In the E-Bite, we will look in more detail at the extensive mapping capabili-
ties of BRFplus. You will learn how to leverage the wide range of possibilities
that BRFplus decision tables offer in the areas of value and structure map-
pings. You’ll also investigate how other BRFplus expressions can supple-
ment decision tables in creating complex and nested structure mappings,
allowing BRFplus to serve as a fully customizable and high-performance
mapping engine.

Finally, you’ll also learn how to integrate BRFplus with SAP Application Inter-
face Framework. You will implement BRFplus calls in SAP Application In-
terface Framework configurations on value and structure mappings, as well
as checks. You’ll observe standard error-handling behavior and enhance it
with custom logic to maximize SAP Application Interface Framework moni-
toring capabilities.

Personal Copy for Fernando Andres, facgal@hotmail.com 5


1 BRFplus as a Mapping Engine

Prerequisites for Scenarios


This E-Bite focuses on the usage of BRFplus decision tables as a mapping engine
and on the integration of this engine with SAP Application Interface Frame-
work. Those are advanced BRFplus and SAP Application Interface Framework
topics, so for this E-Bite, we assume that you already have basic BRFplus and
SAP Application Interface Framework knowledge, as well as access to a system
that is already working with both technologies.
All scenarios presented in this E-Bite use the FIDCC2 standard SAP IDoc. To be
able to follow along, you need to have working examples of the FIDCC2 IDoc
that can be processed correctly in your system both with SAP Application Inter-
face Framework and without. This E-Bite will not focus on the setup of the IDocs
because it’s out of the scope of the presented scenarios.

1.1 BRFplus as a Simple Rule Engine


The basic application of BRFplus is to use it as a simple rules engine. In this
way, you can understand the usage of BRFplus to include handling single-
value mappings or value verification based on the business logic. In such
scenarios, you provide one or a couple of values to determine one output
value, usually transforming from external to internal values (or the other
way around). You can also perform basic checks like verifying the length,
prefix, or structure of a value provided in the BRFplus function input. An
important fact to remember is that BRFplus objects are reusable and can call
one another, so even if you’re designing a simple conversion, it might be a
good idea to have it in BRFplus because it can be incorporated someday into
a more advanced BRFplus solution.

Whether your goal is to achieve a simple transformation or complex logic,


you always work with same objects in BRFplus. There will always be func-
tions and expressions. A function is an interface provider for BRFplus logic,
and expressions are the heart of BRFplus, running all types of logic you need.
To make things simple for simple solutions, BRFplus introduced top expres-
sions for functions running in functional mode. In this mode, a function is
focused only on providing an interface to a single expression. Running a

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 6


1 BRFplus as a Mapping Engine

function in functional mode allows a BRFplus expression to be called from


your ABAP code. As mentioned, BRFplus objects can also call one another,
so functional mode is also a very efficient way to encapsulate some stand-
alone logic to be reused by many other BRFplus objects.

Figure 1.1 shows the simplest conversion from an external to internal value.
In this case, value AB01 will be converted to 1710, and AC01 will be converted
to 1310.

Figure 1.1 Simple Conversion of Values

This is the simplest scenario for BRFplus: you can achieve this goal in many
other ways, but keep in mind that editing such conversions in BRFplus has
proven to be well-received by many business users. Users appreciate the
web-based intuitive environment of BRFplus and the ability to download
and upload Excel files with these conversions. What’s more, it might be
company policy to reduce the number of custom ABAP Dictionary tables in
favor of BRFplus which is recognized to be configuration.

This basic approach will be covered in Section 2.

1.2 BRFplus as an Advance Mapping Engine


BRFplus is a very comprehensive and flexible tool that allows you to model
your business logic in various ways, providing dozens of expressions as
tools to achieve every business need in your scenarios.

The most important parts of complexity handling are rulesets and rules.
These are used when you run your BRFplus function in action mode. This
mode assumes that you will create a ruleset and populate it with rules,

Personal Copy for Fernando Andres, facgal@hotmail.com 7


1 BRFplus as a Mapping Engine

applying expressions therein. This means you won’t have a single top expres-
sion: you can put as many expressions as you like in rules and even use a rule-
set header, which provides endless opportunities to model your logic.

One very efficient way of leveraging those opportunities is to use BRFplus


as an advanced mapping engine. In this way, you use complex logic that
doesn’t map single values to other values, but populates destination struc-
tures (even deep ones) based on the source structures, delivering the ability
to alter logic based on the source values and even provide the ability to
apply logic on the level of single cells.

For example, Figure 1.2 shows complex structure mapping. Based on two
input columns (shaded grey), a decision about how to populate the green
columns is made. That can let you run different logic—for example, for dif-
ferent sending systems. Also note the different icons in the green cells. The
circle, triangle, and rectangle icon indicates that a cell will be populated
based on the value in some input field. For example, the BSCHL destination
field will be populated from the BSCHL source field. The triangle with a small
circle icon shows that this cell contains reference to an expression. That
means that to determine what value should be placed in, for example, the
SGTXT field, an expression will be called and its logic will be performed to
return a value.

Figure 1.2 Complex Structure Mapping in BRFplus

Imagine now that from a single cell you can call any expression, and there is
an expression that can call a BRFplus function. The potential is great: you
only need to leverage it.

These topics will be covered in Section 2, Section 3, and Section 4.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 8


2 Working with Decision Tables

2 Working with Decision Tables


Decision tables are one of the most often used and most powerful BRFplus
expressions. They can serve a variety of purposes, from simple value map-
ping to complex scenarios that map whole structures. This section will
focus on simple applications of decision tables to familiarize you with all
the technical details involved in working with them. You will explore their
capabilities and learn how to create, set up, and populate them and finally
provide versioning along with documentation.

You’ll map a single value from IDoc FIDCC2 field XREF1_HD to field BUKRS. That
will be the only change in the IDoc content, which will be applied in this sce-
nario. To be able to test the solution, you’ll call the implemented BRFplus
function from enhancement IDOC_INPUT_FIDCC2_G1 in function module
IDOC_INPUT_FIDCC2, which is the standard function module assigned to IDoc
FIDCC2.

2.1 Table Creation and Table Content Maintenance


The simplest usage of decision tables is to embed them in a BRFplus func-
tion with the functional mode. This approach is usually used to provide
simple value mapping that you can call from your ABAP code or SAP Appli-
cation Interface Framework. In this scenario, you will use a decision table to
provide mapping from an external company ID to an internal SAP company
code.

Create BRFplus Application


A BRFplus application is a container to organize and manage BRFplus
objects. Any BRFplus objects you create need to be created in the scope of an
application.

Figure 2.1 shows the details of the application you need to set when creat-
ing it:

Personal Copy for Fernando Andres, facgal@hotmail.com 9


2 Working with Decision Tables

쐍 Type: Application

쐍 Name: FIDCC2_MAPPING

쐍 Short Text: FIDCC2 IDoc mappings

쐍 Text: FIDCC2 Inbound IDoc mapping tools

쐍 Storage Type: Customizing

쐍 Development Package: ZBRF_SAPPRESS

쐍 Software Component: HOME

Values under the Application section are inherited by all objects assigned to
this application. You need to enter the application Name, Text, and Short
Text. In addition, you need to choose the Storage Type; in most cases, includ-
ing this one, it will be Customizing. The last step is assigning a Development
Package and Software Component, as you do for all workbench objects.

Note
When creating BRFplus objects, try to be as descriptive as possible. Name is
object main identification and is used by users working in BRFplus expert user
mode. Short Text is shown as the object name in simple user mode. Text can be
used as part of the self-documentation of objects.

Figure 2.1 Application Creation

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 10


2 Working with Decision Tables

Create BRFplus Function


A BRFplus function is an interface between rules defined by you and the
calling application. It defines the inputs (called context) and outputs (called
results) of BRFplus processing. The following steps will guide you through
the creation of a function:

1. To create a function, right-click the application you have just created (in
the navigation panel on the left-hand side of the window) and select Cre-
ate 폷 Function (Figure 2.2). Then populate the following details in the pop-
up window (Figure 2.3):
– Type: Function
– Name: GET_BUKRS
– Short Text: Get Company Code
– Text: Get Company Code value based on external company ID
– Application: FIDCC2_MAPPING

Figure 2.2 Right-Click Application to Create Function

Personal Copy for Fernando Andres, facgal@hotmail.com 11


2 Working with Decision Tables

Figure 2.3 Function Details

2. Next, add context data objects by clicking the Add New Data Object but-
ton and choosing Add New Data Object (Figure 2.4).

Figure 2.4 Add New Data Object

3. Choose Type for the Element because this is a representation of a single


value.
4. You need to apply binding to XREF1_HD DDIC Element as shown in Figure
2.5. To do this, select the Binding Type drop down menu and choose Bind to
DDIC Element. A popup window will show one field to be populated DDIC
Element. Populate it with value XREF1_HD. The binding is applied with
same ABAP dictionary type, as a source field in the inbound IDoc, from
which a value to be mapped of will be fetched. Binding will automatically
populate Short Text, Text, Length, Element Type and Convert to Uppercase
fields, with values fetched from ABAP Dictionary Data Type, you have
pointed to as DDIC Element. Other possible values for Type are Structure
(consisting of multiple elements and structures) and Table (consisting of
multiple structures of same type). They can also be bound to DDIC ele-
ments.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 12


2 Working with Decision Tables

Figure 2.5 Create Object Details, Binding to DDIC

5. Similarly, for a context data object, you need to create a Result Data
Object, by clicking on circular icon, next to the data object (as shown in
Figure 2.6). Then, select Create on the next menu.

Figure 2.6 Create Result Data Object

Personal Copy for Fernando Andres, facgal@hotmail.com 13


2 Working with Decision Tables

6. The result data object should be bound to BUKRS DDIC Element. Populate
details in same way as for XREF1_HD in Figure 2.5, but use BUKRS as DDIC ele-
ment this time. All other fields will be populated automatically. Binding
in this case will also provide you with value help, so values entered in the
decision table will be checked against value table T001, assigned in the
ABAP Dictionary to the BUKRS domain.

Create Decision Table


When you have your input (XREF1_HD) and your output (BUKRS), you can
proceed with decision table creation. The decision table will be core of the
processing that will provide mapping between values. The following steps
will guide you through creation of the simplest application of a decision
table:

1. Create a decision table as a Top Expression of a function in Functional


Mode. To do this, change Mode of the function to Functional Mode from
dropdown menu. When Functional Mode is set, a new element called Top
Expression will appear on the screen. Click on circular icon next to Top
Expression and select Create on menu, as on Figure 2.7.

Figure 2.7 Create Expression as Function Top Expression

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 14


2 Working with Decision Tables

Note
For a BRFplus function, you can select one of four different modes:
쐍 Functional Mode: process only top expression; no rulesets
쐍 Event Mode: process only assigned rulesets; no top expression
쐍 Functional and Event Mode: process top expression, then process assigned
rulesets
쐍 Analytical Mode: used for evaluation of large datasets persisted in the data-
base

2. From the available expressions, choose Decision Table, and populate the
other fields as shown in Figure 2.8:
– Type: Decision Table
– Name: DT_GET_BUKRS
– Short Text: DT Get Bukrs
– Text: Decision Table Get Company Code value based on external ID
– Application: FIDCC2_MAPPING
– Is Reusable: Check
– Result Name: BUKRS
– Text: Company Code
Note that the Possible Result Data Objects entry is inherited from the
function and populated automatically.
3. Select Create and Navigate to Object to take a closer look at all the features
that are available on the screen for the newly created Decision Table.

The General tab includes several fields holding the main administration
data of the decision table (as shown in Figure 2.9). Here you’ll see the Name,
unique ID, info about whether Versioning is on, and creation details, along
with the change log, Storage Type (inherited from the application), and
application assignment.

Personal Copy for Fernando Andres, facgal@hotmail.com 15


2 Working with Decision Tables

Figure 2.8 Create Expression Type Decision Table

Figure 2.9 General Tab

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 16


2 Working with Decision Tables

The Texts tab is used to adjust text entered during table creation (as shown
in Figure 2.10). Source can be changed to Text Symbol or Exit Class.

Figure 2.10 Texts Tab

The Documentation tab can be used to hold documentation text (as shown
in Figure 2.11). It can be provided via Free Text Input, an SAPscript object, or
an Exit Class (selected under the Source dropdown). This is a very good place
to keep self-documentation for the object. Details for Texts and Documenta-
tion will be covered in Section 2.4.

Figure 2.11 Documentation Tab

The Versioning tab (shown in Figure 2.12) is used to work with versions,
which are described in more detail in Section 2.3.

Figure 2.12 Versioning Tab

Personal Copy for Fernando Andres, facgal@hotmail.com 17


2 Working with Decision Tables

The Transport information tab contains info about the current transport
request assignment of the object (as shown in Figure 2.13).

Figure 2.13 Transport Information Tab

When you look down on the screen, below the General tab, you will see three
buttons: Additional Actions, Context Overview, and Start Simulation like on
Figure 2.14. Additional Actions will allow you to perform the following:

쐍 Check Completeness
Check if all of a table’s mandatory fields are populated
쐍 Check Overlaps
Check if all table entries are accessible
쐍 Rearrange
Change order of the columns
쐍 Merge Rows
Combine multiple rows into one row
쐍 Import from Excel
Import table content from Excel file
쐍 Export to Excel
Export table content to Excel file

Context Overview will display context objects available at the decision table
level. Start Simulation will take you to the BRFplus simulation tool. If you
trigger a simulation from the Decision Table screen, only this decision table

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 18


2 Working with Decision Tables

expression will be simulated, not the whole function that the decision
table is assigned to.

Figure 2.14 Decision Table Screen Buttons

Below these buttons, you’ll see the Table Contents area (Figure 2.15). Cur-
rently, this area is empty, but you’ll populate it going forward.

Figure 2.15 Decision Table Content

Now, click Table Settings on the right side of the Table Contents menu bar
(Figure 2.15). A pop-up window will appear with all decision table options
related to its content. The window is broken down into four sections to help
you distinguish with what type of configuration you’re working on.

These setups will be covered in detail in Section 2.2.

Next you need to add a condition column by clicking on Insert Column and
choosing From Context Data Objects (Figure 2.16). A condition column also
can be an expression that returns a Boolean-type result.

Figure 2.16 Add Context Data Object as Condition Column

The Context Query pop-up window now will appear. Choose XREF1_HD as
your result (Figure 2.17). XREF1_HD will be added as Condition Column. Now
you can close the Table Settings window.

Personal Copy for Fernando Andres, facgal@hotmail.com 19


2 Working with Decision Tables

Figure 2.17 Context Query Result

Populate Decision Table with Data


The decision table has been created, but it’s empty. This means it will not
map any values. It’s time to add data to your decision table to make it map.
To populate values, proceed as follows:

1. Click the green button with a plus sign to add a row.


2. Click the three dots (…) in the first cell of the first row (column XREF1_HD).
Populate a value as shown in Figure 2.18. You’ve now created a condition.
If the value of XREF1_HD is AB01, then this row will be selected as a match-
ing row and its result will be returned as a result of expression processing.

Figure 2.18 Populate Value in Decision Table Condition Column

Now that you’ve created a condition for a row, you need to set up what
result it will return.
3. Click the three dots in the BUKRS column and populate the result with a
company code that you have in your system, as shown in Figure 2.19
(company code 1710). Note that because you bound BUKRS to the DDIC ele-
ment, you can now use search help on this field. Doing so will also provide
you with a description of the chosen company code.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 20


2 Working with Decision Tables

Figure 2.19 Populate Value in Decision Table Result Column

4. Condition column input can be more complex. By clicking Change, to the


right of the input options, (Figure 2.20), you can add additional include
and exclude conditions. The example shown in Figure 2.20 shows the
condition that will be matched if XREF1_HD matches pattern +C0* (+ is a
single character, * any number of characters), unless XREF1_HD is RC02.
Add this condition to your decision table.

Figure 2.20 Complex Condition Column Input

5. Add conditions and results to make the finalized content look like Figure
2.21. You’ve already added a line with the condition checking if XREF1_HD
is equal AB01, and you have also added line with condition working with
patterns in previous step. The only missing line is the one that will
check if XREF1_HD is equal to AC01. Use company codes present in your
system.

Personal Copy for Fernando Andres, facgal@hotmail.com 21


2 Working with Decision Tables

Figure 2.21 Final Content of Decision Table

Simulate Decision Table


BRFplus offers a very good simulation framework that allows you to simu-
late any expression or function you have created. It’s very useful because it
allows for test-driven development of BRFplus objects directly from the
BRFplus workbench. You can access it from any expression or function.
Accessing a simulation from an expression such as a decision table simu-
lates only this expression in isolation from the function or ruleset to which
it is assigned.

To access a simulation, proceed as follows:

1. Click the Start Simulation button (shown in Figure 2.14). You will be moved
to BFRplus simulation framework (Figure 2.22). The options here are
divided into the following sections:
– Object
Display object that will be tested. Click the Select button to change
objects.
– Simulation Mode
You can select whether you want code for tested objects to be gener-
ated before simulation execution, by choosing Generation Mode, or
not, by choosing Interpretation Mode.
– Version
You can select which version you would like to test: the current active
version, the newest changes not yet activated, or the version active at a
selected date and time.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 22


2 Working with Decision Tables

– Action Settings
Check the Execute Actions checkbox if you want the simulation to also
execute actions. If not checked, the simulation will only inform you
that an action was reached.

Figure 2.22 Decision Table Simulation

2. Click the Continue button. On the screen that appears, you can populate
context before simulation execution. Each simulation must have context
populated because the BRFplus simulation framework always tests objects
in certain conditions. Figure 2.23 shows manually populated context.

Figure 2.23 Simulation Context: Manual Input

Personal Copy for Fernando Andres, facgal@hotmail.com 23


2 Working with Decision Tables

3. Click Import Test Data to import data from Excel (Figure 2.24). Importing
from Excel is not supported if the context contains a table-type data
object. The Create Import Field Structure button prepares a sample Excel
file in the correct format, which you can populate with data and import
back into BRFplus. You don’t need to import test data from Excel in this
example.

Figure 2.24 Simulation Context: Import Data

Note
Notice that the Variants button is grayed out. Variants are supported only for
functions.

4. Populate data in the XREF1_HD manual input field and click Execute and
Display Processing Steps. This simulation method will show all processing
steps that were involved in providing the result. It’s the best way to debug
your BRFplus objects and learn how they are processing data. Execute will
just run and show the result, which is useful if you already know what’s
happening inside your objects.
5. Figure 2.25 shows the results of the simulation with the processing steps
displayed. In the Result section, you’ll see the actual results. Because the

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 24


2 Working with Decision Tables

data object is bound to the DDIC element, you’ll also see the description
of the value.

Figure 2.25 Results of Simulation Execution with Processing Steps Displayed

6. The Processing Steps section shows all the processing steps; you can even
drill down to each cell evaluation procedures (Figure 2.26). Note that
because this is an expression simulation, BRFplus creates a temporary
function to be able to execute it.

Figure 2.26 Evaluation of Single Cell

Personal Copy for Fernando Andres, facgal@hotmail.com 25


2 Working with Decision Tables

Implement Function Call


After a decision table is tested via simulation, it’s time to implement a call
for the function that contains it within the ABAP code. BRFplus offers the
ability to generate an ABAP function module from a BRFplus function. To
create a function module, proceed as follows:

1. Open GET_BUKRS function created in Section 2.1, Create BRFplus Function


in BRFplus and click Generate 폷 Function Module (RFC), as in Figure 2.27.

Figure 2.27 Create Function Module


from BRFplus Function

2. This will take you to the screen shown in Figure 2.28. Provide data as fol-
lows in the Function Group, Function Module, and Transport sections:
– Function: GET_BUKRS
– Function Description: (Get Company Code)
– Create Function Group: Check
– Function Group: ZFIDCC2_BRF_MAPPING
– Function Module: ZFIDCC2_XREF1_HD_TO_BUKRS
– Development Package: ZBRF_SAPPRESS
– Workbench Request: S42K900259
– Customizing Request: S42K900261
These details will be applied to ABAP function module that will be gener-
ated for you, and thus you’ll have an easy-to-use and reusable ABAP inter-
face for your BRFplus function.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 26


2 Working with Decision Tables

Figure 2.28 Create Function Module Details

The goal of this decision table implementation is to map an external com-


pany ID stored in field E1FIKPF-XREF1_HD of IDoc FIDCC2 to field E1FIKPF-
BUKRS, which should contain the internal SAP company code value. As men-
tioned earlier, the implementation should be called from function module
IDOC_INPUT_FIDCC2 using enhancement IDOC_INPUT_FIDCC2_G1. To avoid
issues with data types when passing data to the newly created function
module ZFIDCC2_XREF1_HD_TO_BUKRS, you should go to the function module
and change the associated types for XREF1_HD and E_BUKRS to E1FIKPF-
XREF1_HD and E1FIKPF-BUKRS.

A code snippet for the enhancement implementation is presented in List-


ing 2.1.

ENHANCEMENT 1 ZIDOC_INPUT_FIDCC2_GL.
DATA: ls_e1fikpf TYPE e1fikpf.
ASSIGN idoc_data[ segnam = |E1FIKPF| ]-sdata
TO FIELD-SYMBOL(<fs_e1fikpf>).
ls_e1fikpf = <fs_e1fikpf>.
CALL FUNCTION 'ZFIDCC2_XREF1_HD_TO_BUKRS'
EXPORTING
XREF1_HD = ls_e1fikpf-xref1_hd

Personal Copy for Fernando Andres, facgal@hotmail.com 27


2 Working with Decision Tables

IMPORTING
E_BUKRS = ls_e1fikpf-bukrs
EXCEPTIONS
CX_FDT = 1
CX_FDT_NO_RESULT = 2
CX_FDT_ARITHMETIC_ERROR = 3
CX_FDT_PROCESSING = 4
OTHERS = 5.
<fs_e1fikpf> = ls_e1fikpf.
ENDENHANCEMENT.
Listing 2.1 Enhancement Implementation with BRFplus-Generated Function Module

Now you can input IDoc FIDCC2 and check if the mapping is working cor-
rectly.

2.2 Table Settings


Your decision table is now created and populated with data. It’s also assigned
to a function so that it can be called. That’s all that needs to be done to make
a simple decision table work, but decision tables offer much more flexibility
and can be configured to suit your needs. This section will cover all possible
configuration options that can be applied to a decision table.

Configuration Options
Now we’ll go through all the set up options available for decision tables so
that you can familiarize yourself with all the possibilities offered to make
them work exactly as you need.

To start, click the Table Settings button in the top-right corner of the deci-
sion table contents.

The Result Data Object section shown in Figure 2.29 defines the Result Data
Object and how the decision table should behave in different processing sit-
uations. Three checkboxes are available:

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 28


2 Working with Decision Tables

쐍 Return All Matches Found


Allows multiple rows to be returned as a result of one decision table exe-
cution; requires the result data object to be a table
쐍 Return Initial Value if No Match Is Found
If checked, initial value is returned if no match is found and exception is
not raised
쐍 Return Exception for Partial Match
If checked, exception is raised if no match found; provides info on a max-
imum condition fulfilled

Figure 2.29 Result Data Object

Two options can be found in the Table Check Settings section, shown in Fig-
ure 2.30:

쐍 Overlap Check Settings


Checks if all lines are reachable. Because the decision table processes lines
sequentially, some lines might not be accessible because of conditions in
lines above them.
쐍 Completeness Check Settings
Checks if mandatory fields are populated.

Figure 2.30 Table Check Settings

For both table check settings, the following four options can be chosen,
determining the behavior if an issue appears:

Personal Copy for Fernando Andres, facgal@hotmail.com 29


2 Working with Decision Tables

쐍 Show Messages as Error


Show an error, which means you can’t activate the decision table
쐍 Show Messages as Warning
Show a warning, which means you can activate the decision table
쐍 Do Not Show Any Messages
Hide all messages related to the issue
쐍 Application Default
Inherit behavior from the application

The next section is List of Columns, which breaks down to Condition Columns
and Result Columns. Your List of Columns section should look like Figure 2.31.

Figure 2.31 List of Columns

Note that you can set up a few more parameters for both Condition Columns
and Result Columns. First, the Mandatory Input checkbox indicates if a field
needs to be populated or not. Column Accessibility is used to hide some col-
umns or restrict access to them.

For Result Columns, you can also click Insert Action Column, which will add a
special column in the decision table that triggers BRFplus actions for spe-
cific rows. BRFplus actions can include, for example, sending mail or start-
ing a workflow.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 30


2 Working with Decision Tables

Testing Check Settings


You can test the check settings setup directly in the decision table itself via
the following simple steps:

1. Change decision table content by removing the result in second row. To


do so, click the small circular icon in the cell and select Remove Cell Value,
as shown in Figure 2.32.

Figure 2.32 Remove Cell Value

2. The content should look like that shown in Figure 2.33, so there should be
no value in the result data column in the second row, just three dots indi-
cating a BRFplus cell without a value. The rest of the cells should remain
as set up previously.

Figure 2.33 Content with Missing Mandatory Input

3. Notice that now the second row in Figure 2.33 has an empty result col-
umn, which was selected to be mandatory in the result columns setup
shown in Figure 2.31. Click the Check button at the top of the screen,
shown in Figure 2.34.

Figure 2.34 Check Button

4. Because of the setup you’ve done, the Mandatory Input column checkbox
is checked for BUKRS, and missing mandatory input will be treated as an
error. You’ll see a message like the one in Figure 2.35.

Personal Copy for Fernando Andres, facgal@hotmail.com 31


2 Working with Decision Tables

Figure 2.35 Missing Mandatory Input Error

2.3 Versioning
Versioning is a very powerful option and a great tool to trace changes made
to BRFplus objects and secure older versions. It’s extremely useful, espe-
cially with decision tables. Because you can upload decision table content
from Excel, which overwrites all the content, it’s very important to keep ver-
sioning on for the crucial tables so as not to lose data. A trace of version
changes can also be handy when issues occur after configuration updates.

The Versioning tab is visible at the top of the decision table screen, as shown
in Figure 2.36.

Figure 2.36 Versioning with Multiple Versions

Versioning can be switched on or off with the Set Versioning button. After
activation of versioning, each time an object is activated, a new version is
stored. The other button, Object History, allows you to access the detailed

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 32


2 Working with Decision Tables

history of the object. After clicking it, you’ll see a pop-up window with a few
selections, as shown in Figure 2.37.

Figure 2.37 Object History Selections

You can set up a date range for which you would like to query the object his-
tory. You can also choose whether to display processing-relevant changes
and non-processing-relevant changes. After clicking the Show History but-
ton, detailed historic info will be shown, as in Figure 2.38.

Figure 2.38 Object History

This information will show you in detail who changed what and when.

Going back to the Versioning tab, you’ll find two more useful functions. The
first one lets you copy an old version. To do this, you just need to select the
version that you’re interested in and click the button with the Copy icon.
The retrieved version will be stored as a new and already active version.

Personal Copy for Fernando Andres, facgal@hotmail.com 33


2 Working with Decision Tables

When coping a version, you’ll see the pop-up window in Figure 2.39. It is not
recommended to copy child objects unless you’re sure that you need to do
so. In most cases, you just want to retrieve decision table content.

Figure 2.39 Confirmation: Copy Version

The last option is version comparison. To compare, you need to select two
versions and click the Compare button. The result will show a comparison of
the two versions in a vertical or horizontal layout (Figure 2.40).

Figure 2.40 Version Comparison in Horizontal View

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 34


2 Working with Decision Tables

Finally, you can click each version line in the Changes column to see the
change log for a single version (Figure 2.41).

Figure 2.41 Single Version Change Log

2.4 Texts and Documentation


BRFplus expressions allows users not only to add descriptive texts along
with a technical name, but also to attach documentation. Texts are displayed
to BRFplus users using simple user mode instead of technical names. Docu-
mentation is just stored on the Documentation tab. Both options have three
different ways of providing input, as we’ll discuss in the following sections.

Free Text Input


This is the simplest way of providing documentation and texts. You just
need to enter Short Text, Text, and Documentation manually using the avail-
able text boxes. One important thing to mention is that if you provide Short
Text, it will be used instead of Text.

For both Texts and Documentation, four types of dependencies can be set
up:

쐍 Independent of Language and version

쐍 Language Dependent but Not Version Dependent

Personal Copy for Fernando Andres, facgal@hotmail.com 35


2 Working with Decision Tables

쐍 Version Dependent but Not Language Dependent

쐍 Language and Version Dependent

Text Symbol and SAPscript Object


The text symbol is used only by texts. You can point to an ABAP program,
and its text symbol will be the source that will be used by the object. Each
ABAP program has a separate section for texts that you can access from the
editor (Transaction SE38) via menu path Goto 폷 Text Elements 폷 Text Symbols.
You can point BRFplus objects’ texts to point to those ABAP program text
IDs. It is recommended to use this option only if you use BRFplus logic in
the ABAP program to which you are referring.

An SAPscript object is used only by documentation. You can point to an


SAPscript object and ID to be source of the BRFplus object documentation.
SAPscript is an SAP tool used to create formatted texts, mostly used for
printouts. You can create an SAPscript document in Transaction SE71 that
will be referred to by BRFplus as documentation text for the object.

Exit Class
Exit class is an SAP name for a class called from BRFplus object configura-
tion to supply additional custom ABAP logic. These are regular SAP ABAP
classes that implement required interfaces. The best option is to copy an
example class that SAP delivers to be sure that all requirements are fulfilled.

One common class can handle texts and documentation for many objects.
SAP provides sample class template CL_FDT_DEMO_EXIT_CLASS, which you
can copy and adapt to your requirements. Because it’s a regular ABAP class,
you can develop any kind of complex logic you’d like to provide texts and
documentation. Sample code snippets for implementations can be found
in Listing 2.2 and Listing 2.3. To fetch Texts or Documentation from Exit
Class, you just need to provide a class name in Exit Class field, as shown on
Figure 2.42.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 36


2 Working with Decision Tables

Figure 2.42 Documentation Provided via Custom Exit Class

METHOD if_fdt_text_docu_exit~get_text.
ev_text = COND #(
WHEN iv_id = |12B17D7689C01ED9A7ADAE3F8556C2D4|
THEN |DT exit text |
ELSE |text not found| ).
ev_text_type = if_fdt_admin_data=>gc_text_dep_no.
ENDMETHOD.
Listing 2.2 Provide Text from Custom Exit class

Listing 2.2 shows a sample implementation of text retrieval from an exit


class. As class is common and can be called from many objects, so it’s very
important to remember that you need to check the object ID before passing
a text value. It is also recommended to provide some standard text, like text
not found, to let users know that text for this object was not found if this
object should have text delivered via an exit class. The last line in this listing
sets the type of text dependency, the same as we described in Section 2.4,
Free Text Input.

METHOD if_fdt_text_docu_exit~get_documentation.
ev_documentation = COND #(
WHEN iv_id = |12B17D7689C01ED9A7ADAE3F8556C2D4|
THEN |DT exit documentation |
ELSE |documentation not found| ).
ev_dependency_type = if_fdt_admin_data=>gc_docu_dep_no.
ENDMETHOD.
Listing 2.3 Provide Documentation from Custom Exit Class

Listing 2.3 shows a sample implementation of documentation retrieval


from an exit class. Because a class is common and can be called from many

Personal Copy for Fernando Andres, facgal@hotmail.com 37


3 Advanced Mapping

objects, it’s very important to remember that you need to check the object
ID before passing a documentation value. It is also recommended to pro-
vide some standard text, like documentation not found, to show users that
documentation for this object was not found if this object should have doc-
umentation delivered via an exit class. The last line in this listing sets the
type of documentation dependency, the same as we described in Section
2.4, Free Text Input.

So far, you’ve learned how to work with decision tables. You’ve created, con-
figured, and tested them. Now it’s time to use this knowledge to develop
more complex solutions and learn how powerful decision tables and BRF-
plus can be.

3 Advanced Mapping
In this section, you’ll learn how to create nested decision table calls, reuse
decision tables with function call expressions, and enable nested calls to a
decision table with more than one result column. All the examples are
based on same standard IDoc FIDCC2, and we’ll also use the decision table
you created in the previous section so that you can smoothly continue
extending your BRFplus knowledge.

3.1 Nested Calls in Decision Tables


In the previous section, you populated a decision table with simple direct
input values. This was possible because you were mapping only to one out-
put field. Imagine now that your BRFplus function result is a whole struc-
ture. Your core decision table will populate fields of this structure based on
the source values just by coping it, but in some cases you might need to not
only to pass a value, but also transform it. In such a situation, you can use
the ability of BRFplus expressions to call each other. Instead of passing a
value, you can call another expression directly from a decision table cell.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 38


3 Advanced Mapping

Note
An example of calling a BRFplus function from ABAP code was presented in Sec-
tion 2. All exercises in this section are tested within the BRFplus simulation
framework to put more focus on this core topic of this E-Bite. All of them can be
called from ABAP code by following same steps as described in Section 2.

Decision Table with Structure as a Result


In this section, you’ll create a function with a decision table that will return a
structure as a result data object and therefore will learn how to use decision
tables to perform structure mapping. To avoid overcomplicating the exam-
ple, you’ll map between the same structures, but they can be different in more
complex situations. The following steps will guide you through the process:

1. Create a function (as in Section 2.1, Create BRFplus Function) with the fol-
lowing details, as shown in Figure 3.1:
– Type: Function
– Name: GET_E1FIKPF
– Short Text: Get E1FIKPF Segment
– Text: Get E1FIKPF Segment
– Application: FIDCC2_MAPPING

Figure 3.1 Create Function GET_E1FIKPF

2. Create a new data object by clicking the Add New Data Object button and
choosing Add New Data Object. Populate the following details, as shown
in Figure 3.2:

Personal Copy for Fernando Andres, facgal@hotmail.com 39


3 Advanced Mapping

– Type: Structure
– Name: INB_E1FIKPF
– Text: FI Document Header (BKPF)
– Application: FIDCC2_MAPPING
– Binding Type: Select Bind to Structure Type (DDIC)
– DDIC Type Name: E1FIKPF
Create also a result data object named OUT_E1FIKPF with exactly the same
details (as in Section 2.1, Create BRFplus Function). Now both your context
object and result data object are of the same structure type.

Figure 3.2 INB_E1FIKPF Object with binding to E1FIKPF DDIC Type

3. Set Function to Functional Mode and create a new top expression with the
following details, shown in Figure 3.3 (as in Section 2.1, Create Decision
Table):
– Type: Decision Table
– Name: DT_GET_E1FIKPF
– Short Text: Get E1FIKPF Segment

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 40


3 Advanced Mapping

– Text: Get E1FIKPF Segment


– Application: FIDCC2_MAPPING
– Is Reusable: Check
– Result Name: OUT_E1FIKPF
– Text: FI Document Header (BKPF)
The new expression will be a decision table, with a result data object of
type structure.
That means the result of this decision table processing will contain all
fields from this structure. Thanks to that, you can manipulate all of them
in one processing step. In this scenario, you will map from E1FIKPF to
E1FIKPF, but this process also can be done with completely different
inbound and outbound structures.

Figure 3.3 Decision Table Creation with Result Data Object of Type Structure

Personal Copy for Fernando Andres, facgal@hotmail.com 41


3 Advanced Mapping

4. Go to the table settings by clicking the Table Settings button of the newly
created decision table, then check that the Result Columns table contains
all the fields from the OUT_E1FIKPF structure. Obviously, you don’t need
all of them; in most business cases, only a few out of all the available fields
are used. These fields are created to cover all possible scenarios, but usu-
ally one scenario uses only a portion of them. Use the Column Accessibility
option to hide all fields except BUKRS, BLART, BLDAT, BUDAT, WWERT, XBLNR,
BKTXT, WAERS, GLVOR, and AWTYP. No columns should be set as mandatory, as
shown in Figure 3.4.

Figure 3.4 Table Settings with Mandatory Input Not Checked and Hidden Columns

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 42


3 Advanced Mapping

In this scenario, you will use the decision table as a simple mapping engine,
so there will be no condition columns. Therefore, all inbound E1FIKPF lines
will be processed in the same way.

1. Now it’s time to populate the result columns with some content. Close
the table settings and add a new line to the decision table.
2. To assign context value to the result data object, click the small icon with
an arrow in a cell you want to populate, choose Context 폷 More (Figure 3.5),
and search for the source field. Because you’re mapping between the
same structures, the source field name will be the same as the target field
name.
3. Repeat this for the following columns: BLART, BLDAT, BUDAT, WWERT,
XBLNR, BKTXT, and WAERS. Columns GLVOR and AWTYP populate with
constants. When you’re done, the result should look like Figure 3.6.

Figure 3.5 Assign Context Value


to Result Data Object Column

Personal Copy for Fernando Andres, facgal@hotmail.com 43


3 Advanced Mapping

Figure 3.6 Mapping of Structure in BRFplus Decision Table

The mapping is done! The only missing field is BUKRS. Now you’re going to
implement a nested call to the decision table that will populate BUKRS by
processing expression.

Nested Call to Another Decision Table


You already created a decision table with a function that returns structure
as a result. Now it’s time to implement a nested call to see how deep the
BRFplus logic can go. Because this E-Bite is focused on decision tables, you’ll
implement a call to another decision table via the following steps:

1. Click the BUKRS column and choose Select Expression (Figure 3.7). A pop-
up search window will open; choose decision table DT_GET_BUKRS, which
you created in Section 2, as shown in Figure 3.8. Now your screen should
look like Figure 3.9. Note that result column BUKRS contains not a simple
value, but a call for another expression—in this case, a decision table. This
is a nested call.

Figure 3.7 Select Expression Available at Decision Table Cell Level

Figure 3.8 Object Query Screen to Select Expression

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 44


3 Advanced Mapping

Figure 3.9 Nested Call to Decision Table Implemented in Decision Table Result Column Cell

A nested expression has access to the same BRFplus context as the


expression calling it. This means that all fields and structures visible for
parent expression are visible also for the nested expression; you don’t
need to worry about passing them between expressions, though, because
the BRFplus workbench is doing that for you.
The only requirement that needs to be fulfilled is that the parent expres-
sion needs to contain context parameters that are needed by the nested
expression.
2. If you now go to function GET_E1FIKPF and click the Check button, you’ll
see an error like the one in Figure 3.10. This is because you created deci-
sion table DT_GET_BUKRS as a top expression for function GET_BUKRS. The
context in this function contains only the XREF1_HD field. In function GET_
E1FIKPF, the context is of type structure. It also contains the XREF1_HD
field, but as a part of the structure; for BRFplus, those are two different
objects. That means calling decision table DT_GET_BUKRS from the GET_
E1FIKPF function level will not provide decision table DT_GET_BUKRS with
sufficient context.
To be able to fix it, you need to adjust both the GET_BUKRS function and
decision table DT_GET_BUKRS to start using the INB_E1FIKPF-XREF1_HD con-
text parameter instead of XREF1_HD as a single separate element. Thanks
to those adjustments, the same context will be shared among all objects,
allowing nested calls to be executed.

Figure 3.10 Missing Context in Function

Personal Copy for Fernando Andres, facgal@hotmail.com 45


3 Advanced Mapping

3. To change XREF1_HD in the GET_BUKRS function context to INB_E1FIKPF-


XREF1_HD shared with the GET_E1FIKPF function, go to the GET_BUKRS func-
tion and click the Add Existing Data Object button. Search for “XREF1_
HD” and choose the result under INB_E1FIKF, as shown in Figure 3.11. That
is how reusability works in BRFplus: objects created under an applica-
tion are visible to all objects in that application. Because you created
INB_E1FIKPF for the GET_E1FIKPF function, it’s now available for other
functions and expressions. Remove the other XREF1_HD and save the
function.

Figure 3.11 XREF1_HD from INB_E1FIKPF Structure

4. You’ve changed the context in function GET_BUKRS; now you need to


change decision table DT_GET_BUKRS to start using it. Go to decision table
DT_GET_BUKRS. Open the table settings and insert new column from the
context data object. There will be only one XREF1_HD available now, the
new one: the old one is no longer in the context. Remove the old XREF1_
HD column and populate the new one with values as shown in Figure 3.12:
– =AB01
– =AC01
– [_C0*] exclude =RC02
Now activate objects DT_GET_BUKRS, GET_BUKRS, and GET_E1FIKPF.

Figure 3.12 DT_GET_BUKRS Decision Table after Column Change

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 46


3 Advanced Mapping

5. Go to the GET_E1FIKPF function and enter the simulation workbench.


Populate values and test how the function behaves. In the processing
steps, you should see a nested call, as in Figure 3.13.

Figure 3.13 Nested Call Visible in Test Workbench

3.2 Reusability of Decision Tables with Function Call


Expressions
In the previous section, you learned that decision tables can be used from
other decision tables via nested calls. You also learned that it might be diffi-
cult to reuse those tables due to context issues that might appear. Adjusting
all calling expressions and functions to use the same context is not only
challenging but also, in some cases, not feasible at all.

In this section, you’ll learn how to use function call expressions to enable
reusability of decision tables on a higher level. Function call expressions are
basically a context mapping tool. They allow you to call other BRFplus func-
tions as though they were expressions, providing context mapping. Thanks
to that, you can build a generic function with a decision table in it that will
be an interface to your decision table and call this interface with different
function calls depending on the context available.

Personal Copy for Fernando Andres, facgal@hotmail.com 47


3 Advanced Mapping

In this example, you’ll build another structure mapping example with the
E1FISEG structure from IDoc FIDCC2. You’ll use this again in the next sec-
tion. The key point here will be that you will create a single decision table
that will be used differently depending on input parameters. You can imag-
ine two source systems sending data into two different fields, and they need
to be mapped to the same field on the receiving side. In the following exam-
ple, you need to map inbound data to the general ledger account number.
One source system will provide input for mapping to the SGTXT field and
second one to the ZUONR field, but they will use same decision table to pro-
vide the general ledger account number.

Create a New Function with the Required Context


The function needed for this exercise will contain two structures in the con-
text and result data object structured types. To create it, proceed as follows:

1. Create new function GET_E1FISEG (as in Section 2.1, Create BRFplus Func-
tion) as shown in Figure 3.14 with the following data:
– Type: Function
– Name: GET_E1FISEG
– Short Text: Get E1FISEG segment
– Text: GET E1FISEG segment
– Application: FIDCC2_MAPPING

Figure 3.14 GET_E1FISEG Function

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 48


3 Advanced Mapping

2. Add existing data object INB_E1FIKPF by clicking Add Existing Data Object.
Then add new data object INB_E1FISEG by clicking on Add New Data
Object,with the following data (as shown in Figure 3.15):
– Type: Structure
– Name: INB_E1FISEG
– Text: FI Document Item (BSEG)
– Application: FIDCC2_MAPPING
– Binding Type: Bind to Structure Type (DDIC)
– DDIC Type Name: E1FISEG

Figure 3.15 New Data Object INB_E1FISEG

3. After you populate the context with two structures, one handling header
and the other the lines of finance document, you need to add a result data
object with the following data, as shown in Figure 3.16:
– Type: Structure
– Name: OUT_E1FISEG

Personal Copy for Fernando Andres, facgal@hotmail.com 49


3 Advanced Mapping

– Text: FI Document Item (BSEG)


– Application: FIDCC2_MAPPING
– Binding Type: Bind to Structure Type (DDIC)
– DDIC Type Name: E1FISEG

Figure 3.16 Result Data Object OUT_E1FISEG

Prepare Ruleset
This time, you’ll set up a function in event mode because you’ll need a rule-
set to achieve the expected mapping result. In more complex scenarios like
this one, the top expression is not enough; you need more flexibility and
processing capabilities to achieve your goal. In such situations, rulesets
come into play. Let’s walk through how to set them up and leverage their
capabilities to extend what is possible in BRFplus:

1. Go to the Assigned Rulesets tab of the function and click the Create Ruleset
button (Figure 3.17). Populate the pop-up window with the following val-
ues (Figure 3.18):

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 50


3 Advanced Mapping

– Type: Ruleset
– Name: RULESET_GET_E1FISEG
– Short Text: Ruleset Get E1FISEG
– Text: Ruleset Get E1FISEG IDoc Segment
– Application: FIDCC2_MAPPING

Figure 3.17 Assigned Ruleset tab on Function in Event Mode

Figure 3.18 New Ruleset Details

A ruleset isn’t only an envelope for the rules that are processed one after
another; a ruleset has its own header and can extend context with its own
variables. To show the ruleset header, click the Show Ruleset Header but-
ton (Figure 3.19).

Personal Copy for Fernando Andres, facgal@hotmail.com 51


3 Advanced Mapping

Figure 3.19 Show Ruleset Header Button

2. In later steps, you will create a decision table that will have a condition
column based on the INB_E1FISEG-KOART field and a result build of all
fields from the OUT_E1FISEG structure, because of that, the decision table
check will let you know that you have condition and result columns with
the same name. To avoid this issue, add a ruleset header variable named
LOCAL_KOART that will store the INB_E1FISEG-KOART value and will be used
as a condition column, bypassing the duplicate name issue. Click Create
(Figure 3.20), then populate the Create Object pop-up with the following
values, as shown in Figure 3.21:
– Type: Element
– Name: LOCAL_KOART
– Short Text: Account Type
– Text: Account Type
– Application: FIDCC2_MAPPING
– Binding Type: Bind to DD
– DDIC Element: KOART
– DDIC Description: Account Type
– Element Type: Text

Figure 3.20 Create New


Ruleset Header Variable

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 52


3 Advanced Mapping

Figure 3.21 New Object LOCAL_KOART Bind to DDIC Element KOART

3. You’ve now created a ruleset header variable. To be able to populate it,


you need to use another ruleset feature: Expressions which initialize the
variables. These are expressions called before any rule is called to initial-
ize ruleset header variables, which is exactly what you need now. Click the
circular icon next to the <Not Assigned> text, below the Expressions which
Initialize the Variables text, then choose Create, as shown in Figure 3.22. In
the Expression Creation pop-up window, choose expression Type from
dropdown menu to be Formula Expression, as shown in Figure 3.23. Popu-
late the following Formula Expression details:
– Type: Formula
– Name: FORM_KOART_TO_LOCAL_KOART
– Short Text: Formula move KOART
– Text: Formula move KOART to LOCAL_KOART

Personal Copy for Fernando Andres, facgal@hotmail.com 53


3 Advanced Mapping

– Application: FIDCC2_MAPPING
– Is Reusable: Check

Figure 3.22 Cerate Expressions which Initialize Variables

Figure 3.23 New Formula Expression

4. Formulas are very useful expressions that allow all sorts of variable pro-
cessing, like arithmetical calculations, text operations, system value
retrieval, and more. You’ll use formula expressions in this example for
value passing. Populate a formula as shown in Figure 3.24 to pass a value
from the inbound context KOART to LOCAL_KOART in the ruleset header.

Figure 3.24 Formula to Pass Inbound KOART to LOCAL_KOART

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 54


3 Advanced Mapping

Rules
You’ve already created a ruleset and learned that it’s an envelope used to
structure rules, but rulesets cannot work on their own: they need to contain
rules to be able to execute required business logic. Your next step is to cre-
ate a rule. Rules are the most basic logic handlers in BRFplus. One ruleset
can contain many rules and calls them in sequence. Rules call expressions
as processing blocks. Create a rule by clicking the Insert Rule dropdown
below Rule section in the ruleset window you’re currently in (see Figure 3.25)
and choosing Create.

Figure 3.25 Create New Rule

Note
Rules, unlike other objects in BRFplus, do not open pop-up windows when you
create them.

To be able to execute planned logic, you need to create a new expression to


be processed within the rule. Click the Add dropdown to the right of the
Then label and choose Process Expression 폷 Create to create a new expression
(Figure 3.26). The new expression will be a decision table with the following
parameters, presented in Figure 3.27:

쐍 Type: Decision Table

쐍 Name: DT_GET_E1FISEG

쐍 Short Text: DT GET E1FISEG seg

쐍 Text: Decision Table Get E1FISEG IDoc segment

쐍 Application: FIDCC2_MAPPING

쐍 Is Reusable: Check

Personal Copy for Fernando Andres, facgal@hotmail.com 55


3 Advanced Mapping

쐍 Result Name: OUT_E1FISEG

쐍 Text: FI Document Item (BSEG)

The result is a whole structure, like in the example in the Decision Table
with Structure as a Result section.

Figure 3.26 Create New Expression to Be Processed by Rule

Figure 3.27 New Decision Table DT_GET_E1FISEG

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 56


3 Advanced Mapping

Main Decision Table Basic Setup


Now a few more steps need to be taken with your new decision table before
it can be used:

1. Hide and unmark as mandatory all the result columns except BUZEI,
BSCHL, KOART, WRBTR, SGTXT, HKONT, MENGE, and MEINS. Then add two
condition columns. One should be INB_E1FIKPF 폷 XREF2_HD and the other
LOCAL_KOART.
2. Populate the values as shown in Figure 3.28. The XREF2_HD value for the
first row should be as shown in Figure 3.29. And the other two should con-
tain values SOURCE_SYSTEM_001 and SOURCE_SYSTEM_002.

Figure 3.28 Decision Table with Initially Populated Values

Figure 3.29 Values for First Cell in First Row

Prepare New Function with Common Decision Table


After the basis for the structure mapping is set up, you need to prepare a
new function with a decision table that will be reused by this structure map-
ping:

Personal Copy for Fernando Andres, facgal@hotmail.com 57


3 Advanced Mapping

1. Create a new function named GET_HKONT (for detailed steps, see Section 2.1,
Create BRFplus Function).
2. Add a new data object named INPUT as a twenty-character long text with-
out binding.
3. Also add a result data object named HKONT and bind HKONT to the DDIC ele-
ment (for detailed steps, see Section 2.1, Create BRFplus Function). The
result should look as shown in Figure 3.30 and include the following data:
– Mode: Functional Mode
– Top Expression: DT_GET_HKONT
– Component Name: INPUT
– Text: Input for Account
– Data Object: HKONT

Figure 3.30 New Function GET_HKONT

4. As you may notice in Figure 3.30, there’s also a top expression DT_GET_
HKONT and its Mode is set to Functional Mode. Set it the same way and cre-
ate a top expression as a decision table (for detailed steps, see Section 2.1,
Create Decision Table) named DT_GET_HKONT with the following parame-
ters as shown in Figure 3.31:

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 58


3 Advanced Mapping

– Settings: Return Exception for partial match


– Result Data Object: HKONT
– Overlap Check Settings: Show Messages as Error
– Completeness Check Settings: Application Default

Figure 3.31 New Decision Table DT_GET_HKONT

5. Populate the table with values as shown in Figure 3.32 and go back to deci-
sion table DT_GET_E1FISEG. In the INPUT column, you have source values
that are delivered from the source system. In the HKONT field, you need to
populate account numbers that you can find in your system and that can
be used for posting.

Personal Copy for Fernando Andres, facgal@hotmail.com 59


3 Advanced Mapping

Figure 3.32 DT_GET_HKONT with Populated Values

6. Click the second row in column HKONT and choose Create Expression (Fig-
ure 3.33). Notice that you are not creating an expression for the whole col-
umn, but only for one cell. Then choose Function Call for the Type and
populate the function call expression details as shown in Figure 3.34.

Figure 3.33 Create New Expression for HKONT in Second Row

Figure 3.34 Function Call Expression GET_HKONT_SRC_001

7. In this function, you need to select OUT_E1FISEG 폷 HKONT as a Result Data


Object and point to GET_HKONT as a Target Function; this is the Function
that will be called by this expression. Map INB_E1FISEG 폷 SGTXT to INPUT—
that changes the context parameter of the current function, which is

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 60


3 Advanced Mapping

INB_E1FISEG 폷 SGTXT, to the context parameter of the target function,


which is INPUT. The result should look like Figure 3.35. What’s happening
here is that you will call the GET_HKONT function from the HKONT cell in the
second row of decision table DT_GET_E1FISEG. Their contexts do not need
to match like in the example in Section 3.1, Nested Call to Another Deci-
sion Table, because the function call expression is providing a mapping
between the context of the GET_E1FISEG and GET_HKONT functions.

Figure 3.35 GET_KHONT_SRC_001 Function Call with Populated Values

8. Repeat the same steps for the HKONT cell in the third row of DT_GET_
E1FISEG, but this time name the new function call GET_HKONT_SRC_002 and
map INB_E1FISEG 폷 ZUONR to INPUT. The result should look like Figure 3.36.
Go to the GET_E1FISEG function, activate all new objects, and simulate to
see how it’s using the function call expression to reuse the same decision
table for different inputs.

Figure 3.36 GET_KHONT_SRC_002 Function Call with Populated Values

In the preceding sets of steps, you’ve learned how to build complex struc-
ture mapping and also how to reuse decision tables with function call

Personal Copy for Fernando Andres, facgal@hotmail.com 61


3 Advanced Mapping

expressions, which allows context mapping and thanks to that allows


sourcing the same decision tables from different fields, dependent on need.
That approach is useful in building mapping templates for solutions that
receive inbound messages with different formats but sharing the same
master data. One decision table handling value mapping can be called via a
function call from many different objects, even separately from ABAP code.

3.3 Nested Call of a Table with Multiple Result Columns


You may encounter in some situations a requirement to nest calls to deci-
sion tables with more than one result column. That means the decision
table that you need to use returns several values from one matched row. In
the following example, the source system provides a material number,
which is used in the receiving system to populate both the short text (SGTXT)
and unit of measure (MEINS) fields. Such a situation can occur when it is
much easier for business users to maintain mappings for some objects to-
gether rather than separately because they’re working under same business
logic. In such a situation, you can’t just simply call such a decision table
from another decision table because the expected result of a call is of type
element, not structure. In this section, you’ll learn how to address this prob-
lem using the function call expressions introduced in the previous section.

The SGTXT Column


To achieve the business goal of having one table with two result columns,
you need to start from one of those columns perspective. Each column will
require its own function, despite sharing the same decision table expres-
sion. You can start with SGTXT column.

Create Function
Let’s start by creating a new function

1. Create a new function with the following info, as shown in Figure 3.37 (for
detailed steps, see Section 2.1, Create BRFplus Function):

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 62


3 Advanced Mapping

– Type: Function
– Name: GET_SGTXT_FROM_MATNR
– Short Text: Get Text from Mat
– Text: Get Short Text from Material
– Application: FIDCC2_MAPPING

Figure 3.37 New Function to Fetch SGTXT Value Based on MATNR Value

2. Populate the Signature tab as shown in Figure 3.38 (for detailed steps, see
Section 2.1, Create BRFplus Function). MATNR should be added using the
Add Existing Data Object button; use the existing INB_E1FISEG 폷 MATNR ele-
ment.

Figure 3.38 Populated Signature of New Function

Personal Copy for Fernando Andres, facgal@hotmail.com 63


3 Advanced Mapping

SGTXT_OUT should be created with the Add New Data Object button with
binding to the SGTXT DDIC object, as shown in Figure 3.39:
– Type: Element
– Name: SGTXT_OUT
– Short Text: Result Short Text
– Text: Result Short Text
– Application: FIDCC2_MAPPING
– Binding Type: Bind to DD
– DDIC Element: SGTXT
– DDIC Description: Text
– Element Type: Text

Figure 3.39 New SGTXT_OUT Object Details

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 64


3 Advanced Mapping

Create Ruleset
The next step is to create a ruleset for your new function, using the follow-
ing details, as shown in Figure 3.40 (for detailed steps, see Section 3.2, Pre-
pare Ruleset):

쐍 Type: Ruleset

쐍 Name: RULESET_GET_SGTXT

쐍 Short Text: Ruleset Get SGTXT

쐍 Text: Ruleset GET Short Text

쐍 Application: FIDCC2_MAPPING

Figure 3.40 New Ruleset for Getting SGTXT

In the ruleset, go to header and create a structure variable (for detailed


steps, see Section 3.2, Prepare Ruleset) with the following details, as shown
in Figure 3.41:

쐍 Name: SGTXT_MEINS_STRUCTURE

쐍 Short Text: SGTXT and MEINS Stru

쐍 Text: Short Text and Unit of Measure Structure

쐍 Application: FIDCC2_MAPPING

쐍 Binding Type: No Binding

Personal Copy for Fernando Andres, facgal@hotmail.com 65


3 Advanced Mapping

Figure 3.41 New Structure Variable for Ruleset

Create only two fields from existing data objects INB_E1FISEG-MEINS and
INB_E1FISEG-SGTXT. The result should look like Figure 3.42, so you should
see the two fields you have just added, MEINS and SGTXT. Activate and close
the structure.

Figure 3.42 Fields of New Structure

Decision Table Expression


After the variable is created, it’s time to create the expression that will fill it in.
That will be a decision table with the following details, shown in Figure 3.43,

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 66


3 Advanced Mapping

and table settings like those shown in Figure 3.44 (for detailed steps, see Sec-
tion 2.1, Create Decision Table and Prepare Ruleset):

쐍 Type: Decision Table

쐍 Name: DT_GET_SGTXT_MEINS

쐍 Short Text: DT Get Text and Unit

쐍 Text: Decision Table Get Short Text and Unit of Measure

쐍 Application: FIDCC2_MAPPING

쐍 Is Reusable: Check

Figure 3.43 New Decision Table with Two Result Columns

Populate the decision table with values like those shown in Figure 3.45.

In the MATNR column, you can provide some material numbers from your
system or some random values; these values will not be used during the
posting. Texts provided in the SGTXT column are free texts; you can enter
any values that will help you in the exercise. The MEINS column should be
filled in with some existing unit of measure values.

Personal Copy for Fernando Andres, facgal@hotmail.com 67


3 Advanced Mapping

Figure 3.44 Table Settings of New Decision Table

Figure 3.45 Decision Table with Two Result Columns Populated with Values

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 68


3 Advanced Mapping

Finally, pass SGTXT from the variable to the SGTXT_OUT result of the func-
tion. You can do this simply by adding a rule to the ruleset, as shown in Fig-
ure 3.46. This function is completed.

Figure 3.46 Complete Ruleset with Filled in Header and Rule

The MEINS Column


You prepared one part of solution, which is fetching the value of SGTXT
based on the MATNR value. As you saw in previous steps, the decision table
created has two columns. Now you’ll fetch values from the MEINS col-
umn.

Create Function
First, you need to create a function:

1. Create a function like that shown in Figure 3.47 (for detailed steps, see Sec-
tion 2.1, Create BRFplus Function):

Personal Copy for Fernando Andres, facgal@hotmail.com 69


3 Advanced Mapping

– Type: Function
– Name: GET_MEINS_FROM_MATNR
– Short Text: Get UoM from Mat
– Text: Get Unit of Measure from Material
– Application: FIDCC2_MAPPING

Figure 3.47 New Function to Fetch MEINS Value Based on MATNR Value

2. Create a result data object with the following details (as shown in Figure
3.48):
– Type: Element
– Name: MEINS_OUT
– Short Text: Result UoM
– Text: Result Unit of Measure
– Application: FIDCC2_MAPPING
– Binding Type: No Binding
– Element Type: Text

The context should be same as in the previous function (for detailed steps,
see Section 2.1, Create BRFplus Function), so only the MATNR field should be
there. Set the function to event mode.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 70


3 Advanced Mapping

Figure 3.48 New Object MEINS_OUT Details

Create Ruleset
Create a ruleset called RULESET_GET_MEINS and a ruleset header just like in
the The SGTXT Column section. To do so, use the existing SGTXT_MEINS_
STRUCTURE as a Variable and decision table DT_GET_SGTXT_MEINS as Expression
which Initializes the Variables. The only change will be in the rule, which
should be as shown in Figure 3.49. Instead of changing the SGTXT_OUT ele-
ment, you will change MEINS_OUT, which is a result data object of the GET_
MEINS_FROM_MATNR function.

Personal Copy for Fernando Andres, facgal@hotmail.com 71


3 Advanced Mapping

Figure 3.49 Complete Ruleset with Filled in Header and Rule

Expression
Once you’ve created two new functions, create a function call expression
for each one. Name them GET_SGTXT_FROM_MATNR and GET_MEINS_FROM_MATNR.
Their details should match those shown in Figure 3.50 and Figure 3.51. They
should be pointing to GET_SGTXT_FROM_MATNR and GET_MEINS_FROM_MATNR as
Target Function. They should both map source MATNR field to target MATNR
field. Result Data Objects should be set to OUT_E1FISEG-SGTXT and OUT_
E1FISEG-MEINS.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 72


3 Advanced Mapping

Figure 3.50 Function Call for GET_SGTXT_FROM_MATNR Function

Figure 3.51 Function Call for GET_MEINS_FROM_MATNR Function

To use the function call expressions you just created, go to decision table
DT_GET_E1FISEG and populate columns SGTXT and MEINS with calls to their
corresponding function call expressions. The result should look like Figure
3.52. Activate all objects and go to the simulation to see them in action.

Figure 3.52 Decision Table DT_GET_E1FISEG Populated with New Function Calls

Personal Copy for Fernando Andres, facgal@hotmail.com 73


4 Integration with SAP Application Interface Framework

4 Integration with SAP Application Interface


Framework
In the last two sections, you learned how to use various BRFplus techniques
to fulfill all kinds of business and technical demands. In this section, you’ll
see how they can be integrated in an easy way with SAP Application Inter-
face Framework. You’ll use BRFplus functions you created in previous sec-
tions to see how easy it can be to move BRFplus logic placed in enhance-
ments or exits into SAP Application Interface Framework.

As stated in the introduction, as a prerequisite to follow along in this sec-


tion, you need to have a working SAP Application Interface Framework
interface for IDoc FIDCC2 in place.

4.1 BRFplus Call in Value Mapping


In this section, you’ll learn how to apply a BRFplus function to SAP Applica-
tion Interface Framework value mapping. You’ll reuse the GET_BUKRS func-
tion you created earlier because it represents a single-value mapping that
we can apply to SAP Application Interface Framework value mapping. To be
able to do so, you need to create a BRFplus wrapper around it to match SAP
Application Interface Framework requirements. You already know that best
wrappers are function call expressions.

To get this set up, follow these steps:

1. Go to SAP Application Interface Framework configuration via Transac-


tion /AIF/CUST and open the structure mapping for the IDoc FIDCC2–
related interface.
2. Open source structure E1FIKPF from the list on the right and select Define
Field Mappings from the menu on the left.
3. Click the Create button and create a field mapping for field BUKRS with
Field Name 1 set to XREF1_HD, as shown in Figure 4.1.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 74


4 Integration with SAP Application Interface Framework

Figure 4.1 Field Mapping from XREF1_HD to BUKRS

4. Create a new value mapping, which you can name XREF1_HD_TO_BUKRS as


shown in Figure 4.2. Note that you should use a namespace appropriate for
your system; BRF is the only value valid for this demo system. If there is no
value mapping with the name you provided, you will be asked if you would
like to create one. Saying yes will create a new value mapping for you.

Figure 4.2 New Value Mapping

5. Scroll down to the bottom of the value mapping, click BRFplus Function
Name, and press (F1). You’ll see what’s required from the BRFplus func-
tions for them to work with SAP Application Interface Framework. Your
BRFplus function GET_BUKRS doesn’t fulfill those conditions because its
context is not aligning with what’s described in the help info. Notice that
there is no information related to processing itself, so the only thing
that’s mandatory is the matching context.
6. As you learned in previous sections, the best BRFplus tool to adjust your
function’s context to the current needs is the function call expression,
but you need to also create a function that has the correct context and
can be called from SAP Application Interface Framework. Go to the BRF-
plus workbench and create a new function named GET_BUKRS_AIF (for
detailed steps, see Section 2.1, Create BRFplus Function). Its signature
should only consist of VALUE1 bound to DDIC element XREF1_HD, and the
result object can be named as you wish; there is no SAP Application

Personal Copy for Fernando Andres, facgal@hotmail.com 75


4 Integration with SAP Application Interface Framework

Interface Framework prerequisite for this (for detailed steps, see Section
2.1, Create BRFplus Function). Next, create a top expression GET_BUKRS_
AIF of type call function (for detailed steps, see Section 2.1, Create Deci-
sion Table). Your result should look like Figure 4.3. You should have one
context parameter named VALUE1, a result data object created, and top
expression GET_BUKRS_AIF.

Figure 4.3 New Function with Context Prepared to Be Called from SAP AIF

7. Now you can go to the call function expression and set up Result Data
Object as BUKRS_OUT, Target Function as GET_BUKRS, and map VALUE1 to
XREF1_HD (for detailed steps, see Section 3.2, Prepare Ruleset). The result
should look like Figure 4.4.

Figure 4.4 Call Function Expression Calling Original GET_BUKRS Function

8. Activate all newly created BRFplus objects and go back to SAP Application
Interface Framework value mapping.
9. The only thing left is to place your BRFplus application and function in
SAP Application Interface Framework value mapping as shown in Figure
4.5. You need to populate BRFplus Application Name and BRFplus Function
Name with values corresponding to the BRFplus application you’re using
and the newly created function, then save the configuration.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 76


4 Integration with SAP Application Interface Framework

Figure 4.5 BRFplus Function Called from SAP Application Interface Framework Value
Mapping

10. You can send in FIDCC2 IDoc that you have in your system by going to
Transaction WE19, providing the existing IDoc number and clicking the
Standard Inbound button to send in IDoc. You can also test the new GET_
BUKRS_AIF function using BRFplus simulations (for detailed steps, see
Section 2.1, Simulate Decision Table) or the SAP Application Interface
Framework Interface Test Tool (Transaction /AIF/IFTEST).

4.2 BRFplus Call in Structure Mapping


In this section, you’ll use SAP Application Interface Framework structure
mapping, a more complex and flexible way of handling mappings. It focuses
not only on the value of a single field; it can provide value mapping for any
field in the structure, along with structure changes between source and des-
tination. Like in the previous section, you’ll be reusing the previously cre-
ated structure mapping GET_E1FISEG, so a real structure change won’t be in
play, but remember that this is also an option when the source and destina-
tion structures in the SAP Application Interface Framework interface are dif-
ferent.

Follow these steps to enable GET_E1FISEG for SAP Application Interface


Framework:

1. Go to the SAP Application Interface Framework configuration via Transac-


tion /AIF/CUST and open structure mapping for the IDoc FIDCC2–related
interface.

Personal Copy for Fernando Andres, facgal@hotmail.com 77


4 Integration with SAP Application Interface Framework

2. Then open source structure E1FISEG and go to the field mappings.


3. Notice in Figure 4.6 that there are two BRFplus-related fields. Similarly to
the value mapping, you’ll see Application Name and Function Name. Click
on BRFplus Function Name label and press (F1), and a help pop-up will
appear. Similarly to value mapping, there is a specific requirement for the
structures to be used. Of course, names to be used are standard SAP Appli-
cation Interface Framework names for raw and destination structures.
There’s no need to use all of them; you need to use only the ones that are
needed for your mapping. Output can be named freely; its name is not
passed outside BRFplus.

Figure 4.6 BRFplus-Related Fields in SAP Application Interface Framework Structure


Mapping

BRFplus Adjustments
You need to create a new function GET_E1FISEG_AIF that will be called as an
SAP Application Interface Framework structure-mapping BRFplus function.
This time, you can’t simply apply a function call expression on the previ-
ously created function because structure types created by SAP Application
Interface Framework and BRFplus are of different types. Fortunately, there
is a way to achieve your goal of reusing existing BRFplus functions in SAP
Application Interface Framework:

1. The new function needs to be in event mode. In the Signature tab, you
need to only use RAW_LINE (bind to the type of the E1FISEG line in your
IDoc SAP Application Interface Framework structure) and RAW_STRUCT

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 78


4 Integration with SAP Application Interface Framework

(bind to the raw message structure in your SAP Application Interface


Framework IDoc interface).
2. Name the result data object RESULT_AIF; it shouldn’t have any binding.
This object should be of the structure type. The structure should contain
only one component, named DEST_LINE, which should be bound to the
E1FISEG DDIC element. It should look like Figure 4.7.

Figure 4.7 New Function in Event Mode with AIF Compatible Signature

3. Because your function is in event mode, you need to create a ruleset for it.
Go to the Assigned Rulesets tab and create a ruleset. Name it RULESET_GET_
E1FISEG_AIF.
4. You need to match the context of the functions GET_E1FISEG and GET_
E1FISEG_AIF. GET_E1FISEG_AIF function has its signature defined already.
You also know what structure types are used by GET_E1FISEG because
you’ve created it yourself in previous exercises, so add these to the con-
text of the ruleset to be able to move values from one to another. To do so,
you need to add three variables in the ruleset header, which already exist
in the context of the application:
– INB_E1FIKPF
– INB_E1FISEG
– OUT_E1FISEG

Personal Copy for Fernando Andres, facgal@hotmail.com 79


4 Integration with SAP Application Interface Framework

Notice that these are signature components of the GET_E1FISEG function


and its result object. Variables in the ruleset header should look as shown
in Figure 4.8. You don’t need to use any expressions that would initialize
those variables; that will be done in a later phase of the ruleset process-
ing, as we’ll describe later.

Figure 4.8 Ruleset RULESET_GET_E1FISEG_AIF Header Variables

5. To populate INB_E1FIKPF and INB_E1FISEG, created as variables in the pre-


vious step, with values from the GET_E1FISEG_AIF function context, cre-
ate a new rule (for detailed steps, see Section 3.2, Rules). Inside the rule
under the Then section, use Assign Value to Context to choose INB_
E1FIKPF (to do so, you need to use search functionality), as shown in Fig-
ure 4.9. The result should look like Figure 4.10: you should see word
Change and the INB_E1FIKPF variable next to it.

Figure 4.9 Assign Value to Context

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 80


4 Integration with SAP Application Interface Framework

Figure 4.10 Populate from Value Using Context

6. In Figure 4.10, you can see that the destination context value is already
assigned to this rule step. You need to choose, as shown in Figure 4.10, the
context value that will be the source for the INB_E1FIKPF change. It should
be RAW_STRUCT-E1FIKPF. The result is shown in Figure 4.11, which shows
that INB_E1FIKPF will be changed with values from RAW_STRUCT-E1FIKPF.

Figure 4.11 One Context Value Populated from Another

Note
Note that in terms of the BRFplus name context value, is used in reference to
single values, structures, and tables—so, all BRFplus types.

7. Repeat the previous step to move values from RAW_LINE to INB_E1FISEG.

Now it’s time to provide values for OUT_E1FISEG. For this example, you’ll
want to do this using existing function GET_E1FISEG via function call
expression, so you need to choose Expression Processing from the available
options to create a new expression as shown in Figure 4.12.

Personal Copy for Fernando Andres, facgal@hotmail.com 81


4 Integration with SAP Application Interface Framework

Figure 4.12 Create New Expression in Rule

1. In the pop-up window, choose Function Call from Expression dropdown


menu and name it GET_E1FISEG_AIF. Do not choose Result Data Object
(this will be handled in the next step); click Create, not Create and Navi-
gate to Object. The result should look like Figure 4.13: GET_E1FISEG_AIF
should be already assigned for processing, but there should be no desti-
nation object that should be changed. By doing it this way, you have bet-
ter control over assigning the destination object, and you can force BRF-
plus to stay on the rule screen, rather than moving to the GET_E1FISEG_
AIF expression.

Figure 4.13 Processing of Function Call Assigned to Rule

2. Click the small circular button next to No Available Context and choose
OUT_E1FISEG from context. The result should look like Figure 4.14: OUT_
E1FISEG should be assigned as the object to be changed.

Figure 4.14 Change OUT_E1FISEG by Processing via GET_E1FISEG Function Call

3. Now click the GET_E1FISEG_AIF function call and populate its details as
shown in Figure 4.15: the target function should be set to GET_E1FISEG
and the result data object to OUT_E1FISEG. Mapping should be applied
from INB_E1FIKPF to INB_E1FIKPF and from INB_E1FISEG to INB_E1FISEG.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 82


4 Integration with SAP Application Interface Framework

Figure 4.15 GET_E1FISEG_AIF Function Call

4. The last step that needs to be performed in BRFplus is to move OUT_


E1FISEG, which you get from processing the GET_E1FISEG function, to
RESULT_AIF 폷 DEST_LINE. You should do it same way as you’ve done for
other variables to achieve a result like that shown in Figure 4.16.

Figure 4.16 Final Movement of Data

5. Activate all created objects and go back to SAP Applicaton Interface Frame-
work structure mapping.
6. Populate the BRFplus config as shown in Figure 4.17. You need to populate
BRFplus Application Name and BRFplus Function Name with values corre-
sponding to the BRFplus application you’re using and the newly created
function, then save the configuration.

Figure 4.17 BRFplus Call on Structure Mapping

Personal Copy for Fernando Andres, facgal@hotmail.com 83


4 Integration with SAP Application Interface Framework

7. You can test inbound processing of IDoc FIDCC2 that you have in your
system by going to Transaction WE19, providing existing IDoc number,
and clicking the Standard Inbound button to send IDoc. You can also test
this using the SAP Application Interface Framework Interface Test Tool
(Transaction /AIF/IFTEST).

4.3 BRFplus Call in Check


The last possible usage of BRFplus in an SAP Application Interface Framework
configuration is to apply a function on a check. This is like other applications,
with one small difference. Remember that the result data object name wasn’t
bound by any prerequisites for value and structure mappings? This is differ-
ent for a check. The check result must be named ERROR and be of type Boolean.

Proceed with the following steps:

1. Go to BRFplus and create a new function named CHECK_XREF1_HD (for


detailed steps, see Section 2.1, Create BRFplus Function).
2. The signature of this table should contain only one object, named VALUE1.
You can use the existing one you created in Section 4.1; we’ll use the same
name and same binding to XREF1_HD. The result data object should be of
type Boolean with no binding. The function should be set up in event
mode. The whole function should look like that shown in Figure 4.18 (for
detailed steps, see Section 2.1, Create BRFplus Function).

Figure 4.18 New Function with SAP Application Interface Framework Check Compatibility

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 84


4 Integration with SAP Application Interface Framework

3. Because you’re in event mode, you need to create a ruleset. Name it CHECK_
XREF1_HD (for detailed steps, see Section 3.2, Prepare Ruleset).
4. Create a rule as shown in Figure 4.19. It will check that XREF1_HD is not
equal to 0000, is not empty, and contains only four characters. Activate
all objects and go to SAP Application Interface Framework customizing
for structure mapping.

Figure 4.19 Complete Rule for XREF1_HD Check

5. Open the E1FIKPF structure and go to the checks options by double-click-


ing Assign Checks in the menu on the left. Create a new check by clicking
the New Entries button. Populate the check details as shown in Figure 4.20.

Figure 4.20 New Check in Structure Mapping

Personal Copy for Fernando Andres, facgal@hotmail.com 85


4 Integration with SAP Application Interface Framework

6. If there is no check with the provided name, you’ll be asked if it should be


created; say yes. Navigate to the created check, and then define a single
check by clicking the New Entries button. Populate it as shown in Figure
4.21. Now a BRFplus check will be called for the E1FIKPF structure to vali-
date XREF1_HD.
7. You can send in IDocs with different values and see how the check be-
haves.

Figure 4.21 BRFplus Call from SAP Application Interface Framework Check

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 86


5 Error Handling with SAP Application Interface Framework

5 Error Handling with SAP Application Interface


Framework
In the previous section, you familiarized yourself with BRFplus and SAP
Application Interface Framework integration. You now know that BRFplus
functions can be used to perform value and structure mappings. In this sec-
tion, you’ll learn how BRFplus exceptions are passed to SAP Application
Interface Framework and what you can do to enhance this process to maxi-
mize usage of SAP Application Interface Framework’s error handling and
monitoring capabilities.

First, we’ll look at the standard behavior of possible usages of BRFplus in SAP
Application Interface Framework under unexpected exception conditions.
Second, you’ll learn where those standard procedures can be enhanced to
provide better feedback on errors to SAP Application Interface Framework
users. Finally, you’ll take full control of the error handling in BRFplus, switch-
ing off exception rising and providing SAP Application Interface Framework
with full issue info in a controlled and organized manner, moving the SAP
Application Interface Framework user experience and BRFplus integration
to another level.

5.1 Standard SAP Application Interface Framework


Behavior for BRFplus Exceptions
In this section, you’ll trigger exceptions in value and structure mappings.
You’ll observe how SAP Application Interface Framework is reacting and
search for places where it needs to be extended.

First, as for other exercises, make sure you have IDoc FIDCC2 and that it can
be posted through SAP Application Interface Framework in your system.
You will manipulate this IDoc via Transaction WE19 to generate errors in
SAP Application Interface Framework processing.

Personal Copy for Fernando Andres, facgal@hotmail.com 87


5 Error Handling with SAP Application Interface Framework

Value Mapping
The first test that you will conduct is to verify the behavior of value map-
ping XREF1_HD_TO_BUKRS, which is calling BRFplus function GET_BUKRS_AIF.
You know that it’s deriving a company code based on the XREF1_HD field. In
order to generate an exception in decision table DT_GET_BUKRS, used as a
centerpiece of value mapping, you need to pass a value into XREF1_HD that
isn’t present in a condition column (values there should be as shown in Fig-
ure 5.1). For this example, use value AABB.

Figure 5.1 Values in DT_GET_BUKRS

Now, proceed as follows:

1. Go to Transaction WE19 and open one of existing IDocs from previous


exercises.
2. Change the XREF1_HD field value in the IDoc structure and click the Stan-
dard Inbound button to send the IDoc.
3. Go to SAP Application Interface Framework monitoring, Transaction /AIF/
ERR, to check the results. Open the transaction in a new session; do not
close Transaction WE19, which you’ll need in the next exercise. The
results should look like Figure 5.2. In this case, the information is partially
informative. You see which BRFplus function failed, and you can navigate
from the error to the field that caused the error by double-clicking the
error. You don’t know why the function failed, but if it’s a simple value
mapping you can assume that the issue is probably caused by the deci-
sion table called in this BRFplus function. The behavior of the standard
solution is enough, and with the help of hints and functions, you should

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 88


5 Error Handling with SAP Application Interface Framework

be able to provide SAP Application Interface Framework users with


enough info about how to handle this issue.

Figure 5.2 AIF Error Caused by BRFplus Exception in Value Mapping

Structure Mapping
Now you’ll verify how SAP Application Interface Framework is behaving
when an exception occurs on the structure mapping level. The first test will
be to change the XREF1_HD field back to the AB01 value and replace the cur-
rent value in the XREF2_HD field with SOURCE_SYSTEM_003. Because the only
values expected by decision table DT_GET_E1FISEG are SOURCE_SYSTEM_001
and SOURCE_SYSTEM_002, passing other values will cause an exception when
none of the rows in DT_GET_E1FISEG match such a condition (current condi-
tions are shown in Figure 5.3). Let’s trigger such an error:

1. Switch back to Transaction WE19, which you opened in the previous steps.
2. Change the XREF1_HD field value in the IDoc structure back to AB01.
Change the XREF2_HD value to SOURCE_SYSTEM_003. Click the Standard
Inbound button to send the IDoc.
3. Go to SAP Application Interface Framework monitoring, Transaction /AIF/
ERR, to check the results. There should be an error like that shown in Fig-
ure 5.4. You can see that this error is not really what you would expect.
This is a standard message arriving from standard IDoc processing, saying
that you have not specified an account, but you’d expect to see an error
from BRFplus showing that decision table processing failed. You know
that an exception triggered in BRFplus on the structure mapping level
doesn’t cause an error in SAP Application Interface Framework structure
mapping, and processing continued to the SAP Application Interface
Framework action. For a better look at what happened, you can switch
SAP Application Interface Framework to technical mode by clicking the

Personal Copy for Fernando Andres, facgal@hotmail.com 89


5 Error Handling with SAP Application Interface Framework

Technical Mode button in Transaction /AIF/ERR and transform the mes-


sage using the Transform button. You will notice that in the result, the
E1FISEG segments are not transformed and contain original data, as
shown in Figure 5.5. It seems that SAP Application Interface Framework is
ignoring structures with exceptions.

Figure 5.3 Current Conditions in Decision Table DT_GET_EFISEG

Figure 5.4 Error Displayed after Exception in BRFplus on Structure Mapping

Figure 5.5 E1FISEG with Lines Not Transformed

4. To double-check this behavior, change XREF2_HD back to SOURCE_SYSTEM_


001 and after that change SGTXT field on the second IDoc E1FISEG line to
BCC001002. By doing that you expect to trigger an exception only on this
line in decision table DT_GET_HKONT. Click the Standard Inbound button to
send the IDoc, then go to SAP Application Interface Framework monitor-
ing, Transaction /AIF/ERR. There should still be same error as you saw in
Figure 5.4, but if you run the transform, you will see different results, as

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 90


5 Error Handling with SAP Application Interface Framework

shown in Figure 5.6. This behavior is not very helpful in informing SAP
Application Interface Framework users about the errors and assisting
them in issue solving, so that might be an area in which you’d like to
make some improvements. In the next two sections, you’ll have the
opportunity to try to mitigate this issue and possibly improve the pro-
cessing to the standard expected by SAP Application Interface Framework
users.

Figure 5.6 E1FISEG with Only One (Second) Line Not Transformed

5.2 Catching BRFplus Exceptions in SAP Application


Interface Framework Function Module
In the previous section, you learned that in some cases SAP Application
Interface Framework’s standard functionality for handling complex BRF-
plus exceptions in structure mapping isn’t enough. It’s natural that not all
cases and possibilities are covered by the standard solution; that’s why you
can enhance your processing with custom code. In SAP Application Inter-
face Framework, this is realized by implementing mapping function mod-
ules. In this scenario, you will replace the direct usage of a BRFplus function
on the E1FISEG segment with use of a function module after mapping,
which will call the same BRFplus function in the ABAP code. That will allow
you to catch exceptions and handle them in ABAP so that they can be dis-
played as proper errors in SAP Application Interface Framework and stop an
SAP Application Interface Framework action from being executed.

To start, you’ll need to create a new function module aligned with the
SAP Application Interface Framework requirements for an interface. As
suggested by the SAP Application Interface Framework help, simply copy

Personal Copy for Fernando Andres, facgal@hotmail.com 91


5 Error Handling with SAP Application Interface Framework

template function module /AIF/FILE_TEMPL_MAP, via Transaction SE37.


You can use the name ZFIDCC2_E1FISEG_AIF_MAP.

When the function module is copied, go to SAP Application Interface


Framework Customizing (Transaction /AIF/CUST) and open your interface.
Select the E1FISEG segment from the list and apply your function module as
a function module after mapping (enter its name in the Function Module
after Mapping field) on the E1FISEG segment and remove the BRFplus
entries from there. (They were placed there in previous exercises for struc-
ture mapping.) The result should look like Figure 5.7.

Figure 5.7 BRFplus Direct Call Replaced by Function Module

Populate the Function Module


Now you’ll populate the content of this function module to implement a
BRFplus call in it and apply your custom error handling routines. Follow
these steps:

1. Go to the BRFplus workbench and open function GET_E1FISEG_AIF.


2. Generate a function module from that BRFplus function. You can name it
ZFIDCC2_GET_E1FISEG_AIF (for step-by-step instruction, see Section 2.1,
Implement Function Call).
3. Now you need to adjust its interface a bit. Change the Import parameters
to SAP Application Interface Framework corresponding types, as shown
in Figure 5.8.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 92


5 Error Handling with SAP Application Interface Framework

Figure 5.8 Import Parameters with SAP Application Interface Framework–Related Types

Add a Tables parameter as in Figure 5.9. Those interface changes will allow
you to easily call this function module from the SAP Application Inter-
face Framework function module ZFIDCC2_E1FISEG_AIF_MAP you created
by copying the template SAP Application Interface Framework function
module. Switch to ZFIDCC2_E1FISEG_AIF_MAP now.

Figure 5.9 Tables with AIF Return Tab

4. Populate ZFIDCC2_E1FISEG_AIF_MAP with the code in Listing 5.1, changing


the automatically generated types to types that were generated in your
system. For example, change zfdt_13u9pxr91095s2xhgldv9e4fs to a type
generated for you by BRFplus in your system. Note that this code is
already prepared to pass possible errors from BRFplus processing to the
SAP Application Interface Framework return table.
DATA: lr_raw_str TYPE REF TO zfidccp02_fidcc2,
lr_raw_lin TYPE REF TO zbrf_00001045,
lr_dest_line TYPE REF TO zbrf_00001045,
ls_result TYPE zfdt_13u9pxr91095s2xhgldv9e4fs,
lt_return_tab TYPE STANDARD TABLE OF bapiret2.

GET REFERENCE OF raw_struct INTO lr_raw_str.


GET REFERENCE OF raw_line INTO lr_raw_lin.
GET REFERENCE OF dest_line INTO lr_dest_line.

Personal Copy for Fernando Andres, facgal@hotmail.com 93


5 Error Handling with SAP Application Interface Framework

CALL FUNCTION 'ZFIDCC2_GET_E1FISEG_AIF'


EXPORTING
raw_struct = lr_raw_str->*
raw_line = lr_raw_lin->*
IMPORTING
e_result_aif = ls_result
TABLES
return_tab = lt_return_tab.

IF lt_return_tab[] IS INITIAL.
lr_dest_line->* = CORRESPONDING #(
BASE ( lr_dest_line->* ) ls_result-dest_line ).
ELSE.
APPEND LINES OF lt_return_tab TO return_tab.
ENDIF.
Listing 5.1 Call of BRFplus-Generated Function Module from SAP Application Interface
Framework after Mapping Function Module

5. After you’ve populated the main function module with the code from
Listing 5.1, go to the ZFIDCC2_GET_E1FISEG_AIF function module gener-
ated by BRFplus to adjust exception handling there. Find the line of code
like the one in Listing 5.2.
CATCH cx_fdt_processing.
Listing 5.2 Catch for Standard Processing Exception in BRFplus

6. Change the code to match that in Listing 5.3. Remove the message trigger-
ing by removing all code in the Catch segment.
CATCH cx_fdt_processing INTO DATA(lr_exc).
Listing 5.3 Catch with Assignment to Class

7. Place the code from Listing 5.4 in the Catch segment from which you
removed code in the previous step.
return_tab[] = VALUE bapiret2_tab( FOR message
IN zcl_BRFplus_exception=>get_messages( exception = lr_exc )
( COND bapiret2(

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 94


5 Error Handling with SAP Application Interface Framework

WHEN message-msgno = |138|


AND message-msgv1 = |DT_GET_E1FISEG|
THEN
VALUE bapiret2(
id = |ZBRF|
number = |001|
type = |E|
message_v1 = raw_line-buzei )
WHEN message-msgno = |138|
AND message-msgv1 = |DT_GET_HKONT|
AND raw_struct-e1fikpf-xref2_hd = |SOURCE_SYSTEM_001|
THEN
VALUE bapiret2(
id = |ZBRF|
number = |002|
type = |E| message_v1 = raw_line-sgtxt
parameter = |E1FIKPF-E1FISEG|
row = CONV int4( raw_line-buzei )
field = |SGTXT| )
WHEN message-msgno = |138|
AND message-msgv1 = |DT_GET_HKONT|
AND raw_struct-e1fikpf-xref2_hd = |SOURCE_SYSTEM_002|
THEN
VALUE bapiret2(
id = |ZBRF|
number = |002|
type = |E|
message_v1 = raw_line-zuonr
parameter = |E1FIKPF-E1FISEG|
row = CONV int4( raw_line-buzei )
field = |ZUONR| )
ELSE
VALUE bapiret2(
id = message-msgid
number = message-msgno
type = message-msgty
message_v1 = message-msgv1
message_v2 = message-msgv2

Personal Copy for Fernando Andres, facgal@hotmail.com 95


5 Error Handling with SAP Application Interface Framework

message_v3 = message-msgv3
message_v4 = message-msgv4 ) ) ) ).
Listing 5.4 Example of Processing Exception from BRFplus

Helper Class for Fetching Errors from BRFplus


Now you need to create a few missing pieces that will help catch exceptions
from BRFplus processing and transform them into SAP Application Inter-
face Framework error messages:

1. First, create the ZCL_BRFPLUS_EXCEPTION class and inside static method GET_
MESSAGES. The signature should be set as shown in Figure 5.10: the inbound
parameter name EXCEPTION is referring to the BRFplus exception class, and
the returning parameter MESSAGES is of a type corresponding to the mes-
sage table. Insert ABAP code from Listing 5.5, as GET_MESSAGES method
source code.

Figure 5.10 Signature of GET_MESSAGES Method

METHOD get_messages.
IF exception->previous IS NOT INITIAL.
messages = get_messages( exception =
CAST cx_fdt_processing( exception->previous ) ).
ELSE.
messages = exception->mt_message.
ENDIF.
ENDMETHOD.
Listing 5.5 ABAP Code for GET_MEESSAGES Method

The GET_MESSAGES method in Listing 5.5 allows you to fetch BRFplus


exception messages from nested previous exceptions.
2. You also need to create two messages in class ZBRF, as shown in Figure 5.11.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 96


5 Error Handling with SAP Application Interface Framework

Figure 5.11 Two New Messages for Exception Handling

3. Now you have everything in place. Go to Transaction WE19 and run the
two example IDocs from the Structure Mapping section first should
result in exceptions on all lines and the second one should have excep-
tion on the second line. The results of these runs should look like Figure
5.12 and Figure 5.13. You will see line numbers and table names that cause
the errors and the information that an account cannot be determined
based on the input provided, along with the value of this input.

Figure 5.12 Result of All Failing Lines with Descriptive Errors

Figure 5.13 Failure Only on Second Line with Account Determination

Thanks to your enhancements, you’re providing SAP Application Interface


Framework with meaningful text about the real errors that occur in BRFplus
processing. Because of that, the SAP Application Interface Framework action
isn’t executed and doesn’t populate the log with unnecessary information.
You can implement handling for all BRFplus decision tables and other
expressions in a similar manner. This exercise only showed two examples,
but it can be extended to all BRFplus expressions used in mapping.

Personal Copy for Fernando Andres, facgal@hotmail.com 97


5 Error Handling with SAP Application Interface Framework

What’s more, because you populated BAPIRET2 with PARAMETER, FIELD, and
ROW values, you enabled forward navigation to work when double-clicking
on an error, which will now take you to the field that caused the error.
Thanks to that, SAP Application Interface Framework users will not see the
difference between exceptions generated from BRFplus and those triggered
by SAP Application Interface Framework value mappings, guaranteeing the
same user experience in both cases.

5.3 Passing Errors from BRFplus to SAP Application


Interface Framework without Raising Exceptions
In previous sections, you experimented with BRFplus exceptions, checking
how they impact SAP Application Interface Framework processing and try-
ing to improve their handling to increase the level of information about
the errors provided to SAP Application Interface Framework users. All the
actions were based on the content delivered in BRFplus standard exceptions,
and it’s very important to provide the best possible processing for them.

In this section, you’ll learn that there is a different option that you can use
to change the BRFplus decision table processing behavior, so that instead of
raising exceptions, it will provide meaningful error messages that can be
propagated to SAP Application Interface Framework.

You know from the previous section that raising an exception if no match is
found in the table is a configurable option, so if you switch that behavior
off, you can stop the decision table from raising exceptions if there is no
row with matching conditions for the given input. Stopping exceptions is
one thing, but another is that you want to still have as informative error
information as you’d have with exceptions because that info is needed by
SAP Application Interface Framework users operating on the interface. Fol-
low these steps to meet these needs:

1. You need to open the class created in the Section 5.2, Helper Class for
Fetching Errors from BRFplus for BRFplus exception handling and add the
attribute BAPIRET2_TAB with the level Static Attribute, set visibility as

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 98


5 Error Handling with SAP Application Interface Framework

Private, and the associated type as BAPIRET2_TAB. This will serve as the
container for all BRFplus error messages you’ll add through BRFplus pro-
cessing and is fully compatible with the SAP Application Interface Frame-
work return table.
2. Next, create three new simple static and public methods:
– SET_BAPIRET2
Only one importing parameter named IM_BAPIRET2 with associated
type BAPIRET2 and code as in Listing 5.6
– GET_BAPIRET2_TAB
Only a returning parameter named RE_BAPIRET2_TAB with associated
type BAPIRET2_TAB and code as in Listing 5.7
– CLR_BAPIRET2_TAB
No parameters, with code as in Listing 5.8
METHOD set_bapiret2.
APPEND im_bapiret2 TO bapiret2_tab.
ENDMETHOD.
Listing 5.6 SET_BAPIRET2 Code

METHOD get_bapiret2_tab.
re_bapiret2_tab = bapiret2_tab.
ENDMETHOD.
Listing 5.7 GET_BAPIRET2_TAB Code

METHOD clr_bapiret2_tab.
CLEAR bapiret2_tab.
ENDMETHOD.
Listing 5.8 CLR_BAPIRET2_TAB Code

3. Add a new message to class ZBRF with the number 3 and text MATNR &1
value has no match in Table DT_GET_SGTXT_MEINS.

Once you’ve prepared the methods that will allow you to store, retrieve, and
clear errors, open BRFplus and go to decision table DT_GET_SGTXT_MEINS.

Personal Copy for Fernando Andres, facgal@hotmail.com 99


5 Error Handling with SAP Application Interface Framework

You need to change a few things in the settings to prevent errors being
raised:

1. Open the table settings by clicking the Table Settings button.


2. Deselect Return Exception for Partial Match and select the checkbox for
Return Initial Value if No Match Is Found, as shown in Figure 5.14.

Figure 5.14 Change Settings for DT_GET_SGTXT_MEINS

3. Add an action column by clicking the Insert Action Column button (see
Figure 5.15). You also need to deselect the Mandatory Input column check-
boxes for SGTXT and MEINS. The setup should look like Figure 5.15. The
action column will be added to the table and will provide you with the
ability to call the static method you created earlier. It will be used if no
match is found, so you’ll be unable to provide SGTXT and MEINS, which why
you need to mark them as not mandatory.

Figure 5.15 Changed Result Columns with Added Action Column

4. The next step is to add a new line in the decision table (for detailed steps,
see Section 2.1, Populate Decision Table with Data). This new line should
be the last one, with all condition columns and result columns empty.
The only cell populated there should be Action. Because it will be the last
line and the decision table is set to return the first match found, you know
that if the last line is checked, it means no match was found.

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 100


5 Error Handling with SAP Application Interface Framework

5. To create an action, click the icon in the Action cell and select Create. Pop-
ulate the pop-up window as shown in Figure 5.16: enter the name of the
action and a corresponding text description, then choose Call Procedure
for the Type because this action will call a static class method. Create the
action and navigate to it. Notice that the message type, class, and number
are provided in the name because it will be a BRFplus action that will pro-
vide SAP Application Interface Framework with this message. That should
help make the usage of this action clear.

Figure 5.16 New Action to Store Error Messages

6. Choose the class created for BRFplus exception handling and method
SET_BAPIRET2. Then, under Mapped Parameters, click the Add Parameter
button and choose IM_BAPIRET2, as shown in Figure 5.17.
7. Map the method fields as follows:
– TYPE: Enter value E
– ID: Enter value ZBRF
– NUMBER: Enter value 003
– MESSAGE_V1: Select Context Parameter MATNR
– PARAMETER: Enter value E1FIKPF-E1FISEG
– FIELD: Enter value MATNR

Personal Copy for Fernando Andres, facgal@hotmail.com 101


5 Error Handling with SAP Application Interface Framework

Figure 5.17 Action Calling Static Method

8. You cannot provide a value for ROW at this point because the row number
isn’t passed to this BRFplus function, but the function is called on the
line level, so you can set ROW after returning to ABAP from BRFplus.
9. BRFplus is now ready to store error messages in the static attribute of the
class. You need to add code to the ZFIDCC2_GET_E1FISEG_AIF function
module to be able to retrieve errors stored during BRFplus processing. In
the last line, add the code in Listing 5.9.
LOOP AT zcl_BRFplus_exception=>get_bapiret2_tab( )
REFERENCE INTO DATA(lr_line).
lr_line->row = CONV int4( raw_line-buzei ).
APPEND lr_line->* TO return_tab.
ENDLOOP.
zcl_BRFplus_exception=>clr_bapiret2_tab( ).
Listing 5.9 Code to Retrieve Errors Stored by BRFplus in SAP Application Interface
Framework

10. Now you can go to Transaction WE19 and run the IDoc with the MATNR val-
ues changed—for example, to W0001 and W0003. The results should be
like those shown in Figure 5.18. Note that this method was able to retrieve
an error twice for each line. Because an exception wasn’t triggered, BRF-
plus processing continued and was able to call the decision table for both
fields it’s used for. This approach is useful if you have many decision table

© 2022 by Rheinwerk Publishing Inc., Boston (MA) 102


6 What’s Next?

calls on one line and you want to present all existing errors to SAP Appli-
cation Interface Framework users after one run of the interface.

Figure 5.18 Four Errors for All Four Decision Table Calls

6 What’s Next?
So far, you’ve learned how to use BRFplus as a mapping engine, how to use
decision tables for mapping with advanced rules, and how to integrate SAP
AIF for value mapping, structure mapping, and more. Yet, your BRFplus
journey doesn’t stop there.

Recommendation from Our Editors


BRFplus—Business Rule Management for ABAP Appli-
cations introduces BRFplus in all its aspects, including
the tool’s architecture and how its rules are struc-
tured. You will learn how to modify and develop rules,
how to incorporate them into your own landscape,
and how to extend BRFplus. Including extensive exam-
ples and tutorials, this book is a one-stop resource for
developers as well as business analysts.

Visit www.sap-press.com/2106 and check out BRFplus—Business Rule Manage-


ment for ABAP Applications by Thomas Albrecht and Carsten Ziegler!

In addition to this book, our editors picked a few other SAP PRESS publica-
tions that you might also be interested in. Check out the next page to learn
more!

Personal Copy for Fernando Andres, facgal@hotmail.com 103


More from SAP PRESS
SAP Cloud Platform Integration
This guide provides everything you need to create
and configure SAP Cloud Platform Integration flows.
Explore predefined integration content, debug and
secure integration projects, enable B2B integration,
develop custom adapters, and more.
791 pages, 2nd edition, pub. 08/2018
E-book: $79.99 | Print: $89.95 | Bundle: $99.99
www.sap-press.com/4650

SAP Gateway and OData


Use SAP Gateway and OData to connect your SAP and
non-SAP systems. Walk through SAP Gateway instal-
lation and configuration; then develop and generate
OData services using step-by-step instructions. Learn
how OData is consumed during app development:
SAPUI5, mobile, and social media applications.
841 pages, 3rd edition, pub. 12/2018
E-book: $79.99 | Print: $89.95 | Bundle: $99.99
www.sap-press.com/4724

SAP API Management


Manage the end-to-end API lifecycle with this guide to
SAP Cloud Platform API Management. Walk through
key processes that optimize your APIs: traffic man-
agement, mediation, security, and monetization. Put
APIs into action with expert guidance on building
applications, running analytics, and more.
365 pages, pub. 12/2019
E-book: $69.99 | Print: $79.95 | Bundle: $89.99
www.sap-press.com/4928

© 2022 by Rheinwerk Publishing Inc., Boston (MA)


1

Usage, Service, and Legal Notes

Notes on Usage
This E-Bite is protected by copyright. By purchasing this E-Bite, you have
agreed to accept and adhere to the copyrights. You are entitled to use this
E-Bite for personal purposes. You may print and copy it, too, but also only
for personal use. Sharing an electronic or printed copy with others, how-
ever, is not permitted, neither as a whole nor in parts. Of course, making
them available on the Internet or in a company network is illegal.

For detailed and legally binding usage conditions, please refer to the section
Legal Notes.

Service Pages
The following sections contain notes on how you can contact us.

Praise and Criticism


We hope that you enjoyed reading this E-Bite. If it met your expectations,
please do recommend it. If you think there is room for improvement,
please get in touch with the editor of the E-Bite: Will Jobst (willj@rheinwerk-
publishing.com).

We welcome every suggestion for improvement but, of course, also any


praise! You can also share your reading experience via Twitter, Facebook, or
email.

Personal Copy for Fernando Andres, facgal@hotmail.com


Technical Issues
If you experience technical issues with your e-book or e-book account at SAP
PRESS, please feel free to contact our reader service: support@rheinwerk-
publishing.com.

About Us and Our Program


The website http://www.sap-press.com provides detailed and first-hand
information on our current publishing program. Here, you can also easily
order all of our books and e-books. Information on Rheinwerk Publishing
Inc. and additional contact options can also be found at http://www.sap-
press.com.

Legal Notes
This section contains the detailed and legally binding usage conditions for
this E-Bite.

Copyright Note
This publication is protected by copyright in its entirety. All usage and
exploitation rights are reserved by the author and Rheinwerk Publishing; in
particular the right of reproduction and the right of distribution, be it in
printed or electronic form.

© 2020 by Rheinwerk Publishing, Inc., Boston (MA)

Your Rights as a User


You are entitled to use this E-Bite for personal purposes only. In particular,
you may print the E-Bite for personal use or copy it as long as you store this
copy on a device that is solely and personally used by yourself. You are not
entitled to any other usage or exploitation.

© 2022 by Rheinwerk Publishing Inc., Boston (MA)


In particular, it is not permitted to forward electronic or printed copies to
third parties. Furthermore, it is not permitted to distribute the E-Bite on the
Internet, in intranets, or in any other way or make it available to third par-
ties. Any public exhibition, other publication, or any reproduction of the
E-Bite beyond personal use are expressly prohibited. The aforementioned
does not only apply to the E-Bite in its entirety but also to parts thereof (e.g.,
charts, pictures, tables, sections of text). Copyright notes, brands, and other
legal reservations as well as the digital watermark may not be removed
from the E-Bite.

Digital Watermark
This E-Bite copy contains a digital watermark, a signature that indicates
which person may use this copy. If you, dear reader, are not this person,
you are violating the copyright. So please refrain from using this E-Bite
and inform us about this violation. A brief email to info@rheinwerk-
publishing.com is sufficient. Thank you!

Limitation of Liability
Regardless of the care that has been taken in creating texts, figures, and pro-
grams, neither the publisher nor the author, editor, or translator assume
any legal responsibility or any liability for possible errors and their conse-
quences.
1

Personal Copy for Fernando Andres, facgal@hotmail.com


Imprint

This E-Bite is a publication many contributed to, specifically:

Editor Will Jobst


Acquisitions Editor Hareem Shafi
Copyeditor Melinda Rankin
Cover Design Graham Geary
Icon made by Kiranshastry from www.flaticon.com
Layout Design Graham Geary
Production Graham Geary
Typesetting III-Satz, Husby (Germany)

ISBN 978-1-4932-1906-3
© 2020 by Rheinwerk Publishing, Inc., Boston (MA)
1st edition 2020

All rights reserved. Neither this publication nor any part of it may SAP, the SAP logo, ABAP, Ariba, ASAP, Concur, Concur ExpenseIt,
be copied or reproduced in any form or by any means or translated Concur TripIt, Duet, SAP Adaptive Server Enterprise, SAP Advan-
into another language, without the prior consent of Rheinwerk tage Database Server, SAP Afaria, SAP ArchiveLink, SAP Ariba, SAP
Publishing, 2 Heritage Drive, Suite 305, Quincy, MA 02171. Business ByDesign, SAP Business Explorer, SAP BusinessObjects,
SAP BusinessObjects Explorer, SAP BusinessObjects Lumira, SAP
Rheinwerk Publishing makes no warranties or representations BusinessObjects Roambi, SAP BusinessObjects Web Intelligence,
with respect to the content hereof and specifically disclaims any SAP Business One, SAP Business Workflow, SAP Crystal Reports,
implied warranties of merchantability or fitness for any particular SAP EarlyWatch, SAP Exchange Media (SAP XM), SAP Fieldglass,
purpose. Rheinwerk Publishing assumes no responsibility for any SAP Fiori, SAP Global Trade Services (SAP GTS), SAP GoingLive, SAP
errors that may appear in this publication. HANA, SAP HANA Vora, SAP Hybris, SAP Jam, SAP MaxAttention,
SAP MaxDB, SAP NetWeaver, SAP PartnerEdge, SAPPHIRE NOW,
“Rheinwerk Publishing” and the Rheinwerk Publishing logo are
SAP PowerBuilder, SAP PowerDesigner, SAP R/2, SAP R/3, SAP
registered trademarks of Rheinwerk Verlag GmbH, Bonn, Ger-
Replication Server, SAP S/4HANA, SAP SQL Anywhere, SAP Strate-
many. SAP PRESS is an imprint of Rheinwerk Verlag GmbH and
gic Enterprise Management (SAP SEM), SAP SuccessFactors, The
Rheinwerk Publishing, Inc.
Best-Run Businesses Run SAP, TwoGo are registered or unregistered
trademarks of SAP SE, Walldorf, Germany.
All of the screenshots and graphics reproduced in this book are
subject to copyright © SAP SE, Dietmar-Hopp-Allee 16, 69190 Wall- All other products mentioned in this book are registered or unreg-
dorf, Germany. istered trademarks of their respective companies.

Personal Copy for Fernando Andres, facgal@hotmail.com

You might also like