This documentation covers the details of Using the CL_JAVA_SCRIPT Class in ABAP programming
Using the CL_JAVA_SCRIPT Class
The areas where the CL_JAVA_SCRIPT class is used can be split up as follows:
Executing JavaScript Programs
You can use the CL_JAVA_SCRIPT class to execute JavaScript programs that, for example, have been loaded from external resources or programmed in an Editor you have written yourself: The following are the methods you use, in the sequence in which they are called:
- CREATE to create a JavaScript context
- CREATE to compile a JavaScript source in the current context
- EXECUTE to execute a compiled JavaScript
- EXECUTE to delete a compiled JavaScript from the context
Methods 2 to 4 are combined in the method EVALUATE.
Binding between JavaScript and the ABAP program
JavaScript programs can access data objects and objects in ABAP programs. This technique is based on two methods:
BIND allows you to link variables and objects in JavaScript with data objects and references to objects in ABAP. Changes made in the JavaScript program also change the objects in ABAP. You can also bind objects from ABAP objects directly using BIND_INSTANCE.
You can also access the public instance attributes of bound objects and call public instance methods.
As well as binding JavaScript objects to ABAP objects, you can set or get values from JavaScript objects directly using the SET and GET methods respectively.
Debugging
If you want to include and test JavaScript programs in an ABAP development environment, the following methods are available to support you:
Handling breakpoints
Executing programs step by step
Evaluating the call stack
Example
The ABAP program DEMO_JAVA_SCRIPT_MINI_EDITOR from the Examples Library (transaction ABAPDOCU) is an example of a basic JavaScript Editor, where you can edit, execute, and test JavaScript programs. The program was created using ABAP exclusively and uses the CL_JAVA_SCRIPT class. This mini-editor is only a demonstration for the purposes of this documentation, but it shows what you can do using CL_JAVA_SCRIPT in ABAP.
Related 10 ABAP and JAVA Tutorials
Most readed SAP Tutorials
- WRITE - Output to a list ( SAP ABAP Keyword)
WRITE ( Output to a list ) is a keyword used in SAP ABAP programming.This tutorial covers its introduction & syntax details. - List of SAP HR TABLES and Infotypes tables
Detailed full list of tables and infotypes used in SAP HR module. - List of SAP MM Transaction codes
This documentation covers the details of SAP MM Transaction codes - SELECT-OPTIONS ( SAP ABAP Keyword)
SELECT-OPTIONS is a keyword used in SAP ABAP programming.This tutorial covers its introduction & syntax details. - FI Accounts Receivable and Accounts Payable | SAP FI PDF manual
The following topics are an introduction to the Accounts Receivable and Accounts Payable application components. - SELECT clause ( SAP ABAP Keyword)
SELECT clause is a keyword used in SAP ABAP programming.This tutorial covers its introduction & syntax details. - SAP MM Process Flow
The typical procurement cycle for a service or material consists of the following phases:
Latest Added SAP documents
- 9KE9 Transaction code
Details about SAP transaction code 9KE9 - 9KE8 Transaction code
Details about SAP transaction code 9KE8 - 9KE7 Transaction code
Details about SAP transaction code 9KE7 - 9KE6 Transaction code
Details about SAP transaction code 9KE6 - 9KE5 Transaction code
Details about SAP transaction code 9KE5 - 9KE4 Transaction code
Details about SAP transaction code 9KE4 - 9KE3 Transaction code
Details about SAP transaction code 9KE3 - 9KE2 Transaction code
Details about SAP transaction code 9KE2 - 9KE1 Transaction code
Details about SAP transaction code 9KE1 - 9KE0 Transaction code
Details about SAP transaction code 9KE0