Node.js Code Samples (SAP HANA): Unterschied zwischen den Versionen

Aus MattWiki
Keine Bearbeitungszusammenfassung
Zeile 69: Zeile 69:
<listing-here>
<listing-here>


== Exits for OData V4 Services ==
<listing-here>


[[Category:JavaScript]]
[[Category:JavaScript]]
[[Category:SAP]]
[[Category:SAP]]
[[Category:HANA]]
[[Category:HANA]]

Version vom 10. November 2020, 17:46 Uhr

This entry contains SAP HANA specific JavaScript listings for Node.js runtime within XS Advanced environment.

For basics knowledge on JavaScript language itself see JavaScript Basics

Language Basics on Node.js Runtime

https://github.com/mattxdev/openSAPHANA/blob/master/srv/router/routes/JavaScriptBasics.js

Content:

/dates - Date processing
/array - Array processing
/json - JSON JavaScript Object Notation processing
/objects - JavaScript Objects
/strings - String processing
/classes - JavaScript Classes
/promises - Promises
/constants - Constants
/blockScoped - Block-Scoped Variables and Functions
/parameterDefaults - Parameter Defaults
/parameterMultiple - Handling unknown number of input parameters easily
/unicode - Unicode Strings and Literals
/numFormat - International Number Formatting
/currFormat - International Currency Formatting
/dateFormat - International Date/Time Formatting

Text Bundles

Lessons Learned

  • Use TextBundle module @sap/textbundle";
  • Get locale from Client Browser Headers
  • Store language specific text files in _i18n subfolder
  • Create instance bundle of type TextBundle
  • Get text with getText Method of bundle instance

https://github.com/mattxdev/openSAPHANA/blob/master/srv/router/routes/textBundle.js

Open Source Modules for Node.js

How to utilize open source Node.js modules for:

Object Oriented JavaScript

  • Constructor
  • This-Pointer
  • Static methods
  • Instance methods
  • Inheritance and extending methods

<listing-here>

WebSockets

By default Webaccess is initiiated from the browser / client side by sending a request to the server in order to receive a result.

In use cases where one would like to update the data on the client side when something changed on server side the resulting periodical polling would not be efficient.

With Web Sockets the server can initiate the communication with one or even multiple clients at a time. This enables BI and Dashboard applications where the server can send new data to the client as soon as is has changed in the database.

Example: Chat application


<listing-here>


Exits for OData V4 Services

<listing-here>