cancel
Showing results for 
Search instead for 
Did you mean: 

making database connection

Former Member
0 Kudos

Hi,

Can anyone tell me how to make database(sap r/3) connection from a webdynpro application.

it would be of great help if you send me a sample example also.

Regards,

Rashmi.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Rashmi,

If you were able to solve the problem and if you got the solution then please close this thread.

Regards,

Bhavik

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi all,

Thanks for the info.

Regards,

Rashmi.

former_member8655
Active Participant
0 Kudos

Hi Rashmi

you can use RFC's for connecting with R/3 system

you can get through tha example given in following link

http://help.sap.com/saphelp_nw04/helpdata/en/16/36d93f130f9115e10000000a155106/frameset.htm

by the topic 'web dynpro app. accessing abap functon'

you need further help you can post msg

this whole example is using bapi

guru_subramanianb
Active Contributor
0 Kudos

Hi Rashmi,

Not sure whether your problem is solved.

Try some thing which is simple like this in your connection method of your Web Dynpro.

try

{

// Load the jdbc-odbc driver

Class.forName("oracle.jdbc.driver.OracleDriver");

// Open a connection to the odbc data source entered by the user

Connection connect =DriverManager.getConnection("jdbc:oracle:thin:@10.201.103.78:1521:HCM" ,"<userid>","<passwd>");

System.out.println("Connection Established --->"+connect);

Statement stmt = connect.createStatement();

//Sample Query--->Replace your query here

ResultSet rst = stmt.executeQuery("select text from category where category_id='Index100'");

//Iterate thro' your resultset like this

while(rst.next())

{

resultString = rst.getString("text");

}

//Close your Resultset

rst.close();

}

// If not connected to DB catch your exception to know what was the problem is

catch(Exception e)

{

e.toString();

System.out.println(e.toString());

}

// Close your connection in Finally Block

finally(){

if(connect==null)

{

connect.close();

}

}

Not but not the least copy your DB drivers file in your lib folder of your project structure which sets the classpath to get connected to DB.

Hope it is simple and will help you.

Regards,

Guru

Former Member
0 Kudos

Hi Guru,

Rashmi was asking about connecting to SAP R/3 system. What you have given is a java code for connecting to Oracle database.

Rashmi,

Refer to the link which explains "Accessing ABAP Functions in Web Dynpro"

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/stu/tutorial on accessing abap functions in web dynpro - 4.htm

If you want to create the connection in your application, then you can use the JCo.

Refer to "SAP JCo Client Programming"

http://help.sap.com/saphelp_nw04/helpdata/en/35/42e13d82fcfb34e10000000a114084/frameset.htm

Regards,

Santhosh.C

Former Member
0 Kudos

Hi Rashmi,

You can not connect to the SAP R/3 database. But you can create one custom function module and enable it as RFC eanbled. Write code for fetching data from database in this function module.

Then, cretae one RFC model in webdynpro application and there you can call this Function module.

you cna look at the tutorial for this in below link:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/web dynpro sample applications and tutorials.htm#program

Regards,

Bhavik

Former Member
0 Kudos

Hi Rashmi,

There is an example tutorial which shows you how to design, implement, deploy, and run a basic Web Dynpro application that accesses persistent data from a remote SAP system.

Please check the link below :

http://help.sap.com/saphelp_nw04/helpdata/en/c3/76b45d9688e04abe1a1070410ddc1e/content.htm

Regards,

Vijith