cancel
Showing results for 
Search instead for 
Did you mean: 

Development in JAVA within SAP ERP

Former Member
0 Kudos

Hi folks,

i have a general question. My last attempt was testing a Java application which connects via JCo and RFC to an ABAP module and receives some table data or send some integers to that module.

The approach was to write a Java application that handles all the logic and then do some RFC's to get data within a SAP database table and then process this data in the Java application again.

After some beginner problems, everything is working fine now. But now i want to test 2 more approaches.

First, i want to do most of the logic in ABAP and just the most necessary in JAVA, is it possible to do a RFC from ABAP to call a JAVA module? (just the reverse direction as i tried it the last time).

Second, is it possible to deploy a Java application inside a SAP ERP system, that the application can access to all the SAP databases without using an ABAP RFC? I want to write everything in Java that i do not have to write a single line in ABAP but whithout having any limitations.

Thanks in advance!

Kind regards

Felix

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

To answer your first question:

- It is possible to create an RFC server in Java. Please refer to [JCO 3.0 Server Programming|http://help.sap.com/saphelp_nw73/helpdata/en/48/64db09c88307dbe10000000a42189b/frameset.htm] for the details. It can then be called by SAP.

- Technically, you can always access your SAP databases from Java. However, in general it is not a good idea since you lose all application logic and it can be harmful to your data. It is always good practice to use RFCs. For non-SAP data, of course you can always connect directly to a database.

Former Member
0 Kudos

Ok thanks,

but what do you mean by "you lose all application logic"? I can mess it up if i use JAVA only for my SAP database connections or if i use RFC's and let ABAP do it but send the wrong request. Its a design problem to seperate the logic from the persistence and i always have to watch that i do not mess with my data, or what did you want to tell me exactly?

Do you have any examples for me of how to deploy a Java application on an ERP system, and how to connect to any database?

Thanks!

Former Member
0 Kudos

Maybe I misunderstood your question. With Java you can directly connect to the database you use for SAP via JDBC but that is in almost all cases a very bad idea.

Typically, you would not deploy a Java application directly on the ERP system, but in an instance of a J2EE server such as SAP WebAS or JBoss. Depending on what you want to achieve, you could also use a web container like Apache Tomcat. On all of those you could run an RFC server. However, I always turned to the SAP Basis admin to let them setup the connection from ERP to the Java RFC server. Once they did that, I was able to call my Java RFC server from within SE37.

I hope that helps a bit.

Former Member
0 Kudos

Maybe I misunderstood your question. With Java you can directly connect to the database you use for SAP via JDBC but that is in almost all cases a very bad idea.

Because you shouldnt change SAP content from an external application?

Is it better to do table inserts,updates,deletes with Abap that future administrators can see "whats going on", or what?

Former Member
0 Kudos

Not only that. Using BAPIs, you first of all know that business validations are taking place as they would be in the normal transactions. Moreover, the physical structure of databases could change over time while BAPIs are defined interfaces that in almost all cases also work after an upgrade. And there are numerous more reasons as being able to audit transactions, making it easier for other developers etc.

Former Member
0 Kudos

Summary:

I write all the application logic in JAVA and then use BAPI's for the SAP communication to retrieve and send data to database tables. And these BAPI interface methods are written in ABAP?

Former Member
0 Kudos

The BAPI's are SAP provided function modules written in ABAP, yes.

Former Member
0 Kudos

Do you know any good examples of how to use BAPI with Java RFC?

PS: If i want to use BAPI's then there must exist Business objects for my data tables which represents the structure of the tables and BAPI's which allow me to access via RFC to these business objects?

What if there arent any BO's or BAPI's that fit? Can i create them by my own? (If i have the neccessary rights

Former Member
0 Kudos

To get an idea how to call BAPI's or function modules via RFC from Java you could have a look [here|http://help.sap.com/saphelp_nw04/helpdata/en/35/42e13d82fcfb34e10000000a114084/content.htm]. There are different versions of the JCo library, the latest one is 3. There are a host of other ways to connect to ERP, but this would be one way to do it from Java.

If you cannot work with the standard business objects in SAP, you could of course create Z-tables and custom function modules. BAPI's are the function modules already delivered by SAP, but you can always extend or build your own.