In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
I believe that through Jerry's previous article 30 minutes to develop a Restful ABAP Programming model to support the addition, deletion, modification and query of the Fiori application, we must have a basic understanding of the Restful ABAP Programming model, right?
Recall that in the previous article, we created a Z table in the SAP cloud platform ABAP programming environment, then created a CDS view based on this custom database table, created a Service Definition based on this view, exposed view as a service, and then added, deleted, modified and queried the Z table through Behavior Definition.
In the first article, a friend left a message asking how to deploy Fiori applications generated through the RAP model to the cloud. This friend forgot that Jerry operates on the SAP cloud platform ABAP environment from beginning to end, so the generated Fiori application is also available directly on the cloud.
Double-click TravelProcessor in Service Binding or select Open Fiori Elements App Preview from the right-click menu to access the Fiori application.
Consultants with a little experience understand that the function of adding, deleting, changing and checking a model cannot meet the actual needs of customers. In SAP Cloud for Customer, development consultants can create script files such as beforeSave and afterModify in Cloud Application Studio and implement business logic. Jerry has also introduced that they are equivalent to determination created in the S/4HANA BOPF framework.
In addition to the above logic that can only be triggered at a specific point in time at run time, the Action mechanism provides a more liberal mechanism for writing business logic. Reflected in UI, Action logic is generally triggered by the UI button.
Validation is easier to understand-custom data validation logic.
This paper introduces Action and Validation.
To introduce how to develop Action,Jerry under the Restful ABAP Programming model, you need to add a field to the SFLIGHT table created in the first article to represent the flight reservation status, and develop an Action that can be modified when it is called.
(1) add an OVERALL_STATUS field to the database table:
Of course, on the corresponding CDS view, you also need to configure this field to the UI through the @ UI related annotations. This field of view is displayed on the table control of the search results and on the flight details page by annotating lineItem and identification, respectively. Specify the label displayed on the UI through the label, and bind the status field to an Action named acceptTravel through the annotated dataAction.
After reactivating CDS view, we can see on the toolbar that the label text maintained by label in CDS view is Accept Travel:
Because of the lack of implementation, clicking at this time has no effect.
(2) in the declaration section of Behavior Definition, add the following three lines of code:
Action (features: instance) acceptTravel result [1] $self;validation validateCustomer on save {field customer_id;} validation validateDates on save {field begin_date, end_date;}
In addition to defining an Action, the above code declares two Validation that trigger the check logic when a particular field changes and is saved, and the field name is maintained in curly braces.
The rest is implemented by ABAP programming. In the ABAP implementation class of Behavior Definition, declare the following ABAP class methods to implement the definition in Behavior Definition.
First, let's take a look at the implementation of Action, which is located in the ABAP method SET_STATUS_COMPLETED:
Set the status field of the flight reservation record specified by the input parameter travel_id to A-Accepted.
Now I select the record with ID 22 and click the Accept Travel button:
After clicking, the status is successfully set to A:
Add to that the check of the flight date: if the flight end date is before the start date, it is obviously unreasonable and an error message needs to be played.
Lines 87 to 91 read the flight information contained in the input parameters into the inner table lt_travel_result, and then line 95 compares the end date with the start date. If the latter is earlier than the former, enter the IF branch at line 97 and click an error message to UI.
The error message is still the same as traditional ABAP programming, defined by the ABAP Message class:
Now, before maintaining the end date as the start date, you see the expected error message when you save it:
So far, our SFLIGHT model not only adds, deletes, modifies and searches, but also adds the functions of Action and Validation.
In the next article in this series, Jerry will talk about simple debugging of Restful ABAP Programming model-based applications in the SAP cloud platform ABAP programming environment.
For more original Jerry articles, please follow the official account "Wang Zixi":
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.