2006 Jun 22 4:49 PM
hi,
i am trying to create a salesorder in r/3 from website using jco. can any one tell me the sites where i can get the stuff regarding this.
thanking u in advance.
regards,
mounika.
2006 Jun 22 4:51 PM
2006 Jun 22 4:56 PM
2006 Jun 22 4:58 PM
hi,
You need to call the BAPI - BAPI_SALESORDER_CREATEFROMDAT2
Here is a simple example...
import com.sap.mw.jco.*;
public class Bapi1 extends Object{
JCO.Client mConnection;
JCO.Repository mRepository;
public Bapi1(){
try{
mConnection = JCO.createClient(client,userid,password,
lang,host,system no );
mConnection.connect();
mRepository = new JCO.Repository("MyRepos", mConnection);
}catch(Exception ex){
ex.printStackTrace();
System.exit(1);
}
JCO.Function function = null;
JCO.Table codes = null;
try{
function = this.createFunction("BAPI_SALESORDER_CREATEFROMDAT2");
if (function == null){
System.out.println("BAPI_SALESORDER_CREATEFROMDAT2" + "not found in SAP");
System.exit(1);
}
//here you need to pass the paramters also.........
//pass all the parameters needed for the creation of the sales order in JCO.Structure.
mConnection.execute(function);
JCO.Structure returnStructure = function.getExportParameterList().getStructure("RETURN");
if (!(returnStructure.getString("TYPE").equals("")||
returnStructure.getString("TYPE").equals("S"))){
System.out.println(returnStructure.getString("MESSAGE"));
System.exit(1);
}catch(Exception ex){
ex.printStackTrace();
System.exit(1);
}
mConnection.disconnect();
}
public JCO.Function createFunction(String name) throws Exception{
try{
IFunctionTemplate ft = mRepository.getFunctionTemplate(name.toUpperCase());
if (ft == null)
return null;
return ft.getFunction();
}catch(Exception ex){
throw new Exception("Probelm retrieving JCO.Fucntion object");
}
}
public static void main(String agrs[]){
Bapi1 app = new Bapi1();
}
}
Hope you will find it useful
Regards,
Richa.
2006 Jun 23 7:12 PM
hai ravi
thanks a lot for ur program it really helped me alot
bye
mounika.