SAP PO for Beginners Part – 14 – Introduction to Java Mapping with Examples in SAP PO – Part – 1

This blog will serve as an introduction to Java Mapping with Examples in SAP PO, helping you learn how to write, validate, and export Java mappings using SAP NWDS software.

So, underneath is the substance we will be intricate in this instructional exercise:

  • Overview
  • JAVA PROGRAM -1 – Copy the contents from input to output file
  • Import Java Mapping libraries
  • Write a simple Java Program on copy the contents from input to output file
  • Compile Java Program
  • Extracting as JAR file
  • Import JAR file and test run Operation Mapping
  • JAVA PROGRAM -2 – Copy the contents from input to output by reading line-by-line
  • JAVA PROGRAM – 3 – Adding traces to java program on copying contents

1. Overview:

Here, we will foster java programs in NWDS programming, approve it and product it as a Container record for bringing in it in ESR vault as a Java Planning document in Activity Planning. Java Planning is a Java based program that is written in NWDS Manager with Java Planning Libraries and afterward transferred in the ESR. Java Planning is elective way to deal with composing Graphical Message Planning/XSLT Planning.

We should get everything rolling.

2. JAVA PROGRAM – 1 – Copy the contents from input to output file:

Prior to continuing with the production of Java Undertaking, one need to arrangement NWDS programming with the JAVA JDK document. Allude to the arrangement present on NWDS on PI:

Click on Document – > NEW – > Java Task

Give a substantial Undertaking name. Under JRE, select “Use project explicit JRE – JDK 1.8” and click on Straightaway and FINISH.

You can see under the work area; new envelope will be made with project name as organizer name.

Within it contains two primary envelopes, Src and Container organizer which holds the source code and receptacle organizer contains the class document once you characterize new class.

To make another class, Right snap on the venture name – > New – > Class

Class name will be same as undertaking name. Tick “public static void primary”. When done, this is the manner by which starter format seems to be.

3. Import Java Mapping libraries

Whenever you have made the Java Task, subsequent stage is to add the Java Planning Libraries to your venture. For that, right snap on the .java document – > Fabricate Way – > Arrange Assemble Way

Under libraries tab – > click on Add Outside Containers button and import the java planning library records. Click on Apply and Save.

For our sap java planning point of view, we are including those Container records. Once imported, you can see those records in the venture sheet – > Referred to libraries.

4. Write a simple Java program on copy the contents from input to output file

Presently we will compose a basic Java Program which will peruse the items in the information document or from the info field and duplicate for what it’s worth to yield record or result field.

First thing we need to do is, broaden the class Conceptual change. This class is the expansion of the planning program that you as of now have is important for graphical planning. As you are utilizing dynamic strategy, we really want to abrogate the change technique.

@Override
public void transform(TransformationInput arg0, TransformationOutput arg1) throws StreamTransformationException {
	try{
	  execute(arg0.getInputPayload().getInputStream(),arg1.getOutputPayload().getOutputStream());
	}
       catch(Exception ee){

          throw new StreamTransformationException(ee.toString());
	}
}

The principal strategy that will be executed by PI is the change technique at runtime. This change technique will call the execute as displayed in the code above. We should characterize the execute public technique.

The explanation EXCEUTE technique is added is for In reverse Similarity. If you have any desire to run this code in XI framework, then execute is the technique which it anticipates. Thus, we are including it. It’s in every case great to compose the code in attempt and catch block to get the exemptions and showing it in logs.

public void execute(InputStream in, OutputStream out) throws StreamTransformationException {
	try{
	   int buffer;  
           // variable for holding the copied contents
	   while((buffer = in.read()) != -1) { 
           // checking if chars reached end of line
	   out.write(buffer);
	   }
	out.flush();
	}

        catch(Exception ee)
       {
         throw new StreamTransformationException(ee.toString());
       }
}

Then, we will focus on adding contents in principal technique.

public static void main(String[] args) {
	try{
	   FileInputStream fin = new FileInputStream("inputFile.txt");
	   FileOutputStream fout = new FileOutputStream("outputFile.txt");
			
	   JM_FirstJavaMapping instance = new JM_FirstJavaMapping();
	   instance.execute(fin, fout);
// passing the input file as IN to execute method and performing operations in execute method. Same way output filename is also passed for writing the copied contents.
	}
        catch(Exception ee)
        {
	  ee.printStackTrace();
	}
}

IMPORT STATEMENTS OF LIBRARIES/PACKAGES:

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;

5. Compile Java Program:

While in Java document, in the menu bar, click on Run – > Run. Remember to put the inputFile.txt with some example contents put on it.

As we haven’t referenced the way of the document where it is situated in the java code, it will default get set in the work area organizer.

Java Program is working fine.

GITHUB REPO:

6. Exporting as JAR file:

For transferring the .container document to Drain PO ESB, we really want to get the .container record. In the container envelope, you can see the class record. Right snap on it – > 7zip – > Add to “JM_First… 7z”. It will get packed. Change the augmentation from .Flash to .Container.

