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:
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.