Quantcast
Channel: SCN : All Content - ABAP for SAP HANA
Viewing all articles
Browse latest Browse all 831

Fiori/UI5 + CDS + BOPF - For beginners Part 2

$
0
0

This blog is on continuation to  Part 1.


In this part we shall create the BOPF action and display the sale order scenario in the Fiori App using Smart Template.


For the BOPF action, go to BOPF Business Object ZDEMO_I_SALESORDER  from Tcode BOBX. Click on change mode. Under the Node Elements, traverse to node ZDEMO_I_SALESORDER and select Action element. Right Click on Action and Click "Create".

 

BOPF Action create.jpg

BOPF Action create 2.JPG

 

Go to Class Builder and create the class ZCL_A-DEMO_SALESORDER.

Action class 1.jpg

Action class 2.JPG

Implement the method Execute.

Action class 3.jpg

 

Save and Activate. The code can be found in the attachment. Basically the code reads the selected sales order and then change the corresponding BOPF node instance with the new lifecycle status value.



Okay we are done with all the backend stuff.


Lets display this using as Fiori App using Smart Template.


If all the Web IDE set up explained in Part 1 is fine, we can proceed. Go to Web IDE.  Click on File.

Create app 1.jpg


Click on File --> New --> Project from template

Smart template 2.jpg

On next screen, Select Service Catalog. Click on the dropdown and select your backend system.

Smart template 3.jpg


Once the backend system is selected, OData services in the system are listed. Look for our OData generated service  ZDEMO_C_SALESPRDER_CDS  ie <final consump CDS view>_CDS

Smart template 4.jpg


Select the Odata service. Click on Show details to check if the OData is up and running

Smart template 5.jpg


Here we see the OData service is running fine.

Smart template 6.jpg

Click on Next. In the Next screen the system will read and the OData service metadata file and also the CDS Annotations file(final consumption CDS). These are necessary to display the app.


The annotations in the final consumption CDS view (ZDEMO_C_SALESORDER) contain the UI line position which shall form the basis for field positioning in the app.


Smart template 7.jpg


Click Next. In OData collection, select the consumption view(where OData was published). Our final consumption view has an association to Item. Hence here the OData navigation refers to "_item".


Smart template 8.jpg


Click Next or Finish and its done !

SMART template 9.jpg


The project name is visible under the workspace. Right click on the project. Click Run as -> Web Application

smart template 10.jpg


If prompted, choose flp sandbox.html. These are used to for test data basically.

Smart template 11.jpg


Click Ok. If prompted, for login credentials, enter the backend system details. Finally the app icon is displayed in the Catalog Tile.

Smart template 12.jpg


Click on the App. If prompted for the login credentials, enter the back-end system details.


Click on Go in the app to display the sales order records.

App 1.jpg



Select the record by selecting the radio button and clicking. The navigation happens to the detail screen.

App 3.jpg


Click on Edit. For example, lets update the Gross Amount and click on Save.

App 4.jpg


The Gross amount value is edited to 3500 INR.  Click Save. 

"Object saved" message appears.  Go back to previous app page.


The new Gross amount is reflected here.

App 5.jpg

The Edit is excuted in BOPF via CDS and the particular BOPF node instance is edited. This is achieved as we have given the create/update/delete enabled in the final consumption CDS which delegates to the Basic CDS and then to BOPF.

BOPF Update.JPG


Create a new record.

In the basic CDS ZDEMO_I_SALESORDER, we have maintained the annotation @objectmodel.create enabled: true which means the create logic is taken care by BOPF.


Click on + icon in the app to create a new sales header record.


Enter the values and click on Save.

Create record 3.jpg

 

An object saved message appears. The record is saved. Go to previous page and see the newly created record.

Create record 4.jpg


The delete icon works the same way. Just select an record and click on delete.



Change the sales order Lifecycle status

Select an sales order which has initial status and click on icon "Set Lifecycle Status to Paid". The code which we have written for the BOPF Action is triggered and the status is changed to P.

Change status 1.jpg


Lifecycle status has changed to P(Paid)

change status 2.jpg


That's it. Hope this is helpful.



Viewing all articles
Browse latest Browse all 831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>