It has been really a while that I blogged on sdn due to the hectic schedules of my marriage:-)). Finally, I pulled up my socks to write one, which was an awaiting one.

Going to the flash back of my XI implementation I learn by heart that we need to download a Textpad /SAP NW studio for deploying /developing java mapping programs and there are lot of security/logistic concerns to do so. We finally used Text pad for whatever reasons and I used to feel XI need to come up with editors for all types of mapping, as that would be ideal.

This is the driving factor, which has made me to blog today. I have developed a proto java editor in the integration stack of XI and exposing it to sdn folks. It is not a user-friendly and enhanced java editor but indeed a simple one to start with. Definitely it can form the base for developing a more advanced one.

There is an excellent blog “Java-Editor Inside ABAP” by Vijay. It is definitely a great one but there are few bottle necks of the approach as described below:

1.Installation of JDK/JVM on every client PC’S which might not be feasible as it is an overhead.

2.Editor-call for ITAB is used which can take only 72 characters in a single line.

3.Files are stored on the client’s machine and so it is not integrated with the App Server.

Probably that is the solution for WAS < 6.20.But we can have a more enhanced one for WAS>= 6.20 as we have JVM installed on WAS and so we use it.

New Approach:

1.Create a Folder in WAS for storing java files and give the appropriate permissions for the folder. You can view the directory structure using AL11 transaction.

2.Create/Modify the java files using the report ZJAVA_EDITOR_IN_XI that provides an interface to save the java files in app server. You use the same SE38 editor for creating/modifying java code.

3.Check the jdk/jvm directory on your WAS through AL11 in ‘/usr’ directory and confirm with basis about the right directory where jdk/jvm is installed.

4.Create 2 commands

zjava

and

zjavac

in SM69 transaction. In place of operating system command give “/usr/< Your WAS Java Folder Path> /bin/java” for zjava and “/usr/< Your WAS Java Folder Path> /bin/javac” for zjavac commands. You can test this command using SM49 transaction. These commands are used from ZJAVA_EDITOR_IN_XI report in the FM SXPG_COMMAND_EXECUTE for executing/compiling the java programs.

Pictural Representation

Create Java File:

Modify Java File:

Compile Java File:

Execute Java File:

Source Code:

&—-


*& Report  ZJAVA_EDITOR_IN_XI                                          *

*&                                                                     *

&—-


*&                                                                     *

*&                                                                     *

&—-


REPORT  zjava_editor_in_xi.

*************Data Declarations***************************************

PARAMETERS:p_name(20) OBLIGATORY LOWER CASE.

PARAMETERS :p1 RADIOBUTTON GROUP jfnc.

PARAMETERS :p2 RADIOBUTTON GROUP jfnc.

PARAMETERS :p3  RADIOBUTTON GROUP jfnc.

PARAMETERS :p4  RADIOBUTTON GROUP jfnc.

****Path of the appserver where files have to be stored****************************************

DATA: class_path(100)  VALUE ‘/local//’.

**************************************************************************************************

DATA msg(100).

TYPES: line TYPE string.

DATA: itab TYPE STANDARD TABLE OF line.

DATA line TYPE string.

************************************************************************

********Creates Java files in the path specified******************************

IF p1 = ‘X’.

  CLEAR itab[].

  CONCATENATE ‘Class’ p_name ‘{}’ INTO line SEPARATED BY space.

  APPEND line TO itab.

  INSERT REPORT ‘ZJAVTEST’ FROM itab PROGRAM TYPE  ‘I’.

  EDITOR-CALL FOR REPORT ‘ZJAVTEST’.

  CLEAR itab[].

  READ REPORT ‘ZJAVTEST’ INTO itab.

  CONCATENATE class_path p_name ‘.java’ INTO class_path.

  OPEN DATASET class_path FOR OUTPUT MESSAGE msg  IN TEXT MODE  ENCODING DEFAULT .

  IF sy-subrc <> 0.

    WRITE / msg.

    STOP.

  ENDIF.

  LOOP AT itab INTO line.

    TRANSFER line TO class_path.

  ENDLOOP.

  CLOSE DATASET class_path.

  DELETE REPORT ‘ZJAVTEST’.

ENDIF.

***********************************************************************************

********Modify Java Files in the path specified*********************************

