Skip to Content
Technical Articles
Author's profile photo Ramjee Korada

ABAP RAP : Enabling custom actions with a dialog for additional input fields

Prerequisites:

  • Knowledge on ABAP Restful Application Programming
  • Knowledge on Entity Manipulation Language (EML)
  • [Optional] Hands on exercises in OpenSAP course https://open.sap.com/courses/cp13.

This blog gives you an idea to develop a custom action with a dialog for additional input fields that are needed based on scenario.

  • Use case:
    • There is a purchase contract that needs to be extended to next year by buyer.
  • Business logic:
    • Only extend those validities which are running on existing valid to
      • [i.e. continue business with same supplier].
    • Don’t touch items which are older than existing valid to.
      • [i.e. no need to continue business with this supplier]

In my example: 

Old valid to: Jun 30, 2021

New valid to: Dec 31, 2021

Item #10 runs on Jun 30,2021 hence it is expected to extend till Dec 31, 2021

Item #20 ends on Mar 31, 2021 hence it is not expected to touch.

Click the button Extend and to see results on Object page and item page

 

Implementation steps:

  1. Create a data model with Header (Parent), Item (Child), Conditions (Grand Child) having fields “Valid from”, “Valid to “.
  2. Create an abstract CDS entity with required input fields.
@EndUserText.label: 'Abstract entity to extend the validity'
@Metadata.allowExtensions: true
define abstract entity ZRK_A_Doc_Extend 
 // with parameters parameter_name : parameter_type 
  {
    extend_till : /dmo/end_date;
    comments : abap.string( 300 );
    
}

3.Enrich the entity with UI annotations such as labels.

@Metadata.layer: #CORE
annotate entity ZRK_A_Doc_Extend
    with 
{
   @EndUserText.label: 'New validity to:'
   extend_till; 
   @EndUserText.label: 'Enter your comments:'
   comments;
    
}

4. In Behavior Definition, define action “extendDoc” with parameter using the abstract entity                created in step#2.

  action extendDoc parameter ZRK_A_Doc_Extend result [1] $self;

       5. Implement the core ABAP logic for extend in Behavior Pool Class

METHOD extendDoc.

    DATA : lt_update_doc  TYPE TABLE FOR UPDATE zrk_i_doc_head.
    DATA(lt_keys) = keys.
    DATA(lv_today) = cl_abap_context_info=>get_system_date( ).

    LOOP AT lt_keys ASSIGNING FIELD-SYMBOL(<fs_key>).

      IF <fs_key>-%param-extend_till < lv_today.

        APPEND VALUE #( %tky                = <fs_key>-%tky ) TO failed-head.

        APPEND VALUE #( %tky                = <fs_key>-%tky
                        %msg                = new_message(  id       = 'ZRK_CM_DOC'
                                                            number   = '001' " Document cannot be extended into the past
                                                            severity = if_abap_behv_message=>severity-error )
                        %element-ValidTo = if_abap_behv=>mk-on ) TO reported-head.

        DELETE lt_keys.


      ELSE.
        DATA(lv_new_valid_to) = <fs_key>-%param-extend_till.
      ENDIF.

    ENDLOOP.

    " Once the validations are passed, proceed with extending document.
    CHECK lt_keys IS NOT INITIAL.

    READ ENTITIES OF zrk_i_doc_head IN LOCAL MODE
        ENTITY Head
        FIELDS ( ValidFrom ValidTo )
        WITH CORRESPONDING #( keys )
        RESULT DATA(lt_doc_head).


    CHECK lt_doc_head IS NOT INITIAL.

    LOOP AT lt_doc_head ASSIGNING FIELD-SYMBOL(<fs_head>).

      " Capture old valid to
      DATA(lv_old_valid_to) = <fs_head>-ValidTo.

      " Read items from entity
      READ ENTITIES OF zrk_i_doc_head IN LOCAL MODE
          ENTITY Head BY \_Items
          FIELDS ( ValidFrom ValidTo )
          WITH VALUE #( ( %tky = <fs_head>-%tky ) )
          RESULT DATA(lt_items).

      " Loop through items that are running on old valid to
      LOOP AT lt_items ASSIGNING FIELD-SYMBOL(<fs_item>)
                            WHERE ValidFrom LE lv_old_valid_to
                               AND ValidTo GE lv_old_valid_to.

        " Modify item with new valid to
        <fs_item>-ValidTo = lv_new_valid_to.

        " Read conditions from entity
        READ ENTITIES OF zrk_i_doc_head IN LOCAL MODE
            ENTITY Items BY \_Conds
            FIELDS ( ValidFrom ValidTo )
            WITH VALUE #( ( %tky = <fs_item>-%tky ) )
            RESULT DATA(lt_conds).

            LOOP AT lt_conds ASSIGNING FIELD-SYMBOL(<fs_conds>)
                                    WHERE ValidFrom LE lv_old_valid_to
                                     AND ValidTo GE lv_old_valid_to..

              <fs_conds>-ValidTo = lv_new_valid_to.

            ENDLOOP.

            " Modify conditions entity
            MODIFY ENTITIES OF zrk_i_doc_head IN LOCAL MODE
                ENTITY Conds
                UPDATE FIELDS ( ValidTo )
                WITH CORRESPONDING #( lt_conds ).


      ENDLOOP.

      " Modify Items entity
      MODIFY ENTITIES OF zrk_i_doc_head IN LOCAL MODE
            ENTITY Items
            UPDATE FIELDS ( ValidTo )
            WITH CORRESPONDING #( lt_items ).


    ENDLOOP.

    " Modify header entity
    MODIFY ENTITIES OF zrk_i_doc_head IN LOCAL MODE
        ENTITY Head
        UPDATE
        FIELDS ( ValidTo )
        WITH VALUE #( FOR <fs_doc> IN lt_doc_head
                        ( %tky = <fs_doc>-%tky
                          validTo = COND #( WHEN lv_new_valid_to IS NOT INITIAL
                          THEN lv_new_valid_to
                          ELSE <fs_doc>-ValidTo )  ) )
        REPORTED DATA(lt_update_reported).

    reported = CORRESPONDING #( DEEP lt_update_reported ).

    " Return result to UI
    READ ENTITIES OF zrk_i_doc_head IN LOCAL MODE
        ENTITY Head
        ALL FIELDS
        WITH CORRESPONDING #( keys )
        RESULT lt_doc_head.

    result = VALUE #( FOR <fs_doc_head> IN lt_doc_head ( %tky = <fs_doc_head>-%tky
    %param = <fs_doc_head> ) ).

  ENDMETHOD.

