In this post, you will learn how to create your own IDE actions for Eclipse.

The IDE action framework allows you to extend the ABAP development tools for Eclipse (ADT) with additional features called IDE actions. The IDE action framework offers you a toolset to build custom functionalities that are completely server-driven using ABAP. You can also use these custom functionalities for AI integration.

Ref: https://help.sap.com/docs/abap-cloud/abap-development-tools-user-guide/working-with-ide-actions

An IDE action has following

  • a development object of the type SAIA i.e. IDE Action
  • a title and a summary, as well as filter capabilities.
  • a class implementing the interface IF_AIA_ACTION.
  • an optional input UI configuration class implementing the interface IF_AIA_SD_ACTION_INPUT.

Let us create one action. I created a package to store all IDE actions.

Creating IDE Actions

Right click on the package and choose New > Other ABAP Repository Object.

Select IDE Action from the node Other. Click Next.

Provide Name and Description, click Next, Assign a transport request if needed and click Finish.

Provide Title, Summary, and Names for the Implementation classes. Select Cardinality as One for this demo. The IDE Action will keep showing 2 errors as the classes provided do not exist yet.

Add filter for the Object Types on which this actions can be applied by clicking on the Add button.

On the next pop-up select ‘CLAS’ as Object Type and click Add.

Now, click on the Implementing Class link to create the Implementing class.

Provide the description and add the interface IF_AIA_ACTION. This interface must be implemented in the action class.

As of now the class is empty.

Similarly create class for Input UI Configuration with interface IF_AIA_SD_ACTION_INPUT. Please note that for the demo in the later part of this post, this class is removed. You can skip this step as well.

Once both the classes are activated, IDE action class can also be activated.

Information related to Implementing IDE Actions

  • Implementing Class should have interface IF_AIA_ACTION
  • Input UI Configuration Class should have interface IF_AIA_SD_ACTION_INPUT
  • IDE Action Context represents the current state of your IDE and also contains information for the action input dialog. Context has information about all open resources in IDE.

The resources types and their examples are as follows –

  • Source-based development object – Class
  • Form-based development object – Data Element, Domain
  • Other resources – an ATC run or a short dump

Information about the resources contains following –

  • Name
  • Type
  • Resource Kind
  • Is the resource focused?
  • Is the resource coming from a selection?
  • Is there any unsaved content if available?
  • Resource URI
  • Referrer URI (optional)

IDE Actions Result Types

IDE Action Result TypeDescriptionUse Case Example
Text Get a simple text result in the result dialog.Create Output “Demo for DiscoveringABAP”
HTML Get an HTML-formatted result in the result dialog.Show the objects that are in focus with an HTML-formatted result.
Source Code ChangeGenerate a source code change result, which is either directly inserted in the source code editor or shown in the optional code review dialog.Inserts source code into the editor.

For this demo, we will use the simplest action result type i.e. Text

Implement the method if_aia_action~run from the class zjp_ide_action_demo_class.

CLASS zjp_ide_action_demo_class DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .
  PUBLIC SECTION.
    INTERFACES if_aia_action .
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.

CLASS zjp_ide_action_demo_class IMPLEMENTATION.
  METHOD if_aia_action~run.
   FINAL(text_result) = cl_aia_result_factory=>create_text_popup_result( ).
   text_result->set_content( 'Demo for DiscoveringABAP' ).
   result = text_result.
  ENDMETHOD.
ENDCLASS.

Activate the class and you are ready to run the action.

For this demo – remove the Input UI Configuration Class.

Running IDE Actions

You can run an IDE action using the Run ABAP IDE Action dialog.

Choose Run > Run ABAP IDE Action or use shortcut Ctrl+Alt+R.

Select the action created – IDE Action Demo and Click Run.

The action is executed and you get the text set in the action class.

While running the action Eclipse shows option to Inspect IDE Context. Run it to see context for all the resources opened in source/form editors.

All the Objects opened at the time of Running this action.

In next posts, we will explore the HTML and code change results.

Note: Your user must be assigned to the SAP_A4C_BC_DEV_AIA_PC business catalog. This enables you to create, implement, change, delete and activate IDE actions in ADT.

Visit ABAP on HANA series for Tutorials on CDS, AMDP, Eclipse, and ALV IDA.


If you like the content, please subscribe…

Join 515 other subscribers

Discovering ABAP YouTube Channel