IF p2 = ‘X’.

  CLEAR itab[].

  CONCATENATE class_path p_name ‘.java’ INTO class_path.

  OPEN DATASET class_path FOR INPUT MESSAGE msg  IN TEXT MODE  ENCODING DEFAULT .

  IF sy-subrc <> 0.

    WRITE / msg.

    STOP.

  ENDIF.

  DO.

    CLEAR line.

    READ DATASET class_path INTO line.

    IF sy-subrc <> 0.

      EXIT.

    ELSE.

      APPEND line TO itab.

    ENDIF.

  ENDDO.

  INSERT REPORT ‘ZJAVTEST’ FROM itab PROGRAM TYPE  ‘I’.

  EDITOR-CALL FOR REPORT ‘ZJAVTEST’.

  IF sy-subrc EQ 0.

    READ REPORT ‘ZJAVTEST’ INTO itab.

    DELETE DATASET class_path.

    OPEN DATASET class_path FOR OUTPUT MESSAGE msg  IN TEXT MODE  ENCODING DEFAULT .

    IF sy-subrc <> 0.

      WRITE / msg.

      STOP.

    ENDIF.

    LOOP AT itab INTO line.

      TRANSFER line TO class_path.

    ENDLOOP.

    CLOSE DATASET class_path.

    DELETE REPORT ‘ZJAVTEST’.

  ENDIF.

ENDIF.

*****************************************************************************************

*****************Compiles Java files***************************************************

IF p3 = ‘X’.

  DATA : i_comp LIKE TABLE OF btcxpm WITH HEADER LINE.

  DATA add_par_c LIKE sxpgcolist-parameters.

****Location of java file is given in add_par_c.

  CONCATENATE class_path p_name ‘.java’ INTO add_par_c.

  CALL FUNCTION ‘SXPG_COMMAND_EXECUTE’

    EXPORTING

      commandname                   = ‘ZJAVAC’

      additional_parameters         = add_par_c

       TABLES

      exec_protocol                 = i_comp

    EXCEPTIONS

      no_permission                 = 1

      command_not_found             = 2

      parameters_too_long           = 3

      security_risk                 = 4

      wrong_check_call_interface    = 5

      program_start_error           = 6

      program_termination_error     = 7

      x_error                       = 8

      parameter_expected            = 9

      too_many_parameters           = 10

      illegal_command               = 11

      wrong_asynchronous_parameters = 12

      cant_enq_tbtco_entry          = 13

      jobcount_generation_error     = 14

      OTHERS                        = 15.

  .

  IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ELSE.

    LOOP AT i_comp.

      WRITE:/ i_comp-message.

    ENDLOOP.

  ENDIF.

ENDIF.

*************************************************************************

************Executes Java Files*****************************************

IF p4 = ‘X’.

  DATA : i_exec LIKE TABLE OF btcxpm WITH HEADER LINE.

  DATA add_par_e LIKE sxpgcolist-parameters.

****Location of class file is given in add_par_e.

  CONCATENATE class_path p_name  INTO add_par_e.

  CALL FUNCTION ‘SXPG_COMMAND_EXECUTE’

    EXPORTING

      commandname                   = ‘ZJAVA’

      additional_parameters         = add_par_e

     TABLES

      exec_protocol                 = i_exec

    EXCEPTIONS

      no_permission                 = 1

      command_not_found             = 2

      parameters_too_long           = 3

      security_risk                 = 4

      wrong_check_call_interface    = 5

      program_start_error           = 6

      program_termination_error     = 7

      x_error                       = 8

      parameter_expected            = 9

      too_many_parameters           = 10

      illegal_command               = 11

      wrong_asynchronous_parameters = 12

      cant_enq_tbtco_entry          = 13

      jobcount_generation_error     = 14

      OTHERS                        = 15.

  .

  IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
LOOP AT i_exec.
WRITE:/ i_exec-message.
ENDLOOP.
ENDIF.

ENDIF.
*************************************************************************

Execution Snapshot :

Text Eléments:

Create Java File: User selects to create Hello World Java file.

Report calls ABAP Editor with an empty template class HelloWorld {}.

User adds a comment and press save button, which saves the java file in the app server.

Modify Java File: User selects to modify Hello World Java file.

Report calls ABAP Editor with the code that is created in previous step.User adds main method and saves.

Execute Java Files: User compiles the java files using compile option and then clicks execute.

Output:

Probably this might be useful when you need to do use java in ABAP Proxies and also if we enhance the editor in a well-defined manner we can get more benefit out of it.

New NetWeaver Information at SAP.com

Very Helpfull

User Rating: Be the first one !