Skip to Content

Objective: The objective of this blog is to elaborate on the procedure to change / edit an existing JAVA mapping using NWDS. The target audience for this blog is the SAP PI developers who are new to the concept of JAVA mapping.

  1. Find the imported archive (JAVA mapping) or the .jar file in ESR which you want to change and then download it to your desktop locally. The .jar file would normally contain two or more files, .class file (generated after the .java file is compiled in any JAVA IDE) and .java file which would normally contain the JAVA code for mapping logic.

Go to the Tools->Export Archive

/wp-content/uploads/2014/04/1_441915.png

2.      The .jar file is nothing but an archive like .zip which contains multiple files. To see the files within .jar file, use a tool like WinZip or 7-zip file manager.              Now open the 7-zip file manager and open the .jar files.

    Now by right clicking on the .java file, copy it from .jar archive to your desktop locally. This .java file can be opened using notepad also to view the           JAVA code for mapping.

/wp-content/uploads/2014/04/2_441916.png

3.      Now to edit the .java file, open NWDS, create a new JAVA project. Specify the project name and choose the relevant JRE (JAVA runtime environment          – specific to your machine).


   The NWDS would ask you to open the JAVA perspective for the code change. Click on yes and proceed.

/wp-content/uploads/2014/04/3_441929.png

/wp-content/uploads/2014/04/4_441930.png

/wp-content/uploads/2014/04/5_441931.png

/wp-content/uploads/2014/04/6_441941.png


4.    Copy the .java file (not the content) from your desktop and paste it on the src folder in your java project. Expand the src node within the project and                 the .java file can be seen underneath. Double click on the .java file to see the JAVA code on the right hand side window.

/wp-content/uploads/2014/04/7_441942.png

/wp-content/uploads/2014/04/8_441884.png

5.     Another way to import the .java file to your JAVA project is to import the .jar file directly in NWDS. To do this right click on the JAVA project and click                  on import. Then expand the general node and double click on Archive File.


  Browse the .jar file from your local desktop and click on finish.

/wp-content/uploads/2014/04/9_441943.png

/wp-content/uploads/2014/04/10_441947.png

/wp-content/uploads/2014/04/11_441948.png


6.     Now change the JAVA code in the .java file as per the change requirement and save it. A small red cross mark can be seen with the JAVA mapping               which means that the JAVA code has still some errors within.


  In my scenario I needed to import some external .jar libraries.

  Get access to these external .jar libraries and store them on your desktop locally.

  Right click on the JAVA project, Build path->Add External Archive

/wp-content/uploads/2014/04/12_441949.png


7.    Once added, the external .jar library can be seen under Referenced Libraries and the red cross mark disappears and is replaced by a yellow warning              sign meaning the java code doesn’t have any errors now and only has warnings.

/wp-content/uploads/2014/04/13_441953.png


8.      Ensure to check the option of Build automatically (which is default) from the project menu bar.

/wp-content/uploads/2014/04/14_441954.png


9.    Now export the .jar file for this JAVA project to your desktop which would again contain the newly generated .class file and the changed .java file.

Right click on the JAVA project, click on export, expand the JAVA node and click on JAR file.

/wp-content/uploads/2014/04/15_441955.png

/wp-content/uploads/2014/04/16_441956.png


10.    Ensure following while exporting the .jar file.

    1. The correct JAVA project is selected.
    2. The .classpath and .project files are unchecked (As they were not part of the original .jar file.  But these might be needed if they were part of the original .jar file which you downloaded from ESR as specified in step no 1.
    3. The checkboxes are ticked which would generate files for .class (first check box) and .java (third checkbox).
    4. Specify the target .jar file name which would be downloaded to your desktop.

/wp-content/uploads/2014/04/17_441900.png

11.    Click on finish and .jar file is downloaded on your desktop.

   Now go back to change mode of imported archive in ESR and import the new .jar file.

   Save and activate the imported archive.

   Also ensure to double click the .java file and verify whether the new JAVA code changes reflect there or not.

/wp-content/uploads/2014/04/18_441901.png

/wp-content/uploads/2014/04/19_441914.png

Hope it helps.

To report this post you need to login first.

1 Comment

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

Leave a Reply