on 12-06-2005 3:28 PM
Hi All,
Can someone tell me the steps involved in accessing a sql server database table and retrieving the record set from a webdynpro application.
Thanks in advance.
Best regards,
Divya
Hi Divya,
here is a code sample that may help you (SAPTT3DB is the name of the DataSource. In my case,SAP<SID>DB. You can find this in the Visual Administrator):
ResultSet rs;
boolean found=false;
try {
InitialContext ctx = new InitialContext();
javax.sql.DataSource ds =
(javax.sql.DataSource) ctx.lookup("jdbc/SAPTT3DB");
java.sql.Connection con = ds.getConnection();
java.sql.Statement stmt = con.createStatement();
rs = stmt.executeQuery("SELECT * FROM DEMO_FP where NUMERO="+num);
while (rs.next()){
found=true;
wdContext.currentFichePrixElement().setCodeAch(rs.getString("CODE_ACH"));
[...]
}
con.close();
}
catch(Exception e){
msgMgr.reportException(e.getMessage(),true);
}
Best Regards,
Julien
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
Thanks for all the info. I just wanted to know as to how I could bind the values returned in the record set to a table UI element.
This is described in case of BAPIs in the tutorial would be of great help if someone guided as to how this could be done in case of sql query record sets.
Thanks in advance.
Best regards,
Divya Rao
Hi Julien,
This is where am stuck I get the record set but when I assign it to the UI element of type table it does not display it right. I have created a conext of type node attribute having node values.Code is enclosed as below:
while (rs.next()){
wdContext.nodeData().cuurentcontextElement.setDataField1(rs.getString("Test1"));
wdContext.nodeData().cuurentcontextElement.setDataField2(rs.getString("Test2"));
}
The data is not bound to the UI table. Can you suggest another way to do so please.
Thanks in advance.
Best regards,
Divya
Hi Divya,
Create a node with the required attributes.
In the left hand side where the project structure is being shown right click on the view and choose "Apply Template" .
Choose the "table" and then the attributes you want to display in table
Write this code in the implementation
IPrivate<view name>.I<node name>Element element;
While(rs.next())
{
element = wdContext.node<node name>.create<node name>element();
element.setDataField1(rs.getString("Test1"));
element.setDataField2(rs.getString("Test2"));
wdContext.node<node name>.addelement(element);
}
Hope this helps you
Regards
Rohit
Hello Divya,
I would recommend you to read "Java Persistence" section in Development manual describing various options for database integration http://help.sap.com/saphelp_nw04/helpdata/en/61/fdbc3d16f39e33e10000000a11405a/frameset.htm
Tutorials
http://help.sap.com/saphelp_nw04/helpdata/en/46/ddc4705e911f43a611840d8decb5f6/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/91/9c2226df76f64fa7783dcaa4534395/frameset.htm
Web serices
http://help.sap.com/saphelp_nw04/helpdata/en/d6/f9bc3d52f39d33e10000000a11405a/frameset.htm
EJB
http://help.sap.com/saphelp_nw04/helpdata/en/19/f9bc3d8af79633e10000000a11405a/frameset.htm
Best regards, Maksim Rashchynski.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.