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 use MAP function in SQL script

In a previous post, "How to Use Window Functions in SQL Script", we introduced the window function that allows you to generate partitions within the SELECT command.

In this article, we will introduce MAP function, another handy function that allows you to map simple mapping rules. This function searches for an expression within a set of search values and returns the corresponding result. It is comparable to IF/ELSE or CASE statements in ABAP.

Syntax

The syntax of the MAP function looks like this:

MAP (<expression>, <search>, <result> [{, <search>, <result>}...] [, default_result])

You can define any number of search and result pairs. If the searched value is not found and a default result has been defined, the function outputs the predefined result. If no default result has been defined, the function outputs "NULL". Search values and corresponding results are output in pairs.

Examples

Let's consider a simple example for clarification. With the following code, we search for the values 0, 1, 2, and 3 in expression 3. If the value 0 is found, “Zero” is returned. If the value 1 is found, “One” is output. And so on.

SELECT MAP(3, 0, 'Zero', 1, 'One', 2, 'Two', 3, 'Three', 'Default') "map" FROM DUMMY;

Since we have defined only one value, 3, in the expression, the 3 will also be found and "Three" will be output.

001-value-found_map function

Let's consider the next example. Now we are looking for the same values, but in expression 815.

SELECT MAP(815, 0, 'Zero', 1, 'One', 2, 'Two', 3, 'Three', 'Default') "map" FROM DUMMY;

Since none of the search terms were found, the predefined result, meaning "Default", is output.

002-value-not-found-default-value_map function

Now let's consider the code where no default value has been defined.

SELECT MAP(815, 0, 'Zero', 1, 'One', 2, 'Two', 3, 'Three') "map" FROM DUMMY;

Since no default value was specified, the initial value "NULL" is output.

003-initial-value-null_map function


Increase the performance of your BW with SQLScript!
Click here for the whitepaper!

Neuer Call-to-Action


In SAP context, you can use the Map function to assign categories to product master data on the fly:

SELECT "PRODUCT",

        MAP("PRODUCT",

        'SM', 'Smartphone',

        'SP', 'Smartphone',

        'TM', 'Tablet',

        'TP', 'Tablet') as Category

FROM "/BI0/MPRODUCT"

 

004-category_map function

Let's consider another example where the Map function is used to output the delivery status of an order.

SELECT

        "PO_NUMBER" AS "Purchase_Order",

        "ACT_DL_DTE" AS "Delivery_Date",

        MAP("ACT_DL_DTE",

        '00000000', 'open',

        current_date, 'delivered today',

        'delivered') AS "Delivery_status"

FROM "/BIC/AZD023R0017"

GROUP BY

        "PO_NUMBER","ACT_DL_DTE"

Please note that the delivery date # (not assigned) is stored internally in SAP as 000000. This means that undelivered orders have the date 00000000. These are assigned the status "open". All orders delivered on today's date are output with the delivery status "delivered today". The current date is determined by the SQL function current_date. The orders with all other delivery dates are marked as "delivered".

005-delivery-date_map function

MAP function - Our Summary

With the SQL MAP function, you have a useful tool in your toolbelt that allows you to implement simple mapping rules.

Do you have questions about SAP HANA SQLScript? Are you trying to build up the necessary know-how in your department or do you need support with a specific question? We are happy to help you. Request a non-binding consulting offer today!

Learn more about  SAP HANA SQLScript

,

avatar

Irvin

Irvin has worked with HANA Native and Datasphere since 2019. He can primarily draw on experience as a consultant and in development on the XSA platform using SQLScript. In his spare time, he is passionate about playing basketball and is also a big NBA fan.

Got a question about this blog?
Ask Irvin

Blog - NextLytics AG 

Welcome to our blog. In this section we regularly report on news and background information on topics such as SAP Business Intelligence (BI), SAP Dashboarding with Lumira Designer or SAP Analytics Cloud, Machine Learning with SAP BW, Data Science and Planning with SAP Business Planning and Consolidation (BPC), SAP Integrated Planning (IP) and SAC Planning and much more.

Subscribe to our newsletter

Related Posts

Recent Posts