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

1361

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.



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.


Script: ABAP Tools - Update your IDE [014]

Category - YouTube

How can you view your current version in the ABAP Development Tools, find the update settings, and perform an update? In this video, we'll go into the various details.

08/24/2025

ABAP Tools - Working with Eclipse (Table Comparison)

Category - ABAP

Comparing internal tables with the debugger in the ABAP Development Tools? With the latest feature, it's no longer a problem and can be used in many situations.

08/19/2025

Script: OData Batch Creator [007]

Category - YouTube

Want to create and test batch requests in OData easily and without headaches? Without knowing the rules, it's going to be difficult. But with this little tool, it should be no problem in the future.

07/06/2025

ABAP Tools - Work with Eclipse (Informations)

Category - ABAP

If you're new to ABAP development tools, obtaining the necessary information about an object isn't always easy. In this article, we'll show you a few sources for this.

07/04/2025

ADT - My IDE Actions

Category - ABAP

Write your own functions in the ABAP Development Tools? No problem anymore with the standard IDE Actions and also without Java.

02/18/2025