Skip to content
NextLytics
Megamenü_2023_Über-uns

Shaping Business Intelligence

Whether clever add-on products for SAP BI, development of meaningful dashboards or implementation of AI-based applications - we shape the future of Business Intelligence together with you. 

Megamenü_2023_Über-uns_1

About us

As a partner with deep process know-how, knowledge of the latest SAP technologies as well as high social competence and many years of project experience, we shape the future of Business Intelligence in your company too.

Megamenü_2023_Methodik

Our Methodology

The mixture of classic waterfall model and agile methodology guarantees our projects a high level of efficiency and satisfaction on both sides. Learn more about our project approach.

Products
Megamenü_2023_NextTables

NextTables

Edit data in SAP BW out of the box: NextTables makes editing tables easier, faster and more intuitive, whether you use SAP BW on HANA, SAP S/4HANA or SAP BW 4/HANA.

Megamenü_2023_Connector

NextLytics Connectors

The increasing automation of processes requires the connectivity of IT systems. NextLytics Connectors allow you to connect your SAP ecosystem with various open-source technologies.

IT-Services
Megamenü_2023_Data-Science

Data Science & Engineering

Ready for the future? As a strong partner, we will support you in the design, implementation and optimization of your AI application.

Megamenü_2023_Planning

SAP Planning

We design new planning applications using SAP BPC Embedded, IP or SAC Planning which create added value for your company.

Megamenü_2023_Dashboarding

Dashboarding

We help you with our expertise to create meaningful dashboards based on Tableau, Power BI, SAP Analytics Cloud or SAP Lumira. 

Megamenü_2023_Data-Warehouse-1

SAP Data Warehouse

Are you planning a migration to SAP HANA? We show you the challenges and which advantages a migration provides.

Business Analytics
Megamenü_2023_Procurement

Procurement Analytics

Transparent and valid figures are important, especially in companies with a decentralized structure. SAP Procurement Analytics allows you to evaluate SAP ERP data in SAP BI.

Megamenü_2023_Reporting

SAP HR Reporting & Analytics

With our standard model for reporting from SAP HCM with SAP BW, you accelerate business activities and make data from various systems available centrally and validly.

Megamenü_2023_Dataquality

Data Quality Management

In times of Big Data and IoT, maintaining high data quality is of the utmost importance. With our Data Quality Management (DQM) solution, you always keep the overview.

Career
Megamenü_2023_Karriere-2b

Working at NextLytics

If you would like to work with pleasure and don't want to miss out on your professional and personal development, we are the right choice for you!

Megamenü_2023_Karriere-1

Senior

Time for a change? Take your next professional step and work with us to shape innovation and growth in an exciting business environment!

Megamenü_2023_Karriere-5

Junior

Enough of grey theory - time to get to know the colourful reality! Start your working life with us and enjoy your work with interesting projects.

Megamenü_2023_Karriere-4-1

Students

You don't just want to study theory, but also want to experience it in practice? Check out theory and practice with us and experience where the differences are made.

Megamenü_2023_Karriere-3

Jobs

You can find all open vacancies here. Look around and submit your application - we look forward to it! If there is no matching position, please send us your unsolicited application.

Blog
NextLytics Newsletter Teaser
Sign up now for our monthly newsletter!
Sign up for newsletter
 

How to implement an Import BAdI for NextTables

◀ Back to Knowledge Base

In the “How to auto-correct imported values with NextTables” article, I have shown a practical implementation of fuzzy search algorithm for import. Using the Import BAdI you can ensure that only the correct values are imported in the system. In this article, I will guide you step by step through the technical implementation of this BAdI.

In this example, data for company codes is imported. The file to be imported contains the descriptions of company codes instead of the technical key. In the BAdI, we differentiate two cases. If a company code with the respective description exists, the technical key of this company code is used.

How to implement an Import BADi for NexTables 1-1

If no company code with the imported description can be found, we utilize the fuzzy search algorithm in order to look for a similar description. As you might guess, someone most likely means NextLytics AG if he imports NextLytics AG.

gif DSO 2

Necessary steps

In order to achieve this result, we utilize /NLY/IF_IMPORT~SET_IMPORT_EXIT method of the /NLY/BADI_IMPORT BAdI. But first, we have to setup the filter accordingly.

Filter

In the How to implement a BAdI for NextTables article you have learned how to create a BAdI implementation. To make sure that the BAdI is executed for a certain table only, you have to setup the filter criteria accordingly. Please enter respective table name and table type. Furthermore, you have to specify the field for which the BAdI should be executed. In our example we use the DSO ZDREXMPL. The field for company code is /BIC/ZDRCCODE.

How to implement an Import BADi for NexTables 3-1

Implementation

