cancel
Showing results for 
Search instead for 
Did you mean: 

DDL in Web Dynpro

former_member8655
Active Participant
0 Kudos
261

hi all

Is it possible to write ddl statements of sql in web dynpro.

i wish to create table from dynpro.

bye

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi ,

One more way !!

1. I have created the tables using the Dictonary project

in MaxDB

I have imported the tables as Models in WebDynpro using

JavaBean importer.

I wrote a simple generator that will generate a simplebean out the tables in webdympro. (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)

Note : There are some limitations in the tool

2.Another way is write all your SQL statements in the component/custom controller (JDBC programming) and access those methods from the view .

Regards, Anilkumar

Message was edited by: Anilkumar Vippagunta

guru_subramanianb
Active Contributor
0 Kudos

Hi Mitesh,

Adding to Ghosh's comment the best way I suggest you to do is create your table manually using Dictionary for MaxDB or in any other Vendor SQL manually.

Use the corresponding vendor driver file to connect to the DB.Try DML statement alone from your Webdynpro fo contacting and querying your DB.

The reason why DDL is not suggested from Webdynpro is that the Webdynpro meta model user interface does not by itself supports effective DDL statement like we normally do in .jsp file. or javafile.

Hence the performance is also affected if you have DDL in WD.

Hope it helps.

Regards,

Guru

Former Member
0 Kudos

Hi Mitesh,

Its not possible to use DDL statements in Webdynpro.

You can only use DML statements in webdynpro or any other J2ee applications.

Regards,

Bhavik

Former Member
0 Kudos

Hi Mitesh,

Try this link on relational persistance

http://help.sap.com/saphelp_nw04/helpdata/en/bd/b127af68234e868cfd4e9f440aa0bf/frameset.htm

Regards,

Jaydeep

Former Member
0 Kudos

Hi,

you should not use DDL or DML directly from WebDynpro ever, as the WD framework is meant only for User Interface creation. You should envelope your Business Processing logic in some EJB or normal Java helper classes and call the same from WD classes. If you use a core java helper class you can execute its method from WD. From a core java class you can create a table like below

String url = "jdbc:mySubprotocol:myDataSource";

Connection con;

String createString;

createString = "create table COFFEES " +

"(COF_NAME VARCHAR(32), " +

"SUP_ID INTEGER, " +

"PRICE FLOAT, " +

"SALES INTEGER, " +

"TOTAL INTEGER)";

Statement stmt;

try {

Class.forName("myDriver.ClassName");

} catch(java.lang.ClassNotFoundException e) {

System.err.print("ClassNotFoundException: ");

System.err.println(e.getMessage());

}

try {

con = DriverManager.getConnection(url, "myLogin", "myPassword");

stmt = con.createStatement();

stmt.executeUpdate(createString);

stmt.close();

con.close();

} catch(SQLException ex) {

System.err.println("SQLException: " + ex.getMessage());

}

But please dont use DDL, DML or any business processing in WD code directly.

Regards,

Shubhadip