If necessary, you can duplicate the .java document and spot it in .Compress record and afterward change the expansion to .Container

7. Import JAR file and test run Operation mapping:

Make a new namespace and under it, make IMPORTED Documents.

Give the imported document name same as Class Name. Import the record.

We will make test information type with one field and check whether the items in the information field gets replicated to yield field.

Data type:

Message Type:

SI – Outbound:

SI – Inbound:

Message Mapping:

NA. No need of message planning as we are utilizing Java planning for the change.

Operation Mapping:

Testing:

Operation Mapping -> Test tab

JAVA PROGRAM – 2 – Copy the contents from input to output by reading line-by-line:

Scenario:

Compose a Java Program on perusing the items in the record line by line and duplicate it to the result document.

The distinction between prior program and that’s what this program is, in program 1, the code will duplicate the items without perusing line by line and gluing it in yield document. However, in this program 2, we can peruse the items line by line, so that assuming there is any change required in the approaching lines, it tends to be done which is unimaginable in Program 1.

The change technique and the primary strategy will be the equivalent on the grounds that change strategy just calls the execute strategy by passing contentions and void strategy makes another article and passes it to execute strategy.

Execute method:

public void execute(InputStream in, OutputStream out) throws StreamTransformationException{
	try {
	   StringBuffer sourcePayload = new StringBuffer();
	   BufferedReader docInput = new BufferedReader(new InputStreamReader(in));			
			
	   String inputLine = "";
			
	   while( (inputLine = docInput.readLine() ) != null ) 
           {
	      sourcePayload.append(inputLine + "\r\n");
	   }
			
	   out.write( new String(sourcePayload).getBytes("UTF-8") );
	   out.flush();			
			
        }catch(Exception ee) 
        {
	   throw new StreamTransformationException(ee.toString());
	}		
}

Same way, place an info document and incorporate the java program to check whether its functioning true to form.

GITHUB REPO:

JAVA PROGRAM – 3 – Adding traces to java program on copying contents:

Scenario:

In this program we will figure out how to compose data, troubleshoot, and cautioning messages from Java planning, such as following the execution of the java program. Follow is only the review logs that we can see when the code is executed at runtime in ESB/AEX.

There are three sorts of follows:

Data

Troubleshoot

Caution

We will utilize a similar existing Java Program-2 which peruses the document line by line and add follows to it.

Make another Java Undertaking and class. Add Outside Containers. Duplicate the current Java Program and glue it in recently made Java document. Supplant the Class name.

Adding traces to Java Program:

GITHUB REPO:

Import the Container record to Activity planning and Actuate it.

Activity Planning – > Test tab – > Glue an example test lines of string type and change it to see the hints of the result.

Trust you loved it. Assuming you feel somewhat skeptical, questions or ideas for us, kindly put your remarks underneath.

 

YOU MAY LIKE THIS

SPTA Parallel Processing Framework in ABAP

Power of Parallel Cursor in SAP ABAP

SAP ABAP CRM Tips

Free

SAP SD S4 HANA

SAP SD (Sales and Distribution) is a module in the SAP ERP (Enterprise Resource Planning) system that handles all aspects of sales and distribution processes. S4 HANA is the latest version of SAP’s ERP suite, built on the SAP HANA in-memory database platform. It provides real-time data processing capabilities, improved…
₹25,000.00

SAP HR HCM

SAP Human Capital Management (SAP HCM)  is an important module in SAP. It is also known as SAP Human Resource Management System (SAP HRMS) or SAP Human Resource (HR). SAP HR software allows you to automate record-keeping processes. It is an ideal framework for the HR department to take advantage…
₹25,000.00

Salesforce Administrator Training

I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.
₹25,000.00

Salesforce Developer Training

Salesforce Developer Training Overview Salesforce Developer training advances your skills and knowledge in building custom applications on the Salesforce platform using the programming capabilities of Apex code and the Visualforce UI framework. It covers all the fundamentals of application development through real-time projects and utilizes cases to help you clear…
₹25,000.00

SAP EWM

SAP EWM stands for Extended Warehouse Management. It is a best-of-breed WMS Warehouse Management System product offered by SAP. It was first released in 2007 as a part of SAP SCM meaning Supply Chain Management suite, but in subsequent releases, it was offered as a stand-alone product. The latest version…
₹18,000.00

Oracle PL-SQL Training Program

Oracle PL-SQL is actually the number one database. The demand in market is growing equally with the value of the database. It has become necessary for the Oracle PL-SQL certification to get the right job. eLearning Solutions is one of the renowned institutes for Oracle PL-SQL in Pune. We believe…
Free

Pega Training Courses in Pune- Get Certified Now

Course details for Pega Training in Pune Elearning solution is the best PEGA training institute in Pune. PEGA is one of the Business Process Management tool (BPM), its development is based on Java and OOP concepts. The PAGA technology is mainly used to improve business purposes and cost reduction. PEGA…
₹27,000.00

SAP PP (Production Planning) Training Institute

