on 05-16-2005 3:29 PM
hey,
I'm having a problem and I hope you can help me. I have two web interfaces that log into a SAP server to do some work. They used to be working fine, but suddenly they stopped working. What happens is, when I try to connect, as soon as I set up my mConnection object (Client object) anywhere I try to use this object it won't work... it simply jumps to the jsp where it was called from. This is what happens:
-
mConnection =
JCO.createClient("400", // SAP client
"*****", // userid
"*****", // password
"", // language
"*****", // application server host name
"02"); // system number
a = a + "testing output";
a = a + mConnection.getAttributes().getHost();
a = a + "after using";
mConnection.connect();
mRepository = new JCO.Repository("ARAsoft",mConnection);
-
it goes through the mConnection setup... when I ask to output a, it outputs:
testing output
it doesn't output anything else... not the Host, neither the after using... so obviously it doesnt even connect into the server nor it sets up the repository.
Any ideas as to what might have happened? Again, this was working fine... it suddenly stopped working!
Well.... after a lot of print outs in jsp pages and thanks to the help of Ratna I discovered my userId has been blocked. I've contacted the SAP people and asked them if it is in fact blocked and if it is to unblock it. As soon as they do and I get my code up and running again I'll contact!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
I took your code and tried it, it works fine if you call you .connect() before the a= statements.
In your calling sequence, no connection has been established and thus the code dumps immediately (I debugged and found the catch clause was thrown) and thus it returns to the JSP.
As you are calling it from an JSP it is perhaps harder to debug this (depending on the tools you use) and thus I attach my code which was executed using a non-JSP direct JCO call.
Hope this helps!
Ratna
import com.sap.mw.jco.*;
public class JCOconnectionTest {
public static void main(String[] args)
{
System.out.println("\n\nJCO Ping Tester ");
if (args.length < 6)
{
// All files must be supplied with escpaed "\" e.g. C:
sourcefile.txt instead of C:\sourcefile.txt
System.err.println("\n\nPlease provide the correct input parameters : ");
System.err.println("\n arg 1 = R/3 Client no ");
System.err.println("\n arg 2 = R/3 Username ");
System.err.println("\n arg 3 = R/3 Password ");
System.err.println("\n arg 4 = Language e.g. EN ");
System.err.println("\n arg 5 = Application server hostname ");
System.err.println("\n arg 6 = Application server sys nr ");
System.exit(-1);
}
System.out.println("\n----
Input parameter -
");
String Client = args[0];
System.out.println("arg 1 R/3 Client no : " + args[0]);
String Username = args[1];
System.out.println("arg 2 R/3 Username : " + args[1]);
String Password = args[2];
System.out.println("arg 3 R/3 Password : " + args[2] );
String Langauge = args[3];
System.out.println("arg 4 Language : " + args[3] );
String Hostname = args[4];
System.out.println("arg 5 Hostname : " + args[4]);
String SysNr = args[5];
System.out.println("arg 5 Sys nr : " + args[5]);
JCO.Client client = null;
try {
// Print the version of the underlying JCO library
System.out.println("\n\nVersion of the JCO-library:\n" +
"----
\n" + JCO.getMiddlewareVersion());
// Create a client connection to a dedicated R/3 system
client = JCO.createClient( Client,
Username,
Password,
Langauge,
Hostname,
SysNr ); // system number
// Open the connection
client.connect();
String a = "testing output ";
a = a + client.getAttributes().getHost();
a = a + " after using";
System.out.println(a);
// Get the attributes of the connection and print them
JCO.Attributes attributes = client.getAttributes();
System.out.println("Connection attributes:\n" +
"----
\n" + attributes);
boolean is_backend_unicode = attributes.getPartnerCodepage().equals("4102") ||
attributes.getPartnerCodepage().equals("4103");
// Create metadata definition of the input parameter list
JCO.MetaData input_md = new JCO.MetaData("INPUT");
input_md.addInfo("REQUTEXT", JCO.TYPE_CHAR, 255, 255 * (is_backend_unicode? 2 : 1 ),
-1, 0, null, null, 0, null, null);
// Create the input parameter list from the metadata object
JCO.ParameterList input = JCO.createParameterList(input_md);
// Set the first (and only) input parameter
input.setValue("This is my first JCo example.", "REQUTEXT");
// Create metadata definition of the output parameter list
JCO.MetaData output_md = new JCO.MetaData("OUTPUT");
// Specify the parameters types of the function will be returned
output_md.addInfo("ECHOTEXT", JCO.TYPE_CHAR, 255, 255 * (is_backend_unicode? 2 : 1 ),
-1, 0, null, null, 0, null, null);
output_md.addInfo("RESPTEXT", JCO.TYPE_CHAR, 255, 255 * (is_backend_unicode? 2 : 1 ),
-1, 0, null, null, 0, null, null);
// Create the output parameter list from the metadata object
JCO.ParameterList output = JCO.createParameterList(output_md);
// Call the function
client.execute("STFC_CONNECTION", input, output);
// Print the result
System.out.println("The function 'STFC_CONNECTION' returned the following parameters:\n" +
"----
");
for (int i = 0; i < output.getFieldCount(); i++) {
System.out.println("Name: " + output.getName(i) + " Value: " + output.getString(i));
}//for
// All done
System.out.println("\n\nCongratulations! It worked.");
}
catch (Exception ex) {
System.out.println("Caught an exception: \n" + ex);
}
finally {
// do not forget to close the client connection
if (client != null) client.disconnect();
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
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.