6. Position the Action button on List Report and Object Page using annotations.

  @UI: {

  lineItem: [
      { type: #FOR_ACTION,  dataAction: 'ExtendDoc' , label: 'Extend' , position: 90 } ] ,

  identification : [
      { type: #FOR_ACTION,  dataAction: 'ExtendDoc' , label: 'Extend' , position: 90 } ]
  }

7. Generate the service Binding using OData V4 . [ If you use OData V2, then you have to enrich metadata in fiori app from webide or business studio ]

Service%20binding%20for%20document%20app%20with%20Odata%20V4

Service binding for document app with OData V4

Everything is set and its ready for user action:) Hope it helps in learning advanced ABAP RAP.

 

Assigned Tags

      104 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jagtar singh
      Jagtar singh

      Thanks for detail explanation , It will help a lot for start further extension and gives heads up 🙂 .

      Author's profile photo Prateek Mitter
      Prateek Mitter

      Dear Ramjee, thanks for a great introduction to RAP. Looking forward to more tricks and tips!

      Author's profile photo Oana-Elena Vladescu
      Oana-Elena Vladescu

      Hello Ramjee,

      I am trying to do basically the same thing, but for me it does not work as expected.

      I added a button using @UI.identification and UI.lineItem annotations, that should open a dialog box with input fields.

      I created the abstract entity :

      @EndUserText.label: 'Abstract Entity for Release Information'
      @Metadata.allowExtensions: true
      define abstract entity ZOV_A_SYSTEM_RELEASE {
      system_release : z_release_version;
      }

      and the metadata extension for UI labels:

      @Metadata.layer: #CORE
      annotate entity ZOV_A_SYSTEM_RELEASE with
      {
      @EndUserText.label: 'Release'
      system_release;

      }

       

      I added the action in the Behaviour definition:

      action SelectRelease parameter ZOV_A_SYSTEM_RELEASE;

       

      The result in my app is the following: the dialog box opens, I can see the field maintained in the abstract entity, but no annotations are taken into consideration. No label is displayed. Just the field as written in the entity ( system_release ), not even the description from the data element.

      Any idea what am I missing?

      Author's profile photo Ramjee Korada
      Ramjee Korada
      Blog Post Author

      Hi Oana,

      Did you try to refresh the app ? Sometimes metadata reflection on UI takes more time.

      Is it in trail system so that I can have look ?

       

      Best wishes,

      Ramjee Korada

      Author's profile photo Mohandoss Palanisamy
      Mohandoss Palanisamy

      Hello Oana, Ramjee,

      Have you resolved this issue?

      I'm now into the same issue as the metadata entension for End user label not getting reflected on the popup.

      Author's profile photo Aynur Vasbiev
      Aynur Vasbiev

      Hello Oana,

      It is just the version of your Odata binding type, use OData V4 - UI instead of V2

       

      So now its works, and there checkboxes instead of radiobuttons=)

      BR, Aynur

      Author's profile photo Ramjee Korada
      Ramjee Korada
      Blog Post Author

      Hi Aynur,

      Thanks for highlighting. I was using V4 for quite sometime and did not realize that others might be using still V2.

      I have updated the blog with this point.

      BR,

      Ramjee

      Author's profile photo Malini M
      Malini M

      Hi Ramjee, This is very interesting. Thanks for the detailed explanation.

      Author's profile photo Daniel Ojados Conesa
      Daniel Ojados Conesa

      Thanks Ramjee for sharing. I'm not getting the popup being shown up although the abstract entity and its metadata is created properly. When triggering the action by pushing the corresponding button, it jumps directly to the behavior implementation where I can see the parameters defined in the abstract entity in blank (obviously 🙂 ) but no popup asks me for the input data.

      Would you have an idea about how I can solve it? I already refresh the system a couple of times 🙂

      Thx

      Author's profile photo iMRO DEV TEAM
      iMRO DEV TEAM

      Hi Daniel Ojados Conesa ramjee korada ,

      We are facing the similar issue in case of parameterized action where multi select is enabled. In my case actions are working fine if multi select is disabled ,once we are enabling multi select the action directly goes into further processing and doesn't ask for input data.

      Did you get solution for this issue ?

       

      Thanks & Regards,

      Arushi Nautiyal

      Author's profile photo iMRO DEV TEAM
      iMRO DEV TEAM

      Mahesh Palavalli Can you please help here ?

      I have created an order maintenance application in RAP and have exposed the service as Odata V2.  This development is done in 1909 version

      Actions buttons are working as expected when we have not enabled multi select . Once we enable multi select for our application we get an error as below

      Current%20Behavior

       

      Thanks,

      Arushi Nautiyal

      Current Behavior

      Author's profile photo Johannes Kretschmer
      Johannes Kretschmer

      Hi,

      i have the same problem.

      did you find a solutions on SAP HANA 1909 on premise ?

       

      Author's profile photo Aynur Vasbiev
      Aynur Vasbiev

      Dear Ramjee,

      The popup and entity work fine, but there are some problems caused by changing binding type of my service to OData V4 - UI from V2.

      Those are currency and unit of measure assignments for fields. So the error popup is like this:

      How did manage this? And which data types did you use for that?

      BR, Aynur

       

      Author's profile photo Ramjee Korada
      Ramjee Korada
      Blog Post Author

      Hello Aynur,

      This problem is solved when you enter respective Uom ( for quantity ) , Currency for ( Amount ) in object page.

      However, It does not allow me to activate abstract entity with UoM field. 

      Once I added semantics, I am able to see the values entered from the dialog in debugging.

       

      BR,

      Ramjee

      Author's profile photo Aynur Vasbiev
      Aynur Vasbiev

      Hello Ramjee,

      Actually, I had problem with UOM fields using that annotation. In Odata V2 it was ok to use any type of amout (INT4, DEC 15/2), while here with Odata V4 it causes errors, like: invalid type '\TYPE=STRING'.

      Now, based on your screenshot I got that we should use 3 decimals after comma=)

      That worked! Thanks!

      BR, Aynur

      Author's profile photo Vignesh Subramanian
      Vignesh Subramanian

      Hi Ramjee,

      Could you please explain, what needs to be added for OData V2 from the UI end ? Please try to provide a screenshot explanation for OData V2.

      Thanks,

      Vignesh.

      Author's profile photo Romina Ganserer
      Romina Ganserer

      Hi Ramjee,

       

      we use OData V2 in our project and changing to Odata V4 is not possible at the time.

      You wrote "If you use OData V2, then you have to enrich metadata in fiori app from webide or business studio". But I can't do this in my annotation file. Can you give an example, how this works?

       

      Thanks, Romina.

      Author's profile photo Koonal Aanand
      Koonal Aanand

      Hi Romina,

      Did you find a solution on OData V2. Please share if you did.

      Regards,

      Koonal

      Author's profile photo Venkat Srikantan
      Venkat Srikantan

      I am facing an issue

      When am trying to add an action . it is giving error in service binding  -  Duplicate action external name .

      There is no action with the same name . When am trying to expose the action in Behavior Implementation (Projection of Behavior Definition) . then this error comes, and without that the action button is not available in UI .

      Can you please help me.

       

      Thank you

      Regards

      Venkat Srikantan

      Author's profile photo David Sun
      David Sun

      HI Ramjee

      Thanks for your sharing, I just confused with this development mode, you didn't declare any logic about dialog, how system know it should popup a dialog rather than others?

      Author's profile photo Ramjee Korada
      Ramjee Korada
      Blog Post Author

      Hi David,

      As mentioned in step #4, we are using parameters for an action. That means user has to fill the values and hence dialog is opened .

        action extendDoc parameter ZRK_A_Doc_Extend result [1] $self;
      Author's profile photo David Sun
      David Sun

      hi Ramjee

      Could you plz share the detail of the parameters value

      Author's profile photo Ramjee Korada
      Ramjee Korada
      Blog Post Author

      Hi David,

      Its there in step #2 and step #3.

      Author's profile photo Muhammed Syed
      Muhammed Syed

      This is a very informative post. Thanks!!!

      What if we want to make a parameter as Mandatory? Do we have to add an annotation to achieve this?

      Author's profile photo Muhammed Syed
      Muhammed Syed

      Found the annotation

      @ObjectModel.mandatory: true
      Author's profile photo Wolfgang Röckelein
      Wolfgang Röckelein
      "@ObjectModel.mandatory: true"

      gives error "Use of Annotation 'ObjectModel.mandatory' is not permitted (not released)" for me, so I need a different solution.

      Author's profile photo Hendrik Poehlmann
      Hendrik Poehlmann

      Hello Wolfgang,

      have you found another solution?

       

      Author's profile photo Wolfgang Röckelein
      Wolfgang Röckelein

      Hi Hendrik,

      I had a lengthy incident discussion with SAP on this.

      For Steampunk @ObjectModel.mandatory is not released because steampunk is only RAP and in RAP this is supposed to be specified in the BDEF and not in the CDS (but internally all parameters are currently considered to be mandatory, but this is neither signalled in the annotation - and thus the UI - nor is it enforced). Since 2202: If you don't use strict you can currently use "field ( mandatory ) Type;" in the BDEF and it is then at least signalled in the annotation and thus in the UI (and is then enforced in a fiori elements UI). You still have to manually validate this in the BDEF implementation. However this is not yet finalized by SAP (thus it does not work with strict).

      Regards,

      Wolfgang

      Author's profile photo Hendrik Poehlmann
      Hendrik Poehlmann

      Hello Wolfgang,

      thanks for the detailed answer. I did not understand in which behavior the part "field ( mandatory ) type" has to be since for the abstract entity there is no own behavior and the fields par1, par2 & par3 are not known in the behaviour where the action is defined.

       

        action ( features : instance ) ACTION parameter SOME_NAME result [1] $self;

       

      define abstract entity SOME_NAME  {
        par1     : abap.char(2);
        par2     : abap.dats;
        par3     : abap.char(2);
         }
      

       

      BR

      Hendrik

      Author's profile photo Wolfgang Röckelein
      Wolfgang Röckelein

      No, there can be a BDEV for an abstract entity and this is the place where this belongs

      abstract;
      //strict;
      
      define behavior for /NEO/A_SKD_TypeXYZ alias TypeXYZ
      {
        field ( mandatory ) Type;
      }

      Regards,

      Wolfgang

      Author's profile photo Hendrik Poehlmann
      Hendrik Poehlmann

      Thanks Wolfgang, this works.

      For completion:

      1. define abstract root entity with parameters

      define root abstract entity SOME_NAME  {
        par1     : abap.char(2);
        par2     : abap.dats;
        par3     : abap.char(2);
         }

      2. define own behavior definition for the abstract root view

      abstract;
      //strict;
      
      define behavior for SOME_NAME
      {
        field ( mandatory ) par1, par2, par3;
      
      }

      3. use abstract cds in the behavior definition as parameter value for the action

        action ( features : instance ) ACTION parameter SOME_NAME result [1] $self;

       

      Last question:

      You wrote

       You still have to manually validate this in the BDEF implementation

      By this you mean the validation has to be in the method which implements the action since abstract behavior definition throws an error when trying to do something like

      validation validatePAR1 on save { create; update;}

      Br

      Hendrik

       

      Author's profile photo Wolfgang Röckelein
      Wolfgang Röckelein

      Yes, in the action implementation.

      Mandatory is currently not validated by the RAP framework (neither with create/update nor with actions), you have to do this manually in the BDEV implementation...

      Author's profile photo Hendrik Poehlmann
      Hendrik Poehlmann

      Hello,

      now this is strange(good?). The UI is enforcing the mandatory somehow without implementing a seperate validation. When trying to push the button with empty fields an error appears to enter a value for par1

      The $metadata for the Functionimport looks like this:

      in the BDEV only par1 is mandatory which implictly leads to a nullable="false" in the metadata?

      <FunctionImport Name="SOMEACTIONAME" ReturnType="SOMETYPE" EntitySet="SOMEENTITYSET" m:HttpMethod="POST" sap:action-for="SOMETYPE" sap:applicable-path="ACTIONPATH">
      <Parameter Name="HeadUuid" Type="Edm.Guid" Mode="In" sap:label="UUID"/>
      <Parameter Name="PAR1" Type="Edm.String" Mode="In" MaxLength="2"/>
      <Parameter Name="PAR2" Type="Edm.DateTime" Mode="In" Precision="0" Nullable="true" sap:display-format="Date"/>
      <Parameter Name="PAR3" Type="Edm.String" Mode="In" MaxLength="2" Nullable="true"/>
      </FunctionImport>
      Author's profile photo Wolfgang Röckelein
      Wolfgang Röckelein

      Yes, the Fiori Elements UI is enfording this, since meanwhile the annotations are sent correctly (nullable is IMHO not enough, there is second thing sent somewhere).

      But eg a API or a Fiori Freestyle app could ignore the annotation, thus the backend needs also to validate this.

      Author's profile photo Yury Rychko
      Yury Rychko

      Many thanks Ramjee. Your post is very helpful.

      Maybe somebody could answer me. Is it possible to call this action with popup from back-end? I need to fill comment field before save. I'm trying to call this action from determination via EML and action is called, but popup is not showed.

       determination CommentPopup on save { update; create; }
       action extendComment parameter z_comment_ext result [1] $self;
      
      
       METHOD commentpopup.     
          MODIFY ENTITY c_test
           EXECUTE extendComment
           FROM VALUE #( ( %key-uuid = keys[ 1 ]-uuid
                        %param-comments = 'Test' ) )
             REPORTED DATA(edit_reported)
             FAILED DATA(edit_failed)
             MAPPED DATA(edit_mapped).
        ENDMETHOD.
      
        METHOD extendComment .
          
        ENDMETHOD.
      Author's profile photo Vijay Chintarlapalli
      Vijay Chintarlapalli

      ramjee korada  : Thanks for useful blog, I have similar requirement to read notes and expose via API instead of displaying in Fiori app. Should i expose abstract entity via action or Function ?

      Author's profile photo Udita Saklani
      Udita Saklani

      Hello ramjee korada,

      We have tried implementing an action by the exact same way as you have mentioned.
      However, the button is coming disabled in our scenario.
      Can you let us know what could be possibly missing here?

      Thanks & Regards,

      Udita Saklani

      Author's profile photo Guilherme Salazar
      Guilherme Salazar

      Hello, ramjee korada,

      Great and very useful explanation!

      However, I have another requirement for a custom action that I was still not able to do:

      Is it possible to open a popup confirmation in a custom action?

      As an example, I have a custom action called "Cancel document", which I want the user confirmation before (Yes/No).

      Is this possible?

      Thanks in advance,

      Guilherme

      Author's profile photo Ramjee Korada
      Ramjee Korada
      Blog Post Author

      Hello Guilherme,

      This can be done using Fiori elements application . But I dont think possible at ABAP RAP level .

      https://sapui5.hana.ondemand.com/sdk/#/topic/87130de10c8a44269c605b0322df6b1a

      <Annotations Target="GWSAMPLE_BASIC.GWSAMPLE_BASIC_Entities/RegenerateAllData">
      <Annotation Term="com.sap.vocabularies.Common.v1.IsActionCritical" Bool="true"/>
      </Annotations>

       

      Best wishes,

      Ramjee

      Author's profile photo Former Member
      Former Member

      Hello Ramjee,

       

      Do Value Helps not work at all with these dialogs?

      The annotation @Consumption.valueHelpDefinition do nothing.

       

      Thanks

      Author's profile photo Ramjee Korada
      Ramjee Korada
      Blog Post Author

      Hi Tim,

      This annotation worked in Odata V4 but not in V2.

       

      Below is example for V4.

      Author's profile photo Christophe Bontron
      Christophe Bontron

      Hello,

      I have created an OData V4 and I have an issue with the value help in the dialog screen. I used the annotation Consumption.valueHelpDefinition in metadat annotation abstract view.

      @Consumption.valueHelpDefinition: [{ entity : { name: 'I_CndnContrCustomerStdVH' , element: 'ConditionContract'} }]

      When I run the app and click on the value help I get an empty screen as below:

       

      Any idea what is wrong?

      The same entity for the value help of the selection field 'Condition Contract' is working find.

      Thank you for your help

      Christophe

      Author's profile photo Selvakumar Mohan
      Selvakumar Mohan

      The value help you linked must be tied to a View and not "View Entity".

      Author's profile photo Diego Borja
      Diego Borja

      I had the same issue. The problem was due to using an external alias for the action. I removed the alias and it worked. I reckon there is a limitation with that generic service that provides value helps that cannot do the mapping between the internal and external action names.

      static factory action CustomCreate parameter yrap_i_header_create_ae [1];
      Author's profile photo Tassilo Gätjens
      Tassilo Gätjens

      Hello Ramjee,

      I have tried to publish the Services Binding with the OData V4.
      But I got the following error:


      Can you help me further?
      Or is there a way to include a value help in the ABSTRACT ENTITY even without OData V4?

      thanks!

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Finally I got answer for these value help dialogs in Odata V2.

      In OData V2, If you need F4 help in an action Dialog, you have to expose the value help definition explicitly in Service definition along with "@Consumption.valueHelpDefinition".

      @EndUserText.label: 'ZRK_UI_PUR_CON_UD'
      define service ZRK_UI_PUR_CON_UD {
        expose ZRK_C_PUR_CON_UD as PurCon;                " Root view entity
        expose ZRK_C_PUR_CON_I as PurConItems;            " Child view entity
        expose ZRK_C_PUR_COND_I as PurConItemConds;       " Grand Child view entity
        expose ZRK_I_BUYER as BuyerF4;                    " Value help definition
      }
      Author's profile photo mohan dandu
      mohan dandu

      Hi Ramjee,

      Even after exposing the search help view in service definition, the F4 help is not working

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Hi Mohan,

      Are you trying from fiori app or adt preview?

      In case of fiori app, you have to sync metadata in BAS or WebIDE .

       

      Best wishes,

      Ramjee Korada

      Author's profile photo mohan dandu
      mohan dandu

      Hi Ramjee,

       

      I am trying explore the standard application like PO  and SO creation using the Restful ABAP, but could not find any RAP V2 services. Could you please help me with standard examples' package or application name or is there any way to find the standard examples with RAP?

      Thanks in Advance

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Hi Mohan,

      I think SAP has not yet migrated PO/SO apps to RAP in OnPremise. I am not sure on Cloud.

       

      There is Business Partner application that is rebuilt using RAP in OnPremise.

       

      Best wishes,

      Ramjee Korada

      Author's profile photo mohan dandu
      mohan dandu

      Hi Ramjee,

      Thanks for your immediate response. Could you please let me know in which package the business partner application is rebuilt..

      Thanks

      Author's profile photo mohan dandu
      mohan dandu

      HI Ramjee,

      I found this package ODATA_SD_SALESORDER for sales order, i can only find projection BDEF, could not get  the actual BDEF. Please have a look into this package once. Thanks

      Author's profile photo mohan dandu
      mohan dandu

      Hi Tassilo,

       

      Did you resolve this issue?

      I am also facing the same issue.

      Author's profile photo Christophe Bontron
      Christophe Bontron

      Hello,

      Very nice blog.

      I have created an app with two custom actions. The buttons are active only when a record is selected. Is there a way to have the button always active independently from a record has been selected or not.

      Example: I have a button 'Create'. When the user click on create, a dialog appears where the user enter a contract number. Then a new line is added with the contract number and its data. As you can see this action is NOT relevant for record selection so I expect the button to be always active.

      Thank you

      Christophe

      Author's profile photo Ramjee Korada
      Ramjee Korada
      Blog Post Author

      Hi Christophe,

      Custom Actions :

      you can declare the action as "static" so that button is always active.

      static action <action name> parameter <parameter> result <entity_type>;

      Create :

      I think you use existing feature "Enabling Object Creation Using the Dialog in the List Report" for your case. please have a look

      https://sapui5.hana.ondemand.com/sdk/#/topic/ceb9284b16f64f30865ce999dbd56064

       

      Best wishes,

      Ramjee

      Author's profile photo Christophe Bontron
      Christophe Bontron

      thank you

      Author's profile photo Christophe Bontron
      Christophe Bontron

      Hello Ramjee,

      it is related to the value help on the dialog screen. I have describe my problem in an above post. Currently I test the app  in ADT with the "Preview" functionality.

      I want to mention that in the UI5 I get the below error:

      /sap/opu/odata4/baa1/o2c_ccs_imptlev_srv/srvd_f4/sap/i_cndncontrcustomerctdvh/0001;ps=%27srvd-%2Abay0%2Ao2c_ccs_imptlev_srv-0001%27;va=%27com.sap.gateway.srvd.baa1.o2c_ccs_imptlev_srv.v0001.ae-/baa1/c_ccs_imptierlev.insert_records.selnum.ImpTierLevType.X%27/$metadata - In the context of Data Services an unknown internal server error occurred sap.ui.model.odata.v4.lib._MetadataRequestor

      in debugging i can see that the service variant is: com.sap.gateway.srvd.baa1.o2c_ccs_imptlev_srv.v0001.ae-

      Is there any specific step to be done for the value help to work correctly?

      Best regards

      Christophe

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Hello Christophe,

      There are 2 points regarding value help in ODataV2.

      1. Actions with Parameters : In case a value help is added to an action parameter (e.g. via annotation @ValueHelpDefinition in corresponding abstract entity for the action parameters) the value help isn't added automatically to the service and must be added to the service definition explicitly.
        Reference : Documentation
      2. Field name in abstract entity must be different from the name in actual entity.
        Ex: Take an example of assign/change a supplier in an item.
        Field name entity : Supplier
        Field name in parameter / abstract entity : ToBeSupplier.
        Reference : Not found . But tested with different examples.

      Best wishes,
      Ramjee Korada

       

      Author's profile photo Jorge Bastos
      Jorge Bastos

      In manifest file, you have to delete the row that contain: "sap-value-list": "none"

      manifest

      manifest

      Author's profile photo Diego Valdivia
      Diego Valdivia

      Thanks Jorge! This one did the trick for me.

      Author's profile photo Selvakumar Mohan
      Selvakumar Mohan

      Do you have an idea how to make the field which appears in pop up as a File uploader?

      Author's profile photo rajesh maripeddi
      rajesh maripeddi

      Hello Ramjee,

       

      Its very helpful blog. Can we create a custom bottom which will be active without selecting the line. Just like the "Create" button, Actually my requirement is create a line item without going to object page but should appear a dialog box.

      Whether this can be achieved using RAP.

       

      Regards,

      Rajesh

      Author's profile photo Ramjee Korada
      Ramjee Korada
      Blog Post Author

      Hello Rajesh,

      I dont prefer custom button in your case as this is available out of the box. please see below link for steps.

      Enabling Object Creation Through Dialog in the List Report

      Few restrictions : Draft is not supported , Maximum of 8 fields can be shown.

      If above restrictions are concerns then you can create custom "Static" action so that button is always enabled without selecting any line.

      Best wishes,

      Ramjee Korada

      Author's profile photo mohan dandu
      mohan dandu

      Hi Ramjee,

      How Can I add the dialog for input fields for standard actions like Create, Update and Delete with RAP framework?

      Thanks in Advance

      Author's profile photo Ramjee Korada
      Ramjee Korada

      I think no from RAP but I am not sure.

      If needed, you might to enhance UI logic to generate dialogs

      Author's profile photo rajesh maripeddi
      rajesh maripeddi

      Thanks Ramjee for for sharing the link.

      I will try to implement. Also in your blog as is there any option where will can set the values of the pop-up fields before the pop-up appears.

      I mean add comment in comment field before pop-up like PBO of Pop-up. Also do we have the option to dynamically display the fields on pop-up.

      Regards,

      Rajesh

      Author's profile photo Florian Halder
      Florian Halder

      Hello Ramjee,

      is it possible to display a text area with multiple lines on the pop up.

      I tried with the following UI annotation in the metadata extension, but this had no effect.

      @UI.multiLineText: true

      Thanks Florian

      Author's profile photo Christine Kendrick
      Christine Kendrick

      Hello Ramjee,

      Very helpful blog. I have a question for anyone. Is it possible to display a read-only field in the  RAP action popup?

      I have tried a few annotations to do this like '@ObjectModel.readOnly: true' with no success.

      Thank you 🙂

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Hi Kendrick,

       

      i have not tried yet but I think it’s possible by defining “behaviour definition “ for abstract entity.( see above comments on 22-apr-2022 for the process and it is about mandatory and your case is read only)

      there you can mark as read only.

      but the challenge is how will you fill it to show on the screen unless it is constant to default in metadata.

       

      best wishes,

      Ramjee

       

       

       

      Author's profile photo Christine Kendrick
      Christine Kendrick

      Hello Ramjee,

       

      Thank you for taking a look at my comment.

      abstract;
      
      define behavior for ABSTRACT_ENTITY alias ALIAS
      {
          field( readonly ) Currency;
          field( mandatory ) Price;
      }

      It looks like this method does work for mandatory fields, but not read only.

      If you can see I have added some text to the Trade currency field but the Price now has the mandatory * on it.

      I will keep looking into possible solutions!

       

      Thank you

      Author's profile photo Himanshu Kawatra
      Himanshu Kawatra

      Hi ramjee korada,

      Can you please tell me, How to handle Warning or Error messages in an Unmanaged scenario?

       

      Regards,

      Himanshu Kawatra

      Author's profile photo Former Member
      Former Member

      Hello Ramjee,

      Is it possible to fill the dialog box with a default value or leave it empty?

       

      In my case (see picture) the dialog field ist filled with the value of the table, but this field should be empty. In an other case it should show an default value.

      dialog%20with%20value%20of%20the%20table

       

      Or can I display a calculated value there? For example a calculated date.

       

      regards

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Hello Tim,

      If you don't want to default the value from the record, then you can use different field name in abstract entity different than the one in actual entity.

      I have tried some logic to default based on some calculation.. it did not work so far. I don't know yet if there is a solution.

      There is a workaround to use extension point in fiori app by creating new fragment to default these values.

      1. Define a function to get a calculated value
      2. Then map it on fiori and let user accept or change it
      3. Then fire the action with final user input.

      Yes, there is fiori development needed here.

      Best wishes,

      Ramjee Korada

      Author's profile photo Mainak Aich
      Mainak Aich

      Hi Tim Muller , Ramjee Korada ,

      Can you please suggest how to pass the list report record value to the popup screen? How are you achieving it currently as you are showing in your screenshot?

      Thanks,

      Mainak

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Hi Mainak,

      I answered it in another question.

      Please see https://answers.sap.com/answers/13945315/view.html

       

      Best wishes,

      Ramjee Korada

      Author's profile photo Koonal Aanand
      Koonal Aanand

      ramjee korada ,

      I am trying to achieve the same functionality but via OData V2. Can you kindly elaborate how do we achieve this through enriching the metadata ?

      Any direction would be helpful. - Updated the behavior definition with action and pop up displayed.

      Regards,

      Koonal

       

      Author's profile photo Ramjee Korada
      Ramjee Korada

      kunal anand

      As discussed, issue is resolved after "using the action in projection behavior definition"

       

      Best wishes,

      Ramjee Korada

      Author's profile photo vinith moduguru
      vinith moduguru

      Is there any way to get the labels in OData V2?

      I'm getting entity names instead of label.

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Have you used annotation "@EndUserText.label: ' ' ".

      Below example. Ideally this should be fine.

      @Metadata.layer: #CORE
      annotate entity ZRK_A_Doc_Extend
          with 
      {
         @EndUserText.label: 'New validity to:'
         extend_till; 
         @EndUserText.label: 'Enter your comments:'
         comments;
          
      }
      Author's profile photo vinith moduguru
      vinith moduguru

      Yes, I did exactly the same way.

      Author's profile photo Shweta .
      Shweta .

      Hi Ramjee,

      I have a case which has action button to change user status of order. In this action button, their is drop down which gives list of user status.
      But, currently we get all user status maintained in the system.

      so, is their a way to pass value of Status Profile to the action button in such a way that we only get user status based on that profile only.

      We have implemented this button via RAP like -
      action ( features : instance ) Update_UserStatus parameter ZOper_User_Status;

      Abstract Entity - ZOper_User_Status

      @EndUserText.label: 'Structure for Operation User status'
      define abstract entity ZOper_User_Status
      {
      @EndUserText.label: 'User Status'
      User_Status : abap.char(30);
      StatusProfile : j_stsma;
      }

      And, created this action button via Annotation on lineitem

      @UI: {
      lineItem: [
      { type: #FOR_ACTION, dataAction: 'Update_UserStatus', label: 'User Status
      With Number', position: 70 },
      ] }

       

      Regards.

      Shweta

      Author's profile photo vinith moduguru
      vinith moduguru

      Hi all,
      While updating the UI, instead of updating the particular instance, is there any way to update the complete entity? I didn't get any references on the web.

      Author's profile photo Abhishek Dalakoti
      Abhishek Dalakoti

      Thanks Ramjee for for sharing the link.

      I have one question , I have created a separate abstract entity and created a action in BD also , but still I am not getting any pop up . I am using ODATA v2. Can you tell me what else I have to do in this ....

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Hi Abhishek,

      There is no special steps needed for OData v2. Please check if you exposed action in projection level Behavior definition?

      Regarding value help, you can refer to my previous comments .

      Best wishes,

      Ramjee Korada

       

      Author's profile photo Abhishek Dalakoti
      Abhishek Dalakoti

      Thanks Ramjee for the reply ,

      I have one doubt that can we show all the relevant Schedule line item data for the sales order in the popup once the user click on the Schedule lines button .

       

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Hi Abhishek,

      I have not tried it yet. As per my knowledge, Answer is NO.

      The popup is for the input to the action but not result.

      I think the best way to do is to Define a function in Behavior definition and consume it from fragment in Fiori extension project.

       

      Best wishes,

      Ramjee Korada

      Author's profile photo Mainak Aich
      Mainak Aich

      Hi Ramjee Korada ,

      Can you please share if there any blog or URL which describes how to "Define a function in Behavior definition and consume it from fragment in Fiori extension project." in this case?

      Thanks,

      Mainak

      Author's profile photo Alexandra Köthe
      Alexandra Köthe

      Hi Ramjee,

       

      thank you very much for this post. We have implemented it in the way you discribed and it works well.

      But now we have an additional requirement, for which we hvae not found a solution yet.

       

      The requirement is to perform some validations before executing the action. That means, when the user presses the button we would like to check if the user has filled out everything correctly and only if the data are correct, we then show the pop up.

      Our problem is mainly the time for the checks. In the action implementation the pop up has already been processed, so it is to late to trigger the checks here.

      Also, we do not want to use the feature control, because we would like to give feedback, why the action is not possible.

      Do you have any idea how we could do this?

      Best regards and thanks in advance,

      Alex

       

       

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Hi Alex,

      Thanks for the feedback.

      I have tried with "Precheck' but this is also executed after popup.

      One way is to implement with Fiori Custom code to fire

      1.  A Function to give validation result if it is error or success
      2. If error, show the message
      3. If success, proceed with existing Action popup.

      Also kindly request you raise a question so that SAP Experts can be notified and can answer this .

      Best wishes,

      Ramjee Korada

      Author's profile photo Christof Unterste
      Christof Unterste

      Hi Ramjee,

       

      thank you for your helpful blog.

      I found out, that it is possible to fill the input fields in the dialog, if you name the fields after fields in your root entity. However, those fields must be non-key fields and must not be hidden with @UI.hidden annotation.

      Do you know any way to fill the input parameters, with for example the key fields?

      I use this action to copy entries, so I only have to enter the new key values.

       

      Best regards

      Christof

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Hi Christof,

      Isn't it late or external numbering ?

       

      Best wishes

      Ramjee Korada

      Author's profile photo Christof Unterste
      Christof Unterste

      Hi Ramjee,

      no, there is no numbering.

       

      Best Regards

      Christof

      Author's profile photo Ramjee Korada
      Ramjee Korada

      I hope you defined it as factory action?

      Author's profile photo Shilpi Agarwal
      Shilpi Agarwal

      Hello Ramjee,

      I am facing a similar issue where i want custom action button to be always active and also on click of button should ask for parameters. Mine in V2 Unmanaged scenario.

      i have defined button - CreateValCat in behaviour definition and also an abstract entity as below :

      static action CreateValCat parameter ZValtCate;

      define abstract entity ZValtCate
      {
      @EndUserText.label: 'Valuation Category'
      VALUE_CATEGORY : acpos;

      @UI.hidden : true
      wteseq : numc3;

      @UI.hidden : true
      billmethod : zbillmeth;
      }

      so using

      because of this blog i got to know about static and hence getting button active always. But on click this button, it does not give pop up to allow enter value for Value Category and so a blank entry gets created in the table.

      Can you please let me know which step i am doing wrong.

      Thanks.
      Shilpi

      Author's profile photo Akshay Verma
      Akshay Verma

      Hi Ramjee,

      Thank you for this informative blog. I was able to successfully implement the custom action button with dialog box by following your blog. However, I wanted to know if it is possible to have radio button group in the dialog box like in the image below:

      Also, is it possible to have different title for the dialog box than the Custom action button name?

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Hi Akhshay,

      I don't think that flexibility we have in RAP annotations.

      You have to implement custom Fiori Fragment.

       

      Best wishes,

      Ramjee Korada

      Author's profile photo Jonah Notthoff
      Jonah Notthoff

      Hi Ramjee,

      Thank you for your informative and helpful blog.

      I use a factory action to copy entries and I'm trying to figure out how to display an input field in the dialog only if the object you want to apply the factory action to meets certain properties. Do you know of any way to accomplish this?

       

      Best Regards

      Jonah Notthoff

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Hi Jonah,

      thank you for the feedback.

      you can use instance feature control so that you can do those validations and then enable the COPY button.

      There is no opportunity available to execute some logic before opening the dialog.

      Last option is to go with Fiori App extensions with custom code.

      Best wishes,

      Ramjee Korada.

       

      Author's profile photo j abhishek
      j abhishek

      Hi Ramjee,

      I have an abstract entity cds and have also created an action button with parameter in behaviour definition.This parameter points to abstract entity cds.

      The abstract entity cds has many fields which in UI are displayed inside dialog.

      I have a field as a drop-down used value help definition to get values.

      Now I want to default values to a particular key for the drop-down. How can I default values to a drop down coming from abstract entity cds.

      I tried all annotation like @consumptio.defaultvalue:"key".but it doesn't work.

      Any specific way by which I can default the drop-down inside the dialog ?

      Regards,

      Abi

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Hi Abi,

      It is not currently possible to have a custom logic to default from RAP.

      It is planned to deliver in Q4 2023 or Q1 2022 in BTP environment.

      You have to use annotation or custom code in Fiori.

       

      Best wishes,

      Ramjee Korada

      Author's profile photo j abhishek
      j abhishek

      Hi Ramjee,

      Thanks alot

      If it's not possible via cds annotation.

      What annotation can i use in XML to default the drop-down values for the field in abstract entity cds?

      Suppose I have a function import named -> statusPut

      In my annotation XML what can I use it

      Kindly provide me a detailed example how I can use the annotation in this case?

       

      Regards,

      Abi

       

      Author's profile photo Ramjee Korada
      Ramjee Korada

      Hi Abhishek,

      I hope below helps.

      https://answers.sap.com/answers/13943182/view.html

      https://sapui5.hana.ondemand.com/sdk/#/topic/5ada91cc1ad8455bbfb7e6aee96383f2

      Best wishes,

      Ramjee

      Author's profile photo Mohan Dandu
      Mohan Dandu

      HI Ramjee...

       

      After executing custom action (Service is V4 version), the application is enabling the CREATE button at end of execution. How to avoid that error.  below is the screen shot.

       

      If I use V2 version service, Im getting below error.

       

      Could you please guide me, what could the root cause

      Author's profile photo Yusuf Öner
      Yusuf Öner

      Hello Ramjee

      Thanks for explanation.

      I created a custom screen. but Labels dont appear and i want to change last field to multiple line, how can i do this.

       

      Best Regards

       

      Yusuf Öner

       

      @EndUserText.label: 'XXX'
      @Metadata.allowExtensions: true
      define abstract entity ZA_MMPUR_PENALTY_ABST with parameters Penalty : boole_d
      {

      @EndUserText.label: 'Strafe'
      Penalty : boole_d;

      @EndUserText.label: 'Rechnung'
      Rechnung : boole_d;

      @EndUserText.label: 'Kommentar'
      PenaltyText : abap.char( 500 );

      }

       

       

      @Metadata.layer: #CORE
      annotate entity ZA_MMPUR_PENALTY_ABST with
      {

      @EndUserText.label: 'Strafe'
      Penalty;

      @EndUserText.label: 'Rechnung'
      Rechnung;

      @EndUserText.label: 'Kommentar'
      PenaltyText;

      }

      Odata Version V4 looks like