This is a test message to test the length of the message box.
Login
|
Tools My IDE Actions
Created by Software-Heroes

ADT - MIA Select Converter

1605

For MIA, there is now a new action in the ABAP Development Tools that allows you to convert your old Open SQL statements to ABAP SQL and ABAP Cloud.

Advertising


In this article, we'll look at an update to the Select Converter and discuss the new integration in MIA and how it was implemented.

 

Introduction

IDE Actions have been available on the ABAP Environment since release 2502, and we already provided the first action with MIA in an older article. With IDE Actions, you can extend the ABAP Development Tools at specific points and thus make ABAP-based extensions. This allows you to automate certain functions, replace code, or extract information.

 

ABAP Select Converter 

A while ago, we introduced the ABAP Select Converter together with the CDS Extractor. The focus was primarily on converting SELECT statements into the new world, away from traditional tables and toward Core Data Services. The extractor provides the foundation via Git and shows what the mapping looks like at the field level. The converter takes the SELECT statement and breaks it down into its components in order to then replace tables and fields.

 

The converter has now received an overhaul and now completely breaks down the statement in order to generate it as ABAP SQL in the new syntax. This not only replaces the table, but also modernizes the statement.

 

Hint: Since this is a complex action, errors or inaccuracies may still occur.

 

Action

You can now find the new IDE action in the MIA open source project, where the action is documented and can be installed together with the other actions.

 

Structure

This is a fairly simple IDE action that we have implemented here. We define a class for the action and that it can only be executed in a class.

 

To do this, we read the current code of the object in the action and determine the position of the selection or cursor. You can find further information in the documentation below.

DATA(resource) = CAST if_adt_context_src_based_obj( context->get_focused_resource( ) ).
DATA(sources) = resource->get_source_code( ).
DATA(position) = resource->get_position( ).

 

In the next step, we need to extract the entire SELECT statement from the source code. To do this, we use a small function that searches for the beginning and end and compresses the select statement onto one line.

DATA(extraction) = zcl_mia_strings=>extract_statement( statement = `SELECT`
                                                       sources   = sources
                                                       start     = position->pos-start ).

 

If the determination worked, we pass the SELECT to the API, which calls the Select Converter endpoint to convert the statement. We then receive the result back in our response structure.

DATA(conversion) = zcl_mia_core_factory=>create_swh_tools( )->convert_select_statement(
    request = VALUE #( statement  = extraction-statement
                       abap_cloud = abap_true ) ).

 

Finally, we pass the new statement to a Source-Change-Result, which then offers us the appropriate dialog so that you, as the developer, can check the result.

DATA(change_result) = cl_aia_result_factory=>create_source_change_result( ).
change_result->add_code_replacement_delta( content            = conversion-data-new_statement
                                           selection_position = position ).
result = change_result.

 

Execution

How do you now execute the actual action? To do this, you must select the SELECT statement you want to replace in your source code. Then start the IDE action with the keyboard shortcut CTRL + ALT + R and select the IDE action "Migrate SELECT Statement".

 

Finally, the source code comparison will be displayed, and you can decide whether you want to accept the changes. In principle, the action also works in deactivated or activatable source code. This allows you to convert a SELECT that comes from on-premise and that you have only copied into the ABAP environment.

 

GitHub

You can find the open source project on GitHub and use it freely. If you find any errors or have suggestions for improvements, simply open an issue on GitHub.

 

Conclusion

If all the building blocks are in place, integrating it as an IDE action is very easy to implement. Using the SAP documentation, results can also be achieved quickly.

 

Source:
SAP Help - Implementing a Code Insertion


Included topics:
ToolsADTEclipseIDE ActionsMIA
Comments (0)



And further ...

Are you satisfied with the content of the article? We post new content in the ABAP area every Tuesday and Friday and irregularly in all other areas. Take a look at our tools and apps, we provide them free of charge.


ABAP Tools - IDE Actions (Table)

Category - ABAP

How do you actually create a table and edit it in the IDE Action? Let's look at the input options and how you can ultimately work with the data.

12/09/2025

ABAP Tools - IDE Actions (Side Effects)

Category - ABAP

How can we automatically update information on the UI when something happens with the IDE action? Let's take a closer look at the side effects.

11/18/2025

ABAP Tools - IDE Actions (Value Help)

Category - ABAP

Let's take a detailed look at how we can create a value help for our input for our IDE action in ADT. We'll examine several possibilities and dependencies.

11/11/2025

ABAP Tools - IDE Actions (Input)

Category - ABAP

How can we retrieve information before the actual IDE action is executed in ABAP? Let's implement the first version of a simple input.

11/04/2025

ABAP Tools - IDE Actions (Output)

Category - ABAP

Let's look at the output options we currently have with IDE Actions and what we can achieve with them. We will look at different implementation examples for each case.

10/28/2025