cancel
Showing results for 
Search instead for 
Did you mean: 

Creation of individual Java classes within UDFs in mappings?

Former Member
0 Kudos

Hello,

is it possible to create new specific Java classes and objects within UDFs in a mapping?

I often have to do mappings from IDoc (e.g. ORDERS) to some totally different Inhouse structures. I have to work a lot with java in order to map the source structure to the target structure.

It would be easyier if I could define classes like "CAR" and create objects like "myCar1", store them in the globalContainer and read these objects at another position of the target structure.

Is something like that possible?

Thanks,

Christoph

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello,

thanks for the feedback.

@Shabarish: That means I create a java class e.g. "CAR" and import it as a java class / package? I would prefer do define the class just within the mapping in a UDF which is executed at the first element of the target structure. I am wondering if the class is then known / can be accessed from within the whole mapping?

@ Gourav Khare: Which feature do you mean?

Thanks,

Christoph

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Chris,

Create Java Class(CAR) and genarate JR file and import it in Imported archieves,then if u want to use this java class (CAR) in UDF, just cal the Java Class CAR in UDF.it will work fine.

Cheers,

Raj

Former Member
0 Kudos

Hi,

I still need help as I am not an Java expert

I generated a class "Car" in a package MappingObjects with eclipse. I generated a JAR file and imported it in PI. In my mapping, i added the Archive used and imported MappingObjects.*.

In a UDF i try to generate a Car object with "Car testCar = new Car();"

While compiling I get the error message:

cannot access MappingObjects.Car bad class file: /usr/sap/PIE/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map5e168b30528411deab780050568f4fb3/classpath/MappingObjects_6.jar(MappingObjects/Car.class) class file has wrong version 50.0, should be 49.0

My class:

______________

package MappingObjects;

public class Car {

int price;

String name;

public int getPrice() {

return price;

}

public void setPrice(int price) {

this.price = price;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

}

Thanks,

Christoph

Former Member
0 Kudos

Hello,

I fixed the problem myself. In Eclipse, I had to set the JDK compliance level to 5.0, now it works fine.

Points have been assigned.

Thanks,

CHRISTOPH

Former Member
0 Kudos

This feature is available in PI7.1.

Regards,

Gourav

Shabarish_Nair
Active Contributor
0 Kudos

you can always write a class / package, compile and save it under the imported archives.

the package can then be then referenced in your UDF .

an example /people/pooja.pandey/blog/2005/06/27/xslt-mapping-with-java-enhancement-for-beginners - here you will find a XSLT mapping referring a java class