Top Ten Mistakes Java
From Abap2Java
- = is not ==:
- Keyword missing? Search for classes and methods to do the task:
- Double Quotes (") are used for strings, and // start a comment.
- No SQL statements in plain code:
- Where is the transport request?:
- Are my strings translated?:
- No DATA definition using LIKE:
- Only one exporting parameter (and no changing one at all):
- Add your example here:
The = operator does an assignment, while the == operator is used for comparison.
= corresponds to MOVE or = in ABAP, while == corresponds to EQ or =.
if( a = b ){ ... } "will copy b to a!! syntax error! if( a == b ){ ... } "compares a and b
Some keywords in ABAP don't have a direct equivalent in Java (for example SELECT, READ TABLE). Look for classes and methods in the API that do what you want to do. A good documentation of the APIs is essential. Or use this dictionary to find the equivalents of your ABAP keywords in Java.
System.out.print( 'this is not a string' ); System.out.print( "this is a string" ); System.out.print( "anything" ); // this is a comment
Open SQL is directly embedded into ABAP. Therefore, statements like SELECT, INSERT, MODIFY, UPDATE or DELETE can be called at any time in the coding. In Java, you have to use classes and methods to access the database.
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection("jdbc:postgresql://hostname:port/database?encoding=UNICODE","user","password");
Statement stmt = con.createStatement();
ResultSet result = stmt.executeQuery("SELECT * FROM table");
The ABAP language is shipped together with the ABAP Workbench, which is more than just an editor. In Java, many different editors and development environments IDEs can be used. They do not automiatically have a transport system integrated. Often, applications based on CVS are used to transport coding from one system to another.
The ABAP language is shipped together with the ABAP Workbench, which is more than just an editor. Most Java development environments IDEs do not have the same support for translating strings into multiple languages like in the ABAP Workbench (Text Elements, OTR, Message Classes, Exception Classes).
DATA lv_number LIKE lv_other_number. "not possible in Java
In Java, you cannot define a variable and refer to the type of another variable. Just use the underlying type of the variable that you want to refer to.
While ABAP supports any number of exporting parameters, Java allows many importing, but only one returning parameter. If your method wants to return more than one parameter, think about a re-design, export some kind of array/list (filled with objects for example) , or export an object reference that can of course have any number of attributes. If your method wants to change the value of a parameter, think about having that parameter as an importing and exporting parameter, or pass a object reference to the method, whose attributes can be changed inside the method.
What do you think is an common mistake of ABAp developers learning Java? Add your example here. Just click edit on this page.
See also:
Top Ten Mistakes ABAP