SAP PP Training Institute in Pune SAP PP training (Production Planning) is one of the largest functional modules in SAP. This module mainly deals with the production process like capacity planning, Master production scheduling, Material requirement planning shop floor, etc. The PP module of SAP takes care of the Master…
₹24,999.86

SAP Basis Training in Pune

SAP BASIS Module Course Content (1) Hardware and Software Introduction (i) Hardware (a) Hardware Introduction (b) Architecture of different Hardware devices (ii) Software (a) Software Introduction (b) Languages and Software Development (c) Introduction to OS (d) Types of OS (iii) Database Concepts (a) Introduction (b) Database Architecture and concepts (c)…
₹30,000.00

Courses For Sap HANA Administration Training

Curriculum Details  SAP HANA Administration SAP HANA Introduction SAP HANA Introduction SAP HANA Information Sources Installation Preparation SAP HANA Sizing   Linux Operating system requirements SAP HANA Installation Introduction to SAP HANA Lifecycle Management tools Describing Advanced Installation options Explaining a Distributed system SAP HANA Architecture SAP HANA Architecture and Technology…
₹30,000.00

Courses For Sap BW On HANA Training

Business Warehouse (BW) is SAP’s data warehousing application; it uses an SAP NetWeaver application server, but can run on many different databases. Improvements come with each version of Courses for sap BW on HANA training, but a really big jump in functionality comes when SAP BW is installed on the…
₹30,000.00

Courses For Sap Hana Simple Logistics Training

SAP SAP HANA simple logistics is also known as HANA enterprise management. Different area of business is combined in this suit itself like HANA enterprise-management helps in faster and efficient processing of business data in the area of logistics, supply chain, procurement, user experience, sales, partner management. So Course for…
₹30,000.00

Courses For Sap ABAP On HANA Training

ABAP remains a key language as many SAP business applications and custom developments are written in ABAP, with Courses for sap ABAP on HANA training there are numerous improvements. The ABAP language, which allows writing streamlined ABAP code and benefit from SAP HANA. SAP HANA is a relational DBMS in SAP…
₹30,000.00

Courses For Sap Hana Training

SAP HANA is the latest ERP Solution from SAP, which is a combination of Hardware and Software. HANA has unprecedented adoption by the SAP customers. courses for SAP HANA training institutes. SAP HANA is the latest, in-memory database, and platform which can be deployed on-premises or cloud. SAP HANA is a…
₹25,000.00

Oracle HRMS (Human Resource Management System) Course Details, Syllabus and Fees

Oracle Applications R12 HRMS is one of the most demanded applications by most organizations. It is the core application possess by the ERP system. The core objective of the organization to implement Oracle R12 HRMS is to organize the entire activates of human resources management. An Elearning solution is well…
₹25,000.00

Oracle Apps SCM (Supply Chain Management) Training & Certification Courses

Elearning solutions provide training suit for Oracle Apps R12 SCM with training from industry experts. The organizations are adopting Oracle’s supply chain management cloud as they deliver the insights, visibility, and capabilities for organizations’ management. Oracle Apps R12 SCM allows the industry to create own intelligent supply chain. Hence, it…
₹25,000.00

Oracle Apps R12 Technical Training Course and Module Overview

Oracle Apps R12 Technical Course Elearning solutions is the best Oracle Apps R12 technical course in Pune owned by well trained and certified trainers. The training is conducted by the best experienced IT professionals with skilled resources. The course structure is based on the real-time scenario so that it will…
FICO & FICO HANA
₹25,000.00

SAP FICO ( Financial Accounting) Online Training And Certification in Pune

Elearning solutions is the best SAP FICO training institute in Pune. SAP FICO is the Finance and Cost controlling module is one of the most important and widely used SAP ERP modules among organizations. As it is very robust and encounter almost all the business processes. In SAP FICO, FI…
₹25,000.00

SAP SD (Sales & Distribution) Training Course Admission Details

Elearning solutions provide SAP SD training. The tutorials are designed for the students who desired to understand SAP SD concepts and implement them in practice. The SAP SD training is delivered by industry experts, who are aware of the real-time scenarios. Hence, supporting students understand, what will be there on…
₹25,000.00

Be an Certified Professional in SAP WM (Warehouse Management)

SAP WM training is offered by Elearning solutions provides 100% hands-on practical classes. The primary focus of training is getting placement for all the students. The tutorials are designed for the students who wished to work on live projects for the organizations. The syllabus of SAP WM training is crafted…
₹25,000.00

Training for SAP MM (Material Management) Course Modules

Elearning solutions are the best SAP MM training institute in Pune. SAP MM (material management system) is one of the important models of the SAP ERP system, which is particularly designed for business processes. SAP MM deals with the entire material and inventory management of the organization. The module is…
₹25,000.00

SAP ABAP Training Institute in Pune, SAP ABAP Courses Online

Elearning Solutions best SAP ABAP training institute in Pune provides real-time training for students. SAP ABAP (Advanced Business Application Programming) is a programming language for building SAP applications such as SAP R/3 which runs in the SAP ABAP runtime environment. (SAP ABAP online course) SAP ABAP is used by organizations…
WhatsApp WhatsApp us
Call Now Button