Let’s get started on How to Create SM30 Like Table Maintenance T-Code in SAP RAP?
This is the continuation of my previous blog post on how to create SM30 like table maintenance T-Code in SAP RAP to replicate TMG-like Fiori applications using ABAP RAP. In the previous post, we created a RAP-based service where we could create, delete, and edit (multi-inline). In this blog, we will add a few validations and introduce a new action for duplicating existing records.
In our RAP based application, Following functionalities will be added:
- Approval for compulsory fields and copy records
- Duplicate a current record
Application in ADT Review mode will be look like as follow:
Error display when duplicate order is entered
When we select a few existing records and snap on the Duplicate As button, chose records in the table will be replicated.
When we select a few existing records and snap on the Duplicate As button, chose records in the table will be replicated.
Use Case 1 : Duplicate Order No.
While making records, Clients can give excess request no too. Application shouldn’t permit clients to save records with copy request no. To deal with this, we can add an approval in our RAP Business Item for Request hub.
1. New Validation in BDEF:
- We have made approval validateDuplicateID inside youngster hub Request for Conduct Definition ZPBDEMO_I_SINGLETON.
- Trigger time for approvals must be set as save for example at the point when we will attempt to save the substances, approvals will be set off (commonly during CheckBeforeSave in save succession stage)
- Trigger circumstances have been given utilizing trigger tasks make, update and trigger field OrderNo .
- Approval is characterized inside another gathering OrderValidations which has its own BIL class. It will assist our execution with being modularized appropriately for example all approvals will be carried out in a different execution class.
2. Add Validation in BDEF as Determine Action:
- For Draft empowered applications, It’s essential to incorporate approvals inside draft decide activity Plan,
- Draft decide activity must be characterized in the root hub where any remaining draft activities are characterized.
- We can likewise characterize approvals of kid substances utilizing hub name as:
Order ~ ValidateName
3. Implementation of Validation in Behavior Implementation:
3.1. Method Definition:
- Utilize a fast collaborator in BDEF for approval execution.
- Technique with approval name ValidateDuplicateID will be characterized with bringing in boundary keys which contains conditional key information for input BO examples.
- Since trigger activity for this approval is characterized as Make and Update, all the BO examples which are recently made or refreshed , will be given by keys structure.
- Keys part comprises of %tky which will have draft pointer and key fields of Request BO case.
3.2. Method Implementation:
With this approval, we want to check assuming there is any copy request no. entered by end clients in any of the records. Whenever found, a mistake message must be raised and the affected cell ought to be featured. Following advances must be carried out in this technique:
- Utilizing the keys boundary, we really want to get the root information. There is a relationship to root element from Request substance. We will utilize the READ EML articulation to get the root hub information.
- Presently, from this root table, we really want to get all the draft youngster entities(existing + recently entered records). There is a relationship to the kid substance in the root hub. We will involve this relationship in one more Perused EML proclamation to get all the Youngster occasions from the root hub:
- We really want to set up a temp table with Request no as the main section so we can sort and find in the event that there are any copy records with a similar request no.
- Right when duplicate Solicitation No is found, we truly need to fill Besieged structure with the restrictive key(draft marker + keys) of the looking at case.
- We additionally need to bring the blunder message up in the UI application. For that, we really want to fill Announced structure with following data:
%tky – Transactional key of the failed BO instance
%state_area – Unique state area(any string uniquely define the validation)
%msg – contains reference from RAP message wrapper
%path – required for child entities and pass transactional key of root
%element – field name to be highlighted.
Complete code for finding copy request and raising blunder message:
Use Case 2 : Copy Order
For fast information section, Duplicate usefulness can be utilized where client can choose a few existing records from the Request table and duplicate those to make new passages. It ought to just be conceivable in Alter mode. For that, another custom activity can be made in the RAP BO Request hub.
1. New Action in BDEF:
- New production line activity duplicate has been made in RAP BDEF ZPBDEMO_I_SINGLETON inside hub Request.
- Production line activities in RAP are utilized for making new BO occasions. It requires no result boundary. It will naturally take the result structure(MAPPED) as of the element wherein it is pronounced. For our situation, yield for duplicate activity will be of type element Request.
- We have added Element occasion with the goal that this activity is just empowered for draft examples (Alter mode).
- Activity is characterized inside another gathering Activities which has its own BIL class. It will assist our execution with being modularized appropriately for example all activities will be executed in a different execution class.
2. Action Implementation:
2.1. Method Definition:
There will be different methods defined for our action:
- Include Control technique
- Case Approval technique
- Business Rationale for Duplicate Activity technique
- Utilize a speedy collaborator in BDEF for activity execution.
- Bringing in Boundary Keys in every one of the strategies will contain conditional key information for input BO occurrences.
- By utilizing highlight control for activity duplicate, there are extra strategies characterized by the RAP system for taking care of field control values for duplicate activity. We can progressively empower/debilitate the activity.
- Highlight control technique will have coming about boundary RESULT which ought to be loaded up with value-based key of the occurrence and elements for activity control boundary ( empowered/incapacitated)
- Assuming that there are any approval in light of chosen BO occurrences, we can likewise carry out it in the technique get_instance_authorization.
- Keys part comprises of %tky which will have draft marker and key fields of Request BO occurrence.
2.2. Method Implementation:
- Feature Control
We really want to check assuming the ongoing BO example is in draft mode. Duplicate activity ought to possibly be empowered when BO occurrence is in draft(edit mode). For dynamic examples, duplicate activity ought to be incapacitated.
- We will utilize the READ EML explanation to get the request hub information utilizing the keys structure.
- At the point when the root hub is in alter mode, draft occurrences will be shown and all the items(Orders) will likewise be accessible in draft mode as it were. We will plan yield table Outcome by relegating the element control boundary for duplicate activity as empowered exclusively for draft cases.
- Copy
In this execution, we really want to make new draft occurrences for request hub by duplicating the information from chose hubs from keys structure.
- We will peruse total hub information for the chose record utilizing keys structure
- Declare internal table as Order Entity for create operation.
- RAP offers extraordinary information statement for EML.Since we are making new cases for Request hub, we want a table kind for Make activity.
- Likewise, in our BDEF, we have not characterized direct Make activity for Youngster entity(Order) yet It tends to be made utilizing relationship from root hub.
- We really want to plan Request information in the inside table lt_order_cba. Following parts must be filled:
%is_draft – should be marked as on
OrderSingletonID – key data for root entity(in our case, Its 1 always)
%target – table with Item Data.
%target Component:
%is_draft – should be marked as on
%cid – content id(unique string for each record)
data for Order record
- We really want to refresh BO Hub with this new Request records ready in table lt_order_cba. We really want to utilize the Change EML proclamation for make activity.
Complete code for Duplicate activity can be alluded as:
3. Use the Action in Projection Behavior Definition:
For activity to be uncovered in UI administration, we really want to uncover this activity in the projection BO as:
4. MetaData Extension in Projection CDS:
For activity to be displayed in the activity toolbar of the table Request, we want to add UI explanation @UI.LineItem
With these means, we will actually want to add a completely practical Duplicate As element like what we have utilized in SAP GUI exchange SM30.
In this blogpost, we have learnt:
- How to add and execute approvals in a RAP BO?
- Step by step instructions to add a custom activity ?
- How to deal with dynamic component control for activities?
How to involve EML in RAP based programming rationale? We have see by 2 models each for READ and Adjust EML.
In the following blog, we will explore how to create SM30 like table maintenance T-Code in SAP RAP by consuming this OData service in a List Report template-based Fiori application within Business Application Studio. Additionally, we will dive into some cool UI features using SAP Fiori tools.
YOU MAY BE INTERESTED IN
Cracking the Code: Your Earning Potential as a SAP ABAP Developer with 5 Years of Experience
OData in SAP ABAP: Streamlining Data Exchange and Integration
Power of Parallel Cursor in SAP ABAP