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

Aus MattWiki
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
This entry contains SAP HANA specific code listings which can be executed in either XSJS or Node.js runtime within XS Advanced environment.
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]]
For basics knowledge on JavaScript language itself see [[JavaScript Basics]]


== Language Basics on XSJS Runtime ==
== Language Basics on Node.js Runtime ==


String: https://github.com/mattxdev/openSAPHANA/blob/master/xsjs/lib/xsjs/JavaScriptBasics/my-strings.xsjs
https://github.com/mattxdev/openSAPHANA/blob/master/srv/router/routes/JavaScriptBasics.js


Datum: https://github.com/mattxdev/openSAPHANA/blob/master/xsjs/lib/xsjs/JavaScriptBasics/my-dates.xsjs
Content:  


Arrays: https://github.com/mattxdev/openSAPHANA/blob/master/xsjs/lib/xsjs/JavaScriptBasics/my-arrays.xsjs
/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


JSON-Output: https://github.com/mattxdev/openSAPHANA/blob/master/xsjs/lib/xsjs/JavaScriptBasics/my-json.xsjs
== Text Bundles ==
 
Objects: https://github.com/mattxdev/openSAPHANA/blob/master/xsjs/lib/xsjs/JavaScriptBasics/my-objects.xsjs
 
Classes: https://github.com/mattxdev/openSAPHANA/blob/master/xsjs/lib/xsjs/JavaScriptBasics/my-classes.xsjs
 
== Language Basics on Node.js Runtime ==
 
The listings are basically the same as for XSJS but they are implemented to be run on Node.js / XSA :
 
https://github.com/mattxdev/openSAPHANA/blob/master/srv/router/routes/JavaScriptBasics.js


== Text Bundles ==
'''Lessons Learned'''


* Use TextBundle module '''@sap/textbundle"''';
* Use TextBundle module '''@sap/textbundle"''';
Zeile 32: Zeile 36:


https://github.com/mattxdev/openSAPHANA/blob/master/srv/router/routes/textBundle.js
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:
* '''Create Excel:''' https://github.com/mattxdev/openSAPHANA/blob/master/srv/router/routes/excel.js
* '''Create and parse XML:''' https://github.com/mattxdev/openSAPHANA/blob/master/srv/router/routes/xml.js
* '''Create ZIP:''' https://github.com/mattxdev/openSAPHANA/blob/master/srv/router/routes/zip.js


== Object Oriented JavaScript ==
== Object Oriented JavaScript ==

Version vom 10. November 2020, 12:26 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

WebSockets