After the filter setup, we have to implement the logic in the implementing class. In order to check and adjust imported values, we use the method /NLY/IF_IMPORT~SET_IMPORT_EXIT. Please double click on the method to create an implementation.

How to implement an Import BADi for NexTables 4-2

You can use the following code for the implementation.

METHOD /nly/if_import~set_import_exit.

TYPES:
BEGIN OF ts_changes,
score TYPE decfloat34,
ccode TYPE /b787/oibukrs,
txtmd TYPE rstxtmd,
END OF ts_changes,
tt_changes TYPE TABLE OF ts_changes.

DATA: ls_validation TYPE /nly/ts_validation,
lv_sql TYPE string,
lo_t_table TYPE REF TO data,
lv_search_term TYPE string,
lv_ccode TYPE /b787/oibukrs.

FIELD-SYMBOLS:
<fs_s_table> TYPE ts_changes,
<fs_t_table> TYPE tt_changes.

IF i_step = 1.

* Search term
lv_search_term = i_value.


REPLACE ALL OCCURRENCES OF '%20' IN lv_search_term WITH ` `.
REPLACE ALL OCCURRENCES OF '%22' IN lv_search_term WITH `"`.
* check if exists
SELECT SINGLE /b787/s_bukrs FROM /b787/tbukrs
INTO lv_ccode
WHERE txtmd = lv_search_term.

IF lv_ccode IS NOT INITIAL.
e_value = lv_ccode.
* Notify the user
ls_validation = VALUE #( rowidx = i_tabix
column = is_fields_info-fname
hdr = 'Value was successfully assigned.'
msg = |Company code { e_value } corresponds to the description { i_value }.|
type = /nly/cl_table_rest_v3=>co_msg_type_warning
) .
APPEND ls_validation TO ct_validation.
ELSE. "lv_ccode IS INITIAL
* If nothing found, fuzzy search
CREATE DATA lo_t_table TYPE tt_changes.
ASSIGN lo_t_table->* TO <fs_t_table>.

lv_sql = |SELECT TOP 300 DISTINCT SCORE() AS SCORE, "/B787/S_BUKRS", TXTMD |
&& |FROM "/B787/TBUKRS" | " Text Table
&& |WHERE CONTAINS(("/B787/S_BUKRS", "TXTMD" ), '{ lv_search_term }', FUZZY(0.7, 'similarCalculationMode=compare')|
&& | , weight (0.8, 1 )) |
&& |ORDER BY score() desc|.

TRY.
" Prepare SQL connection and statement
DATA(lo_result) =
cl_sql_connection=>get_connection(
)->create_statement(
)->execute_query( lv_sql ).

lo_result->set_param_table( REF #( <fs_t_table> ) ).

" Get result
lo_result->next_package( ).
lo_result->close( ).
CATCH cx_sql_exception INTO DATA(err).

" Error handling
DATA l_error(200) TYPE c.
l_error = |{ err->get_text( ) }|.

RAISE EXCEPTION TYPE /nly/cx_table_rest
EXPORTING
textid = /nly/cx_table_rest=>custom_message
msgv1 = l_error(50)
msgv2 = l_error+50(50)
msgv3 = l_error+100(50)
msgv4 = l_error+150(50).

ENDTRY.


READ TABLE <fs_t_table> ASSIGNING <fs_s_table> INDEX 1.
* Assign value
e_value = <fs_s_table>-ccode.
* Notify the user
ls_validation = VALUE #( rowidx = i_tabix
column = is_fields_info-fname
hdr = 'Value was adjusted'
msg = |Company code { i_value } does not exist. Company code { e_value } with description { <fs_s_table>-txtmd } was determined with a score { ROUND( val = <fs_s_table>-score dec = 2 mode = 2 ) } and therefore adopted as a value.|
type = /nly/cl_table_rest_v3=>co_msg_type_warning
) .
APPEND ls_validation TO ct_validation.
ENDIF. "lv_ccode IS NOT INITIAL

ENDIF. "IF I_STEP = 1.
ENDMETHOD.

 

In this code we check the text table of company code InfoObject for the description. If an entry with the respective description exist, we use the corresponding key as company code value. Afterwards, we notify the user about the changes.

If nothing was found, we prepare and execute a SQL query against the text table using fuzzy search algorithm. The result with the highest score is used as key for company code. After the company code was determined, we notify the user about the changes made by the BAdI.

Activate your changes

As you implement your custom logic, please make sure that all involved pieces are activated, not only the implementing class. You need to activate the following objects:

  • Implementing class together with methods
  • BAdI implementation
  • Enhancement implementation

Which License is needed for this feature Professional | Enterprise


Do you have a question regarding NextTables? Already a customer? Please click here for Support.