This is a test message to test the length of the message box.
Login
ABAP RAP Deep Table Action
Created by Software-Heroes

RAP - Deep Table Action

4566

Is it currently possible to pass tables to actions in RAP? This article is intended to provide a better insight into the topic.



Last year we wrote about Deep Actions in OData v4 and looked at an implementation of how you can call an action with deep structures from outside. The question of how deep table actions can be implemented came up via Marian Zeis.

 

Introduction

Deep Actions is about wanting to pass a nested structure to the action. For example, we can not only pass a document, but also the table of the various positions and other additional data in the same structure. Since we are working with deep structures here, we can provide different information at different levels.

 

Implementation

Let's look at an implementation in our application for the complex entity and what you should pay attention to.

 

Extension

To do this, we extend our API "ZBS_API_RAPC_INVOICE_O4" from the blog mentioned above. In the first step, we need a new action. This is basically structured like the other action, except that the keyword TABLE must be added.

static action CreateMultipleInvoices deep table parameter ZBS_S_RAPCreateInvoice;

 

This changes the parameter from a structure to a table. This means we can now pass a table directly to the object.

 

Problem

However, there is now an error in the OData service when we try to access it. When we call the service binding, however, we receive an error message "Error in entity 'ZBS_C_RAPCINVOICE(CDS)': 'T' is not a valid value of the enumeration type 'TY_ACTION_PARAMETER_DEPTH'.":

 

Via me.sap.com you can also find a corresponding question in the SAP Community on the topic. You won't find an answer from SAP there, but the developer had already debugged through the SADL framework and found the commented-out section plus the comment.

 

Hint: We checked this status in the ABAP environment, so the deep table does not seem to be supported in OData at the moment.

 

EML

However, the example still works with the RAP business object in EML. We can prepare the corresponding data for this.

DATA lt_document TYPE tt_document.

INSERT VALUE #( %cid = xco_cp=>uuid( )->value ) INTO TABLE lt_document REFERENCE INTO DATA(lr_new_item).

lr_new_item->%param = VALUE #( Partner = '1000000004'
                               ( Document  = 'TEST'
                                 _position = VALUE #( Unit     = 'ST'
                                                      Currency = 'EUR'
                                                      ( Material = 'F0001' Quantity = '2' Price = '13.12' )
                                                      ( Material = 'H0001' Quantity = '1' Price = '28.54' ) ) )
                               ( Document  = 'TEST2'
                                 _position = VALUE #( Unit     = 'ST'
                                                      Currency = 'USD'
                                                      ( Material = 'G0001' Quantity = '2' Price = '17.12' )
                                                      ( Material = 'Z0001' Quantity = '1' Price = '29.55' ) ) ) ).

 

We then call our action via EML and pass the two documents to the statement. We can then test the action.

MODIFY ENTITIES OF ZBS_R_RAPCInvoice
       ENTITY Invoice
       EXECUTE CreateMultipleInvoices FROM lt_document
       FAILED DATA(ls_failed_deep)
       REPORTED DATA(ls_reported_deep).

 

If we now set a breakpoint in the action and look at the payload, we receive our sent data as a table.

 

Workaround

There is currently a workaround for the problem. You can use the structure as a dummy and append the table at the next level. In the article you will learn more about the use and implementation in a Fiori app. You can take a closer look at the topic in our article on Deep Action. There we explain the call from outside and the use as EML.

However, the use of tables in Fiori Elements applications (Actions) is still not supported; here you can only use flat structures.

 

Complete example

The adjustments and resources shown can be found on GitHub in the repository. The changes were made via the following commit.

 

Conclusion

Currently you can only use the DEEP TABLE PARAMETER function to a limited extent in the EML environment and not directly in the service. However, the workaround using the dummy structure can help to avoid throwing the whole idea out the window.

 

Source:
SAP Help - Modeling Parameters for Non-Standard Operations


Included topics:
RAPBTPActionDeep
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.


RAP - Generator (from Scratch)

Category - ABAP

Does your development with RAP sometimes feel very slow? Generators do the work for you, building the actual stack and eliminating repetitive work.

08/05/2025

RAP - Action (Processing options)

Category - ABAP

How do you actually enable multi-select in RAP and control the various processing options? Here we'll look at the different options in the framework.

08/01/2025

RAP - Custom Entity with Action

Category - ABAP

How can you cleanly implement an action in a Custom Entity to update the UI und utilize EML? Let's take a closer look at the different steps.

07/29/2025

RAP - API Pattern

Category - ABAP

In this article, we look at the API pattern for RAP and how you can use it flexibly in ABAP development to provide interfaces.

06/20/2025

RAP - Multiple filters and settings

Category - ABAP

What happens if we want to set several filters and fields as default in RAP and also need a default sorting?

05/16/2025