Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

salesorder creation using jco

Former Member
0 Kudos
123

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.

4 REPLIES 4

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
77

All you need to do is call BAPI_SALESORDER_CREATEFROMDAT2 from your java program.

Regards,

Rich Heilman

former_member181962
Active Contributor
0 Kudos
77

Refer these links:

Regards,

Ravi

Former Member
0 Kudos
77

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.

0 Kudos
77

hai ravi

thanks a lot for ur program it really helped me alot

bye

mounika.