cancel
Showing results for 
Search instead for 
Did you mean: 

How can I set the data binding between Web Dynpro & Database table

Former Member
0 Kudos

Dear friend,

I am a beginner of Web Dynpro. I want to develop my simple project like these:

1. Create my own database table via Dictionary Project such as TAB_USER and have 3 fields: USER_ID, USER_NAME, USER_POSITION and I have already deployed & archived it.

2. Create my own Web Dynpro Project, and create the input fields as User ID, User name, User position and icon 'Save' on the selection screen and I have deployed it already.

For the process, I want to input data at the screen and save the data in the table, please give me the guide line like these:

1. How can I set the data binding between Web Dynpro and Database table ?

2. Are there any nescessary steps that I will concern for this case?

Sorry if my question is simple, I had try to find solution myself, but it not found

Thanks in advances,

SeMs

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

hi

type these following code in the onactionsave method in the view controller.

1)get the data from the contextelement binded to your inputfields and store them in respective string variables(say s1,s2,s3 respectively)

2)then establish the connection with your database with the following code

InitialContext ctx=new InitialContext();

javax.sql.DataSource ds= (javax.sql.DataSource) ctx.lookup("jdbc/SAPJ2EDB");

(here the string"jdbc/SAPJ2EDB"corresponds to underlying database of my server.check yours give the appropriate string)

java.sql.Connection con=ds.getConnection();

java.sql.Statement stmt=con.createStatement();

stmt.executeUpdate("insert into TMP_USER(USER_ID,USER_NAME,USER_POSITION) values('s1','s2','s3')");

(this inserts the data entered by the user into the database)

ResultSet rs=stmt.executeQuery("select * from TMP_USER");

con.close();

Former Member
0 Kudos

hi sukasem,

for binding ur dictionary table with the WD

appln u have to do the following steps:

1) RIGHT CLICK WDAPPLN>PROPERTIES>JAVA BUILD PATH.

2) In <b>projects</b> tab-->check ur dictionary table name.

3) In the <b>orders and Exports</b> tab -->check ur

dictionary table name.

4) Add all the neccessary External jars to ur projects in the LIBRARY tab.

Then in ur implementation u just write down the normal

SQL query to insert into ur database.

Hope so this one clears ur Query Sukasem.

Regards,

Nagarajan.

Former Member
0 Kudos

Hi,

You can write your own connection class for establishing the connection with DB.

Ex:

public class ConnectionClass {

static Connection con = null;

public static Connection getConnection() {

try{

Context ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup("jdbc/TSPAGE");

con = ds.getConnection();

return con;

}catch(Exception e){

}

return null;

}

}

You can place the above class file in src folder and you can use this class in webdynpro.

You can have another UserInfo class for reading and writing the data into the DB .

Regards, Anilkumar

PS : Refer

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/java/simple java bean generator for database.pdf

Message was edited by: Anilkumar Vippagunta