Skip to Content

Introduction:

Few day before I found an interesting Blog on SAP Java Connector outbound connection by Gregor wolf . https://weblogs.sdn.sap.com/pub/wlg/739 .  I then thought of creating Java Editor inside ABAP! I have created one using simple ABAP programs which will run using the JDK stored locally. The theme of this blog is to Create, Modify, Compile and Execute java programs inside ABAP particularly inside ABAP editor.

Concept:

Part1: Creating java File:

Part1 uses program zjavacreate.

Description:

 In Part 1 java file is created. Using the editor-call function for Itab we can call a blank text area in which we can write our java program. On saving the program in the editor area the Itab gets upload which is saved into the local disk as .java file using Function module GUI_DOWNLOAD.

image

                                      Getting Class File Name

image

               Editor with default PSVM

image

Code is entered for sample.java and saved (ctrl+s)

image

                                    Program logic for java file Creation.

  

Part 2

Part2 uses program zjavamodify

2.1: Modification.

Description:

   We can modify an existing java file. The java file is loaded into an Itab using Function module GUI_UPLOAD. The editor-call for this itab will fill the editor area with the existing java file which is modified and then saved back in the same location using GUI_DONLOAD.

Modify existing java file:

image

                   Sample File is selected for modification

image

    Sample.java is modified and saved

(Note the error System.out.println (“Modify here);

 

image

                                Program logic for modification

 

2.2: Compilation

Description:

    Compilation is the most important step. Initially a batch file is created with the content as in the following image. The jCompiler class file and class path is created and stored in the working directory of sapgui logon which is responsible for the creation of error and output file for the newly created java file. The Function module dsvas_ws_execute_50 is used to invoke the batch file which will create an error report file and an output report file. On execution the batch file appears and disappears.

image

                 Batch file in the notepad mode

image

                        Bat file pops up during compilation and disappears

image

                                   Program logic for compilation

2.3: Output Display

Description:

 The content of error or output file is put into an Itab using GUI_UPLOAD and displayed in the list area.

image

Sample. java with Error After correction and recompilation

image

                              Program logic for output display

Program zjavacreate:

Program zjavamodify:

Program jComplier.java:

Note: While using these programs be cautious in setting the path for java file and also store the jCompiler file, class path and class file in the sapgui logon working directory also your batch file need to be created in that directory only. Also please note that awt is not handled!

To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

      1. Community User
        This could easily be turned into an editor for several languages – not bad.

        Don’t forget there is a whole community here that might be willing to help you out!

        (0) 
      2. Sravya Talanki
        One tip is not to store the files in GUI.Instead try to store in APP server and try wether you can store the versions of java files just as abap versions.
        Just see if you can simulate the minor version of ABAP editor functionalities.
        This will be very useful when you want to test java and abap from the same stack.This will be very useful to the community with the WAS supporting JAVA and ABAP stacks.
        (0) 

Leave a Reply